bind-append

1.0.1 • Public • Published

bind-append

Creates a new function with the given this and the appended arguments.

. It works like Function.prototype.bind

.. but does not pollute Function.prototype

... and appends the arguments to the new Function arguments

.... instead of prepending them

install

npm i -S bind-append

use

var bindAppend = require('bind-append');
 
function linear(x, a, b) {
    return a + b * x;
}
 
var fn = bindAppend(linear, null, 1, 2);
 
assert.equal(fn(0), 1);
assert.equal(fn(1), 3);
assert.equal(fn(2), 5);
 

test

npm test

API

bindAppend(function, thisArg[, arg1[, arg2[, ...]]])

license

MIT

author

Andi Neck @andineck

Package Sidebar

Install

npm i bind-append

Weekly Downloads

10

Version

1.0.1

License

MIT

Last publish

Collaborators

  • andineck