Last active
August 29, 2015 13:56
-
-
Save juliangruber/8819271 to your computer and use it in GitHub Desktop.
co-stream pipe example
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
function pipe(){ | |
var streams = [].slice.call(arguments); | |
return streams.slice(1).reduce(function(acc, stream){ | |
return stream(acc); | |
}, streams[0]); | |
} | |
// usage: | |
var read = pipe(a(), b(), c(), d()); | |
// which is the same as: | |
var read = d(c(b(a()))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment