Skip to content

A function that returns the normally hidden `AsyncGeneratorFunction` constructor

License

Notifications You must be signed in to change notification settings

ljharb/async-generator-function

Repository files navigation

async-generator-function Version Badge

github actions coverage License Downloads

npm badge

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

Getting started

npm install --save async-generator-function

Usage/Examples

const assert = require('assert');
const AsyncGeneratorFunction = require('async-generator-function')();

const fn = new AsyncGeneratorFunction('return 1');

assert.equal(fn.toString(), 'async function* anonymous(\n) {\nreturn 1\n}');

const iterator = fn();
iterator.next().then(x => {
    assert.deepEqual(x, { done: true, value: 1 });
});

Tests

Clone the repo, npm install, and run npm test

About

A function that returns the normally hidden `AsyncGeneratorFunction` constructor

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks