-
-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Hi,
While working with minimist, I noticed a few parsing behaviors that might be either limitations or intentional design choices. I would appreciate clarification on whether the following are expected behaviors, and whether there's a recommended approach to handle them.
Environment
- Node.js: v22.13.0
- minimist: v1.2.8
Cases
1. Negative number not parsed correctly when not using =
node main.js position 0 0 -3Expected:
{ _: [ 'position', 0, 0, -3 ] }Actual:
{ '3': true, _: [ 'position', 0, 0 ] }2. Negative number parsed correctly only when using = syntax
node main.js position -x=0 -y=0 -z=-3This works correctly and gives:
{ _: [ 'position' ], x: 0, y: 0, z: -3 }Note: It would be more convenient if negative numbers could be handled the same way in both cases, without needing = syntax.
3. Float values not parsed correctly
node main.js -x=0.1Expected:
{ _: [], x: 0.1 }Actual:
{ _: [ 0.1 ], x: 0 }4. Negative number parsed correctly only when not using = syntax
node main.js -x 0.1This works correctly and gives:
{ _: [], x: 0.1 }5. If only number stringified numbers lose their leading zeros
node main.js --name "0123"Expected:
{ _: [], name: '0123' }Actual:
{ _: [], name: 123 }6. If only number stringified numbers lose their leading zeros even using = syntax
node main.js --name="0123"Expected:
{ _: [], name: '0123' }Actual:
{ _: [], name: 123 }7. If use leading zeros number plus chars parsed correctly
node main.js --name "0123kk"This works correctly and gives:
{ _: [], name: '0123kk' }8. If use leading zeros number plus chars and using using = syntax parsed correctly
node main.js --name="0123kk"This works correctly and gives:
{ _: [], name: '0123kk' }shadowspawn
Metadata
Metadata
Assignees
Labels
No labels