# node-avro-io

> This will allow you to encode / decode avro binary format to / from json format, it supports both deflate and snappy compressions and supports node streams

Latest version **2.0.0** (published 2019-01-07) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install node-avro-io
pnpm add node-avro-io
yarn add node-avro-io
bun add node-avro-io
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-01-07 |
| First published | 2013-03-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.x |
| Dependencies | 4 |
| Unpacked size | 12.1 MB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 27 |
| Author | James Power |
| Maintainers | jamesbrucepower, mdlavin |

## Links

- npm: https://www.npmjs.com/package/node-avro-io
- Repository: https://github.com/jamesbrucepower/node-avro-io
- Homepage: https://github.com/jamesbrucepower/node-avro-io#readme
- Issues: https://github.com/jamesbrucepower/node-avro-io/issues
- npm.io page: https://npm.io/package/node-avro-io

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^2.4.1
- [snappy](https://npm.io/package/snappy.md) ^6.1.1
- [buffer-crc32](https://npm.io/package/buffer-crc32.md) ^0.2.5
- [int64-native](https://npm.io/package/int64-native.md) ^0.5.0

## Recent versions

- 2.0.0 (latest) — 2019-01-07
- 1.0.1 — 2017-04-10
- 1.0.0 — 2016-10-04
- 0.3.3 — 2015-08-10
- 0.3.1 — 2015-08-07
- 0.3.0 — 2015-08-04
- 0.2.0 — 2013-11-27
- 0.1.0 — 2013-03-02

## README

Node Avro IO
============

[![Build Status](https://secure.travis-ci.org/jamesbrucepower/node-avro-io.png)](http://travis-ci.org/jamesbrucepower/node-avro-io)

Implements the [avro spec](http://avro.apache.org/docs/current/spec.html)

This status of this repository is *initial release*

```bash
npm install node-avro-io
```

or

```bash
npm install git://github.com/jamesbrucepower/node-avro-io.git
```

Serializing data to an avro binary file
```
var avro = require('./index').DataFile.AvroFile();
var schema = {
            "name": "data",
            "type": "record",
            "fields": [
                {"name":"key","type": "string"},
                {"name":"value","type": "string"},
                {"name":"flag","type": "boolean"},
                {"name":"subrecord","type":"record","fields":[
                    {"name":"key","type":"string"},
                    {"name":"value","type":["string","int","null"]}
                ]}
            ]
};
var writer = avro.open("test.avro", schema, { flags: 'w', codec: 'deflate' });
writer
    .append({ key:"john", value:"hive", flag: true, subrecord: { key: "preference", value: 2}})
    .append({ key:"eric", value:"lola", flag: true, subrecord: { key: "postcode", value: null}})
    .end({ key:"fred", value:"wonka", flag: false, subrecord: { key: "city", value: "michigan"}});
```

Deserializing data to from avro binary file
```
require("./index").DataFile.AvroFile()
	.open('test.avro', null, { flags: 'r' })
		.on('data', function(data) {
	  		console.log(data);
		});
```

See tests for more usage examples

TODO:

- Avro RPC
- Support for Trevni (column major data serialization)

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