alien-bind
v1.0.1
Published
An implementation of bind that does not use Function.prototype.bind.
Downloads
25
Readme
Alien Bind
An implementation of bind
that does not use Function.prototype.bind
(alien being the opposite of native).
Motivation
Many libraries such as underscore.js use the native bind function from Function.prototype
however some people (ಠ_ಠ MooTools) like to overwrite this with a version that only works partially. Use this to be confident that bind
will work as expected.
Installation
npm install alien-bind
Usage
Example shamelessly stolen from underscore.js.
var bind = require('alien-bind')
var func = function (greeting){ return greeting + ': ' + this.name }
func = bind(func, {name: 'moe'}, 'hi')
func()
// => 'hi: moe'
Compatibility
Tests pass in
- IE8+
- Chrome
- Firefox
- Opera