Last active
May 25, 2017 04:05
-
-
Save gt3/24ea3813878ee01d9221e5e64bfb0efb to your computer and use it in GitHub Desktop.
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
| function pipe(...fns) { | |
| function invoke(v) { | |
| return fns.reduce((acc, fn) => (fn ? fn.call(this, acc) : acc), v) | |
| } | |
| return invoke | |
| } | |
| let i=1, fn = m => console.log(i++,m) | |
| let piped = pipe.bind(null, fn) | |
| piped = piped.bind(null, fn) | |
| piped.bind(null, fn)()('xxx') //piped.bind(null, fn)('xxx') will just return invoke fn! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment