Native Function Composition

Simon Staton simon.staton at bynd.com
Thu Aug 24 16:04:33 UTC 2017


I'm not sure if this has been proposed before, if not I would like to
propose a native way to handle function composition.

This is not that trivial, it can be achieved via a generic utility however
considering this is quite a common pattern it might make sense to include
it as a native feature set

Something along the lines of

Function.prototype.compose(); // chained at end of callstack

Function.prototype.composeBefore();


This could* A) *return a new function* B) *chain from the original reference

Quite often composition is not limited to a single function so it could be
a better approach to allow multiple arguments to be chained

Could also follow a similar design as the Java implementation
<https://docs.oracle.com/javase/8/docs/api/java/util/function/Function.html#compose-java.util.function.Function->

Regards,
Simon Staton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170824/a8e930d3/attachment.html>


More information about the es-discuss mailing list