viabiliza/node_modules/async-generator-function/README.md
equipe desenvolvimento a499796cf7 first commit
2025-10-15 15:07:36 -03:00

2.0 KiB

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