Created
November 7, 2015 20:45
-
-
Save dtipson/065e848811bd1d2f71aa to your computer and use it in GitHub Desktop.
Composing functions with Promises
This file contains hidden or 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 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