Open
Description
Use case
Example where Intl.Segmenter
is a bit verbose:
const segmenter = new Intl.Segmenter('en-us', { granularity: 'word' });
const segments = segmenter.segment('How are you?');
console.log(
Iterator.from(segments).filter(x => x.isWordLike).map(x => x.segment).toArray()
// Alternative:
// segments[Symbol.iterator]().filter(x => x.isWordLike).map(x => x.segment).toArray()
);
Solution
Add a method (e.g.) called .values()
to %IntlSegmentsPrototype%
that returns this[Symbol.iterator]()
.
segments.values().filter(x => x.isWordLike).map(x => x.segment).toArray()
Almost all other built-in iterables have string-keyed methods that return iterators, so this addition would bring %IntlSegmentsPrototype%
into the fold.
Metadata
Assignees
Labels
No labels