# burro

> auto-packaged, length-prefixed JSON byte streams

Latest version **0.4.13** (published 2013-06-21) · BSD license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.13 |
| Published | 2013-06-21 |
| First published | 2013-02-20 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ~0.10.12 |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Naomi Kyoto |
| Maintainers | naomik |
| Keywords | json, stream, buffer, streams2 |

## Links

- npm: https://www.npmjs.com/package/burro
- Repository: https://github.com/naomik/burro
- Issues: https://github.com/naomik/burro/issues
- npm.io page: https://npm.io/package/burro

## Dependencies (1)

- [bun](https://npm.io/package/bun.md) ~0.0.6

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.4.13 (latest) — 2013-06-21
- 0.4.12 — 2013-04-03
- 0.4.11 — 2013-03-13
- 0.4.10 — 2013-03-12
- 0.4.9 — 2013-03-11
- 0.4.8 — 2013-03-10
- 0.4.7 — 2013-03-10
- 0.4.6 — 2013-03-10
- 0.4.5 — 2013-03-10
- 0.4.4 — 2013-03-08
- 0.4.3 — 2013-02-27
- 0.4.2 — 2013-02-27
- 0.4.1 — 2013-02-25
- 0.4.0 — 2013-02-25
- 0.3.0 — 2013-02-23
- … 3 more at https://npm.io/package/burro/versions

## README

Burro  ![build status][build_status]
=====

Burro is a useful creature that auto-packages objects in length-prefixed JSON
byte streams.


Overview
--------

Burro is made up of **4 streams** that makes sending/receiving objects a breeze

Sender streams:

* _burro.Encoder_ - encodes objects into proper JSON strings
* _burro.Framer_ - frames JSON in a **uint32be** length-prefixed buffer

Receiver streams:

* _burro.Unframer_ - processes length prefix and parses out JSON
* _burro.Decoder_ - decodes JSON into objects


Example
-------

```js
var burro  = require("burro"),
    stream = require("stream");

// dummy network stream
var network = new stream.PassThrough();
    
// wrap! auto encode/decode json frames
var socket = burro.wrap(network);

// send data
socket.write({message: "どもうありがとう！", from: "japan", to: "usa"});
socket.write({message: "thank you!", from: "usa", to: "japan"});

// dummy parser; extracts message from payload
var parser = new stream.Transform({objectMode: true});
parser._transform = function _transform (obj, encoding, done) {
  this.push(obj.from + " says: " + obj.message + "\n");
  done();
};

// cross the streams!
socket.pipe(parser).pipe(process.stdout);
```


Output

```
japan says: どもうありがとう！
usa says: thank you!
```


Installation
------------

Available via [npm][burro]:

> $ npm install burro

Or via git:

> $ git clone git://github.com/naomik/burro.git node_modules/burro


API
---

**wrap**

This is burro's easy mode. It will automatically construct the entire burro
chain around your existing duplex stream. If you want to configure the burro
chain manually, please see [lib/burro.js][lib]

```js
var socket = burro.wrap(duplexStream);
```

Arguments

* _duplexStream_ - an object implementing the `stream.Duplex` API. It must have 
  the following functions defined: `_read`, `_write`, `pipe`, `unpipe`.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 


Tests
-----

Burro is a pretty versatile beast and can even handle very large payloads. It is
also tested against network packet **fragmenting** and **buffering**, thanks to
[hiccup][hiccup]. See the [tests][tests] for more details.

Development dependencies: 

* [mocha][mocha]
* [hiccup][hiccup]

> $ npm install mocha

> $ npm install hiccup

[build_status]: https://travis-ci.org/naomik/burro.png
[burro]: https://npmjs.org/package/burro
[lib]: https://github.com/naomik/burro/blob/master/lib/burro.js#L10-L14
[tests]: https://github.com/naomik/burro/tree/master/test
[mocha]: https://npmjs.org/package/mocha
[hiccup]: https://npmjs.org/package/hiccup

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