Created
October 1, 2016 18:31
-
-
Save xat/003ae3c2ea31c8ab61da0201c51225ef to your computer and use it in GitHub Desktop.
This file contains 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 pipeline = (...fns) => (val) => fns.reduce((prom, fn) => prom.then(fn), Promise.resolve(val)); | |
const myPipe = pipeline( | |
(val) => val + 1, | |
(val) => val + 1 | |
); | |
Promise.resolve(1) | |
.then(myPipe) | |
.then((result) => { | |
console.log('result', result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment