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

argpa

v1.0.2

Published

Like minimist, less mini

Readme

argpa

WARNING: this is a work in progress, the API might change significantly in future versions.

Middleweight arg parsing library.

npm install argpa

Usage

const Argpa = require('argpa')

const cmd = new Argpa()
const argv = '-a -b c'.split(' ')
const { alpha, beta } = cmd.parse(argv, {
  boolean: ['alpha'],
  string: ['beta'],
  alias: {
    alpha: 'a',
    beta: 'b'
  }
})
console.log(alpha) // prints true
console.log(beta)  // prints 'c'

API

The module exports a class, the constructor for it is

const cmd = new Argpa(flags, help, teardown)

All three arguments are optional.

flags defines the general flags that should be available to all commands and subcommands. Defaults to []

help defines a helper function to run with --help in complex CLIs. It can be invoked with any command or subcommand, and it gets passed the commandName as argument. It's called by cmd.run Defaults to function (commandName) { return commandName }

teardown defines a function that gets run at the end of cmd.run()as

finally {
  await this.teardown()
}

It defaults to the noop function () {}

cmd.add(commandName, fn)

This method introduces a command with an associated function. When invoked via cmd.run, the function will be passed the flags and arguments that follow the command, for example

command subcommand -flag argument

will invoke the command command subcommand by calling its associated function and passing to it ['-flag', 'argument']. You can parse that argument array inside the function, using cmd.parse

const x = await cmd.run(argv = argv = process.argv.splice(2))

This async method is probably going to be the starting point of the CLI, it will parse the argument array and select the correct command between the ones added. It also launches the help function if the array contains --help.

const result = cmd.parse(argv = process.argv.splice(2), opts = {})

This method is the main parser of the library. It parses the provided array of arguments and return an object that contains a key/value entry for each flag/argument, plus a _ entry for an array of positional arguments, and a -- entry for an array of arguments passed down using --. The opts object can have the following properties:

{
  boolean: [],
  string: [],
  alias: {},
  default: {},
  validate: true 
}

boolean is an array of the flags you want to have a boolean value. Boolean flags will be true by default, unless prepended with no-, in which case they will be false

string is an array of the flags you want to have a string value.

alias is a key/value pairing of flags and their aliases.

default is a key/value pairing of flags and their default values.

validate will make the parser throw an error if an unknown flag is called.

The arguments of list flags, like --numbers=1,2,3, will automatically be parsed as strings, in this case 1,2,3

Summary

If you don't need subcommands, you just construct your parser with const cmd = new Argpa(...) and use cmd.parseto parse the provided arguments.

If you need something more complex

  • construct your parser with const cmd = new Argpa(...)
  • use cmd.add to add commands & subcommands and associate them to functions
  • use cmd.parse inside those functions to define specialized parsers for the flags&arguments of those commands
  • launch the parser with cmd.run