Skip to main content

A simple byte-buffer reader and writer. Uses Node.js' Buffer. Supports little- and big-endianness. Supports signed & unsigned integers of 8, 16, and 32 bits, as well as floats of 32 and 64 bits.

This package works with Node.js, DenoIt is unknown whether this package works with Cloudflare Workers, Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
JSR Score
100%
Published
a day ago (1.0.5)
class Reader

A reader for a byte buffer

Constructors

new
Reader(buffer: Buffer)

Properties

The current position in the buffer

The endianness of the source buffer

Methods

Reads a number of a given type

readBytes(length: number): Buffer

Reads a number of bytes

readBytesWithLen(lenType: NumType): Buffer

Reads a number of bytes determined by a number of a given type

readUnicodeString(
glyphType: NumType,
length: number,
nullTerm?: boolean,
): string

Reads a string of the given encoding and length. Supports UTF-8 and UTF-16 strings.

readUnicodeStringWithLen(
glyphType: NumType,
lenType: NumType,
nullTerm?: boolean,
): string

Reads a string of the given encoding and length determined by a preceeding number of the given type. Supports UTF-8 and UTF-16 strings.

skipBytes(length: number): this

Skips a number of bytes

Add Package

deno add jsr:@zerm/rwbuf

Import symbol

import { Reader } from "@zerm/rwbuf";

---- OR ----

Import directly with a jsr specifier

import { Reader } from "jsr:@zerm/rwbuf";

Add Package

npx jsr add @zerm/rwbuf

Import symbol

import { Reader } from "@zerm/rwbuf";

Add Package

yarn dlx jsr add @zerm/rwbuf

Import symbol

import { Reader } from "@zerm/rwbuf";

Add Package

pnpm dlx jsr add @zerm/rwbuf

Import symbol

import { Reader } from "@zerm/rwbuf";

Add Package

bunx jsr add @zerm/rwbuf

Import symbol

import { Reader } from "@zerm/rwbuf";