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

dicom-toolkit

v0.1.1

Published

Pure TypeScript DICOM parsing, ingestion, and export toolkit for the browser

Readme

dicom-toolkit

Pure TypeScript DICOM parsing, ingestion, and export toolkit for the browser. All processing runs client-side — no data leaves the user's machine.

Install

bun add dicom-toolkit
# or
npm install dicom-toolkit

Optional peer dependencies (only needed for specific export formats):

# PDF export (waveforms, structured reports)
bun add dcmjs jspdf

# 3D mesh export (STL, OBJ, GLTF)
bun add three

# File download trigger
bun add file-saver

Usage

DICOM Parsing

import { fastParse, buildHierarchy, detectDataType } from "dicom-toolkit/dicom";

// Pass 1: fast parse (reads classification tags only, ~0.1ms/file)
const parsed = fastParse({ fileName: "CT001.dcm", arrayBuffer });

// Build patient/study/series/instance hierarchy
const { patients } = buildHierarchy(parsedFiles);

// Detect data type from SOP Class UID
const dataType = detectDataType(sopClassUID, numberOfFrames);

File Ingestion

import { classifyFile, extractZip, collectFromDragEvent } from "dicom-toolkit/ingestion";

// Classify a file by magic bytes
const fileType = classifyFile(fileName, new Uint8Array(buffer));

// Extract ZIP archives
const entries = extractZip(zipBuffer, "archive.zip");

// Collect files from a drag-drop event (main thread, needs DOM)
const payloads = await collectFromDragEvent(dragEvent);

Export

import {
  exportInstance,
  exportSeries,
  triggerDownload,
  getAvailableFormats,
  ExportFormat,
} from "dicom-toolkit/export";

// Check available formats for a data type
const formats = getAvailableFormats(instance.dataType);

// Export a single instance
const result = await exportInstance(instance, arrayBuffer, {
  format: ExportFormat.PNG,
});
await triggerDownload(result);

// Export a series as NIfTI
const nifti = await exportSeries(series, getArrayBuffer, {
  format: ExportFormat.NIFTI,
});
await triggerDownload(nifti);

Web Workers

Pre-bundled workers for off-main-thread processing:

import { getDicomParserWorkerURL, getIngestionWorkerURL } from "dicom-toolkit/workers";

const worker = new Worker(getDicomParserWorkerURL(), { type: "module" });
worker.postMessage({ type: "parse-files", files: payloads });

Sub-path Exports

| Import path | Contents | |---|---| | dicom-toolkit | Everything re-exported | | dicom-toolkit/dicom | Parsing, types, constants, specialized parsers | | dicom-toolkit/ingestion | File classification, ZIP, DICOMDIR, collection | | dicom-toolkit/export | Multi-format export (PNG, NIfTI, STL, CSV, PDF...) | | dicom-toolkit/workers | Worker URL factories |

Tree-shaking: importing only dicom-toolkit/dicom will not pull in Three.js, jsPDF, or other export-only dependencies.

Key Types

import type {
  DicomPatient,
  DicomStudy,
  DicomSeries,
  DicomInstance,
  DicomDataType,
  ParsedDicomFile,
} from "dicom-toolkit/dicom";

import type {
  RawFile,
  FilePayload,
  IngestionProgress,
} from "dicom-toolkit/ingestion";

import type {
  ExportFormat,
  ExportOptions,
  ExportResult,
} from "dicom-toolkit/export";

Architecture

  • Two-pass parsing: Pass 1 reads only classification tags via dicom-parser (~0.1ms/file). Pass 2 uses dcmjs for full parsing, only on demand when a viewer opens.
  • Web Workers: All CPU-intensive work (parsing, ingestion, export) runs in workers. Workers are self-contained bundles with zero external dependencies.
  • Lazy loading: Export format handlers are dynamically imported — loading the image exporter doesn't pull in Three.js or jsPDF.

License

MIT