{"_id":"@bybrave/arg2","name":"@bybrave/arg2","dist-tags":{"latest":"6.0.0"},"versions":{"6.0.0":{"name":"@bybrave/arg2","version":"6.0.0","description":"Maintained fork of arg — no-dependency CLI argument parser with fixed negative-number parsing (#52), optional flag values (#61), a ReDoS-safe number check (#70), ESM, and bundled types","type":"module","main":"./dist/index.cjs","module":"./index.js","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"build":"node build/build.js","test":"node --test test/*.test.js","test-types":"tsc --noEmit --strict test/type-declarations.ts","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/arg2.git"},"bugs":{"url":"https://github.com/bybraveHQ/arg2/issues"},"homepage":"https://github.com/bybraveHQ/arg2#readme","keywords":["argument","args","argv","cli","parser","command-line","esm","typescript"],"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"contributors":[{"name":"Vercel, Inc.","url":"author of the original arg"}],"license":"MIT","funding":"https://ko-fi.com/bybrave","engines":{"node":">=18"},"devDependencies":{"@types/node":"^20.14.0","esbuild":"^0.23.0","typescript":"^5.5.0"},"_id":"@bybrave/arg2@6.0.0","gitHead":"e25b04e90b9302b6c6d742be8769d094acd894db","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-0UGnsA2jfp3rLRD8JRJLxFE3yxdacuYBrGPyqDSgnIEEHMuKf7IzixL1AZuGFja5DzuKDXgxIXB/oXH16qnfzw==","shasum":"4cc519013e9a5a1895c1e3cf6694d0b847138838","tarball":"https://registry.npmjs.org/@bybrave/arg2/-/arg2-6.0.0.tgz","fileCount":6,"unpackedSize":18268,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDkrmS+6W6M+rBcl+5XYMlABkIvR32WaXI86SORjiPDgwIgM3yUHd6QeMseCETltsNutu8z3KlQa9pTnM9BCFwzEEs="}]},"_npmUser":{"name":"bybrave","email":"opmybrave@gmail.com"},"directories":{},"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/arg2_6.0.0_1783250356563_0.5613145589340953"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-05T11:19:16.430Z","6.0.0":"2026-07-05T11:19:16.702Z","modified":"2026-07-05T11:19:16.871Z"},"maintainers":[{"name":"bybrave","email":"opmybrave@gmail.com"}],"description":"Maintained fork of arg — no-dependency CLI argument parser with fixed negative-number parsing (#52), optional flag values (#61), a ReDoS-safe number check (#70), ESM, and bundled types","homepage":"https://github.com/bybraveHQ/arg2#readme","keywords":["argument","args","argv","cli","parser","command-line","esm","typescript"],"repository":{"type":"git","url":"git+https://github.com/bybraveHQ/arg2.git"},"contributors":[{"name":"Vercel, Inc.","url":"author of the original arg"}],"author":{"name":"bybrave","url":"https://github.com/bybraveHQ"},"bugs":{"url":"https://github.com/bybraveHQ/arg2/issues"},"license":"MIT","readme":"# @bybrave/arg2\n\nMaintained, drop-in fork of [`arg`](https://github.com/vercel/arg) — a simple, no-dependency CLI argument parser.\n\nThe original has had no release since 2022 (`5.0.2`) while still pulling ~440M downloads/month. This fork fixes negative-number parsing, adds optional flag values, closes a ReDoS report, and ships ESM plus bundled TypeScript types. The core API is unchanged.\n\n```sh\nnpm install @bybrave/arg2\n```\n\n```js\nconst arg = require('@bybrave/arg2');   // CommonJS\nimport arg from '@bybrave/arg2';         // ESM\n\nconst args = arg({\n    '--port': Number,\n    '--host': arg.optional(String),\n    '-p': '--port',\n});\n```\n\n## What's fixed\n\n| Issue | Problem | Fix |\n|---|---|---|\n| [#52](https://github.com/vercel/arg/issues/52) | A negative number passed without `=` (`--int -100`) threw `requires argument` unless the handler was exactly `Number`/`BigInt`. `parseInt`, `parseFloat`, `String`, etc. all broke. | A value that looks like a number (including exponents and leading-dot decimals) is accepted as the option's value for **any** handler type. |\n| [#70](https://github.com/vercel/arg/issues/70) | The number check `^-?\\d*(\\.(?=\\d))?\\d*$` was ReDoS-vulnerable (catastrophic backtracking). | Replaced with a linear, backtracking-free pattern. |\n| [#61](https://github.com/vercel/arg/issues/61) | No way to have an option whose value is optional. | New `arg.optional(type)` — see below. |\n| [#66](https://github.com/vercel/arg/issues/66) | No ESM entry. | Ships `import`/`require` via an `exports` map; bundled types. |\n\n## `arg.optional(type)`\n\nWrap a handler so the option's value is optional. With a value it parses normally; without one (at the end of argv, or followed by another option) it resolves to `true`, like a flag:\n\n```js\nconst args = arg({ '--host': arg.optional(String) });\n\narg({ '--host': arg.optional(String) }, { argv: ['--host', 'localhost'] }); // { _: [], '--host': 'localhost' }\narg({ '--host': arg.optional(String) }, { argv: ['--host'] });              // { _: [], '--host': true }\narg({ '--host': arg.optional(String) }, { argv: [] });                      // { _: [] }\n```\n\n## Migration from `arg`\n\nReplace the dependency and the import — everything behaves the same, plus the fixes above. The one intentional behavior change is #52: an option followed by a negative-number-looking token now consumes it as a value instead of throwing. An option followed by a *real* option (e.g. `--foo --bar`) still throws, as before.\n\n## Support\n\nIf this package saves you time, you can support maintenance:\n\n[![Ko-fi](https://img.shields.io/badge/Ko--fi-buy%20me%20a%20coffee-FF5E5B?logo=kofi&logoColor=white)](https://ko-fi.com/bybrave)\n[![Bitcoin](https://img.shields.io/badge/Bitcoin-BTC-F7931A?logo=bitcoin&logoColor=white)](#support)\n\nBitcoin (BTC): `bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q`\n\n## Credits & license\n\nMIT, same as the original — see [LICENSE.md](./LICENSE.md).\nBased on [arg](https://github.com/vercel/arg) by Vercel, Inc.\n","readmeFilename":"README.md","_rev":"1-fb80e9a19cbaaba1f627022e75a95875"}