generator-function
Expose the GeneratorFunction constructor if supported by the runtime
Last updated 11 years ago by timothygu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install generator-function 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.0.1                                ...           latest (6 months ago)

3 Versions

  • 2.0.1                                ...           6 months ago
  • 2.0.0                                ...           6 months ago
  • 1.0.0                                ...           11 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (1)

Copyright 2013 - present © cnpmjs.org | Home |