$ cnpm install free-context
Free context from a function.
var free = require('free-context')
// Free context from `.push` method
var push = free(Array.prototype.push)
// First parameter is context, like `.call` or `.apply`
var foo = []
push(foo, 'hello', 'world')
$ npm install --save free-context
free(fn, [apply])Returns a function you can bind a context to with the first argument.
fn (Function): Target function for freeing context. Returns a new contextless version of this.apply (Boolean): Use array instead of argument list for following parameters.var push = free(Array.prototype.push)
var foo = []
push(foo, 'Hello', 'world', 'foo', 'bar')
Using apply:
// Enable `apply`:
var push = free(Array.prototype.push, true)
var foo = []
var items = ['Hello', 'world', 'foo', 'bar']
// Supply array with `apply` instead of arguments
push(foo, items)
MIT © Jamen Marz
Copyright 2013 - present © cnpmjs.org | Home |