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

@animastor/parser

v0.1.1

Published

Deterministic text parser — chapter/segment detection, offsets, language detection, canonical ParserResult/ChapterMap DTO, legacy chapter projection, verbatim source-coverage analysis, encoding detection. Pure sync (except buffer decode), no AI, no DB.

Readme

@animastor/parser

Deterministic text parser for structured book content.

Parser Core — chapter/segment detection, byte-accurate offsets, language detection, canonical ParserResult/ChapterMap DTO, and legacy chapter projection. Pure sync, no IO, no AI, no database, no filesystem.

What this is

This is the Parser Core extracted from the Animastor book pipeline. It provides:

  • Chapter/segment detection with deterministic structure maps
  • Byte-accurate offset calculations anchored to the source text
  • Language detection (ISO 639-1) via tinyld
  • Canonical ParserResult / ChapterMap contract with validation
  • Legacy chapter DTO projection for backward compatibility
  • Scene splitting and unit segmentation

This package does not include the AI-powered structure analyzer, the text importer, or the book writer. Those remain in the host application.

Installation

npm install @animastor/parser

Requires Node.js >= 18.

Usage

const parser = require('@animastor/parser');

// Bind the structure detector at the composition root.
// The host provides the real detector (deterministic + AI merge).
parser.setStructureDetector(myDetector);

// Split source text into chapters.
const chapters = parser.splitIntoChapters(sourceText);
// → [{ title, type, label, number, startLine, endLine, startOffset, endOffset, length }]

// Detect language.
const lang = parser.detectLanguage(sourceText);
// → 'ru'

Subpath exports

| Import path | Module | |---|---| | @animastor/parser | Main barrel (parser facade + contracts + projection + language) | | @animastor/parser/contracts/parser-contract | C13 contract types, validation, constants | | @animastor/parser/contracts/legacy-projection | mapToLegacyChapters, segmentToLegacyChapter, offsetToLine | | @animastor/parser/language-detector | detectLanguageWithConfidence (tinyld-based) |

Composition root seam

setStructureDetector(detector) binds the structure-detector implementation. The detector must expose buildDeterministicMap(sourceText) returning a canonical ParserResult.

Until a detector is bound, splitIntoChapters() throws — the package is fail-closed.

License

MIT