parallel-transform-web
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

parallel-transform-web

Build JavaScript Style Guide

Parallel transform for web streams. Zero dependencies.

Note: does not preserve ordering.

Install

npm i parallel-transform-web

Usage

import { Parallel } from 'parallel-transform-web'

// a stream that yields random numbers, forever!
const randomNumbers = new ReadableStream({ pull: controller => controller.enqueue(Math.random() * 10) })
// run up to 10 transforms concurrently
const concurrency = 10
// identity transform that adds a short delay
const transformer = n => new Promise(resolve => setTimeout(() => resolve(n), n))
// parallelized transform stream
const delayer = new Parallel(concurrency, transformer)
// writable stream that just logs whatever is written to it
const logger = new WritableStream({ write: n => console.log(n) })

await randomNumbers.pipeThrough(delayer).pipeTo(logger)

Contributing

Feel free to join in. All welcome. Please open an issue!

License

Dual-licensed under MIT + Apache 2.0

Package Sidebar

Install

npm i parallel-transform-web

Weekly Downloads

913

Version

1.0.1

License

Apache-2.0 OR MIT

Unpacked Size

17.3 kB

Total Files

5

Last publish

Collaborators

  • alanshaw