@sergueyarellano/meta-buffer
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

meta-buffer

Append version and meta info to your buffers.

const metaBuf = require('@sergueyarellano/meta-buffer')
const VERSION = 1
const AVRO_SCHEMA_NAME = 'UserCreatedSchemaName' 

const encodedBuf = metaBuf.encode(VERSION, AVRO_SCHEMA_NAME, originalBuffer)

Read the meta info without parsing the original buffer.

const [ version, meta, originalBuffer ] = metaBuf.decode(encodedBuf)

console.log(version) // 1
console.log(meta) // UserCreatedSchemaName
console.log(originalBuffer) // <Buffer 00 00 00 00 1f>
  • version has to be an 8 bit uint. (number between 0 and 255)
  • meta has to be a string of any length. The smaller the string, the smaller the resulting buffer.
  • buf is the original buffer

Readme

Keywords

none

Package Sidebar

Install

npm i @sergueyarellano/meta-buffer

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

2.79 kB

Total Files

4

Last publish

Collaborators

  • sergueyarellano