Grouping

Represents the useGrouping option accepted by Intl.NumberFormat.

See Intl.NumberFormat on MDN for full option details.

fromBool

RESCRIPT
let fromBool: bool => t

Constructs a grouping setting from a boolean.

Examples

RESCRIPT
let 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] => t

Constructs a grouping setting from a string literal.

Examples

RESCRIPT
let formatter = Intl.NumberFormat.make( ~locales=["en-US"], ~options={useGrouping: Intl.NumberFormat.Grouping.fromString(#always)}, ) formatter->Intl.NumberFormat.format(1234.) == "1,234"

ignore

RESCRIPT
let ignore: t => unit

ignore(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.

parsed

RESCRIPT
type parsed = [#always | #auto | #bool(bool) | #min2]

parseJsValue

RESCRIPT
let parseJsValue: 'a => option<[> #always | #auto | #bool(bool) | #min2]>

parseJsValue(value) attempts to interpret a JavaScript value as a grouping setting.

Examples

RESCRIPT
Intl.NumberFormat.Grouping.parseJsValue(Js.Json.string("auto")) == Some(#auto)

t

RESCRIPT
type t