Advertisement
Arinek

Collection

Apr 24th, 2024
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export class Collection {
  2.     data;
  3.  
  4.     constructor(){
  5.         this.data = {};
  6.     }
  7.  
  8.     get data(){
  9.         return this.data
  10.     }
  11.  
  12.     get single(){
  13.         let singles = {};
  14.         for(const item of Object.keys(this.data)){
  15.             if(typeof item !== "object"){
  16.                 singles[item] = this.data[item];
  17.             }
  18.         }
  19.         return singles;
  20.     }
  21.  
  22.     add(key, value){
  23.         this.data[key] = value;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement