Package detail

generator-function

TimothyGu4MIT2.0.1

A function that returns the normally hidden GeneratorFunction constructor

generator, function, native

readme

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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v2.0.1 - 2025-09-30

Commits

v2.0.0 - 2025-09-29

Commits

  • Initial reimplementation, tests, readme, types e5940de
  • [meta] remove unused files 460bbe9
  • [Dev Deps] add missing peer dep b873c0d
  • [meta] fix FUNDING.yml 9ae9d43

v1.0.0 - 2015-10-10

Commits