npm.io
2.0.3 • Published 11 years ago

aureooms-js-functools

Licence
AGPL-3.0
Version
2.0.3
Deps
0
Vulns
0
Weekly
0
Stars
1
DeprecatedThis package is deprecated

js-functools

Function tools for JavaScript.

let j = ( a , b , c , x ) => a * x**2 + b * x + c ;
let p = partial( j , [ 5 , 4 , -1 ] ) ;
p( -1 ) ; // 5 - 4 - 1 = 0

NPM license NPM version Bower version Build Status Coverage Status Dependencies Status devDependencies Status Code Climate NPM downloads per month GitHub issues Inline docs

Can be managed through jspm, duo, component, bower, ender, jam, spm, and npm.

Install

jspm

jspm install github:aureooms/js-functools
# or
jspm install npm:aureooms-js-functools
duo

No install step needed for duo!

component
component install aureooms/js-functools
bower
bower install aureooms-js-functools
ender
ender add aureooms-js-functools
jam
jam install aureooms-js-functools
spm
spm install aureooms-js-functools --save
npm
npm install aureooms-js-functools --save

Require

jspm
let functools = require( "github:aureooms/js-functools" ) ;
// or
import functools from 'aureooms-js-functools' ;
duo
let functools = require( "aureooms/js-functools" ) ;
component, ender, spm, npm
let functools = require( "aureooms-js-functools" ) ;
bower

The script tag exposes the global variable functools.

<script src="bower_components/aureooms-js-functools/js/dist/functools.min.js"></script>

Alternatively, you can use any tool mentioned here.

jam
require( [ "aureooms-js-functools" ] , function ( functools ) { ... } ) ;

Use

let f = x => x + 1 ;
let g = x => 2 * x ;
let odd = compose( f , g ) ;
odd( 7 ) ; // 2 * 7 + 1 = 15

let j = ( a , b , c , x ) => a * x**2 + b * x + c ;
let p = partial( j , [ 5 , 4 , -1 ] ) ;
p( -1 ) ; // 5 - 4 - 1 = 0

let add = curry( ( x , y ) => x + y , 2 ) ;
add(2)(3) ; // 5

Reference