NumberFormatter
A wrapper around Intl.NumberFormat providing additional options, polyfills, and caching for performance.
Introduction
NumberFormatter is a wrapper around the native Intl.NumberFormat API. It exposes the same API, but works around several browser bugs and provides polyfills for newer features. These are currently:
- A polyfill for the
signDisplayoption. - A polyfill for the
unitstyle, currently only for thedegreeunit in thenarrowstyle
See the MDN docs for full details on how to use the API.
Interface
constructor | ||
format | ||
| Formats a number value as a string, according to the locale and options provided to the constructor. | ||
formatToParts | ||
| Formats a number to an array of parts such as separators, digits, punctuation, and more. | ||
formatRange | ||
| Formats a number range as a string. | ||
formatRangeToParts | ||
| Formats a number range as an array of parts. | ||
resolvedOptions | ||
| Returns the resolved formatting options based on the values passed to the constructor. | ||