Created
August 16, 2015 18:33
-
-
Save dtipson/5ff99dadeba9ec5130ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function done_wrapper(fn){ | |
| return function(value){ | |
| fn(value); | |
| return value; | |
| }; | |
| } | |
| function badlog(x){ | |
| console.log(x); | |
| return 'return a complete nonsense string!'; | |
| } | |
| var g = Promise.resolve(5) | |
| .then( done_wrapper( badlog ) )// protected usage | |
| .then( function(value){ | |
| return value + 1; | |
| }) | |
| .then( badlog );// unprotected usage | |
| // logs: 5 | |
| // adds 1 | |
| // logs 6 | |
| // but g = Promise { | |
| // [[PromiseStatus]]: "resolved", | |
| // [[PromiseValue]]: "return a complete nonsense string!" | |
| // } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment