Skip to content

Instantly share code, notes, and snippets.

View saifsmailbox98's full-sized avatar
💣
Cooking The Grenade

Saif Ur Rahman saifsmailbox98

💣
Cooking The Grenade
View GitHub Profile

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):

_(x)
.a(...)
.b(...)
.c(...)
.value()