Skip to content

Commit

Permalink
3.1.0: better segmenter fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
arty-name committed Jan 23, 2022
1 parent cb7f400 commit 66d09cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ export function* makeSlicesGenerator(Intl, collator, string, substring) {
new Intl.Segmenter(locale, { granularity: 'grapheme' }) :
{
*segment(string) {
const { length } = string;
// have to use that instead of `for segment of string` because we need index of chars, not code points
for (let index = 0; index < length; index += 1) {
const segment = string[index];
let index = 0;
for (const segment of string) {
yield { segment, index };
index += segment.length;
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "locale-index-of",
"version": "3.0.0",
"version": "3.1.0",
"description": "A prollyfill for String.prototype.localeIndexOf - a locale-aware Intl-powered version of indexOf.",
"main": "index.js",
"type": "module",
Expand Down

0 comments on commit 66d09cf

Please sign in to comment.