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 -3
Expected:
{ _: [ '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=-3
This 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
Expected:
Actual:
4. Negative number parsed correctly only when not using = syntax
This works correctly and gives:
5. If only number stringified numbers lose their leading zeros
node main.js --name "0123"
Expected:
Actual:
6. If only number stringified numbers lose their leading zeros even using = syntax
node main.js --name="0123"
Expected:
Actual:
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' }
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
Cases
1. Negative number not parsed correctly when not using
=Expected:
Actual:
2. Negative number parsed correctly only when using = syntax
This works correctly and gives:
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
Expected:
Actual:
4. Negative number parsed correctly only when not using = syntax
This works correctly and gives:
5. If only number stringified numbers lose their leading zeros
node main.js --name "0123"Expected:
Actual:
6. If only number stringified numbers lose their leading zeros even using = syntax
node main.js --name="0123"Expected:
Actual:
7. If use leading zeros number plus chars parsed correctly
node main.js --name "0123kk"This works correctly and gives:
8. If use leading zeros number plus chars and using using = syntax parsed correctly
node main.js --name="0123kk"This works correctly and gives: