Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qubitproducts/alien-bind
An implementation of bind that does not use Function.prototype.bind
https://github.com/qubitproducts/alien-bind
ceh implement
Last synced: about 1 month ago
JSON representation
An implementation of bind that does not use Function.prototype.bind
- Host: GitHub
- URL: https://github.com/qubitproducts/alien-bind
- Owner: QubitProducts
- Created: 2015-06-02T15:31:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-03T09:33:53.000Z (over 9 years ago)
- Last Synced: 2024-10-14T08:36:34.383Z (3 months ago)
- Topics: ceh, implement
- Language: JavaScript
- Homepage:
- Size: 145 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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](http://underscorejs.org/) use the native bind function from `Function.prototype` however some people (ಠ_ಠ [MooTools](http://mootools.net/)) like to overwrite this with a version that only works partially. Use this to be confident that `bind` will work as expected.Installation
------------
```bash
npm install alien-bind
```Usage
-----
Example shamelessly stolen from [underscore.js](http://underscorejs.org/#bind).```javascript
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