Advertisement
Guest User

function

a guest
Sep 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   function inventory(userID) {
  2.  
  3.     const getInfo = new Promise ((resolve,error) => {
  4.  
  5.       var data;
  6.  
  7.       function newInventory() {
  8.         var arr = sample;
  9.         var toPush = { 'userid': userID, 'inventory': [] }
  10.         var toPush2 = { 'itemid': '420', 'name': 'weed', 'quantity': '2' }
  11.         toPush.inventory.push(toPush2)
  12.         arr.inventories.push(toPush)
  13.         fs.writeFile ("./info/sample.json", JSON.stringify(arr, null, 2), function(err) {
  14.           if (err) throw err;
  15.         });
  16.         data = toPush; return resolve(data);
  17.       }
  18.  
  19.       function oldInventory() {
  20.         var i =0;
  21.         var total = sample.users.length;
  22.         var ids = [];
  23.         for(; i < total; i++) {
  24.            ids.push( sample.users[ i ].id );
  25.         }
  26.         var found = ids.find(function(element) {
  27.           return element == userID;
  28.         });
  29.         if (found != userID) { addUser(); }
  30.         else if (found == userid) {
  31.           //get tha inventory of this guy by id
  32.           });
  33.           data = vals; returnData();
  34.         }
  35.       }
  36.  
  37.       function runChain() {
  38.  
  39.       }
  40.  
  41.     })
  42.  
  43.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement