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

@pintjuk/golang-regex

v1.0.9

Published

A JavaScript library for Golang-based regex matching using WebAssembly.

Downloads

40

Readme

@pintjuk/golang-regex

@pintjuk/golang-regex is a JavaScript package that enables regex matching using Go's regex engine via WebAssembly. It supports the full Go regex syntax, providing powerful and efficient matching capabilities directly in JavaScript environments.

Features

  • Full compatibility with Go's regex syntax.
  • Efficient WebAssembly-based implementation.
  • Simple integration with modern JavaScript/TypeScript projects.
  • Supports lazy loading for optimized performance.

Demo

For a complete demonstration of how to use this package, check out the live demo repository:

👉 Demo Repo

👉 Demo Site


Installation

Install the package via npm:

npm install @pintjuk/golang-regex

Webpack Configuration for .wasm Files

To use @pintjuk/golang-regex in a Webpack-based project, configure Webpack to handle .wasm files and enable WebAssembly support.

Example Webpack Configuration

const path = require('path');

module.exports = {
  entry: './src/main.js', // Your JavaScript entry point
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
  },
  mode: 'production',
  module: {
    rules: [
      {
        test: /\.wasm$/, // Handles `.wasm` files
        type: 'asset/resource', // Emits `.wasm` files as separate assets
      },
    ],
  },
  experiments: {
    asyncWebAssembly: true, // Enable asynchronous WebAssembly loading
  },
};

Key Configuration Points:

  1. type: 'asset/resource' for .wasm Files:
    • Ensures .wasm files are correctly emitted to the output directory.
  2. Enable asyncWebAssembly:
    • Allows WebAssembly files to be loaded asynchronously.

Usage

Basic Usage

Here’s how to use the package in a typical JavaScript application:

import GolangRegex from '@pintjuk/golang-regex';
import wasmPath from '@pintjuk/golang-regex/goregex.wasm';

(async () => {
  await GolangRegex.initialize(wasmPath);

  const pattern = '^hello';
  const text = 'hello world';

  const isMatch = GolangRegex.match(pattern, text);
  console.log(isMatch ? 'Match found!' : 'No match found.');
})();

Lazy Loading for Optimization

Since @pintjuk/golang-regex uses WebAssembly, it is recommended to lazy load the package to avoid blocking page load. Lazy loading ensures the WebAssembly module is initialized only when required.

Example: Lazy Loading

document.getElementById('regexButton').addEventListener('click', async () => {
  const GolangRegex = await import('@pintjuk/golang-regex');
  const wasmPath = await import('@pintjuk/golang-regex/goregex.wasm');

  await GolangRegex.initialize(wasmPath);

  const pattern = '^hello';
  const text = 'hello world';

  const isMatch = GolangRegex.match(pattern, text);
  console.log(isMatch ? 'Match found!' : 'No match found.');
});

Why Lazy Loading?

  1. Improved Performance: Loads the WebAssembly module only when needed, reducing initial load time.
  2. Non-blocking: Keeps the main thread free during the initial page load.
  3. Scalability: Ideal for applications where regex functionality is used conditionally or infrequently.

Why WebAssembly is Loaded Asynchronously

WebAssembly modules, such as goregex.wasm, must be downloaded and compiled by the browser. Loading these modules asynchronously provides several benefits:

  1. Non-blocking Execution: Prevents UI freezing during WebAssembly loading and compilation.
  2. Streaming Compilation: The WebAssembly.instantiateStreaming method allows browsers to compile the WebAssembly module while it's still downloading, improving performance.
  3. Optimized Resource Loading: Ensures that the WebAssembly module is only downloaded when needed.

License

This project is licensed under the MIT License.