1.0.1 • Published 9 years ago

alien-bind v1.0.1

Weekly downloads
16
License
ISC
Repository
github
Last release
9 years ago

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
1.0.1

9 years ago

1.0.0

9 years ago