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 🙏

© 2025 – Pkg Stats / Ryan Hefner

apg-unicode

v1.0.1

Published

JavaScript APG parser of Unicode code point arrays

Readme

APG Unicode Parser

Parsers created with apg-js and apg-lite operate on arrays of positive integers—typically representing character codes. The apg-unicode variant extends this by supporting typed arrays, enabling more memory-efficient parsing workflows for modern JavaScript environments.

Note: apg-unicode does not natively parse Unicode. Instead, Unicode handling must be implemented via SABNF grammar and application logic. Typed arrays and conversion utilities simplify this process. See ./examples/unicode for an illustration of UTF-8 and UTF-16 parsing without prior transformation.

Key Features

Typed Array Support

apg-unicode accepts the following input types:

  • Array
  • Buffer
  • Uint8Array
  • Uint16Array
  • Uint32Array
  • String (converted internally to Uint32Array of code points)

Using typed arrays—especially Uint8Array—can reduce memory usage by up to 75% for large UTF-8 files.

Substring Parsing

Efficiently parse substrings within large strings without slicing or reallocating. Ideal for partial parsing scenarios. See ./examples/substrings for usage patterns.

Parser Generation

Like apg-lite, apg-unicode does not include a parser generator. To generate a grammar object, for example:

npm run apg -- -i ./examples/stats/sip.bnf -o ./examples/stats/sip

GitHub Usage

Clone the repo and run the user application and examples from the root directory:

git clone https://github.com/ldthomas/apg-unicode.git
cd apg-unicode

Include the modules in an application with:

import { Parser } from './src/parser.js';
import { Ast } from './src/ast.js';
import { Trace } from './src/tracer.js';
import { Stats } from './src/stats.js';
import { utilities } from './src/utilities.js';
import { identifiers } from './src/identifiers.js';

To run the examples use:

| Command | Description | | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | node examples/ast/main | Demonstrates Abstract Syntax Tree (AST) usage | | node examples/trace/main | Traces the parser through the parse tree | | node examples/stats/main | Collects and displays node hit statistics | | node examples/substrings/main | Parses substrings within a full input string | | node examples/unicode/main | Parses UTF-8 and UTF-16 directly without prior transformation to code points | | display examples/web/web.html in any browser | Illustrates running a parser in a web page. Note that web-app.js is created with esbuild from app.js. Use the script npm run esbuild. |

npm Usage

Install the repo from the npm registry. In the application root directory:

npm install apg-unicode

To access the modules in the application:

import { Parser, Ast, Trace, Stats, utilities, identifiers } from 'apg-unicode';

Documentation

The documentation is in in the code in docco format. To generate it use:

npm run docco

The documentation will then be in at ./docs/index.html

Or view it here on the APG website.

License

apg-unicode is licensed under the permissive MIT license.