npm.io
0.1.0 • Published 12 years ago

is-genobj

Licence
MIT
Version
0.1.0
Deps
0
Vulns
0
Weekly
0

is-genobj

Validate an es6 generator object.

'use strict'
var bint = require('bignum'),
    isGobj = require('is-genobj');

// nifty
var fib = function*(){
  let x = bint(0), y = bint(1), z = bint(0);
  while(true){
    z = x.add(y);
    x = y;
    y = z;
    yield y;
  }
};

// no
console.log("Is it a generator object? " + isGobj(fib);

// yes
console.log("Is it a generator object? " + isGObj(fib());

Keywords