function-extended
function-extended
is a Javascript library that can be used standalone or incorporated into extended
var fn = ;
Or
var myextended = ;
Installation
npm install function-extended
Or download the source (minified)
Usage
bind
Binds a function to the specified scope, while currying any extra arguments.
bindAll
Binds all functions or a list of named functions to the specified scope.
var scope = a: "a" b: "b" c: "c" { return thisa; } { return thisb; } { return thisc; }; fn; scopeaFunc; //"a"scopebFunc; //"a"scopecFunc; //"c" //or fn; scopeaFunc; //"a"scopebFunc; //undefinedscopecFunc; //undefined
bindIgnore
Binds a function to the specified scope while ignoring any extra arguments passed in.
var { return argumentslength thistest;};var scope = test: true; var fn1 = fn fn2 = fn3 = ; ; //[1, true]; //[1,true]fn3"world"; //[1, true];
partial
Creates a function that does not change the eventual scope, but allows the you specify arguments that should be passed in.
var { return str + " " + thisworld;}; var a = fn;var b =; a; //hello worldb; //hello world //With a string var c = fn c2 = var scope = { return "hello"; } { return "world"; };c; //helloc2; //world
applyFirst
Binds the function to the first arguments passed in.
var { return thistest;}; var newFn = fn;; //true newFn = ;; var push = fn pop = ; var arr = ;;//arr === [1]; ;//arr === [];
curry
Create a curried function.
var curried = fn; ;;;; //"a,b,c,d" //OR "b""c""d"; //"a,b,c,d"