Skip to content
/ genpipe Public

Tiny data processing library for TypeScript based on composable async generators.

Notifications You must be signed in to change notification settings

niagr/genpipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

genpipe

Tiny data processing library for TypeScript based on composable async generators.

Installation

Copy the file

The library is just one file - genpipe.ts. Copy it to your project and use it.

Install with npm

npm install genpipe

Usage

Basic example

import { Pipeline, toGen, F, delay } from 'genpipe'

const x = new Pipeline(toGen([20, 5, 2, 1]))
    .tf(F.map((i) => i * 2))
    .toAsync()
    .tf(F.mapConcurrent(10, async (i) => {
        const timeout = 1000 * Math.max(0.5, Math.random())
        console.log(`starting timeout async function ${i}`)
        await delay(timeout)
        console.log(`finished timeout async function ${i}`)
        return i
    }))
    .eval()

console.log(await x)

About

Tiny data processing library for TypeScript based on composable async generators.

Resources

Stars

Watchers

Forks

Packages

No packages published