basic.js 342 B

123456789101112131415161718
  1. var Stack=require('../stack');
  2. //create a new Stack instance
  3. var stack=new Stack;
  4. stack.autoRun=false;
  5. for(var i=0; i<50; i++){
  6. //add a bunch of stuff to the stack
  7. stack.add(makeRequest.bind(stack,i));
  8. }
  9. stack.next();
  10. function makeRequest(index){
  11. //do stuff
  12. console.log(`making LIFO request ${index}`);
  13. this.next();
  14. }