Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#1/usr/bin/false
# shellcheck shell=bash

eval "$(mise hook-env --shell bash)"
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

69 changes: 0 additions & 69 deletions .eslintrc.cjs

This file was deleted.

9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: CI
on:
push:
branches:
- main
jobs:
test:
name: Test
uses: mtth/sdk.ts/.github/workflows/test.yaml@main
36 changes: 0 additions & 36 deletions .github/workflows/ci.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: PR
on:
pull_request:
branches:
- main
paths-ignore:
- '**.md'
jobs:
test:
name: Test
uses: mtth/sdk.ts/.github/workflows/test.yaml@main
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.nyc_output
dist
dist/
lib/
node_modules/
out/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

4 changes: 4 additions & 0 deletions .mise/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tools]
pre-commit = "latest"
node = "22"
pnpm = "10"
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: local
hooks:
- id: prettier
name: Prettify TypeScript
language: system
entry: node_modules/.bin/prettier
types: [file, ts]
pass_filenames: true
- id: eslint
name: Lint TypeScript
language: system
entry: node_modules/.bin/eslint
types: [file, ts]
pass_filenames: true
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015-2017, Matthieu Monsch.
Copyright (c) 2015, Matthieu Monsch.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
102 changes: 11 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,94 +3,14 @@
Pure JavaScript implementation of the [Avro
specification](https://avro.apache.org/docs/current/spec.html).


## Features

+ Blazingly [fast and compact][benchmarks] serialization! Typically faster than
JSON with much smaller encodings.
+ All the Avro goodness and more: [type inference][type-inference], [schema
evolution][schema-evolution]...
+ Support for [serializing arbitrary JavaScript objects][logical-types].
+ Unopinionated [64-bit integer compatibility][custom-long].


## Installation

```sh
$ npm install avsc
```


## Documentation

+ [Home][home]
+ [API](https://github.com/mtth/avsc/wiki/API)
+ [Quickstart](https://github.com/mtth/avsc/wiki/Quickstart)
+ [Advanced usage](https://github.com/mtth/avsc/wiki/Advanced-usage)
+ [Benchmarks][benchmarks]


## Examples

```javascript
const avro = require('avsc');
```

+ Encode and decode values from a known schema:

```javascript
const type = avro.Type.forSchema({
type: 'record',
name: 'Pet',
fields: [
{
name: 'kind',
type: {type: 'enum', name: 'PetKind', 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:

```javascript
const type = avro.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})
];
```

+ Get a [readable stream][readable-stream] of decoded values from an Avro
container file (see the [`BlockDecoder` API][decoder-api] for an example
compressed using [Snappy][snappy]):

```javascript
avro.createFileDecoder('./values.avro')
.on('metadata', function (type) { /* `type` is the writer's type. */ })
.on('data', function (val) { /* Do something with the decoded value. */ });
```


[benchmarks]: https://github.com/mtth/avsc/wiki/Benchmarks
[browser-support]: https://github.com/mtth/avsc/wiki#browser-support
[custom-long]: https://github.com/mtth/avsc/wiki/Advanced-usage#custom-long-types
[decoder-api]: https://github.com/mtth/avsc/wiki/API#class-blockdecoderopts
[home]: https://github.com/mtth/avsc/wiki
[idl]: https://avro.apache.org/docs/current/idl.html
[logical-types]: https://github.com/mtth/avsc/wiki/Advanced-usage#logical-types
[node.js]: https://nodejs.org/en/
[readable-stream]: https://nodejs.org/api/stream.html#stream_class_stream_readable
[schema-evolution]: https://github.com/mtth/avsc/wiki/Advanced-usage#schema-evolution
[snappy]: https://avro.apache.org/docs/current/spec.html#snappy
[type-inference]: https://github.com/mtth/avsc/wiki/Advanced-usage#type-inference
## Migration checklist

* [x] Switch to pnpm
* [ ] Port `@avro/types`
* [ ] Port `@avro/streams`
* [ ] Port `@avro/idl`
* [ ] Add `avsc` shim
* [ ] Add benchmark
* [ ] Update README
* [ ] Update metadata in all package.json
* [ ] Add migration guide
1 change: 0 additions & 1 deletion doc
Submodule doc deleted from b36b2f
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import configs from '@mtth/eslint-plugin';

export default configs;
49 changes: 0 additions & 49 deletions etc/benchmarks/avro-serialization-implementations/README.md

This file was deleted.

This file was deleted.

Loading
Loading