# cloneable-readable

> Clone a Readable stream, safely

Latest version **3.0.0** (published 2022-06-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install cloneable-readable
pnpm add cloneable-readable
yarn add cloneable-readable
bun add cloneable-readable
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2022-06-29 |
| First published | 2016-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/cloneable-readable) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 120 |
| Author | Matteo Collina |
| Maintainers | matteo.collina |
| Keywords | readable, stream, clone |

## Links

- npm: https://www.npmjs.com/package/cloneable-readable
- Repository: https://github.com/mcollina/cloneable-readable
- Homepage: https://github.com/mcollina/cloneable-readable#readme
- Issues: https://github.com/mcollina/cloneable-readable/issues
- npm.io page: https://npm.io/package/cloneable-readable

## Dependencies (1)

- [readable-stream](https://npm.io/package/readable-stream.md) ^4.0.0

## 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

- 3.0.0 (latest) — 2022-06-29
- 1.1.3 (readable2) — 2019-05-25
- 2.1.0 — 2021-01-07
- 2.0.1 — 2019-05-23
- 2.0.0 — 2018-08-13
- 1.1.2 — 2018-03-14
- 1.1.1 — 2018-03-07
- 1.1.0 — 2018-03-07
- 1.0.0 — 2016-10-25
- 0.5.0 — 2016-09-21
- 0.4.0 — 2016-09-18
- 0.3.0 — 2016-09-08
- 0.2.0 — 2016-09-01
- 0.1.0 — 2016-04-26

## README

# cloneable-readable

Clone a Readable stream, safely.

```js
'use strict'

var cloneable = require('cloneable-readable')
var fs = require('fs')
var pump = require('pump')

var stream = cloneable(fs.createReadStream('./package.json'))

pump(stream.clone(), fs.createWriteStream('./out1'))

// simulate some asynchronicity
setImmediate(function () {
  pump(stream, fs.createWriteStream('./out2'))
})
```

**cloneable-readable** automatically handles `objectMode: true`.

This module comes out of an healthy discussion on the 'right' way to
clone a Readable in https://github.com/gulpjs/vinyl/issues/85
and https://github.com/nodejs/readable-stream/issues/202. This is my take.

**YOU MUST PIPE ALL CLONES TO START THE FLOW**

You can also attach `'data'` and `'readable'` events to them.

## API

### cloneable(stream)

Create a `Cloneable` stream.
A Cloneable has a `clone()` method to create more clones.
All clones must be resumed/piped to start the flow.

### cloneable.isCloneable(stream)

Check if `stream` needs to be wrapped in a `Cloneable` or not.

## Acknowledgements

This project was kindly sponsored by [nearForm](http://nearform.com).

## License

MIT

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