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

@bybrave/arg2

v6.0.0

Published

Maintained fork of arg — no-dependency CLI argument parser with fixed negative-number parsing (#52), optional flag values (#61), a ReDoS-safe number check (#70), ESM, and bundled types

Readme

@bybrave/arg2

Maintained, drop-in fork of arg — a simple, no-dependency CLI argument parser.

The original has had no release since 2022 (5.0.2) while still pulling ~440M downloads/month. This fork fixes negative-number parsing, adds optional flag values, closes a ReDoS report, and ships ESM plus bundled TypeScript types. The core API is unchanged.

npm install @bybrave/arg2
const arg = require('@bybrave/arg2');   // CommonJS
import arg from '@bybrave/arg2';         // ESM

const args = arg({
    '--port': Number,
    '--host': arg.optional(String),
    '-p': '--port',
});

What's fixed

| Issue | Problem | Fix | |---|---|---| | #52 | A negative number passed without = (--int -100) threw requires argument unless the handler was exactly Number/BigInt. parseInt, parseFloat, String, etc. all broke. | A value that looks like a number (including exponents and leading-dot decimals) is accepted as the option's value for any handler type. | | #70 | The number check ^-?\d*(\.(?=\d))?\d*$ was ReDoS-vulnerable (catastrophic backtracking). | Replaced with a linear, backtracking-free pattern. | | #61 | No way to have an option whose value is optional. | New arg.optional(type) — see below. | | #66 | No ESM entry. | Ships import/require via an exports map; bundled types. |

arg.optional(type)

Wrap a handler so the option's value is optional. With a value it parses normally; without one (at the end of argv, or followed by another option) it resolves to true, like a flag:

const args = arg({ '--host': arg.optional(String) });

arg({ '--host': arg.optional(String) }, { argv: ['--host', 'localhost'] }); // { _: [], '--host': 'localhost' }
arg({ '--host': arg.optional(String) }, { argv: ['--host'] });              // { _: [], '--host': true }
arg({ '--host': arg.optional(String) }, { argv: [] });                      // { _: [] }

Migration from arg

Replace the dependency and the import — everything behaves the same, plus the fixes above. The one intentional behavior change is #52: an option followed by a negative-number-looking token now consumes it as a value instead of throwing. An option followed by a real option (e.g. --foo --bar) still throws, as before.

Support

If this package saves you time, you can support maintenance:

Ko-fi Bitcoin

Bitcoin (BTC): bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q

Credits & license

MIT, same as the original — see LICENSE.md. Based on arg by Vercel, Inc.