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

rad-parser

v2.0.0

Published

A lightweight, performant, self-contained DICOM parser with zero external dependencies

Readme

RAD-Parser

RAD-Parser is a lightweight, performant, self-contained DICOM parser implementation with zero external dependencies. It is designed for safety, efficiency, and reliability in medical imaging applications or cloud-based pipelines where dependency bloat is a liability.

npm version License: MIT TypeScript

Features

  • Zero Dependencies: Pure TypeScript/JavaScript implementation using only native APIs.
  • Plugin System: Extensible architecture for Pixel Data Codecs.
  • Native Codecs:
    • RLE Lossless: Full Decode & Encode (PackBits) in pure TS.
    • PNG Export: Native Node.js encoder (via zlib) and Browser encoder (via <canvas>).
    • JPEG Lossless (Shell): Native bitstream parser/sniffer.
  • AutoDetect: Smart codec routing and content sniffing.
  • Serialization: Write/Convert DICOM files (Explicit VR Little Endian).
  • Anonymization: Built-in anonymization utilities.
  • Safe & Performant: Efficient binary parsing with strict bounds checking.

Installation

npm install rad-parser

Usage

1. Basic Parsing (Metadata Only)

import { parse } from "rad-parser";

const dataset = parse(byteArray);

// string access
const name = dataset.string("x00100010"); // PatientName
console.log(`Patient: ${name}`);

// direct element access
const element = dataset.dict["x00100010"];
console.log(element.Value);

2. Pixel Data & Plugins (The "Full Power" Mode)

To handle compressed pixel data (RLE, JPEG, etc.), you must register the desired codecs. This modular approach keeps the core lightweight.

import {
    parse,
    registry,
    AutoDetectCodec,
    RleCodec,
    NodePngEncoder
} from "rad-parser";

// 1. Register Plugins (Mix & Match)
// AutoDetect uses Priority 1000 to intercept and route calls
registry.register(new AutoDetectCodec());
registry.register(new RleCodec());
registry.register(new NodePngEncoder());

// 2. Parse & Extract
const dataset = parse(u8Buffer);
const pixels = await dataset.extractPixelData(); // Helper or manual usage check

if (pixels.isEncapsulated) {
    // 3. Decode via Registry (AutoDetect will handle routing)
    const decoder = await registry.getDecoder(dataset.transferSyntax);
    if (decoder) {
        const decodedFrame = await decoder.decode(pixels.fragments, 0, {
            transferSyntax: dataset.transferSyntax,
            rows: dataset.rows,
            columns: dataset.columns
        });

        // 4. Export to PNG (Zero-Dep Node.js native export)
        const pngEncoder = await registry.getEncoder('png');
        if (pngEncoder) {
            const pngData = await pngEncoder.encode(decodedFrame, 'png', ...);
            // fs.writeFileSync('output.png', pngData[0]);
        }
    }
}

Plugin Architecture

RAD-Parser uses a Registry-based Plugin System. Codecs are registered at runtime, allowing you to choose between Native (Pure JS) implementations or Adapters (External Libs).

Supported Codecs

| Codec | Implementation | Decode Status | Encode Status | Notes | | ----------------- | -------------------- | --------------------- | --------------------- | ------------------------------------------- | | RLE | Pure TypeScript | ✅ Native | ✅ Native | Full support (PackBits). | | PNG | Node zlib / Canvas | N/A | ✅ Native | Export format. | | AutoDetect | Smart Router | ✅ Active | N/A | Sniffs content / Magic Bytes. | | JPEG 2000 | Adapter | ⚠️ Requires Injection | ⚠️ Requires Injection | Use jpeg2000-js or OpenJPEG. | | JPEG-LS | Adapter | ⚠️ Requires Injection | ⚠️ Requires Injection | Use charls-js. | | JPEG Lossless | Native Shell | ✅ Sniffs Headers | ❌ | Parses structure, needs decoder for pixels. |

Output Formats

  • Node.js: BMP, PNG (Native), RLE, RAW.
  • Browser: BMP, PNG/JPG (Native Canvas), RLE, RAW.

Library Comparison & Ecosystem

A head-to-head comparison of capabilities, ecosystem, and performance.

