# controlstream

> read Streams that have a read function, and pipe to multiple destinations

Latest version **0.0.6** (published 2012-08-11) · 0 weekly downloads

## Install

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

## 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.6 |
| Published | 2012-08-11 |
| First published | 2012-08-11 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tim Gestson |
| Maintainers | timthetoolman |
| Keywords | readable, stream, pipe |

## Links

- npm: https://www.npmjs.com/package/controlstream
- Repository: https://github.com/TimTheToolman/readStream
- npm.io page: https://npm.io/package/controlstream

## 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.6 (latest) — 2012-08-11
- 0.0.5 — 2012-08-11

## README

ReadStream
==========
Install

	npm install controlstream


create a ReadStream

	var controlStream = require('controlstream').controlStream
	var cs = new controlStream()
	
	fs.createReadStream('file').pipe(cs)
	
	cs.read(50, function(err, data){
		//first 50 bytes are available in data
		
	})
	

move to a certain location

	cs.curser = 100
	cs.read(50, function(err, data){
		//read bytes 100 to 150	
	
	})	
	
pipe to a destination

	var controlStream = require('controlstream').controlStream
	var cs = new controlStream()
	
	fs.createReadStream('file').pipe(cs).pipe(dest)
	
pipe to multiple destinations

	var controlStream = require('controlstream').controlStream
	var cs = new controlStream()
	
	fs.createReadStream('file').pipe(cs)
	
	cs.pipe(dest1)
	cs.pipe(dest2)


Advanced
========
	
	var controlStream = require('controlstream').controlStream
	var cs = new controlStream({slice:true})

if you pass options {slice:true}, every time you read, that data is no longer in the buffer 
	
	cs.read(10, function(err, data){
		//read a header and decide what to do with it
		cs.pipe(dest)
		//pipe the remaining bytes to a destination
		cs.pipe(dest2)
		//pipe remaining bytes to another destination
	})
	
only piping to one destination? or is this the last destination you are piping to?

	cs.pipe(dest, {slice:true})
	//when cs is done piping, there will be nothing left in the buffer

describe pace and cadence of the pipe (bytes per second)

	var controlStream = require('controlstream').controlStream
	var cs = new controlStream()
	
	fs.createReadStream('file').pipe(cs)

	cs.pipe(dest1, {pace:50,cadence:1000})
	//pipe at 50 bytes per second

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