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

@fourscore/readsb

v0.1.0

Published

TypeScript decoder for readsb / Mode-S / ADS-B: BEAST, AVR, SBS BaseStation, aircraft.json, and the underlying Mode-S frames.

Downloads

142

Readme

readsb

TypeScript decoder for readsb and the underlying Mode-S / ADS-B protocols. Includes:

  • Mode-S frame decoder — DF 0/4/5/11/16/17/18/20/21, with CRC and address recovery (AP-XOR).
  • ADS-B ME decoder — identification, surface position, airborne position (baro & GNSS), airborne velocity (subtypes 1–4), aircraft status, target state & status, operation status.
  • CPR position decoder — global and local, airborne and surface, with the canonical ICAO Annex 10 NL boundary table.
  • Comm-B / BDS — BDS 1,7 (capability), 2,0 (callsign), 4,0 (selected vertical intent), 5,0 (track and turn), 6,0 (heading and speed).
  • Wire formats — streaming parsers for BEAST binary, AVR raw hex (*…; and @<MLAT>…;), and SBS BaseStation CSV.
  • readsb outputs — typed loader for aircraft.json and a binary decoder for aircraft.binCraft / globe_*.binCraft (binCraft format version 20250403).
  • Aircraft tracker — merges decoded messages into per-aircraft state with global+local CPR pairing.

ESM only. Tested on Bun and Node 18+.

Install

bun add readsb        # or:  npm i readsb

Quick examples

Decode a single Mode-S frame

import { decodeModeS, decodeAdsb, fromHex } from "readsb";

const frame = fromHex("8D4840D6202CC371C32CE0576098");
const m = decodeModeS(frame);
// { df: 17, icao: "4840D6", crcOk: true, ca: 5 }

const adsb = decodeAdsb(frame);
// { kind: "identification", callsign: "KLM1023", category: 0, categorySet: "A", tc: 4 }

Parse a BEAST stream

import { BeastParser, decodeModeS } from "readsb";

const parser = new BeastParser();
for await (const chunk of socket) {
  for (const frame of parser.parse(chunk)) {
    if (frame.type !== "mode-s-long" && frame.type !== "mode-s-short") continue;
    const decoded = decodeModeS(frame.bytes);
    console.log(frame.timestamp, decoded);
  }
}

Decode a CPR pair

import { decodeCprGlobalAirborne } from "readsb";

const pos = decodeCprGlobalAirborne(
  { lat: 93000, lon: 51372, format: "even" },
  { lat: 74158, lon: 50194, format: "odd" },
);
// { lat: 52.25720, lon: 3.91937 }

Track aircraft over time

import { Tracker, parseBeast } from "readsb";

const tracker = new Tracker({ receiverLocation: { lat: 52.0, lon: 4.0 } });
for (const f of parseBeast(buf)) {
  tracker.ingest(f);
}
console.log(tracker.aircraft());

Decode a aircraft.binCraft.zst snapshot

import { decodeBinCraft } from "readsb";
import { readFileSync } from "node:fs";
import { decompress } from "fzstd";  // or run `zstd -d` externally

const compressed = readFileSync("./aircraft.binCraft.zst");
const bytes = decompress(compressed);
const snap = decodeBinCraft(bytes);

console.log(`${snap.aircraft.length} aircraft, snapshot ${new Date(snap.header.nowMs)}`);
for (const a of snap.aircraft) {
  console.log(a.icao, a.callsign, a.lat, a.lon, a.altBaroFt);
}

Public API

| Module | Exports | |---|---| | Mode-S | decodeModeS, expectedLength, crc24, parityField, decodeAC12, decodeAC13, decodeID13 | | ADS-B | decodeAdsb, typeCode, meField | | CPR | decodeCprGlobalAirborne, decodeCprGlobalSurface, decodeCprLocalAirborne, decodeCprLocalSurface, nl | | Comm-B | decodeCommB, guessBds | | Wire | BeastParser/parseBeast, AvrParser/parseAvr, SbsParser/parseSbs/parseSbsLine | | readsb | parseAircraftJson, decodeBinCraft | | State | Tracker |

All types are exported from the package root.

Limitations

  • Mode-A/C-only frames (type 0x31 in BEAST) are surfaced as BeastFrame but no further decoding is performed.
  • BDS register inference for Comm-B replies is best-effort. Pass an explicit register to decodeCommB when known; otherwise call guessBds and treat the result as a hint.
  • Military DF19 and Comm-D ELM (DF24) are passed through but not interpreted.

Development

bun install
bun test
bun run typecheck
bun run build

Decode the bundled example.readsb (a base64-encoded zstd-compressed binCraft snapshot):

bun run scripts/decode-example.ts

License

MIT