Created
July 18, 2017 17:47
-
-
Save gurre/b5799ada0b2de19407b200cf4810a1a0 to your computer and use it in GitHub Desktop.
Ramda sync and async promises using pipeP
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 { apply, concat, identity, pipe, pipeP, unapply } = require('ramda'); | |
/** | |
* Similar to `pipe` and `pipeP`, but this method allows interpolation of | |
* async and sync functions by preceding all the passed in functions with a | |
* resolved promise. All functions must be unary (unlike the first argument | |
* of it's sister functions). | |
*/ | |
module.exports = | |
pipe( | |
unapply(identity), | |
concat([a => Promise.resolve(a)]), | |
apply(pipeP) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment