diff --git a/README.md b/README.md index 42adcfb..3330d61 100644 --- a/README.md +++ b/README.md @@ -215,7 +215,7 @@ Since [Hermes doesn't support the `Intl.Segmenter` API](https://github.com/faceb | Name | Unicode® | ESM? | Size | Size (min) | Size (min+gzip) | Size (min+br) | Size (min+zstd) | |------------------------------|----------|------|----------:|-----------:|----------------:|--------------:|----------------:| -| `unicode-segmenter/grapheme` | 16.0.0 | ✔️ | 10,725 | 6,650 | 3,364 | 2,732 | 3,485 | +| `unicode-segmenter/grapheme` | 16.0.0 | ✔️ | 10,565 | 6,581 | 3,357 | 2,728 | 3,477 | | `graphemer` | 15.0.0 | ✖️ ️| 410,435 | 95,104 | 15,752 | 10,660 | 15,911 | | `grapheme-splitter` | 10.0.0 | ✖️ | 122,254 | 23,682 | 7,852 | 4,802 | 6,753 | | `@formatjs/intl-segmenter`* | 15.0.0 | ✖️ | 603,510 | 369,673 | 72,273 | 49,530 | 68,027 | @@ -231,7 +231,7 @@ Since [Hermes doesn't support the `Intl.Segmenter` API](https://github.com/faceb | Name | Bytecode size | Bytecode size (gzip)* | |------------------------------|--------------:|----------------------:| -| `unicode-segmenter/grapheme` | 20,229 | 11,393 | +| `unicode-segmenter/grapheme` | 20,060 | 11,319 | | `graphemer` | 134,089 | 31,766 | | `grapheme-splitter` | 63,946 | 19,162 | diff --git a/src/grapheme.js b/src/grapheme.js index d699c29..b603dd4 100644 --- a/src/grapheme.js +++ b/src/grapheme.js @@ -138,7 +138,7 @@ export function* graphemeSegments(input) { } // else GB999: ÷ Any - if (boundary) { + if (boundary || cursor === len) { yield { segment: input.slice(index, cursor), index, @@ -183,17 +183,6 @@ export function* graphemeSegments(input) { catBefore = catAfter; } - - if (index < len) { - yield { - segment: input.slice(index), - index, - input, - _hd, - _catBegin, - _catEnd: catBefore, - }; - } } /**