0.1.0 • Published 10 years ago

is-genobj v0.1.0

Weekly downloads
1
License
MIT
Repository
-
Last release
10 years ago

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());