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

@claudiu-ceia/combine

v0.3.0

Published

Typed parser combinators for TypeScript (Deno + Node). Build small parsers, then compose them into a grammar.

Readme

combine

Typed parser combinators for TypeScript (Deno + Node). Build small parsers, then compose them into a grammar.

CI JSR npm

Install

Deno (JSR)

import { seq, str } from "jsr:@claudiu-ceia/combine@^0.2.6";

Subpath imports are also supported:

import { recognizeAt } from "jsr:@claudiu-ceia/combine/nondeterministic";
import { createTracer } from "jsr:@claudiu-ceia/combine/perf";

Node (npm)

npm i @claudiu-ceia/combine

Note: the npm package is ESM-only.

import { seq, str } from "@claudiu-ceia/combine";

If you're in a CommonJS project, use a dynamic import:

const { seq, str } = await import("@claudiu-ceia/combine");

Quickstart

Parsers are plain functions: (ctx) => Result<T>. The context tracks where you are in the input: { text, index }.

import {
  eof,
  map,
  optional,
  regex,
  seq,
  space,
  str,
  trim,
} from "@claudiu-ceia/combine";

const name = trim(regex(/[^!]+/, "name"));
const hello = map(
  seq(str("Hello,"), optional(space()), name, str("!"), eof()),
  ([, , who]) => who,
);

const result = hello({ text: "Hello, World!", index: 0 });

if (result.success) {
  console.log(result.value); // "World"
} else {
  console.error(result.expected, result.location);
}

Common Building Blocks

The library exports a lot of small pieces; these are the ones you'll likely reach for first:

  • Parsers: str, regex, digit, letter, int, double, space, eof
  • Composition: seq, any, either, oneOf, many, many1, optional
  • Transform: map, mapJoin, trim

If you like learning by examples, start with tests/.

Recursion (Grammars)

When a parser needs to reference itself (directly or indirectly), wrap the reference with lazy:

import { any, lazy, map, type Parser, seq, str } from "@claudiu-ceia/combine";

type Expr = { kind: "paren"; inner: Expr } | { kind: "lit"; value: string };

const lit: Parser<Expr> = map(str("x"), (value) => ({ kind: "lit", value }));
const paren: Parser<Expr> = map(
  seq(str("("), lazy(() => expr), str(")")),
  ([, inner]) => ({ kind: "paren", inner }),
);

// A tiny recursive expression: x | (expr)
const expr: Parser<Expr> = any(lit, paren);

If you're defining a larger mutually-recursive grammar, use createLanguage (src/language.ts) to avoid worrying about declaration order.

If you want better type inference without writing an explicit language type, use createLanguageThis (see docs/guide.md).

Better Errors

For user-facing parsers, wrap important nodes with context(...), and commit to branches with cut(...) (to avoid confusing backtracking). To print failures:

import { formatErrorStack } from "@claudiu-ceia/combine";

if (!result.success) console.error(formatErrorStack(result));

Nondeterministic Recognizers

Most combinators are deterministic: they return a single success or failure. For tokenizer-like use cases where you want multiple simultaneous matches at the same input position, use the nondeterministic/recognizer module:

import { recognizeAt } from "jsr:@claudiu-ceia/combine/nondeterministic";

These combinators can return multiple successes; you must decide how (or whether) to advance the cursor.

More Examples

  • tests/ has the most coverage and real usage patterns
  • examples/ contains small runnable snippets

Guides

If you want the deeper explanations (recursion patterns, createLanguage, error handling, cut vs context, and any vs furthest), see docs/guide.md.

The guide also covers the optional lexer layer (lexeme, symbol, keyword, createLexer) for trivia/comments.

License

MIT © Claudiu Ceia