Function composition utilities for TypeScript.
This package provides functional composition utilities for TypeScript.
Specifically, it provides two functions:
$ npm install --save @functional-things/compose
compose composes arity-one (single argument) functions in the order written.
This means that
compose(f, g, h)(x) results in:
h(g(f(x))). While not the
traditional way of composing functions, this makes logical sense, since the
first function given to
compose is applied first.
compose, composes arity-one (single argument) functions.
composeRight composes these functions from right to left. This
matches the more traditional way of composing functions.
To given an examle:
composeRight(f, g, h)(x) becomes