nodesource/rapid-stream

Name: rapid-stream

Owner: NodeSource

Description: Through stream that processes elements in parallel, with no regard for input order.

Created: 2015-06-16 17:09:49.0

Updated: 2015-09-22 17:14:33.0

Pushed: 2015-06-16 17:10:07.0

Homepage: null

Size: 100

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

rapid-stream

Through stream that processes elements in parallel, with no regard for input order.

Similar to parallel-transform, however because it ignores input order it can process input faster when incoming chunks take a variable amount of time to resolve, e.g. network requests behind a caching layer.

Usage

NPM

rapid(parallelism, [opts], handle)

Creates a new rapid stream that will handle at most parallelism chunks at any one time. Optionally, you may pass in opts to override the default stream options. Note that this is an object mode stream by default.

handle(chunk, encoding, next) is called for each incoming chunk, and works more or less the same as it does in through2.

t RapidStream = require('rapid-stream')
t from2       = require('from2')

stream = RapidStream(2, function(chunk, encoding, next) {
tTimeout(function() {
next(null, chunk)
 1000 * Math.random())


2([1, 2, 3, 4, 5]).pipe(stream).on('data', function(data) {
nsole.log(data)







License

MIT. See LICENSE.md for details.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.