NumberFormatter
Builds and transforms a numeric value before locale-aware formatting.
Table of contents
Category
Value
Import
jsimport { NumberFormatter } from "valyrian.js/money";Public signature
tsNumberFormatter.create(value?: number | string, shiftDecimal?: boolean): NumberFormatterAPI form
NumberFormatter is a class with a private constructor. Obtain an instance through NumberFormatter.create(...).
Properties and methods
tsNumberFormatter.create(value = 0, shiftDecimal = false): NumberFormatter
readonly value: number
set(newValue: number | string, shiftDecimal = false): this
format(digits = 2, options = { style: "currency", currency: "USD" }, locale = "en"): string
fromDecimalPlaces(decimalPlaces: number): this
toDecimalPlaces(decimalPlaces: number): this
getDecimalPlaces(): number
shiftDecimalPlaces(): thisInput behavior
create() and set() remove nonnumeric characters. An input that cannot produce a number becomes 0. shiftDecimal removes decimal separators before conversion.