Skip to content

handlebauer/avsc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

avsc

A stripped-down Avro implementation. Used for bundling data.

Features

  • Isomorphic: no reliance on node built-ins

Installation

$ npm install @hbauer/avsc
# or
$ yarn add @hbauer/avsc

Example

// Initialize a schema:
import { createSchema } from '@hbauer/avro'

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

export const tagsParser = createSchema({
  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

About

Avro for JavaScript ⚡

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.4%
  • Shell 0.6%