# srough

> Like `through` for async streams.

Latest version **0.0.1** (published 2014-06-21) · 0 weekly downloads

## Install

```sh
npm install srough
pnpm add srough
yarn add srough
bun add srough
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2014-06-21 |
| First published | 2014-06-21 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.6.11 <=0.7.0 \|\| >=0.7.3 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ClickHere |
| Maintainers | tounano |
| Keywords | stream, streams, user-streams, pipe, through |

## Links

- npm: https://www.npmjs.com/package/srough
- Repository: https://github.com/tounano/srough
- Homepage: https://github.com/tounano/srough/
- Issues: https://github.com/tounano/srough/issues
- npm.io page: https://npm.io/package/srough

## Dependencies (1)

- [underscore](https://npm.io/package/underscore.md) latest

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2014-06-21

## README

srough
======

Like [through](https://github.com/dominictarr/through) for async streams.

In 90% of the cases you should use [through](https://github.com/dominictarr/through).
Use `srough` only when you're stream is `async`.

The main idea is that streams are sync units that can perform async operations.

Data objects should be processed and written downstream in the same order they arrived from upstream.

Let's say we have a Transform stream that receives URL's from upstream and writes the response headers downstream.

Now, let's suppose that the urls are being written in the following order:

1.  `slowserver.com`
2.  `fastserver.com`

Downstream, should receive the `response headers` in the same order exactly. If we'll use [through](https://github.com/dominictarr/through)
the URLs would be processed concurrently and the response would be written downstream in a random order.

Eventually, `srough` is exactly the same thing as [through](https://github.com/dominictarr/through), just with `sync` callback.

## Usage

```js
var srough = require("srough");

var stream = srough(function write(data, done) {
                 somethingAsync(data, function (err, res) {
                    this.queue(res) //data *must* not be null
                    done(); // After you call this callback, will process next...
                 });
               },
               function end (done) { //optional
                 this.queue(null);
                 done();
               });
```

Basically same API as [through](https://github.com/dominictarr/through) just with a synchronization callback.

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