Last active
December 30, 2015 19:09
-
-
Save spencewood/7872039 to your computer and use it in GitHub Desktop.
Pipeline mixin for underscore/lodash. Takes a seed as an initial value and any number of functions as parameters. The seed value is passed to the first function, and the return value of each function is passed as the parameter to the next.
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
_.mixin({ | |
pipeline: function (seed) { | |
return _.rest(_.toArray(arguments)).reduce(function (l, r) { | |
return r(l); | |
}, seed); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: