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

undms

v1.1.1

Published

Text and Metadata Extraction Library for Document Files with Text Similarity Comparison

Readme

undms

https://github.com/xcvzmoon/undms/actions

Text and metadata extraction library for document files with text similarity comparison, built with napi-rs.

Installation

bun add undms

Features

  • Extracts text and metadata from document files
  • Computes similarity between extracted documents and reference texts
  • Works in Node.js and Bun (via N-API)

Supported formats

  • Text: text/*, plus JSON/XML/JS/TS MIME variants
  • DOCX: application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • XLSX: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • PDF: application/pdf
  • Images: image/jpeg, image/png, image/gif, image/bmp, image/tiff, image/webp

Metadata schema

Each extracted document may include a metadata payload with these optional fields:

type MetadataPayload = {
  text?: {
    lineCount: number;
    wordCount: number;
    characterCount: number;
    nonWhitespaceCharacterCount: number;
  };
  docx?: {
    paragraphCount: number;
    tableCount: number;
    imageCount: number;
    hyperlinkCount: number;
  };
  xlsx?: {
    sheetCount: number;
    sheetNames: string[];
    rowCount: number;
    columnCount: number;
    cellCount: number;
  };
  pdf?: {
    title?: string;
    author?: string;
    subject?: string;
    producer?: string;
    pageSize?: { width: number; height: number };
    pageCount: number;
  };
  image?: {
    width: number;
    height: number;
    format?: string;
    cameraMake?: string;
    cameraModel?: string;
    datetimeOriginal?: string;
    location: {
      latitude?: number;
      longitude?: number;
    };
  };
};

Handler details

  • Text: decodes content (UTF-8 by default) and provides text metadata.
  • DOCX: extracts paragraphs, plus paragraph/table/image/hyperlink counts.
  • XLSX: extracts cell text and reports sheet/row/column/cell counts.
  • PDF: extracts text and document info (title/author/subject/producer) and page size/count when available.
  • Images: runs OCR to extract text and reads EXIF for camera details and GPS location when present.

Troubleshooting

  • OCR is CPU-intensive; large images can be slow.
  • EXIF GPS fields depend on the source image; if absent, location still exists but latitude/longitude are undefined.
  • PDF metadata fields are optional and may be empty when the source file does not include them.
  • If OCR returns empty text, check that the image has legible, high-contrast text.

Usage

import { extract, computeDocumentSimilarity, computeTextSimilarity } from 'undms';

const result = extract([
  {
    name: 'note.txt',
    size: 12,
    type: 'text/plain',
    lastModified: Date.now(),
    webkitRelativePath: '',
    buffer: Buffer.from('hello world!'),
  },
]);

const matches = computeDocumentSimilarity(
  result[0].documents.map((doc) => ({
    name: doc.name,
    size: doc.size,
    type: result[0].mimeType,
    lastModified: Date.now(),
    webkitRelativePath: '',
    buffer: Buffer.from(doc.content),
  })),
  ['reference text A', 'reference text B'],
  70,
  'hybrid',
);

const textMatches = computeTextSimilarity('alpha beta gamma', ['alpha beta gamma'], 99, 'hybrid');

API

extract(documents)

Extracts text and metadata from input documents. Output is grouped by MIME type.

computeDocumentSimilarity(documents, referenceTexts, threshold?, method?)

Extracts documents and computes similarity against the reference texts.

computeTextSimilarity(sourceText, referenceTexts, threshold?, method?)

Computes similarity for raw text without file extraction.

Development

Requirements

  • Rust (latest stable)
  • Node.js 12+ (for Node-API)
  • Bun

Build

bun run build

Test

bun run test

Benchmarks

bun run bench
bun run bench:sweep