2.0.4 • Published 2 years ago

@via-org/avro v2.0.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

Avro

A via-specific pure JavaScript implementation of the Avro specification. Used for bundling data.

Features

  • Fast! Typically twice as fast as JSON with much smaller encodings.
  • Isomorphic: no reliance on node built-ins

Installation

$ npm install @via-org/avro
# or
$ yarn add @via-org/avro

Example

// Initialize a schema:
import { parse } from '@via-org/avro'

const tagParser = parse({
  type: 'record',
  name: 'Tag',
  fields: [
    { name: 'name', type: 'string' },
    { name: 'value', type: 'string' },
  ],
})

export const tagsParser = parse({
  type: 'array',
  items: tagParser,
})

// Encode
const tags = [{ name: 'Tag-Name', value: 'Tag-Value' }]
const encodedTags = tagsParser.toBuffer(tags) // encodedTags instanceof Uint8Array

// Decode
const decodedTags = tagsParser.fromBuffer(Uint8ArrayBuffer) // decodedTags === tags
2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago