cumpa
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

cumpa

Minimal function composition implementation

cumpa

cumpá in some Italian 🇮🇹 dialects means fellow

Build Status

NPM version NPM downloads MIT License

Usage

import compose from 'cumpa'

const add2 = x => x + 2
const multiplyBy3 = x => x * 3

const add2AndMultiplyBy3 = compose(multiplyBy3, add2)

console.log(add2AndMultiplyBy3(1)) // ((1 + 2) * 3) = 9

API

Table of Contents

composeRight

Similar to compose but performs from left-to-right function composition.
see also

Parameters

  • fns ...[function] ) - list of unary fynctions

Returns any result of the computation

compose

Performs right-to-left function composition. Use Array.prototype.reduce() to perform right-to-left function composition. The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.
source code

Parameters

  • fns ...[function] ) - list of unary fynctions

Returns any result of the computation

Package Sidebar

Install

npm i cumpa

Weekly Downloads

548

Version

2.0.1

License

MIT

Unpacked Size

7.01 kB

Total Files

6

Last publish

Collaborators

  • gianlucaguarini