Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var q = require('q');
  2.  
  3. function cutSeat(WIPchair){
  4.     var def = q.defer();
  5.  
  6.     console.log("Cut the chair's seat.");  
  7.  
  8.     WIPchair.seat = "A nice seat for the chair.";
  9.     def.resolve(WIPchair);
  10.        
  11.     return def.promise;
  12. }
  13.  
  14. function assembleLegs(WIPchair){
  15.     var def = q.defer();
  16.  
  17.     console.log('Assemble chair legs.');
  18.  
  19.     WIPchair.legs = "Chair legs.";
  20.     def.resolve(WIPchair);
  21.        
  22.     return def.promise;
  23. }
  24.  
  25. function buildChair(){
  26.     WIPchair = {};
  27.  
  28.     cutSeat(WIPchair).then(assembleLegs).then(function (DONEchair){
  29.         console.log(JSON.stringify(DONEchair,null,4))
  30.     });
  31.  
  32. }
  33.  
  34. buildChair();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement