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

parserkit

v0.1.0

Published

TypeScript-first parser combinators. Build grammars from small reusable pieces. Zero dependencies. Port of Haskell Parsec / arcsecond.

Readme

parserkit

All Contributors

npm CI license

TypeScript-first parser combinators. Build grammars from small reusable pieces.
Zero dependencies. Full type inference. ESM + CJS.

npm install parserkit

Why?

arcsecond — the most popular TypeScript parser combinator library — has been abandoned since September 2022 (25+ open issues, no releases in 3.5 years). parserkit is a maintained, TypeScript-native successor with the same zero-dependency philosophy.

Quick start

import { str, regex, many1, digit, map, sequence, join, run, tryRun } from "parserkit";

// Parse a positive integer
const integer = map(join(many1(digit)), Number);
run(integer, "42");     // { ok: true, value: 42 }
tryRun(integer, "abc"); // throws ParseError: expected digit at index 0

Core API

Primitives

str("hello")     // matches exact string "hello"
char("a")        // matches single char 'a'
regex(/\d+/)     // matches regex at current position (no 'g' flag)
anyChar          // matches any single character
digit            // [0-9]
letter           // [a-zA-Z]
whitespace       // [ \t\n\r]
spaces           // zero or more whitespace (never fails)
spaces1          // one or more whitespace
eof              // succeeds only at end of input

Combinators

sequence(p1, p2, p3)       // run all in order → [v1, v2, v3]
choice(p1, p2, p3)         // first success wins
many(p)                    // 0 or more → T[]
many1(p)                   // 1 or more → T[]
optional(p)                // 0 or 1 → T | null
between(open, p, close)    // parses open, p, close → p's value
sepBy(p, sep)              // 0+ items separated by sep → T[]
sepBy1(p, sep)             // 1+ items separated by sep → T[]
count(p, n)                // exactly n repetitions → T[]
lookahead(p)               // succeeds without consuming input
not(p)                     // succeeds when p fails, consumes nothing
skip(p1, p2)               // run both, return p1's value
andThen(p1, p2)            // run both, return p2's value (discard left)

Transformers

map(p, fn)        // transform value: Parser<A> → Parser<B>
mapTo(p, value)   // replace value with constant
join(p, sep?)     // Parser<string[]> → Parser<string>
label(p, name)    // override error message
chain(p, fn)      // sequence based on previous value (flatMap)
lazy(() => p)     // defer construction for recursive grammars

Running parsers

run(parser, input)    // { ok: true, value } | { ok: false, error: ParseError }
tryRun(parser, input) // T — throws ParseError on failure

Examples

CSV row

import { regex, char, sepBy1, sequence, eof, join, many, run } from "parserkit";

const field = join(many(regex(/[^,\n]/)));
const row = sepBy1(field, char(","));

run(sequence(row, eof), "Alice,30,Engineer");
// { ok: true, value: [["Alice", "30", "Engineer"], null] }

JSON number

import { digit, char, many1, optional, choice, map, join, sequence, run } from "parserkit";

const sign = optional(choice(char("-"), char("+")));
const digits = join(many1(digit));
const decimal = optional(join(sequence(char("."), digits)));
const number = map(
  join(sequence(
    map(sign, s => s ?? ""),
    digits,
    map(decimal, d => d ?? "")
  )),
  parseFloat
);

run(number, "-3.14"); // { ok: true, value: -3.14 }

Recursive grammar (nested parens)

import { lazy, choice, between, char, mapTo, sequence, run } from "parserkit";

type Tree = null;
const nested: ReturnType<typeof lazy<Tree>> = lazy<Tree>(() =>
  choice(
    between(char("("), nested, char(")")),
    mapTo(sequence(char("("), char(")")), null)
  )
);

run(nested, "(())"); // { ok: true, value: null }

Key–value pairs

import { join, many1, letter, char, andThen, skip, sepBy, spaces, sequence, eof, run } from "parserkit";

const key = join(many1(letter));
const value = join(many1(letter));
const pair = sequence(skip(key, char("=")), value);
const pairs = sepBy(pair, sequence(char(","), spaces));

run(sequence(pairs, eof), "a=1, b=2, c=3");
// { ok: true, value: [[["1"], ["2"], ["3"]], null] }

Error messages

ParseError includes position info:

ParseError: Parse error at index 3 (col 4): expected digit
  ...abc...

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

MIT