Comparing version 1.0.0 to 1.1.0
@@ -87,4 +87,4 @@ 'use strict'; | ||
while (args[idx] !== void 0) { | ||
let incr = 1; | ||
const val = args[idx]; | ||
let incr = 1; | ||
@@ -107,2 +107,6 @@ if (val === '--') { | ||
if (opts.unknown !== void 0 && aliases[key] === void 0) { | ||
return opts.unknown(segs[0]); | ||
} | ||
if (segs.length > 1) { | ||
@@ -109,0 +113,0 @@ tmp = segs[1]; |
{ | ||
"name": "mri", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Quickly scan for CLI flags and arguments", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -96,3 +96,14 @@ # mri [![Build Status](https://travis-ci.org/lukeed/mri.svg?branch=master)](https://travis-ci.org/lukeed/mri) | ||
#### options.unknown | ||
Type: `function`<br> | ||
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 if `options.unknown` **and** `options.alias` are populated. Otherwise, everything will be accepted. | ||
## Comparisons | ||
@@ -113,5 +124,6 @@ | ||
``` | ||
- The `opts.unknown` behaves differently: | ||
- Unlike `minimist`, `mri` will not continue continue parsing after encountering an unknown flag | ||
- Missing `options`: | ||
- `opts.stopEarly` | ||
- `opts.unknown` | ||
- `opts['--']` | ||
@@ -140,2 +152,3 @@ - Ignores newlines (`\n`) within args (see [test](https://github.com/substack/minimist/blob/master/test/parse.js#L69-L80)) | ||
- No [additional configuration](https://github.com/yargs/yargs-parser#configuration) object | ||
- Added [`options.unknown`](##optionsunknown) feature | ||
@@ -147,7 +160,7 @@ | ||
mri | ||
--> 328,452 ops/sec ±0.28% (92 runs sampled) | ||
--> 329,310 ops/sec ±0.27% (88 runs sampled) | ||
yargs | ||
--> 16,014 ops/sec ±0.69% (94 runs sampled) | ||
--> 16,100 ops/sec ±0.57% (91 runs sampled) | ||
minimist | ||
--> 131,896 ops/sec ±0.92% (90 runs sampled) | ||
--> 129,670 ops/sec ±0.72% (93 runs sampled) | ||
``` | ||
@@ -154,0 +167,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10052
127
168
0