neverthrow
neverthrow copied to clipboard
docs: fix `Result.map` example in README.md
Fixes #631.
With the previous example:
(arr: Array<string>) => arr.map(parseInt)
parseInt gets the indices as its second parameter for the base.
Providing a callback where we pass the item gets rid of the issue:
(arr: Array<string>) => arr.map((s) => parseInt(s))
The base now defaults to 10.
To be even more explicit, we could have also added the second argument to parseInt as well, and maybe a comment to explain it:
// Parse the number as base-10
(arr: Array<string>) => arr.map((s) => parseInt(s, 10))
I think the first option is sufficient, but I can make changes to the PR if needed.