Socket
Socket
Sign inDemoInstall

arg

Package Overview
Dependencies
0
Maintainers
21
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 3.0.0

index.d.ts

8

index.js

@@ -14,2 +14,6 @@ function arg(opts, {argv, permissive = false} = {}) {

for (const key of Object.keys(opts)) {
if (key[0] !== '-') {
throw new TypeError(`Argument key must start with '-' but found: '${key}'`);
}
if (typeof opts[key] === 'string') {

@@ -55,3 +59,5 @@ aliases[key] = opts[key];

} else {
throw new Error(`Unknown or unexpected option: ${originalArgName}`);
const err = new Error(`Unknown or unexpected option: ${originalArgName}`);
err.code = 'ARG_UNKNOWN_OPTION';
throw err;
}

@@ -58,0 +64,0 @@ }

6

package.json
{
"name": "arg",
"version": "2.0.1",
"version": "3.0.0",
"description": "Another simple argument parser",
"main": "index.js",
"types": "index.d.ts",
"repository": "zeit/arg",

@@ -10,3 +11,4 @@ "author": "Josh Junon <junon@zeit.co>",

"files": [
"index.js"
"index.js",
"index.d.ts"
],

@@ -13,0 +15,0 @@ "scripts": {

@@ -161,4 +161,28 @@ # Arg

#### Errors
##### ARG_UNKNOWN_OPTION
If an unknown option (not defined in the spec object) is passed, an error with code `ARG_UNKNOWN_OPTION` will be thrown:
```js
// cli.js
try {
require('arg')({ '--hi': String });
} catch (err) {
if (err.code === 'ARG_UNKNOWN_OPTION') {
console.log(err.message);
} else {
throw err;
}
}
```
```shell
node cli.js --extraneous true
Unknown or unexpected option: --extraneous
```
# License
Copyright &copy; 2017-2018 by ZEIT, Inc. Released under the [MIT License](LICENSE.md).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc