The DeconstructPattern abstract operation is called with arguments pattern (which must be a String) and placeables (which must be a
Input: DeconstructPattern("AA{xx}BB{yy}CC", { [[xx]]: {[[Type]]: "hour", [[Value]]: "15"}, [[yy]]: {[[Type]]: "minute", [[Value]]: "06"} }) Output (List of parts records): « {[[Type]]: "literal", [[Value]]: "AA"}, {[[Type]]: "hour", [[Value]]: "15"}, {[[Type]]: "literal", [[Value]]: "BB"}, {[[Type]]: "minute", [[Value]]: "06"}, {[[Type]]: "literal", [[Value]]: "CC"} »
"literal"
, then"literal"
, [[Value]]: patternPart.[[Value]] } to result.
The CreatePartsFromList abstract operation is called with arguments listFormat (which must be an object initialized as a ListFormat) and list (which must be a
"element"
, [[Value]]: list[0] }."element"
, [[Value]]: list[1] }."element"
, [[Value]]: list[size - 1] }."element"
, [[Value]]: list[i] }.
The FormatList abstract operation is called with arguments listFormat (which must be an object initialized as a ListFormat) and list (which must be a
The FormatListToParts abstract operation is called with arguments listFormat (which must be an object initialized as a ListFormat) and list (which must be a
"type"
, part.[[Type]])."value"
, part.[[Value]]).The abstract operation StringListFromIterable performs the following steps:
This algorithm raises exceptions when it encounters values that are not Strings, because there is no obvious locale-aware coercion for arbitrary values.
The ListFormat constructor is the %ListFormat% intrinsic object and a standard built-in property of the Intl object. Behaviour common to all service constructor properties of the Intl object is specified in
When the Intl.ListFormat
function is called with optional arguments locales and options, the following steps are taken:
"%ListFormatPrototype%"
, « [[InitializedListFormat]], [[Locale]], [[Type]], [[Style]], [[TemplatePair]], [[TemplateStart]], [[TemplateMiddle]], [[TemplateEnd]] »)."localeMatcher"
, "string"
, « "lookup"
, "best fit"
», "best fit"
)."type"
, "string"
, « "conjunction"
, "disjunction"
, "unit"
», "conjunction"
)."style"
, "string"
, « "long"
, "short"
, "narrow"
», "long"
).The Intl.ListFormat constructor has the following properties:
The value of Intl.ListFormat.prototype
is
This property has the attributes { [[Writable]]:
When the supportedLocalesOf
method is called with arguments locales and options, the following steps are taken:
The value of the [[AvailableLocales]] internal slot is implementation defined within the constraints described in
The value of the [[RelevantExtensionKeys]] internal slot is « ».
The value of the [[LocaleData]] internal slot is implementation defined within the constraints described in
formats
field for all locale values. The value of this field must be a record, which must have fields with the names of the three list formatting types: conjunction
, disjunction
, and unit
. Each record must have fields with the names of three formatting styles: long
, short
, and narrow
. Each of those fields must be records themselves, and each must have fields with names: Pair
, Start
, Middle
, and End
. Each of those fields must be a template string as specified in LDML conjunction
corresponds to "standard", disjunction
corresponds to "or", and unit
corresponds to "unit".
conjunction
stands for "and"-based lists (e.g., "A, B, and C"), disjunction
stands for "or"-based lists (e.g., "A, B, or C"), and unit
stands for lists of values with units (e.g., "5 pounds, 12 ounces").
The Intl.ListFormat prototype object is itself an ordinary object. %ListFormatPrototype% is not an Intl.ListFormat instance and does not have an [[InitializedListFormat]] internal slot or any of the other internal slots of Intl.ListFormat instance objects.
The initial value of Intl.ListFormat.prototype.constructor
is the intrinsic object
The initial value of the @@toStringTag property is the string value "Intl.ListFormat"
.
This property has the attributes { [[Writable]]:
When the format
method is called with an argument list, the following steps are taken:
When the formatToParts
method is called with an argument list, the following steps are taken:
This function provides access to the locale and options computed during initialization of the object.
Internal Slot | Property |
---|---|
[[Locale]] | "locale" |
[[Type]] | "type" |
[[Style]] | "style" |
Intl.ListFormat instances inherit properties from
Intl.ListFormat instances have an [[InitializedListFormat]] internal slot.
Intl.ListFormat instances also have several internal slots that are computed by the constructor:
"conjunction"
, "disjunction"
, or "unit"
, identifying the list of types used."long"
, "short"
, or "narrow"
, identifying the list formatting style used.
The four internal slots [[TemplatePair]], [[TemplateStart]], [[TemplateMiddle]], and [[TemplateEnd]] are all expected to be valid template patterns. They should each contain one instance of the substring "{0}"
and once instance of the substring "{1}"
, and the substring "{0}"
should occur before the substring "{1}"
.
© 2020 Mozilla, Ecma International
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.