You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`Intl.NumberFormat.formatToParts` was first propsed in #30. The spec for
it was created in #79 and merged in #100. Due to browser implemantations
not being ready at the time, it was moved back to Stage 3 in #101. The
internal refactorings were kept in master and the user-facing method
`formatToParts` was removed from the spec in #102.
As of August 1st, 2017, `Intl.NumberFormat.prototype.formatToParts` has
shipped in two engines (behind a flag): SpiderMonkey and V8. This PR
brings `Intl.NumberFormat.formatToParts` back as Stage 4 proposal.
> const usd = Intl.NumberFormat('en', { style: 'currency', currency: 'USD' });
> usd.format(123456.789)
'$123,456.79'
> usd.formatToParts(123456.789)
[ { type: 'currency', value: '$' },
{ type: 'integer', value: '123' },
{ type: 'group', value: ',' },
{ type: 'integer', value: '456' },
{ type: 'decimal', value: '.' },
{ type: 'fraction', value: '79' } ]
> const pc = Intl.NumberFormat('en', { style: 'percent', minimumFractionDigits: 2 })
> pc.format(-0.123456)
'-12.35%'
> pc.formatToParts(-0.123456)
[ { type: 'minusSign', value: '-' },
{ type: 'integer', value: '12' },
{ type: 'decimal', value: '.' },
{ type: 'fraction', value: '35' },
{ type: 'literal', value: '%' } ]
0 commit comments