# read-write-stream

> Base stream class for RW stream

Latest version **0.1.8** (published 2021-10-08) · 0 weekly downloads

## Install

```sh
npm install read-write-stream
pnpm add read-write-stream
yarn add read-write-stream
bun add read-write-stream
```

## 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.1.8 |
| Published | 2021-10-08 |
| First published | 2012-09-27 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Raynos |
| Maintainers | raynos |

## Links

- npm: https://www.npmjs.com/package/read-write-stream
- Repository: https://github.com/Raynos/read-write-stream
- Issues: https://github.com/Raynos/read-write-stream/issues
- npm.io page: https://npm.io/package/read-write-stream

## Dependencies (3)

- [xtend](https://npm.io/package/xtend.md) ~1.0.3
- [read-stream](https://npm.io/package/read-stream.md) ~0.5.1
- [readable-stream](https://npm.io/package/readable-stream.md) 3.6.0

## Recent versions

- 0.1.8 (latest) — 2021-10-08
- 0.1.7 — 2013-06-21
- 0.1.6 — 2012-12-03
- 0.1.5 — 2012-12-03
- 0.1.4 — 2012-10-21
- 0.1.3 — 2012-10-20
- 0.1.2 — 2012-10-19
- 0.1.1 — 2012-10-15
- 0.1.0 — 2012-09-27

## README

# read-write-stream

Base stream class for through RW stream

## Example through

``` js
var through = require("read-write-stream")
    , transform = through(function write(chunk, queue) {
        queue.push(chunk * chunk)
    }).stream
    , to = require("write-stream").toArray
    , from = require("read-stream").fromArray

from([1,2,3]).pipe(transform).pipe(to([], function end(list) {
    console.log(list); // [1, 4, 9]
}))
```

## Example duplex

``` js
var axon = require("axon")
    , pub = axon.socket("push")
    , sub = axon.socket("pull")
    , duplex = require("read-write-stream")
    , from = require("read-stream").fromArray
    , to = require("write-stream").toArray

// Writable end of duplex
var queue = duplex(function write(chunk) {
    pub.send(chunk)
}, function end() {
    pub.send("__GOODBYE__")
    setTimeout(pub.close.bind(pub), 1000)
})

// Readable end of duplex
sub.on("message", function (chunk) {
    chunk = chunk.toString()
    if (chunk === "__GOODBYE__") {
        queue.end()
        sub.close()
    } else {
        queue.push(chunk)
    }
})

// Open underlying writable data source
pub.bind(3000, function () {
    // Open underlying readable data source
    sub.connect(3000, function () {
        // flow data from array
        from(["foo", "bar", "baz"])
            // into duplex
            .pipe(queue.stream)
            // into array
            .pipe(to([], function (list) {
                console.log("list from sub", list)
            }))
    })
})
```

## Installation

`npm install read-write-stream`

## Contributors

 - Raynos

## MIT Licenced

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