generator-function
Expose the ES2015 GeneratorFunction
constructor.
Installation
npm install generator-function
Description
Like Function
s, one could create generator functions from a JavaScript string
through a special constructor called GeneratorFunction
. However, the
constructor function is not available as a global, so one has to use the
constructor
property of an existing generator function.
This module makes it easy to do so, and falls back gracefully when a runtime not supporting generator functions is encountered.
Usage
On a platform supporting generator functions:
var GeneratorFunction = var generatorFunction = 'arg1' 'yield arg1'var generator = generatornext//=> { value: 1, done: false }generatornext//=> { value: undefined, done: true }
On a runtime that does not support them:
var GeneratorFunction = GeneratorFunction// => undefined
License
MIT