{"name":"avsc","version":"5.7.8","keywords":["api","avdl","avpr","avro","avsc","binary","buffer","data","decoding","encoding","idl","interface","ipc","json","marshalling","message","protocol","rpc","schema","serde","serialization","type"],"author":{"name":"Matthieu Monsch","email":"mtth@apache.org"},"license":"MIT","_id":"avsc@5.7.8","maintainers":[{"name":"mtth","email":"mtth@apache.org"}],"homepage":"https://github.com/mtth/avsc","bugs":{"url":"https://github.com/mtth/avsc/issues"},"dist":{"shasum":"24b054e8f4fed93361cf0af58eb8ba9b8a413c04","tarball":"http://registry-npm.ywwl.com/avsc/download/avsc-5.7.8.tgz","fileCount":17,"integrity":"sha512-6SyyCw6XzdiNrkJ3UF9dIj0cVexNQAGxwjZ69CRgEneBxdDKjjc2IdfEJD11iP4BfwQWrL8HwR04bx/Y3uUNEA==","signatures":[{"sig":"MEYCIQD4wMSAtBmlJ93VpOtPBkJG8OQRzbqz0DjquPyfCPFVRwIhANVQy6RdJFlQ/MiKDHiJp8pUqv+vJWIErj4Y9t6QTrQp","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":263895,"size":68142,"noattachment":false,"key":"/avsc/-/avsc-5.7.8.tgz"},"main":"./lib","types":"./types","browser":{"./lib":"./etc/browser/avsc.js","crypto":"./etc/browser/lib/crypto.js","./lib/files":"./etc/browser/lib/files.js"},"engines":{"node":">=0.11"},"gitHead":"77ee61c8f75447b9a762170ece2851fcfbf7e97f","scripts":{"dist":"./etc/scripts/dist","perf":"./etc/scripts/perf etc/schemas/*","test":"mocha --ui tdd --reporter dot","clean":"rm -rf coverage dist node_modules","cover":"nyc mocha -- --ui tdd","coverAndPublish":"nyc npm test && nyc report --reporter=text-lcov | coveralls"},"_npmUser":{"name":"mtth","actor":{"name":"mtth","type":"user","email":"mtth@apache.org"},"email":"mtth@apache.org"},"repository":{"url":"git://github.com/mtth/avsc.git","type":"git"},"_npmVersion":"11.4.2","description":"Avro for JavaScript","directories":{},"_nodeVersion":"24.3.0","_hasShrinkwrap":false,"devDependencies":{"nyc":"~15.0.0","tmp":"^0.1.0","mocha":"^8.1.1","benchmark":"~2.1.4","coveralls":"^3.0.9"},"_npmOperationalInternal":{"tmp":"tmp/avsc_5.7.8_1751815388658_0.5265686917203167","host":"s3://npm-registry-packages-npm-production"},"readme":"# Avsc [![NPM version](https://img.shields.io/npm/v/avsc.svg)](https://www.npmjs.com/package/avsc) [![Download count](https://img.shields.io/npm/dm/avsc.svg)](https://www.npmjs.com/package/avsc) [![CI](https://github.com/mtth/avsc/actions/workflows/ci.yml/badge.svg)](https://github.com/mtth/avsc/actions/workflows/ci.yml) [![Coverage status](https://coveralls.io/repos/mtth/avsc/badge.svg?branch=master&service=github)](https://coveralls.io/github/mtth/avsc?branch=master)\n\nPure JavaScript implementation of the [Avro\nspecification](https://avro.apache.org/docs/current/spec.html).\n\n\n## Features\n\n+ Blazingly [fast and compact][benchmarks] serialization! Typically faster than\n  JSON with much smaller encodings.\n+ All the Avro goodness and more: [type inference][type-inference], [schema\n  evolution][schema-evolution], and [remote procedure calls][rpc].\n+ Support for [serializing arbitrary JavaScript objects][logical-types].\n+ Unopinionated [64-bit integer compatibility][custom-long].\n\n\n## Installation\n\n```sh\n$ npm install avsc\n```\n\n`avsc` is compatible with all versions of [node.js][] since `0.11`.\n\n\n## Documentation\n\n+ [Home][home]\n+ [API](https://github.com/mtth/avsc/wiki/API)\n+ [Quickstart](https://github.com/mtth/avsc/wiki/Quickstart)\n+ [Advanced usage](https://github.com/mtth/avsc/wiki/Advanced-usage)\n+ [Benchmarks][benchmarks]\n\n\n## Examples\n\nInside a node.js module, or using browserify:\n\n```javascript\nconst avro = require('avsc');\n```\n\n+ Encode and decode values from a known schema:\n\n  ```javascript\n  const type = avro.Type.forSchema({\n    type: 'record',\n    name: 'Pet',\n    fields: [\n      {\n        name: 'kind',\n        type: {type: 'enum', name: 'PetKind', symbols: ['CAT', 'DOG']}\n      },\n      {name: 'name', type: 'string'}\n    ]\n  });\n\n  const buf = type.toBuffer({kind: 'CAT', name: 'Albert'}); // Encoded buffer.\n  const val = type.fromBuffer(buf); // = {kind: 'CAT', name: 'Albert'}\n  ```\n\n+ Infer a value's schema and encode similar values:\n\n  ```javascript\n  const type = avro.Type.forValue({\n    city: 'Cambridge',\n    zipCodes: ['02138', '02139'],\n    visits: 2\n  });\n\n  // We can use `type` to encode any values with the same structure:\n  const bufs = [\n    type.toBuffer({city: 'Seattle', zipCodes: ['98101'], visits: 3}),\n    type.toBuffer({city: 'NYC', zipCodes: [], visits: 0})\n  ];\n  ```\n\n+ Get a [readable stream][readable-stream] of decoded values from an Avro\n  container file compressed using [Snappy][snappy] (see the [`BlockDecoder`\n  API][decoder-api] for an example including checksum validation):\n\n  ```javascript\n  const snappy = require('snappy'); // Or your favorite Snappy library.\n  const codecs = {\n    snappy: function (buf, cb) {\n      // Avro appends checksums to compressed blocks, which we skip here.\n      return snappy.uncompress(buf.slice(0, buf.length - 4), cb);\n    }\n  };\n\n  avro.createFileDecoder('./values.avro', {codecs})\n    .on('metadata', function (type) { /* `type` is the writer's type. */ })\n    .on('data', function (val) { /* Do something with the decoded value. */ });\n  ```\n\n+ Implement a TCP server for an [IDL-defined][idl] protocol:\n\n  ```javascript\n  // We first generate a protocol from its IDL specification.\n  const protocol = avro.readProtocol(`\n    protocol LengthService {\n      /** Endpoint which returns the length of the input string. */\n      int stringLength(string str);\n    }\n  `);\n\n  // We then create a corresponding server, implementing our endpoint.\n  const server = avro.Service.forProtocol(protocol)\n    .createServer()\n    .onStringLength(function (str, cb) { cb(null, str.length); });\n\n  // Finally, we use our server to respond to incoming TCP connections!\n  require('net').createServer()\n    .on('connection', (con) => { server.createChannel(con); })\n    .listen(24950);\n  ```\n\n\n[benchmarks]: https://github.com/mtth/avsc/wiki/Benchmarks\n[browser-support]: https://github.com/mtth/avsc/wiki#browser-support\n[custom-long]: https://github.com/mtth/avsc/wiki/Advanced-usage#custom-long-types\n[decoder-api]: https://github.com/mtth/avsc/wiki/API#class-blockdecoderopts\n[home]: https://github.com/mtth/avsc/wiki\n[idl]: https://avro.apache.org/docs/current/idl.html\n[logical-types]: https://github.com/mtth/avsc/wiki/Advanced-usage#logical-types\n[node.js]: https://nodejs.org/en/\n[readable-stream]: https://nodejs.org/api/stream.html#stream_class_stream_readable\n[rpc]: https://github.com/mtth/avsc/wiki/Quickstart#services\n[schema-evolution]: https://github.com/mtth/avsc/wiki/Advanced-usage#schema-evolution\n[snappy]: https://avro.apache.org/docs/current/spec.html#snappy\n[type-inference]: https://github.com/mtth/avsc/wiki/Advanced-usage#type-inference\n","publish_time":1751815388861,"_cnpm_publish_time":1751815388861,"dist-tags":{"alpha":"6.0.0-alpha.15","latest":"5.7.9"}}