|
|
1 week ago | |
|---|---|---|
| .. | ||
| .github | 1 week ago | |
| test | 1 week ago | |
| .eslintrc | 1 week ago | |
| .nycrc | 1 week ago | |
| CHANGELOG.md | 1 week ago | |
| LICENSE.md | 1 week ago | |
| README.md | 1 week ago | |
| index.d.mts | 1 week ago | |
| index.d.ts | 1 week ago | |
| index.js | 1 week ago | |
| index.mjs | 1 week ago | |
| legacy.js | 1 week ago | |
| package.json | 1 week ago | |
| require.mjs | 1 week ago | |
| tsconfig.json | 1 week ago | |
A function that returns the normally hidden GeneratorFunction constructor, when available.
npm install --save generator-function
const assert = require('assert');
const GeneratorFunction = require('generator-function')();
const fn = new GeneratorFunction('return 1');
assert.equal(fn.toString(), 'function* anonymous(\n) {\nreturn 1\n}');
const iterator = fn();
assert.deepEqual(iterator.next(), { done: true, value: 1 });
Clone the repo, npm install, and run npm test