npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kikuchan/binary-reader

v0.1.0-alpha.6

Published

binary-reader

Readme

@kikuchan/binary-reader

Small binary buffer reader for streaming-style, cursor-based parsing in Node.js and browsers.

Install

npm install -D @kikuchan/binary-reader

Quick Start

import { BinaryReader } from '@kikuchan/binary-reader';

const u8 = new Uint8Array([0x12, 0x34, 0x89, 0xab, 0xcd, 0xef]);
const r = new BinaryReader(u8); // default: big-endian

r.readUint16();     // 0x1234 (BE)
r.readUint32();     // 0x89ABCDEF (BE)

// Force endian per read
r.seek(0);
r.readUint16le();   // 0x3412

// Strings
const s = new BinaryReader(new TextEncoder().encode('Hi\0A'));
s.readString();     // 'Hi' (C-string, consumes trailing NUL)
s.readUint8();      // 0x41 ('A')

// Raw bytes
const r2 = new BinaryReader(new Uint8Array([1,2,3,4]));
const bytes = r2.peekBytes(2); // Uint8Array [1,2], does not advance
const next  = r2.readBytes(3); // Uint8Array [1,2,3], advances by 3

API

  • Position/state:

    • position, size, remain, eof()
    • seek(n | label), bookmark(label), rewind(), skip(n?), align(n)
  • Unsigned integers:

    • Base: readUint8(), readUint16(le?), readUint32(le?), readUint64(le?)
    • Suffix aliases: readUint16le/be(), readUint32le/be(), readUint64le/be()
  • Signed integers:

    • Base: readInt8(), readInt16(le?), readInt32(le?), readInt64(le?)
    • Suffix aliases: readInt16le/be(), readInt32le/be(), readInt64le/be()
  • Floating-point:

    • Base: readFloat16(le?), readFloat32(le?), readFloat64(le?)
    • Suffix aliases: readFloat16le/be(), readFloat32le/be(), readFloat64le/be()
  • Bytes and strings:

    • peekBytes(n?) -> Uint8Array — peek without advancing (default: all remaining)
    • readBytes(n?) -> Uint8Array — read bytes and advance (default: all remaining)
    • readString(len?, encoding?) -> string | undefined
      • len omitted: C-string (null-terminated). Missing terminator returns undefined and does not advance.
      • len provided: reads exactly len bytes; decode failure returns undefined and does not advance.

Endianness

  • Default endianness is big-endian.
  • You can set a default via constructor: new BinaryReader(u8, { littleEndian: true }).
  • Per-call overrides use either the second param (e.g. readUint16(true)) or the le/be suffix methods.

Notes

  • Streaming-focused: the API models a moving cursor over a buffer. Methods read at the cursor and advance.
  • seek() and skip() clamp positions to [0, size].