1.0.2 • Published 5 years ago

p-sink v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

npm version

p-sink is a concurrency-limited promise-runner.

How it werks

import { createPSink } from 'p-sink'

// create runner
const sink = createPSink<number>({ maxConcurrency: 2 })

async function doStuff(): Promise<any> {
    // ...
}

sink.push(() => doStuff()).then(x => console.log('1'));

sink.push(() => doStuff()).then(x => console.log('2'));

sink.push(() => doStuff()).then(x => console.log('3'));

// close it
await sink.join();

Async Generators

for await (let item of sink.results)
    console.log(item)
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago