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

@ieviev/resharp

v0.1.1

Published

WebAssembly bindings for the resharp regex engine.

Downloads

267

Readme

resharp-wasm

A regex library for JavaScript, built on resharp. It supports intersection, complement, and lookarounds, and always runs in time proportional to the input length (no catastrophic backtracking).

For pattern syntax and supported features see the resharp README.

Pre-1.0: the API may change between minor versions.

Install

npm install @ieviev/resharp

Works in Node and with bundlers (Vite, webpack, rollup, esbuild).

Usage

import { Regex } from "@ieviev/resharp";

const r = new Regex("\\d+");
r.isMatch("abc 42");                    // true
Array.from(r.findAll("a12 b34 c5"));    // [1, 3, 5, 7, 9, 10]   string positions
Array.from(r.findAllBytes("αX"));       // [2, 3]                byte positions

Each match is reported as a pair of numbers: where it starts and where it ends. findAll counts in string positions (the same units JavaScript strings use). findAllBytes counts in bytes of the UTF-8 encoding, which is useful when working with Uint8Array data.

Inputs can be a string or a Uint8Array. By default \w, \d, \s, and . follow JavaScript's built-in regex (without the u flag).

Options

The constructor accepts an optional RegexOptions object.

new Regex("hello", { caseInsensitive: true });
new Regex("a.b",   { dotMatchesNewLine: true });
new Regex(pat, {
    mode: "js",              // "js" | "resharp" | "full"
    caseInsensitive: false,
    dotMatchesNewLine: false,
    ignoreWhitespace: false,
    hardened: false,         // prevents adversarial blowup
    dfaThreshold: 0,         // states to eagerly precompile
    maxDfaCapacity: 65535,   // cached DFA states
    lookaheadContextMax: 800,
});

Unknown keys and wrong-typed values are rejected by the constructor.

Cleanup

Each Regex holds memory outside of JavaScript's garbage collector. Release it with r.free(), or let using do it for you:

{
    using r = new Regex("\\d+");
    r.isMatch("42");
}

API

class Regex {
    constructor(pattern: string, options?: RegexOptions);
    isMatch(input: string | Uint8Array): boolean;
    findAll(input: string | Uint8Array): Uint32Array;                   // string positions
    findAllBytes(input: string | Uint8Array): Uint32Array;              // byte positions
    findAnchored(input: string | Uint8Array): Uint32Array | undefined;  // string positions
    free(): void;
    [Symbol.dispose](): void;
}

Limitations

No capture groups. No replace or split. Results give you only the positions of each match. The constructor throws on invalid patterns; matching can throw if the engine hits an internal size or number limit.

The compiled bundle is around 900 KB, mostly Unicode tables. A smaller ASCII-only build is planned.

Build

./build.sh    # build via nix shell
nix build     # pinned toolchain, ./result is the npm layout
nix develop   # devshell

License

MIT