Created
May 14, 2019 08:57
-
-
Save aeinbu/723ab53a17e2d108dfa497f9a43277f8 to your computer and use it in GitHub Desktop.
Helper to chain method calls while we're waiting for |> (the js pipe operator)
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 chain = (obj, op = obj => obj, ...restOps) => restOps.length > 0 | |
? chain(op(obj), ...restOps) | |
: op(obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage
Given these methods to process an array
With the pipe operator I would do like this:
Since we don't have the pipe operator yet, I'll settle for this: