Grouping
Represents the useGrouping option accepted by Intl.NumberFormat.
See Intl.NumberFormat on MDN for full option details.
t
RESCRIPT
type tparsed
RESCRIPT
type parsed = [#always | #auto | #bool(bool) | #min2]fromBool
RESCRIPT
let fromBool: bool => tConstructs a grouping setting from a boolean.
Examples
RESCRIPTlet formatter =
Intl.NumberFormat.make(
~locales=["en-US"],
~options={useGrouping: Intl.NumberFormat.Grouping.fromBool(false)},
)
formatter->Intl.NumberFormat.format(1234.) == "1234"
fromString
RESCRIPT
let fromString: [#always | #auto | #min2] => tConstructs a grouping setting from a string literal.
Examples
RESCRIPTlet formatter =
Intl.NumberFormat.make(
~locales=["en-US"],
~options={useGrouping: Intl.NumberFormat.Grouping.fromString(#always)},
)
formatter->Intl.NumberFormat.format(1234.) == "1,234"
parseJsValue
RESCRIPT
let parseJsValue: 'a => option<[> #always | #auto | #bool(bool) | #min2]>parseJsValue(value) attempts to interpret a JavaScript value as a grouping setting.
Examples
RESCRIPTIntl.NumberFormat.Grouping.parseJsValue(Js.Json.string("auto")) == Some(#auto)
ignore
RESCRIPT
let ignore: t => unitignore(grouping) ignores the provided grouping and returns unit.
This helper is useful when you want to discard a value (for example, the result of an operation with side effects) without having to store or process it further.