Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function composition has one *huge* benefit over chaining APIs: it allows *any* combination of JavaScript functions to be stuck together to form a pipeline. One could create a pipeline involving a function from library A, a function from library B, a function from library C, and a built-in function. With a chaining API one is restricted to the set of functions available on the object facilitating the chaining.
- I found this to be a problem when using Underscore. This would be fine for a pipeline comprised solely of Underscore functions (represented here by lower-case identifiers):
- ```javascript
- _(x)
- .a(...)
- .b(...)
- .c(...)
- .value()
- ```
- "Foreign" functions (represented here by upper-case identifiers) break the pipeline:
- ```javascript
- _(D(_(x)
- .a(...)
- .b(...)
- .c(...)
- .value()))
- .e(...)
- .f(...)
- .value()
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement