bind-gen

0.1.3 • Public • Published

node-bind-gen Build Status

A simple helper function to use bind with generator functions. It works like lodash bind function, or the built-in bind, but takes and returns a generator function instead of a normal one.

Installation

$ npm install bind-gen

Example

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

Readme

Keywords

Package Sidebar

Install

npm i bind-gen

Weekly Downloads

1

Version

0.1.3

License

MIT

Last publish

Collaborators

  • danhper