JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q34808F
  • License MIT

A byte buffer for encoding and decoding binary data.

Package Exports

  • bytebuf

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bytebuf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

bytebuf

npm David

A byte buffer for encoding and decoding binary data in JavaScript. Supports the major web browsers, NodeJS, Deno, and Cloudflare Workers.

Install

npm i bytebuf

Usage

import { ByteBuf } from "bytebuf"

const data = new Uint8Array(1024)
const buffer = ByteBuf.from(data)

buffer.writeInt32(16)
buffer.writeString("Encoding is fun!")
buffer.setInt16(4, 25924, true)
buffer.writeVarInt(49)

console.log(buffer.byteOffset) // 21
buffer.reset()

const byteLength = buffer.readInt32() // 16
console.log(buffer.readString(byteLength)) // "Decoding is fun!"
console.log(buffer.getVarInt(20)) // { value: 49, byteLength: 1 }