lhl 2bdf874dbb create hai 1 ano
..
.github 2bdf874dbb create hai 1 ano
test 2bdf874dbb create hai 1 ano
.eslintrc 2bdf874dbb create hai 1 ano
.nycrc 2bdf874dbb create hai 1 ano
CHANGELOG.md 2bdf874dbb create hai 1 ano
LICENSE.md 2bdf874dbb create hai 1 ano
README.md 2bdf874dbb create hai 1 ano
index.d.mts 2bdf874dbb create hai 1 ano
index.d.ts 2bdf874dbb create hai 1 ano
index.js 2bdf874dbb create hai 1 ano
index.mjs 2bdf874dbb create hai 1 ano
legacy.js 2bdf874dbb create hai 1 ano
package.json 2bdf874dbb create hai 1 ano
require.mjs 2bdf874dbb create hai 1 ano
tsconfig.json 2bdf874dbb create hai 1 ano

README.md

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