We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling this example code:
const yargsParser = require('yargs-parser'); const argv = yargsParser(process.argv.slice(2), { array: ['arr'], }); console.log(JSON.stringify(argv, null, 2));
with these arguments:
node example.js --arr foo 2 bar
gives (as expected) the following output:
{ "_": [], "arr": [ "foo", 2, "bar" ] }
Adjusting the parsing options to treat the array as strings:
const yargsParser = require('yargs-parser'); const argv = yargsParser(process.argv.slice(2), { array: ['arr'], string: ['arr'], }); console.log(JSON.stringify(argv, null, 2));
gives the following output (also as expected):
{ "_": [], "arr": [ "foo", "2", "bar" ] }
However, if I tell it to treat the array as numbers:
const yargsParser = require('yargs-parser'); const argv = yargsParser(process.argv.slice(2), { array: ['arr'], number: ['arr'], }); console.log(JSON.stringify(argv, null, 2));
then I would expect to get all array elements parsed as numbers:
{ "_": [], "arr": [ null, 2, null ] }
Instead, I get this result:
{ "_": [], "arr": [ null ] }
Notably, this is also the case if all array elements are valid numbers:
node example.js --arr 1 2 3
gives the same result:
The text was updated successfully, but these errors were encountered:
@FM-96 at this time we don't yet support typed arrays, I think this would be a pretty neat enhancement however and is worth thinking about supporting.
Sorry, something went wrong.
No branches or pull requests
Calling this example code:
with these arguments:
node example.js --arr foo 2 bar
gives (as expected) the following output:
Adjusting the parsing options to treat the array as strings:
gives the following output (also as expected):
However, if I tell it to treat the array as numbers:
then I would expect to get all array elements parsed as numbers:
Instead, I get this result:
Notably, this is also the case if all array elements are valid numbers:
node example.js --arr 1 2 3
gives the same result:
The text was updated successfully, but these errors were encountered: