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

0.2.5 • Public • Published

Functional · Build Status

Contains methods for functional JavaScript patterns.

Installation

npm install @harbr/functional

Usage

Pipe and compose methods combine functions; calling each function with the output of the last one.

The primary difference is that a pipe is from left-to-right (top-to-bottom), where as compose is right-to-left (bottom-to-top).

pipe

const returnValue = pipe(
    (x) => x + 2,
    (x) => x * 3
)(1);
// returnValue = 9

compose

const returnValue = compose(
    (x) => x + 2,
    (x) => x * 3
)(1);
// returnValue = 5

Async Versions

pipeAsync and composeAsync can be used if any one of the methods in the chain is async or returns a promise.

Readme

Keywords

Package Sidebar

Install

npm i @harbr/functional

Weekly Downloads

5

Version

0.2.5

License

MIT

Unpacked Size

10.1 kB

Total Files

20

Last publish

Collaborators

  • jhorback