The Segmenter
When the Intl.Segmenter
function is called with optional arguments locales and options, the following steps are taken:
The Intl.Segmenter
The value of Intl.Segmenter.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 [[LocaleData]] internal slot is implementation-defined within the constraints described in
The value of the [[RelevantExtensionKeys]] internal slot is « ».
The Intl.Segmenter prototype object is itself an ordinary object. %Segmenter.prototype% is not an Intl.Segmenter instance and does not have an [[InitializedSegmenter]] internal slot or any of the other internal slots of Intl.Segmenter instance objects.
The initial value of Intl.Segmenter.prototype.constructor
is
The initial value of the @@toStringTag property is the String value
This property has the attributes { [[Writable]]:
The Intl.Segmenter.prototype.segment
method is called on an Intl.Segmenter instance with argument string to create a Segments instance for the string using the locale and options of the Intl.Segmenter instance. The following steps are taken:
This function provides access to the locale and options computed during initialization of the object.
Internal Slot | Property |
---|---|
[[Locale]] | |
[[SegmenterGranularity]] |
Intl.Segmenter instances are ordinary objects that inherit properties from
Intl.Segmenter instances have an [[InitializedSegmenter]] internal slot.
Intl.Segmenter instances also have internal slots that are computed by the
A Segments instance is an object that represents the segments of a specific string, subject to the locale and options of its constructing Intl.Segmenter instance.
The CreateSegmentsObject abstract operation is called with arguments Intl.Segmenter instance segmenter and String value string to create a Segments instance referencing both. The following steps are taken:
The %SegmentsPrototype% object:
The containing
method is called on a Segments instance with argument index to return a Segment Data object describing the segment in the string including the code unit at the specified index according to the locale and options of the Segments intance's constructing Intl.Segmenter instance. The following steps are taken:
The @@iterator
method is called on a Segments instance to create a Segment Iterator over its string using the locale and options of its constructing Intl.Segmenter instance. The following steps are taken:
Segments instances are ordinary objects that inherit properties from
Segments instances have a [[SegmentsSegmenter]] internal slot that references the constructing Intl.Segmenter instance.
Segments instances have a [[SegmentsString]] internal slot that references the String value whose segments they expose.
A Segment Iterator is an object that represents a particular iteration over the segments of a specific string.
The CreateSegmentIterator abstract operation is called with arguments Intl.Segmenter instance segmenter and String value string to create a Segment Iterator over string using the locale and options of segmenter. The following steps are taken:
The %SegmentIteratorPrototype% object:
The next
method is called on a Segment Iterator instance to advance it forward one segment and return an IteratorResult object either describing the new segment or declaring iteration done. The following steps are taken:
The initial value of the @@toStringTag property is the String value
This property has the attributes { [[Writable]]:
Segment Iterator instances are ordinary objects that inherit properties from
Internal Slot | Description |
---|---|
[[IteratingSegmenter]] | The Intl.Segmenter instance used for iteration. |
[[IteratedString]] | The String value being iterated upon. |
[[IteratedStringNextSegmentCodeUnitIndex]] | The code unit index in the String value being iterated upon at the start of the next segment. |
A Segment Data object is an object that represents a particular segment from a string.
The CreateSegmentDataObject abstract operation is called with arguments Intl.Segmenter instance segmenter, String value string, and indices startIndex and endIndex within string to create a Segment Data object describing the segment within string from segmenter that is bounded by the indices. The following steps are taken:
"word"
, thenThe FindBoundary abstract operation is called with arguments Intl.Segmenter instance segmenter, String string,
The following aspects of the ECMAScript 2021 Internationalization API Specification are implementation dependent: