Awesome
smart-bind
Smarter binding of function with some context. It uses .apply instead of .bind, with reason.
Install
npm i smart-bind --save
Usage
For more use-cases see the tests
const smartBind = require('smart-bind')
smartBind
Smart bind
ctx
tofn
instead use of native.bind
Params
ctx
{Object|Function}fn
{Function}returns
{Function}
Example
var smartBind = require('smart-bind')
function zoopark () { return this.foo }
var bound = smartBind({foo: 'bar'}, zoopark)
console.log(bound()) // => 'bar'
console.log(bound.toString()) // => 'function zoopark () { return this.foo }'
Related
- bind-context: Bind context to a function and preserves her name. Can be used… more | homepage
- is-bound-function: Check if given function is bound or not. | homepage
- relike: Simple promisify a callback-style function with sane defaults. Support promisify-ing sync functions. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.