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

numparse-ts

v0.1.1

Published

A parser combinator library for TypeScript

Downloads

268

Readme

NumParse

A TypeScript parser combinator library. Build parsers by composing small, reusable pieces.

Installation

npm install numparse-ts

Usage

import { streamFromString, string, append, oneOrMore, digit } from "numparse";

// Create a stream from a string
const stream = streamFromString("hello123");

// Build a parser
const parser = append(string("hello"), oneOrMore(digit));

const result = parser(stream);

if (result.tag === "parse_success") {
  console.log(result.matched); // "hello123"
  console.log(result.value);   // [ParseSuccess<"hello">, ParseSuccess<string>[]]
}

Core concepts

Stream

A Stream is the input to a parser — a character array with a current index.

const stream = streamFromString("input string");

Parser<A>

A Parser<A> is a function (stream: Stream) => ParseResult<A>. It either succeeds with a value of type A or fails with a ParseError.

ParseResult<A>

Either a ParseSuccess<A> (with tag: "parse_success") or a ParseError (with tag: "parse_error").

Combinators

Primitives

| Function | Description | |---|---| | string(s) | Matches a literal string | | digit | Matches a single digit character | | letter | Matches a single letter | | space | Matches a single whitespace character | | alphanumeric | Matches a letter or digit | | whitespace | Matches a whitespace character | | empty | Always succeeds, consuming nothing | | succeed(value) | Always succeeds with value, consuming nothing |

Combining

| Function | Description | |---|---| | append(p1, p2, ...) | Runs parsers in sequence, returning a tuple of results | | appendStr(p1, p2, ...) | Runs string parsers in sequence, concatenating results | | keepLast(p1, p2) | Runs two parsers in sequence, returning only the second result | | oneOf(p1, p2, ...) | Tries each parser in order, returning the first success | | seq(p1, p2) | Runs two parsers in sequence, returning a tuple | | either(p1, p2) | Tries p1, falls back to p2 on failure | | chain(p, f) | Runs p, then passes the result to f to get the next parser |

Repetition

| Function | Description | |---|---| | oneOrMore(p) | One or more matches | | noneOrMore(p) | Zero or more matches | | oneOrMoreStr(p) | One or more matches, concatenated into a string | | strNoneOrMore(p) | Zero or more matches, concatenated into a string | | optional(p) | Zero or one match |

Transformation

| Function | Description | |---|---| | map(f)(p) | Maps a function over a parser's result | | mapResult(f) | Maps over ParseResult, propagating errors | | flatten(p) | Flattens a Parser<ParseResult<A>> into Parser<A> | | trimStart(p) | Skips leading whitespace before running p |

Other

| Function | Description | |---|---| | not(p) | Succeeds (consuming nothing) if p fails | | lazy(fn) | Delays parser construction — use for recursive parsers | | oneOfManyStrings(strings) | Efficiently matches any string in an array (trie-backed) | | slice(start, end) | Extracts the matched string between two stream positions | | is.success(result) | Type guard for ParseSuccess |

License

MIT