Check whether a given value is a generator function (evacuated from NSA/Microsoft Github)
greenkeeper[bot] bceb5f0966 Update dependencies to enable Greenkeeper 🌴 (#5) | 7 gadi atpakaļ | |
---|---|---|
.gitignore | 11 gadi atpakaļ | |
.travis.yml | 9 gadi atpakaļ | |
LICENSE | 11 gadi atpakaļ | |
README.md | 7 gadi atpakaļ | |
is-generator.js | 9 gadi atpakaļ | |
package.json | 7 gadi atpakaļ | |
test.js | 9 gadi atpakaļ |
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.
npm install is-generator --save
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
MIT