elearning/Frontend-Learner/node_modules/generator-function
2026-01-13 10:48:02 +07:00
..
.github Website Structure 2026-01-13 10:48:02 +07:00
test Website Structure 2026-01-13 10:48:02 +07:00
.eslintrc Website Structure 2026-01-13 10:48:02 +07:00
.nycrc Website Structure 2026-01-13 10:48:02 +07:00
CHANGELOG.md Website Structure 2026-01-13 10:48:02 +07:00
index.d.mts Website Structure 2026-01-13 10:48:02 +07:00
index.d.ts Website Structure 2026-01-13 10:48:02 +07:00
index.js Website Structure 2026-01-13 10:48:02 +07:00
index.mjs Website Structure 2026-01-13 10:48:02 +07:00
legacy.js Website Structure 2026-01-13 10:48:02 +07:00
LICENSE.md Website Structure 2026-01-13 10:48:02 +07:00
package.json Website Structure 2026-01-13 10:48:02 +07:00
README.md Website Structure 2026-01-13 10:48:02 +07:00
require.mjs Website Structure 2026-01-13 10:48:02 +07:00
tsconfig.json Website Structure 2026-01-13 10:48:02 +07:00

generator-function Version Badge

github actions coverage License Downloads

npm badge

A function that returns the normally hidden GeneratorFunction constructor, when available.

Getting started

npm install --save generator-function

Usage/Examples

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

Tests

Clone the repo, npm install, and run npm test