Class

ListFmt

ListFmt(options)

Create a new list formatter object that formats lists of items according to the options.

The options object can contain zero or more of the following parameters:

  • locale locale to use to format this list, or undefined to use the default locale
  • length - Specify the length of the format to use. The length is the approximate size of the formatted string.
    • short
    • medium
    • long
    • full
  • style the name of style to use to format the list, or undefined to use the default "conjunction" style. Valid values are:
    • standard create a standard list.
    • conjunction this list should be concatenated with a conjunction "and". This is the default style for "standard".
    • disjunction this list should be concatenated with a disjunction "or".
    • unit this is a list of measures like "5 minutes, 4 seconds". In some languages, these type of lists are concatenated without a conjunction.
  • onLoad - a callback function to call when the locale data is fully loaded and the address has been parsed. When the onLoad option is given, the address formatter object will attempt to load any missing locale data using the ilib loader callback. When the constructor is done (even if the data is already preassembled), the onLoad function is called with the current instance as a parameter, so this callback can be used with preassembled or dynamic loading or a mix of the two.
  • sync - tell whether to load any missing locale data synchronously or asynchronously. If this option is given as "false", then the "onLoad" callback must be given, as the instance returned from this constructor will not be usable for a while.
  • loadParams - an object containing parameters to pass to the loader callback function when locale data is missing. The parameters are not interpretted or modified in any way. They are simply passed along. The object may contain any property/value pairs as long as the calling code is in agreement with the loader callback function as to what those parameters mean.
Constructor

# new ListFmt(options)

Parameters:
Name Type Description
options Object

properties that control how this formatter behaves

View Source ListFmt.js, line 90

Methods

# format(items) → {string}

Format a list of strings as grammatical text that is appropriate for the locale of this formatter.

Parameters:
Name Type Description
items Array.<string>

an array of strings to format in order that you would like them to appear

View Source ListFmt.js, line 156

a string containing the list of items that is grammatically correct for the locale of this formatter

string

# getLocale() → {string}

Return the locale of this formatter.

View Source ListFmt.js, line 202

the locale of this formatter

string

# getStyle() → {string}

Return the style of names returned by this formatter

View Source ListFmt.js, line 210

the style of names returned by this formatter

string