deno_std
deno_std copied to clipboard
fix(fmt): handle missing group separator for 1000.1 in some locales
In some locales there is no group separator in parts which cause error during tests.
const parts = new Intl.NumberFormat().formatToParts(1000.1);
console.log(parts);
const group = parts.find(({ type }) => type === "group")!.value;
[
{ type: "integer", value: "1000" },
{ type: "decimal", value: "," },
{ type: "fraction", value: "1" }
]
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'value')
const group = parts.find(({ type }) => type === "group")!.value;
Change to 10000.1 fix this issue.
const parts = new Intl.NumberFormat().formatToParts(10000.1);
console.log(parts);
const group = parts.find(({ type }) => type === "group")!.value;
[
{ type: "integer", value: "10" },
{ type: "group", value: " " },
{ type: "integer", value: "000" },
{ type: "decimal", value: "," },
{ type: "fraction", value: "1" }
]