|
3 | 3 | Pure JavaScript implementation of the [Avro |
4 | 4 | specification](https://avro.apache.org/docs/current/spec.html). |
5 | 5 |
|
6 | | - |
7 | | -## Features |
8 | | - |
9 | | -+ Blazingly [fast and compact][benchmarks] serialization! Typically faster than |
10 | | - JSON with much smaller encodings. |
11 | | -+ All the Avro goodness and more: [type inference][type-inference], [schema |
12 | | - evolution][schema-evolution]... |
13 | | -+ Support for [serializing arbitrary JavaScript objects][logical-types]. |
14 | | -+ Unopinionated [64-bit integer compatibility][custom-long]. |
15 | | - |
16 | | - |
17 | | -## Installation |
18 | | - |
19 | | -```sh |
20 | | -$ npm install avsc |
21 | | -``` |
22 | | - |
23 | | - |
24 | | -## Documentation |
25 | | - |
26 | | -+ [Home][home] |
27 | | -+ [API](https://github.com/mtth/avsc/wiki/API) |
28 | | -+ [Quickstart](https://github.com/mtth/avsc/wiki/Quickstart) |
29 | | -+ [Advanced usage](https://github.com/mtth/avsc/wiki/Advanced-usage) |
30 | | -+ [Benchmarks][benchmarks] |
31 | | - |
32 | | - |
33 | | -## Examples |
34 | | - |
35 | | -```javascript |
36 | | -const avro = require('avsc'); |
37 | | -``` |
38 | | - |
39 | | -+ Encode and decode values from a known schema: |
40 | | - |
41 | | - ```javascript |
42 | | - const type = avro.Type.forSchema({ |
43 | | - type: 'record', |
44 | | - name: 'Pet', |
45 | | - fields: [ |
46 | | - { |
47 | | - name: 'kind', |
48 | | - type: {type: 'enum', name: 'PetKind', symbols: ['CAT', 'DOG']} |
49 | | - }, |
50 | | - {name: 'name', type: 'string'} |
51 | | - ] |
52 | | - }); |
53 | | - |
54 | | - const buf = type.toBuffer({kind: 'CAT', name: 'Albert'}); // Encoded buffer. |
55 | | - const val = type.fromBuffer(buf); // = {kind: 'CAT', name: 'Albert'} |
56 | | - ``` |
57 | | - |
58 | | -+ Infer a value's schema and encode similar values: |
59 | | - |
60 | | - ```javascript |
61 | | - const type = avro.Type.forValue({ |
62 | | - city: 'Cambridge', |
63 | | - zipCodes: ['02138', '02139'], |
64 | | - visits: 2 |
65 | | - }); |
66 | | - |
67 | | - // We can use `type` to encode any values with the same structure: |
68 | | - const bufs = [ |
69 | | - type.toBuffer({city: 'Seattle', zipCodes: ['98101'], visits: 3}), |
70 | | - type.toBuffer({city: 'NYC', zipCodes: [], visits: 0}) |
71 | | - ]; |
72 | | - ``` |
73 | | - |
74 | | -+ Get a [readable stream][readable-stream] of decoded values from an Avro |
75 | | - container file (see the [`BlockDecoder` API][decoder-api] for an example |
76 | | - compressed using [Snappy][snappy]): |
77 | | - |
78 | | - ```javascript |
79 | | - avro.createFileDecoder('./values.avro') |
80 | | - .on('metadata', function (type) { /* `type` is the writer's type. */ }) |
81 | | - .on('data', function (val) { /* Do something with the decoded value. */ }); |
82 | | - ``` |
83 | | - |
84 | | - |
85 | | -[benchmarks]: https://github.com/mtth/avsc/wiki/Benchmarks |
86 | | -[browser-support]: https://github.com/mtth/avsc/wiki#browser-support |
87 | | -[custom-long]: https://github.com/mtth/avsc/wiki/Advanced-usage#custom-long-types |
88 | | -[decoder-api]: https://github.com/mtth/avsc/wiki/API#class-blockdecoderopts |
89 | | -[home]: https://github.com/mtth/avsc/wiki |
90 | | -[idl]: https://avro.apache.org/docs/current/idl.html |
91 | | -[logical-types]: https://github.com/mtth/avsc/wiki/Advanced-usage#logical-types |
92 | | -[node.js]: https://nodejs.org/en/ |
93 | | -[readable-stream]: https://nodejs.org/api/stream.html#stream_class_stream_readable |
94 | | -[schema-evolution]: https://github.com/mtth/avsc/wiki/Advanced-usage#schema-evolution |
95 | | -[snappy]: https://avro.apache.org/docs/current/spec.html#snappy |
96 | | -[type-inference]: https://github.com/mtth/avsc/wiki/Advanced-usage#type-inference |
| 6 | +## Migration checklist |
| 7 | + |
| 8 | +* [x] Switch to pnpm |
| 9 | +* [ ] Port `@avro/types` |
| 10 | +* [ ] Port `@avro/streams` |
| 11 | +* [ ] Port `@avro/idl` |
| 12 | +* [ ] Add `avsc` shim |
| 13 | +* [ ] Add benchmark |
| 14 | +* [ ] Update README |
| 15 | +* [ ] Add migration guide |
0 commit comments