@functional-things/compose
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@functional-things/compose

Function composition utilities for TypeScript.

This package provides functional composition utilities for TypeScript. Specifically, it provides two functions: compose and composeRight.

Install

$ npm install --save @functional-things/compose

Usage

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.

composeRight

composeRight, like compose, composes arity-one (single argument) functions. However, 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 f(g(h(x))).

Package Sidebar

Install

npm i @functional-things/compose

Weekly Downloads

1

Version

2.0.0

License

Unlicense

Unpacked Size

65.5 kB

Total Files

8

Last publish

Collaborators

  • joebobmiles