Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danhper/node-bind-gen
bind for generators
https://github.com/danhper/node-bind-gen
Last synced: about 1 month ago
JSON representation
bind for generators
- Host: GitHub
- URL: https://github.com/danhper/node-bind-gen
- Owner: danhper
- License: mit
- Created: 2015-07-08T12:23:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-08T12:38:24.000Z (over 9 years ago)
- Last Synced: 2024-10-13T01:01:32.531Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 113 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-bind-gen [![Build Status](https://travis-ci.org/tuvistavie/node-bind-gen.svg)](https://travis-ci.org/tuvistavie/node-bind-gen)
A simple helper function to use `bind` with generator functions.
It works like [lodash](http://lodash.com) `bind` function, or the
built-in `bind`, but takes and returns a generator function
instead of a normal one.## Installation
```sh
$ npm install bind-gen
```## Example
```javascript
var co = require('co');
var bindGen = require('bind-gen');var myGenerator = function *(myArg, myOtherArg) {
console.log(this.v);
console.log(myArg);
console.log(myOtherArg);
};var context = {v: 'the-context'};
var boundGenerator = bindGen(myGenerator, context, 'arg');co(boundGenerator('other arg'));
// will print:
// the-context
// arg
// other arg
```