MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts
What information was incorrect, unhelpful, or incomplete?
The list of 'possible types' is incomplete, when using Intl.NumberFormat({notation: 'compact'}).formatToParts(number) the magnitude of the value is passed in as a part with type: 'compact'
Specific section or headline?
Description, under the Possible types are the following: list.
What did you expect to see?
`'compact' is missing in this list, as per EMCA 402, section 12.1.7 (PartitionNotationSubPattern), step 4. - c. - iv. - 2.:
iv. Else if p is equal to "compactSymbol", then
- [...]
- Append a new Record { [[Type]]: "compact", [[Value]]: compactSymbol } as the last element of result.
as well as step 4. - c. - v. - 2.:
v. Else if p is equal to "compactName", then
- [...]
- Append a new Record { [[Type]]: "compact", [[Value]]: compactName } as the last element of result.
Did you test this? If so, how?
JavaScript code using the part type:
const compactFormat = Intl.NumberFormat('en', {
notation: 'compact',
compactDisplay: 'short',
style: 'decimal',
maximumFractionDigits: 3,
});
// formatValue(42174812) => {formatted: '42.175', magnitude: 'M'}
function formatValue(value) {
let magnitude = '';
return {
formatted: compactFormat
.formatToParts(value)
.reduce((formatted, part) => {
switch (part.type) {
case 'compact':
magnitude = magnitude + part.value;
break;
default:
formatted = formatted + part.value;
}
return formatted;
}, ''),
magnitude: magnitude
};
}
console.log(formatValue(42174812));
outputs
Object { formatted: "42.175", magnitude: "M" }
MDN Content page report details
MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts
What information was incorrect, unhelpful, or incomplete?
The list of 'possible types' is incomplete, when using
Intl.NumberFormat({notation: 'compact'}).formatToParts(number)the magnitude of the value is passed in as a part withtype: 'compact'Specific section or headline?
Description, under the Possible types are the following: list.
What did you expect to see?
`'compact' is missing in this list, as per EMCA 402, section 12.1.7 (PartitionNotationSubPattern), step 4. - c. - iv. - 2.:
as well as step 4. - c. - v. - 2.:
Did you test this? If so, how?
JavaScript code using the part type:
outputs
MDN Content page report details
en-us/web/javascript/reference/global_objects/intl/numberformat/formattoparts