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

@sonicoriginalsoftware/arg-parser

v0.5.0

Published

Ye be parsin' yer args

Readme

arg-parser

Because pirate would be like shooting fish in a barrel, right?

Purpose

There are bazillions of other argument parsers out there.

But much like the rest of the software coming from Sonic Original, they were deemed too complex.

Behold an argument parsing library with the world's easiest API.

API

Input

Using the input looks like this:

import { parse } from "@sonicoriginalsoftware/arg-parser"

const token_list = {
  0: ["your", "first", "keyword", "possibilities"]
  1: ["your", "second", "keyword", "possibilities"]
  2: ["your", "third", "keyword", "possibilities"]
}

const parsed = parse(process.args.split(2), token_list)

Output

What does parsed look like above? Its simple:

import { global_flag_index, token_key } from "@sonicoriginalsoftware/arg-parser"

const output_api = {
  [global_flag_index]: {
    [a_stripped_global_flag_here]: a_value,
    [another_stripped_global_flag_here]: another_value,
    [stripped_global_flag_here]: value,
  },
  [1]: {
    [token_key]: "a value from your token_list[0] above",
    [a_stripped_token_flag]: "a flag that was passed after your first token",
    ...,
  },
  [2]: {
    [token_key]: "a value from your token_list[1] above",
    [a_stripped_token_flag]: "a flag that was passed after your second token",
    ...,
  },
  ...
}

Full Example

Say I called my CLI tool that uses arg-parser like this:

npx @my_scope/my_tool \
    -A_FLAG --Another_Flag \
    -A_third_flag a_third_flag_value \
    --a_fourth_global=use_it_with_equals \
    doTheThing \
      --a_thing_option its_value \
    theSubThing \
      -sub_thing_toggle

In my CLI main function, I need to parse this command, so I:

import { parse } from "@sonicoriginalsoftware/arg-parser"

const token_list = {
  0: ["doTheThing", "orTheOtherThing", "orAnotherThing"]
  1: ["withThisSubCommand", "orThisSubCommand", "theSubThing"]
}

const parsed = parse(process.args.split(2), token_list)

And now I need to route the behavior of the app according to the arguments used. So here's what parsed looks like:

import { global_flag_index, token_key } from "@sonicoriginalsoftware/arg-parser"

const parsed = {
  [global_flag_index]: {
    A_FLAG: true,
    Another_Flag: true
    A_third_flag: "a_third_flag_value",
    a_fourth_global: "use_it_with_equals"
  }
  [1]: {
    [token_key]: "doTheThing",
    a_thing_option: "its_value",
  }
  [2]: {
    [token_key]: "theSubThing",
    sub_thing_toggle: true,
  },
}

And determining values for routing behavior becomes just like managing behavior for any other object!

Limitations (for now)

  • Can only pass single-word values to flags
    • In the future, multiple word values for flags will be supported using quotes

Tests

This might one of the most extensively tested packages of all time, considering the parse function is only a couple lines of code.

There are around 100+ tests currently to validate the intended behavior of the parse function.

Thanks to the ease of use of @sonicoriginalsoftware/jester, testing became a breeze to implement.