Gathering detailed insights and metrics for mri
Gathering detailed insights and metrics for mri
Gathering detailed insights and metrics for mri
Gathering detailed insights and metrics for mri
npm install mri
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.8
Supply Chain
99.5
Quality
75.6
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
647 Stars
81 Commits
18 Forks
4 Watchers
1 Branches
4 Contributors
Updated on Jun 25, 2025
Latest Version
1.2.0
Package Id
mri@1.2.0
Size
4.34 kB
NPM Version
6.4.1
Node Version
10.13.0
Published on
Sep 12, 2021
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Quickly scan for CLI flags and arguments
This is a fast and lightweight alternative to minimist
and yargs-parser
.
It only exists because I find that I usually don't need most of what minimist
and yargs-parser
have to offer. However, mri
is similar enough that it might function as a "drop-in replacement" for you, too!
See Comparisons for more info.
1$ npm install --save mri
1$ demo-cli --foo --bar=baz -mtv -- hello world
1const mri = require('mri'); 2 3const argv = process.argv.slice(2); 4 5mri(argv); 6//=> { _: ['hello', 'world'], foo:true, bar:'baz', m:true, t:true, v:true } 7 8mri(argv, { boolean:['bar'] }); 9//=> { _: ['baz', 'hello', 'world'], foo:true, bar:true, m:true, t:true, v:true } 10 11mri(argv, { 12 alias: { 13 b: 'bar', 14 foo: ['f', 'fuz'] 15 } 16}); 17//=> { _: ['hello', 'world'], foo:true, f:true, fuz:true, b:'baz', bar:'baz', m:true, t:true, v:true }
Return: Object
Type: Array
Default: []
An array of arguments to parse. For CLI usage, send process.argv.slice(2)
. See process.argv
for info.
Type: Object
Default: {}
An object of keys whose values are String
s or Array<String>
of aliases. These will be added to the parsed output with matching values.
Type: Array|String
Default: []
A single key (or array of keys) that should be parsed as Boolean
s.
Type: Object
Default: {}
An key:value
object of defaults. If a default is provided for a key, its type (typeof
) will be used to cast parsed arguments.
1mri(['--foo', 'bar']); 2//=> { _:[], foo:'bar' } 3 4mri(['--foo', 'bar'], { 5 default: { foo:true, baz:'hello', bat:42 } 6}); 7//=> { _:['bar'], foo:true, baz:'hello', bat:42 }
Note: Because
--foo
has a default oftrue
, its output is cast to a Boolean. This means thatfoo=true
, making'bar'
an extra argument (_
key).
Type: Array|String
Default: []
A single key (or array of keys) that should be parsed as String
s.
Type: Function
Default: undefined
Callback that is run when a parsed flag has not been defined as a known key or alias. Its only parameter is the unknown flag itself; eg --foobar
or -f
.
Once an unknown flag is encountered, parsing will terminate, regardless of your return value.
Note:
mri
only checks for unknown flags ifoptions.unknown
andoptions.alias
are populated. Otherwise, everything will be accepted.
mri
is 5x faster (see benchmarks)Number
s when possible
opts.boolean
or opts.string
Boolean
s by default:
1minimist(['-abc', 'hello']); 2//=> { _:[], a:'', b:'', c:'hello' } 3 4mri(['-abc', 'hello']); 5//=> { _:[], a:true, b:true, c:'hello' }
opts.unknown
behaves differently:
minimist
, mri
will not continue continue parsing after encountering an unknown flagoptions
:
opts.stopEarly
opts['--']
\n
) within args (see test)mri
is 40x faster (see benchmarks)Number
s when possible
opts.boolean
or opts.string
options
:
opts.array
opts.config
opts.coerce
opts.count
opts.envPrefix
opts.narg
opts.normalize
opts.configuration
opts.number
opts['--']
parser.detailed()
methodoptions.unknown
featureRunning Node.js v10.13.0
Load Times:
nopt 3.179ms
yargs-parser 2.137ms
minimist 0.746ms
mri 0.517ms
Benchmark:
minimist x 328,747 ops/sec ±1.09% (89 runs sampled)
mri x 1,622,801 ops/sec ±0.94% (92 runs sampled)
nopt x 888,223 ops/sec ±0.22% (92 runs sampled)
yargs-parser x 30,538 ops/sec ±0.81% (91 runs sampled)
MIT © Luke Edwards
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More