free-context
Free context from a function.
Last updated 10 years ago by jamen .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install free-context 
SYNC missed versions from official npm registry.

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')

Installation

$ npm install --save free-context

Usage

free(fn, [apply])

Returns a function you can bind a context to with the first argument.

Parameters

  • 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.

Examples

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)

License

MIT © Jamen Marz


version travis downloads license follow

Current Tags

  • 0.0.0                                ...           latest (10 years ago)

1 Versions

  • 0.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 7
Today 0
This Week 4
This Month 5
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE