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

@heojeongbo/cdr-codec

v0.2.0

Published

CDR (Common Data Representation) encoder/decoder for ROS 2, DDS, and OMG IDL — codec and plan-based runner.

Readme

@heojeongbo/cdr-codec

A TypeScript encoder/decoder for CDR (Common Data Representation) — the wire format used by ROS 2, DDS, and OMG IDL. The codec layer is transport- and schema-agnostic: ROS 2 is the first consumer, but the same primitives serve any CDR producer/consumer.

For high-frequency message decoding, the package also ships a Web Worker layer so decoding does not block the main thread.

Install

pnpm add @heojeongbo/cdr-codec

Quick start (sync codec)

import { CdrWriter, CdrReader, EncapsulationKind } from "@heojeongbo/cdr-codec";

const writer = new CdrWriter({ kind: EncapsulationKind.CDR_LE });
writer.float64(1.5);
writer.string("hello");

const reader = new CdrReader(writer.data);
reader.float64(); // 1.5
reader.string(); // "hello"

Plan-based decoding (JSON-serializable schema)

DecodePlan is a structural description of a CDR-encoded type. It composes primitives, fixed/variable arrays, sequences, strings, and nested structs, and is fully JSON-serializable so you can ship plans across processes or store them alongside data.

import {
  decodeWithPlan,
  encodeWithPlan,
  type DecodePlan,
} from "@heojeongbo/cdr-codec";

const plan: DecodePlan = {
  type: "struct",
  fields: [
    { name: "x", type: { type: "float64" } },
    { name: "y", type: { type: "float64" } },
    { name: "label", type: { type: "string" } },
  ],
};

const buffer = encodeWithPlan(plan, { x: 1.0, y: 2.0, label: "p" });
const decoded = decodeWithPlan(plan, buffer);

For pre-allocating buffers, CdrSizeCalculator walks the same plan and returns the exact wire size.

Worker layer

import { CdrWorkerClient } from "@heojeongbo/cdr-codec/worker-client";
// Vite / modern bundlers — the worker entry is bundled separately:
import CdrWorker from "@heojeongbo/cdr-codec/worker?worker";

const client = new CdrWorkerClient(() => new CdrWorker());
const planId = await client.preparePlan(plan);
const result = await client.decodeWithId(planId, buffer); // transferable
client.dispose();

The worker registers plans by id so subsequent decodes pay only the structured- clone / transfer cost, not plan re-parsing.

Supported encapsulation kinds

CDR1 (CDR_BE, CDR_LE, PL_CDR_BE, PL_CDR_LE) and CDR2 (CDR2_BE, CDR2_LE, PL_CDR2_BE, PL_CDR2_LE, DELIMITED_CDR2_BE, DELIMITED_CDR2_LE).

Acknowledgements

The wire-format behavior — encapsulation header, alignment rules, and fast-path typed-array reads — is modeled after Foxglove's MIT-licensed @foxglove/cdr package. This library restructures it as a generic codec + JSON-plan + Worker for non-ROS use cases.

License

MIT — see the LICENSE in the repository root.