Hi Gilbert, Have you seen https://github.com/zenparsing/es-function-bind/ ? It's a function bind-syntax proposal which covers some of the same use cases (although by binding the `this` parameter instead of passing the first arg). We've also explored some alternatives more closely aligned with your proposal. Check out the discussion here for the latest state: https://github.com/zenparsing/es-function-bind/issues/26#issuecomment-154237803 and feel free to comment!
On Tue, Nov 10, 2015 at 11:54 AM Gilbert B Garza <[email protected]> wrote: > Hello, I'm a JavaScript programmer and instructor who loves functional > programming and writing concise, readable code. I think in general > JavaScript supports programming in a functional style quite well. However, > there is one small missing piece that I miss from other FP languages: the > simple-yet-useful pipeline operator. > > Similar to F#, Elixir, Elm, and other FP languages, the pipeline operator > |> helps make multiple function invocations more readable. Basically, > `sqrt(64)` is equivalent to `64 |> sqrt`. For example, given the following > functions: > > ```js > function doubleSay (str) { return str + ", " + str; } > function capitalize (str) { return str[0].toUpperCase() + > str.substring(1); } > function exclaim (str) { return str + '!'; } > ``` > > you could use the pipeline operator to expand your invocations for > readability: > > ```js > // old way: > // var result = exclaim(capitalize(doubleSay("hello"))); > > // new way: > var result = "hello" > |> doubleSay > |> capitalize > |> exclaim; > > // or, if you like one-liners: > var result = "hello" |> doubleSay |> capitalize |> exclaim > > result //=> "Hello, hello!" > ``` > > You can see a few more examples, including an advanced example with > Promises, here: https://github.com/mindeavor/ES7-pipeline-operator > > I'm inclined to think this feature is small and straight-forward to > implement. Other than the operator, there are no new semantics. The syntax > transformation is simple, and all existing code would remain unaffected. > > Although small, this feature increases the expressiveness of JavaScript > significantly by opening more API design possibilities. You can see this in > the link I included above. > > Thanks for reading. Any thoughts or comments? > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

