Advertisement
CLooker

Untitled

Apr 7th, 2018
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const bool = true;
  2.  
  3. const returnBoolIfTrue = () =>
  4.   new Promise(
  5.     (resolve, reject) =>
  6.       bool ? resolve(bool) : reject(new Error("dat shit ain't true"))
  7.   );
  8.  
  9. const logArg = arg => console.log(arg);
  10.  
  11. //which do you prefer?
  12.  
  13. //case 1
  14. returnBoolIfTrue().then(logArg);
  15.  
  16. //case 2
  17. returnBoolIfTrue().then(result => logArg(result));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement