2.0.3 • Published 11 years ago
aureooms-js-functools v2.0.3
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 = 0Can 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-functoolsduo
No install step needed for duo!
component
component install aureooms/js-functoolsbower
bower install aureooms-js-functoolsender
ender add aureooms-js-functoolsjam
jam install aureooms-js-functoolsspm
spm install aureooms-js-functools --savenpm
npm install aureooms-js-functools --saveRequire
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