Skip to content

Commit 732fe1b

Browse files
committed
maybe this type check?
1 parent e859625 commit 732fe1b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/grapheme.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,16 @@ const BMP_MAX = 0xFFFF;
4545
* @return {GraphemeSegmenter} iterator for grapheme cluster segments
4646
*/
4747
export function* graphemeSegments(input) {
48-
/** Total length of the input string. */
49-
let len = input.length;
48+
let cp = input.codePointAt(0);
5049

5150
// do nothing on empty string
52-
if (len === 0) return;
51+
if (cp == null) return;
52+
53+
/** Total length of the input string. */
54+
let len = input.length;
5355

5456
let index = 0;
5557
let cursor = 0;
56-
let cp = /** @type {number} */ (input.codePointAt(cursor));
5758

5859
/** Category of codepoint immediately preceding cursor */
5960
let catBefore = cat(cp);

0 commit comments

Comments
 (0)