ListFormat

format

RES
let format: (t, array<string>) => string

format(formatter, items) returns the formatted list string.

Examples

RES
let formatter = Intl.ListFormat.make(~locales=["en"]) formatter->Intl.ListFormat.format(["a", "b"]) == "a and b"

formatToParts

RES
let formatToParts: (t, array<string>) => array<listPart>

formatToParts(formatter, items) returns the list as an array of parts describing how it would be rendered.

See Intl.ListFormat.prototype.formatToParts on MDN.

Examples

RES
let formatter = Intl.ListFormat.make(~locales=["en"]) formatter->Intl.ListFormat.formatToParts(["a", "b"])->Array.length > 0

ignore

RES
let ignore: t => unit

ignore(listFormat) ignores the provided listFormat 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.

listPart

RES
type listPart = { \"type": listPartComponentType, value: string, }

listPartComponentType

RES
type listPartComponentType = [#element | #literal]

listType

RES
type listType = [#conjunction | #disjunction | #unit]

make

RES
let make: (~locales: array<string>=?, ~options: options=?) => t

Creates a new Intl.ListFormat instance for formatting lists.

See Intl.ListFormat on MDN.

Examples

RES
let formatter = Intl.ListFormat.make(~locales=["en"], ~options={\"type": #conjunction}) formatter->Intl.ListFormat.format(["apples", "bananas", "cherries"]) == "apples, bananas, and cherries"

options

RES
type options = { localeMatcher?: Intl_Common.localeMatcher, \"type"?: listType, style?: style, }

resolvedOptions

RES
type resolvedOptions = { locale: string, style: style, \"type": listType, }

resolvedOptions

RES
let resolvedOptions: t => resolvedOptions

resolvedOptions(formatter) returns the actual options being used.

See Intl.ListFormat.prototype.resolvedOptions on MDN.

Examples

RES
let formatter = Intl.ListFormat.make(~locales=["en"]) Intl.ListFormat.resolvedOptions(formatter).locale == "en"

style

RES
type style = [#long | #narrow | #short]

supportedLocalesOf

RES
let supportedLocalesOf: ( array<string>, ~options: supportedLocalesOptions=?, ) => array<string>

supportedLocalesOf(locales, ~options) filters locales to those supported for list formatting.

See Intl.ListFormat.supportedLocalesOf on MDN.

Examples

RES
Intl.ListFormat.supportedLocalesOf(["en-US", "klingon"]) == ["en-US"]

supportedLocalesOptions

RES
type supportedLocalesOptions = { localeMatcher: Intl_Common.localeMatcher, }

t

RES
type t