Check whether a given value is a generator function (evacuated from NSA/Microsoft Github)

greenkeeper[bot] bceb5f0966 Update dependencies to enable Greenkeeper 🌴 (#5) 7 лет назад
.gitignore f5d14ece53 Check whether a function is a generator. 10 лет назад
.travis.yml 6d4a0e0703 test on 0.12 and iojs 9 лет назад
LICENSE f5d14ece53 Check whether a function is a generator. 10 лет назад
README.md bceb5f0966 Update dependencies to enable Greenkeeper 🌴 (#5) 7 лет назад
is-generator.js c6ef260ba7 remove `is-generator` check on function proto 9 лет назад
package.json bceb5f0966 Update dependencies to enable Greenkeeper 🌴 (#5) 7 лет назад
test.js da607d06af assert existence of constructor 9 лет назад

README.md

Is Generator

NPM version NPM downloads Build status Test coverage Greenkeeper badge

Check whether a value is a generator or generator function.

Generator: A specific type of iterator object. Reference. Generator Function: A function* declaration, returns a generator object. Reference.

Installation

npm install is-generator --save

Usage

var isGenerator = require('is-generator')
var isGeneratorFn = require('is-generator').fn

isGenerator(null) //=> false
isGenerator(function * () {}) //=> false
isGenerator((function * () {})()) //=> true

isGeneratorFn(null) //=> false
isGeneratorFn(function () {}) //=> false
isGeneratorFn(function * () {}) //=> true

License

MIT