Created
May 26, 2017 21:14
-
-
Save pfrozi/8c8213d74885cd19eb477387f3fad982 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
const g = n => n + 1; | |
const f = n => n * 2; | |
const wait = time => new Promise( | |
(resolve, reject) => setTimeout( | |
resolve, | |
time | |
) | |
); | |
wait(300) | |
.then(() => 20) | |
.then(g) | |
.then(f) | |
.then(value => console.log(value)) // 42 | |
; | |
const res = time => new Promise( | |
(resolve, reject) => resolve(30) | |
); | |
res(300) | |
.then(g) | |
.then(f) | |
.then(value => console.log(value)) // 42 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment