# parallel-stream

> Concurrent transform stream

Latest version **1.1.2** (published 2016-05-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install parallel-stream
pnpm add parallel-stream
yarn add parallel-stream
bun add parallel-stream
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2016-05-29 |
| First published | 2014-12-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Ryan Clark |
| Maintainers | rclark |

## Links

- npm: https://www.npmjs.com/package/parallel-stream
- Repository: https://github.com/rclark/parallel-stream
- Issues: https://github.com/rclark/parallel-stream/issues
- npm.io page: https://npm.io/package/parallel-stream

## Recent versions

- 1.1.2 (latest) — 2016-05-29
- 1.1.1 — 2016-05-28
- 1.1.0 — 2016-05-28
- 1.0.0 — 2016-04-10
- 0.1.4 — 2015-01-17
- 0.1.3 — 2015-01-17
- 0.1.2 — 2015-01-15
- 0.1.1 — 2015-01-15
- 0.1.0 — 2014-12-16

## README

# parallel-stream

[![build status](https://travis-ci.org/rclark/parallel-stream.svg?branch=master)](https://travis-ci.org/rclark/parallel-stream)

Transform and writable streams capable of processing chunks concurrently.

## Usage

### transform

A concurrent transform stream

**Parameters**

-   `work` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a function to process a single chunk. Function
    signature should be `process(chunk, enc, callback)`. When finished processing,
    fire the provided `callback`.
-   `options` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** options to pass to the transform stream. (optional, default `undefined`)
    -   `options.concurrency` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** number of chunks to process concurrently. (optional, default `1`)

**Examples**

```javascript
var parallel = require('parallel-stream');

var transform = parallel.transform(function(chunk, enc, callback) {
  processAsync(chunk)
    .on('done', function(processedData) {
      callback(null, processedData);
    });
}, { objectMode: true, concurrency: 15 });

readable.pipe(transform)
 .on('data', function(data) {
    console.log('got processed data: %j', data);
 })
 .on('end', function() {
   console.log('complete!');
});
```

Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** a transform stream. **Do not** override the `._transform` function.

### writable

A concurrent writable stream

**Parameters**

-   `work` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a function to process a single chunk. Function
    signature should be `process(chunk, enc, callback)`. When finished processing,
    fire the provided `callback`.
-   `flush` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a function to run once all chunks have been
    processed, but before the stream emits a `finished` event. Function signature
    should be `flush(callback)`, fire the provided `callback` when complete. (optional, default `undefined`)
-   `options` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** options to pass to the writable stream. (optional, default `undefined`)
    -   `options.concurrency` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** number of chunks to process concurrently. (optional, default `1`)

**Examples**

```javascript
var parallel = require('parallel-stream');

var writable = parallel.writable(function(chunk, enc, callback) {
  processAsync(chunk)
    .on('done', callback);
}, { objectMode: true, concurrency: 15 });

readable.pipe(writable)
 .on('finish', function() {
   console.log('complete!');
});
```

Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** a writable stream. **Do not** override the `._write` function.

---
_Source: https://npm.io/package/parallel-stream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
