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

@unyt/speck

v0.0.12

Published

> Declarative Specification Parser and Generator for Binary Data Formats

Readme

Speck

Declarative Specification Parser and Generator for Binary Data Formats

Speck is a TypeScript library for parsing and generating binary data formats based on declarative specifications. It is designed to be flexible and extensible, allowing users to define their own data structures and parsing rules.


Features

  • Declarative binary structure definitions
  • Support for endianness (little and big)
  • Nested fields and repeated fields
  • Conditional inclusion of fields using logical conditions (and, or, not, equals, includes, greaterThan, lessThan)
  • Built-in value parsers: boolean, int, uint, float, string, enum, endpoint, pointer
  • Bit masks for extracting values at the bit level
  • Extensible design for building custom binary parsers

Installation

With Deno:

deno add jsr:@unyt/speck

or with npm:

npm install @unyt/speck

or with yarn:

yarn add jsr:@unyt/speck

Usage Example

1. Define a structure (JSON or TypeScript)

{
    "name": "ExampleStruct",
    "sections": [
        {
            "name": "FirstSection",
            "fields": [
                {
                    "name": "FieldA",
                    "byteSize": 4,
                    "parser": { "type": "int" }
                }
            ]
        }
    ]
}

2. Parse binary data

import { parseStructure, type StructureDefinition } from "@unyt/speck";

const definition: StructureDefinition = {
    name: "ExampleStruct",
    sections: [
        {
            name: "FirstSection",
            fields: [
                {
                    name: "FieldA",
                    byteSize: 4,
                    parser: { type: "int" },
                },
            ],
        },
    ],
};

const bytes = new Uint8Array([0x01, 0x00, 0x00, 0x00]);
parseStructure(definition, bytes);

Results in:

[
    {
        name: "FirstSection",
        fields: [
            {
                name: "FieldA",
                bytes: Uint8Array(4)[1, 0, 0, 0],
                parsedValue: 1,
            },
        ],
    },
];

Definitions

StructureDefinition

  • name: string – Name of the structure
  • endian: "little" | "big" (default "little")
  • sections: list of SectionDefinition

SectionDefinition

  • name: string
  • fields: list of FieldDefinition

FieldDefinition

  • id: optional string identifier (used in conditions or repeat)
  • name: string
  • description: optional string
  • category: optional string
  • usage: optional "omit"
  • byteSize: number of bytes to read
  • repeat: number | field reference for repetition
  • if: optional FieldCondition to conditionally include the field
  • parser: optional ValueParser to interpret bytes
  • subFields: for nested structures
  • bitMasks: for extracting bit-level subfields

FieldCondition

Logical and comparison operators for conditional parsing:

  • equals, greaterThan, lessThan, includes
  • and, or, not

ValueParser

  • boolean
  • int, uint, float
  • string
  • enum (with mapping)
  • endpoint
  • pointer

ParsedStructure

The result of parsing is a structured array of ParsedSection, each containing ParsedField objects with:

  • name
  • bytes (raw Uint8Array slice)
  • parsedValue (if a parser is provided)
  • subFields (if nested or bit-masked)

Advanced Example

Conditional Field

{
  "name": "optionalField",
  "byteSize": 2,
  "parser": { "type": "uint" },
  "if": { "equals": ["controlField", 1] }
}

This field is only parsed if controlField == 1.

Bit Masks

{
  "name": "flags",
  "byteSize": 1,
  "bitMasks": [
    { "name": "flagA", "length": 1, "parser": { "type": "boolean" } },
    { "name": "flagB", "length": 2, "parser": { "type": "uint" } }
  ]
}

This extracts flagA and flagB from a single byte.


© unyt 2025 • unyt.org