1.0.25 • Published 2 years ago
@avro/types v1.0.25
Avro types
Pure JavaScript implementation of the Avro specification.
Features
- Blazingly fast and compact serialization! Typically faster than JSON with much smaller encodings.
- All the Avro goodness and more: type inference, schema evolution, ...
- Support for serializing arbitrary JavaScript objects.
- Unopinionated 64-bit integer compatibility.
Installation
$ npm install @avro/types
@avro/types
is compatible with all versions of node.js since 0.11
.
Examples
Inside a node.js module, or using browserify:
const {Type} = require('@avro/types');
Encode and decode values from a known schema:
const type = Type.forSchema({ type: 'record', fields: [ {name: 'kind', type: {type: 'enum', symbols: ['CAT', 'DOG']}}, {name: 'name', type: 'string'} ] }); const buf = type.toBuffer({kind: 'CAT', name: 'Albert'}); // Encoded buffer. const val = type.fromBuffer(buf); // = {kind: 'CAT', name: 'Albert'}
Infer a value's schema and encode similar values:
const type = Type.forValue({ city: 'Cambridge', zipCodes: ['02138', '02139'], visits: 2 }); // We can use `type` to encode any values with the same structure: const bufs = [ type.toBuffer({city: 'Seattle', zipCodes: ['98101'], visits: 3}), type.toBuffer({city: 'NYC', zipCodes: [], visits: 0}) ];
1.0.25
2 years ago
1.0.24
2 years ago
1.0.23
3 years ago
1.0.22
3 years ago
1.0.21
3 years ago
1.0.20
4 years ago
1.0.19
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.11
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago
0.3.11
5 years ago
0.3.10
5 years ago
0.3.9
5 years ago
0.3.8
5 years ago
0.3.7
5 years ago
0.3.6
5 years ago
0.3.5
5 years ago
0.3.4
5 years ago
0.3.3
5 years ago
0.3.2
5 years ago
0.3.1
5 years ago
0.3.0
5 years ago
0.2.0
5 years ago
0.1.1
7 years ago
0.1.0
7 years ago