Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function userData(request) {
  2.  
  3.     switch (request) {
  4.  
  5.       case 'readFile':
  6.       //Reads the JSON and turns it into an object.
  7.       var data = JSON.parse(fileSys.readFileSync('data/data.json'));
  8.       var userXPData = data.xpArray;
  9.  
  10.       //Base object userData(userInfo) fills out to return for user queries
  11.       function requesterInfo(valid,array,XP) {
  12.           this.valid = false;
  13.           this.array = null;
  14.           this.XP = null;
  15.       }
  16.       break;
  17.  
  18.       //Varied, useful information about the entry of a specific user
  19.       case 'userInfo':
  20.           //Reads the JSON before attempting to use it
  21.           userData("readFile")
  22.  
  23.           for(i = 0; i < userXPData.length; i++) {
  24.               if(dataBuild().userXPData[i][0] == ID) {
  25.                   return new requesterInfo(true, userXPData[i], requesterArray[1]); //Healthy answer
  26.               } //ends if statement
  27.           } //Ends for loop
  28.  
  29.       return new requesterInfo(false, null, null); //Bad query, userID didn't match any known
  30.     } //Ends switch statement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement