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

ppegjs

v0.1.3

Published

A portable Parser Expression Grammar.

Readme

pPEGjs

A portable Parser Expression Grammar.

For more information see: pPEG.

To see a demo try the dingus web-page.

To develop your own pPEG grammar use the peg-play command line tool.

The peg-play.mjs module is a small node.js command line tool to compile and run files with a pPEG grammar and input text test(s).

The play/ directory has some examples for peg-play.mjs to run.

The examples/ directory has examples of how to use pPEG in JavaScript.

This repo is an implementation of pPEG in JavaScript, for other languages see: INDEX.

To use pPEG the single file JavaScript module pPEG.mjs is all you need. It has no dependencies, it can be run in Node.js or in a browser.

Example

    import peg from './pPEG.mjs'

    // Equivalent to the regular expression for well-formed URI's in RFC 3986.

    const pURI = peg.compile(`
        URI     = (scheme ':')? ('//' auth)? path ('?' query)? ('#' frag)?
        scheme  = ~[:/?#]+
        auth    = ~[/?#]*
        path    = ~[?#]*
        query   = ~'#'*
        frag    = ~[ \t\n\r]*
    `);

    if (!pURI.ok) throw "URI grammar error:\n"+pURI.show_err();

    const test = "http://www.ics.uci.edu/pub/ietf/uri/#Related";

    const uri = pURI.parse(test);

    if (uri.ok) console.log(uri.show_ptree());
    else console.log(uri.show_err());

    /*
    uri.ptree =
    ["URI",[["scheme","http"],["auth","www.ics.uci.edu"],["path","/pub/ietf/uri/"],
            ["frag","Related"]]]

    uri.show_ptree() =>
    URI
    ├─scheme "http"
    ├─auth "www.ics.uci.edu"
    ├─path "/pub/ietf/uri/"
    └─frag "Related"
    */

API

The import provides a peg object with a compile function which takes a string that defines your grammar.

The compile result is an parser object with a parse function:

{
  ok: boolean, true if there are no errors,

  err: int, # an error code, 0=ok, 1=panic, ...

  show_err: () => a full error report.

  parse: (String) => parser object
}

The parser.parse function takes a string and generates a parse-tree object:

{
  ok: boolean, true if there are no errors,

  err: int, # an error code, 0=ok, 1=panic, ...

  show_err: () => a full error report.

  ptree: parse_tree object,

  show_ptree: (fmt) => ptree pretty print string.
                          # default ascii-art tree, 
                          # fmt=true for json format.
}

The ptree parse tree type is JSON data, as defined in pPEG.