Skip to content

Instantly share code, notes, and snippets.

@dtipson
Created November 7, 2015 20:45
Show Gist options
  • Select an option

  • Save dtipson/065e848811bd1d2f71aa to your computer and use it in GitHub Desktop.

Select an option

Save dtipson/065e848811bd1d2f71aa to your computer and use it in GitHub Desktop.
Composing functions with Promises
const bind = function(aPromise, f) {
return aPromise.then(f);
},
pipe = _.curry(function(functionList, aPromise) {
return _.reduce(functionList, bind, aPromise);
}),
//even_cleaner_pipe = _.curry(_.partial(_.reduce,_, bind),2)
program = function(/*...list of functions*/){
return pipe.call(this,_.flattenDeep(arguments));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment