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

minimist-lite

v2.3.0

Published

parse argument options

Readme

minimist-lite npm bundle size package dependency count Known Vulnerabilities

parse argument options

This module is the guts of optimist's argument parser without all the fanciful decoration.


The original minimist repo have been picked up by devs and is now available again under the original name:

https://github.com/minimistjs/minimist

Please use that package instead of this, as minimist-lite will only get security updates in the future, no further development is to be expected!

more info here: https://github.com/meszaros-lajos-gyorgy/minimist-lite/issues/27


Installation

With npm do:

npm install minimist-lite

With yarn do:

yarn add minimist-lite

License

MIT License. See LICENSE for details.

Examples

See example/parse.js:

var argv = require('minimist-lite')(process.argv.slice(2));

console.log(argv);

Running node example/parse.js with arguments shows how they are parsed by minimist:

No arguments

With no arguments minimist returns an object with a single key "_" (underscore) with a value of an empty array:

$ node example/parse.js
{ _: [] }

Arguments without dashes

Using arguments with no dashes adds them to the "_" array in the object returned by minimist:

$ node example/parse.js abc def
{ _: [ 'abc', 'def' ] }

Single-letter options

A single dash starts a single-letter option that are boolean by default:

$ node example/parse.js -a -b -c
{ _: [], a: true, b: true, c: true }

Single-letter options can be joined together:

$ node example/parse.js -abc
{ _: [], a: true, b: true, c: true }

When a single-letter option is followed by a value with no dashes, the option gets that value in the returned object instead of a boolean value:

$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }

Numeric values can be joined with single-letter options:

$ node example/parse.js -a 1 -b2
{ _: [], a: 1, b: 2 }

Multi-letter options

Multi-letter options start with double dashes and they are boolean by default:

$ node example/parse.js --abc --def
{ _: [], abc: true, def: true }

Values can follow multi-letter options after a space or equal sign:

$ node example/parse.js --abc 1 --def=2
{ _: [], abc: 1, def: 2 }

--no- prefix handling

Options with the prefix --no- will be treated as a flag that has the value false by default:

$ node example/parse.js --no-abc
{ _: [], abc: false }

$ node example/parse.js --no-abc true
{ _: ['true'], abc: false }

Mixed styles

All of those styles can be used together:

$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop --hoo:haa foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
  x: 3,
  y: 4,
  n: 5,
  a: true,
  b: true,
  c: true,
  hoo: [haa],
  beep: 'boop' }

The default parsing of the arguments can be changed by using the second argument to the parsing method, see below.

Repeated options

If an option is provided more than once, the returned object value for that option will be an array (rather than a boolean or a string):

$ node example/parse.js --foo=bar --foo=baz
{ _: [], foo: [ 'bar', 'baz' ] }

Methods

Minimist exports a single method:

var parseArgs = require('minimist-lite');

var argv = parseArgs(args, opts={})

Return an argument object argv populated with the array arguments from args.

argv._ contains all the arguments that didn't have an option associated with them, or an empty array if there were no such arguments.

Numeric-looking arguments will be returned as numbers unless opts.string or opts.boolean is set for that argument name.

Any arguments after '--' will not be parsed and will end up in argv._.

Options

options can be:

  • opts.string - a string or array of strings with argument names to always treat as strings

  • opts.array - a string or array of strings argument names to always treat as array values

  • opts.boolean - a boolean, string or array of strings to always treat as booleans. if true will treat all double hyphenated arguments without equal signs as boolean (e.g. affects --foo, not -f or --foo=bar)

  • opts.alias - an object mapping string names to strings or arrays of string argument names to use as aliases

  • opts.default - an object mapping string argument names to default values

  • opts.stopEarly - when true, populate argv._ with everything after the first non-option

  • opts['--'] - when true, populate argv._ with everything before the -- and argv['--'] with everything after the --. Here's an example:

    > require('./')('one two three -- four five --six'.split(' '), { '--': true })
    { _: [ 'one', 'two', 'three' ],
      '--': [ 'four', 'five', '--six' ] }

    Note that with opts['--'] set, parsing for arguments still stops after the --.

  • opts.unknown - a function which is invoked with a command line parameter not defined in the opts configuration object. If the function returns false, the unknown option is not added to argv.