Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 423 Bytes

README.md

File metadata and controls

27 lines (20 loc) · 423 Bytes

Async Iterators

Usage

function * _sampleIterator(a: number) {
  const b = yield new Promise(
    r => setTimeout(() => r(a + 1), 1000)
  );

  const c = yield function * () {
    const d = yield b + 1;
    yield d + 1;
  }

  const e = yield () => {
    return c + 1
  }

  return e + 1;
}

const taskInstance = asyncIteratorFactory(_sampleIterator(1));

const result = await taskInstance();
// result = 5