# length-prefixed-stream

> Streaming length prefixed buffers

Latest version **2.0.0** (published 2019-02-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install length-prefixed-stream
pnpm add length-prefixed-stream
yarn add length-prefixed-stream
bun add length-prefixed-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 | 2.0.0 |
| Published | 2019-02-04 |
| First published | 2014-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Author | Mathias Buus |
| Maintainers | mafintosh |
| Keywords | varint, length, prefixed, stream, streaming |

## Links

- npm: https://www.npmjs.com/package/length-prefixed-stream
- Repository: https://github.com/mafintosh/length-prefixed-stream
- Issues: https://github.com/mafintosh/length-prefixed-stream/issues
- npm.io page: https://npm.io/package/length-prefixed-stream

## Dependencies (3)

- [varint](https://npm.io/package/varint.md) ^5.0.0
- [inherits](https://npm.io/package/inherits.md) ^2.0.3
- [readable-stream](https://npm.io/package/readable-stream.md) ^3.1.1

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

- 2.0.0 (latest) — 2019-02-04
- 1.6.0 — 2018-06-21
- 1.5.2 — 2018-03-23
- 1.5.1 — 2016-11-04
- 1.5.0 — 2016-03-05
- 1.4.0 — 2015-08-12
- 1.3.2 — 2015-08-06
- 1.3.1 — 2015-08-06
- 1.3.0 — 2015-06-16
- 1.2.0 — 2015-05-15
- 1.1.0 — 2015-03-06
- 1.0.1 — 2014-10-09
- 1.0.0 — 2014-08-16

## README

# length-prefixed-stream

Streaming equivalent of [length-prefixed-message](https://github.com/sorribas/length-prefixed-message).
This module allow you to send buffers with a varint length prefix to ensure that they will arrive unpartioned

```
npm install length-prefixed-stream
```

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

## Usage

``` js
var lpstream = require('length-prefixed-stream')

var encode = lpstream.encode() // create an encode stream to send data
var decode = lpstream.decode() // create an decode stream to receive data

encode.write('hello world') // send "hello world"

decode.on('data', function(data) {
  console.log(data.toString()) // will always print "hello world"
})

encode.pipe(decode) // for testing just pipe to our selves
```

## API

#### `transformStream = lpstream.encode()`

Creates a new encoder transform stream.

#### `transformStream = lpstream.decode()`

Creates a new decoder transform stream.

## License

MIT

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