1.10.0 • Published 8 years ago

halis-compose v1.10.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

halis-compose

Install

npm install halis-compose --save

Unit Tests

npm run test

Usage

Minimal usage:

const compose = require( 'halis-compose' );
let inc = x => x += 1;
let neg = x => x *= -1;

let add3 = compose.foldl( inc, inc, inc );
console.log( add3( 3 ) ); // 6

// foldr - last function takes n args
// the rest take one, this is required
let right = compose.foldr( inc, inc, inc, neg, Math.pow ); 
console.log( right( 3, 4 ) ); // -78

// foldl - first function takes n args
// the rest take one, this is required
let left = compose.foldl( Math.pow, inc, inc, neg );
console.log( left( 3, 4 ) ); // -83

// foldl - last function takes 2 args
let bad = compose.foldl( Math.pow, inc, inc, Math.pow );
// results in an error being thrown

// calling foldl or foldr without args
// results in the identity function
let identity = compose.foldl( );
console.log( identity( 234 ) ); // 234
1.10.0

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago