# packet-stream-codec

> Binary codec for packet-stream

Latest version **1.2.0** (published 2022-01-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install packet-stream-codec
pnpm add packet-stream-codec
yarn add packet-stream-codec
bun add packet-stream-codec
```

## 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 | 1.2.0 |
| Published | 2022-01-29 |
| First published | 2015-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 2 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Dominic Tarr |
| Maintainers | chereseeriepa, happy0, staltz, arj03, pfrazee, mixmix, cel, christianbundy, dominictarr |

## Links

- npm: https://www.npmjs.com/package/packet-stream-codec
- Repository: https://github.com/ssbc/packet-stream-codec
- Issues: https://github.com/ssbc/packet-stream-codec/issues
- npm.io page: https://npm.io/package/packet-stream-codec

## Dependencies (2)

- [pull-reader](https://npm.io/package/pull-reader.md) ^1.3.1
- [pull-through](https://npm.io/package/pull-through.md) ^1.0.18

## Recent versions

- 1.2.0 (latest) — 2022-01-29
- 1.1.3 — 2021-01-05
- 1.1.2 — 2017-06-08
- 1.1.1 — 2016-04-06
- 1.1.0 — 2015-06-25
- 1.0.0 — 2015-06-25

## README

# packet-stream-buffers

A tight binary codec for packet-streams (the internal component to
[muxrpc](https://github.com/ssbc/muxrpc))

This allows streams of binary data, and also supports json objects.
(although, you can't send a buffer inside a json object, but so far
we have not done this in secure-scuttlebutt, so performance is more
important)


The protocol sends zero or more header:body pairs,
then a final header that is all zeros.

```
(
  [flags (1byte), length (4 bytes, UInt32BE), req (4 bytes, Int32BE)]
  [body (length bytes)]
) *
[zeros (9 bytes)]
```

`flags` indicates the encoding type of the body, and whether it's
part of a stream, or an error/end value.

flags is just one byte.
``` js
[ignored (4 bits), stream (1 bit), end/err (1 bit), type (2 bits)]
type = {0 => Buffer, 1 => String, 2 => JSON}

```


## License

MIT

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