Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/grapheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
/** @type {number} Total length of the input string. */
let len = input.length;

/** @type {GraphemeCategoryNum | null} Category of codepoint immediately preceding cursor, if known. */
let catBefore = null;
/** @type {GraphemeCategoryNum | -1} Category of codepoint immediately preceding cursor, if known. */
let catBefore = -1;

/** @type {GraphemeCategoryNum | null} Category of codepoint immediately preceding cursor, if known. */
let catAfter = null;
/** @type {GraphemeCategoryNum | -1} Category of codepoint immediately preceding cursor, if known. */
let catAfter = -1;

/** @type {GraphemeCategoryNum | null} Beginning category of a segment */
let catBegin = null;
/** @type {GraphemeCategoryNum | -1} Beginning category of a segment */
let catBegin = -1;

/** @type {import('./_grapheme_data.js').GraphemeCategoryRange} */
let cache = [0, 0, 2 /* GC_Control */];
Expand Down Expand Up @@ -94,7 +94,7 @@
// Note: Of course the nullish coalescing is useful here,
// but avoid it for aggressive compatibility and perf claim
catBefore = catAfter;
if (catBefore === null) {
if (catBefore < 0) {
catBefore = cat(cp, cache);
catBegin = catBefore;
}
Expand All @@ -105,8 +105,8 @@
index,
input,
_hd,
_catBegin: /** @type {typeof catBefore} */ (catBegin),

Check failure on line 108 in src/grapheme.js

View workflow job for this annotation

GitHub Actions / Checking build

Type '-1 | GraphemeCategoryNum' is not assignable to type 'GraphemeCategoryNum'.
_catEnd: catBefore,

Check failure on line 109 in src/grapheme.js

View workflow job for this annotation

GitHub Actions / Checking build

Type '-1 | GraphemeCategoryNum' is not assignable to type 'GraphemeCategoryNum'.
};
return;
}
Expand Down Expand Up @@ -143,14 +143,14 @@
}
}

if (isBoundary(catBefore, catAfter, risCount, emoji, incb)) {

Check failure on line 146 in src/grapheme.js

View workflow job for this annotation

GitHub Actions / Checking build

Argument of type '-1 | GraphemeCategoryNum' is not assignable to parameter of type 'GraphemeCategoryNum'.
yield {
segment: input.slice(index, cursor),
index,
input,
_hd,
_catBegin: /** @type {typeof catBefore} */ (catBegin),

Check failure on line 152 in src/grapheme.js

View workflow job for this annotation

GitHub Actions / Checking build

Type '-1 | GraphemeCategoryNum' is not assignable to type 'GraphemeCategoryNum'.
_catEnd: catBefore,

Check failure on line 153 in src/grapheme.js

View workflow job for this annotation

GitHub Actions / Checking build

Type '-1 | GraphemeCategoryNum' is not assignable to type 'GraphemeCategoryNum'.
};

// flush
Expand Down
Loading