| Feature | rad-parser | dcmjs | dicom-parser | efferent-dicom | | :----------------------- | :------------------: | :-----------: | :------------: | :------------: | | Dependencies | ✅ Zero | ❌ Multiple | ✅ Zero | ⚠️ Multiple | | Bundle Size | ✅ ~50KB | ⚠️ ~500KB+ | ✅ ~30KB | ⚠️ ~300KB+ | | Self-Contained | ✅ Yes | ❌ No | ✅ Yes | ❌ No | | Part 10 Support | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | | Transfer Syntax Det. | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | | Implicit VR | ✅ Yes | ✅ Yes | ✅ Yes | ⚠️ Limited | | Explicit VR | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | | Big Endian | ✅ Yes | ⚠️ Partial | ✅ Yes | ⚠️ Limited | | Sequence Parsing | ✅ Yes | ✅ Yes | ⚠️ Basic | ⚠️ Basic | | Person Name (PN) | ✅ Structured | ✅ Structured | ⚠️ String only | ⚠️ String only | | Date/Time Parsing | ✅ Date Objects | ⚠️ Strings | ⚠️ Strings | ⚠️ Strings | | Character Sets | ✅ Multiple | ✅ Multiple | ⚠️ Limited | ⚠️ Limited | | Tag Dictionary | ✅ Full (5300+) | ⚠️ Partial | ❌ No | ❌ No | | Error Handling | ✅ Comprehensive | ✅ Good | ⚠️ Basic | ⚠️ Basic | | Safety Limits | ✅ Yes | ⚠️ Limited | ⚠️ Limited | ⚠️ Limited | | Bounds Checking | ✅ All Ops | ⚠️ Some | ⚠️ Some | ⚠️ Some | | Modular | ✅ Yes | ❌ Monolithic | ❌ Monolithic | ❌ Monolithic | | TypeScript | ✅ Full Types | ⚠️ Partial | ⚠️ Partial | ⚠️ Partial | | Performance (Scan) | 🚀 ~1.0 ms | ~3.0 ms | ~1.2 ms | ~7.2 ms | | Memory Usage | ✅ Configurable | ⚠️ High | ✅ Low | ⚠️ Medium | | Pixel Data | ✅ Full Plugin | ✅ Full | ❌ Raw Only | ❌ Raw Only | | Native Codecs | ✅ RLE, PNG | ❌ None | ❌ None | ⚠️ Limited | | Browser Support | ✅ Modern | ✅ Modern | ✅ Modern | ⚠️ Modern | | Node.js Support | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | | Maintenance | ✅ Active | ✅ Active | ⚠️ Slow | ⚠️ Slow | | License | ✅ MIT | ✅ MIT | ✅ MIT | ✅ MIT |

Ecosystem Deep Dive

  • rad-parser: Best for High-Performance Pipelines, Cloud Functions, and Safe Parsing where you need strict TypeScript types, zero dependencies, and the ability to route Compressed Pixel Data dynamically. The Plugin System allows you to keep the core tiny and only load decoders (like WebAssembly builds of OpenJPEG) if actually needed.
  • dcmjs: Excellent for Structured Reporting (SR) and working with the specific JSON format it popularized. It bundles many dependencies, making it heavier but feature-rich for high-level DICOM concepts.
  • dicom-parser: The veteran standard. Extremely fast and lightweight for parsing only. However, it lacks Writing, Anonymization, and Plugin support, limiting its use to read-only scenarios.
  • efferent-dicom: A solid alternative but slower in benchmarks.

Performance Benchmark

Results from parsing 50 DICOM files (Medical Imaging Dataset):

| Parser | Operation | Avg Time | Throughput | vs dicom-parser | | ------------------------ | ---------------- | ----------- | ---------------- | --------------- | | rad-parser (Shallow) | Scan / Route | 1.01 ms | ~990 files/s | 1.2x Faster | | dicom-parser | Scan Only | 1.21 ms | ~826 files/s | 1.0x (Baseline) | | rad-parser (Full) | Full Parse | 3.54 ms | ~282 files/s | 0.3x | | dcmjs | Full Object | 3.06 ms | ~326 files/s | 0.4x | | efferent-dicom | Full Object | 7.20 ms | ~138 files/s | 0.2x |

Note: rad-parser-shallow is optimized for rapid indexing, routing, and header extraction scenarios.

CLI Usage

rad-parser comes with a built-in CLI for common operations:

# Dump tags
npx rad-parser dump file.dcm

# Anonymize file
npx rad-parser anonymize input.dcm output_anon.dcm

Architecture (v2.0.0)

  • src/core: Main logic (parser, writer, anonymizer).
  • src/plugins: The Plugin Ecosystem.
  • src/utils: Helpers (dictionary, validation).

Security & Dependencies

RAD-Parser is strictly Zero Dependency for its core functionalities.

  • Node.js: Uses zlib, fs for native capabilities.
  • Browser: Uses TextDecoder, ImageDecoder (WebCodecs), Canvas.
  • External Codecs: You must explicitly "bring your own library" for J2K/J-LS if needed. The Adapter classes (Jpeg2000Decoder etc.) provide the standard interface to plug them in.

Contributing

  1. Keep Core dependency-free.
  2. Extensions go in src/plugins.
  3. Verify with npm test.