JSPM

@jsoldi/gen

0.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q19414F
  • License ISC

Async-iterator monadic linq-like wrapper.

Package Exports

  • @jsoldi/gen
  • @jsoldi/gen/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jsoldi/gen) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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