From 946e010b64b6ffea8ba12297308728ba0ccfc83f Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Mon, 29 Dec 2025 08:41:19 +0900 Subject: [PATCH 1/2] merge yield statement for draining --- src/grapheme.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) 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, - }; - } } /** From 572f713b0b0674a67aa2935ca57a655765e2f866 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Mon, 29 Dec 2025 08:43:41 +0900 Subject: [PATCH 2/2] update bundle stats --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 |