Skip to content

Instantly share code, notes, and snippets.

@gurre
Created July 18, 2017 17:47
Show Gist options
  • Save gurre/b5799ada0b2de19407b200cf4810a1a0 to your computer and use it in GitHub Desktop.
Save gurre/b5799ada0b2de19407b200cf4810a1a0 to your computer and use it in GitHub Desktop.
Ramda sync and async promises using pipeP
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