We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e859625 commit 732fe1bCopy full SHA for 732fe1b
src/grapheme.js
@@ -45,15 +45,16 @@ const BMP_MAX = 0xFFFF;
45
* @return {GraphemeSegmenter} iterator for grapheme cluster segments
46
*/
47
export function* graphemeSegments(input) {
48
- /** Total length of the input string. */
49
- let len = input.length;
+ let cp = input.codePointAt(0);
50
51
// do nothing on empty string
52
- if (len === 0) return;
+ if (cp == null) return;
+
53
+ /** Total length of the input string. */
54
+ let len = input.length;
55
56
let index = 0;
57
let cursor = 0;
- let cp = /** @type {number} */ (input.codePointAt(cursor));
58
59
/** Category of codepoint immediately preceding cursor */
60
let catBefore = cat(cp);
0 commit comments