Created
April 11, 2020 15:53
-
-
Save EastSun5566/e4cb2e780f88d5ecfbfaeba9e9574678 to your computer and use it in GitHub Desktop.
Pipe function implement
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 pipe = (...fns) => (param) => fns.reduce( | |
(res, fn) => (res.then && res.then(fn)) || fn(res), | |
param | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment