Skip to content

Instantly share code, notes, and snippets.

@pfrozi
Created May 26, 2017 21:14
Show Gist options
  • Save pfrozi/8c8213d74885cd19eb477387f3fad982 to your computer and use it in GitHub Desktop.
Save pfrozi/8c8213d74885cd19eb477387f3fad982 to your computer and use it in GitHub Desktop.
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