@jsoldi/gen
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Gen

This library provides a class Gen<T> that wraps an async generator and offers a LINQ-like interface for handling asynchronous data streams.

import { Gen } from "@jsoldi/gen";

const gen = Gen.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
    .flatMap(a => a % 2 === 0 ? [a, a] : [])
    .take(6);

for await (let item of gen)
    console.log(item); // 2, 2, 4, 4, 6, 6

Package Sidebar

Install

npm i @jsoldi/gen

Weekly Downloads

1

Version

0.0.6

License

ISC

Unpacked Size

9.47 kB

Total Files

8

Last publish

Collaborators

  • jsoldi