Skip to content

Commit 27b88b3

Browse files
committed
Simplify
1 parent b15edab commit 27b88b3

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

library/src/utils/_getCodePointCount/_getCodePointCountCount.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
* @internal
99
*/
1010
export function _getCodePointCount(input: string): number {
11-
let count: number = 0;
12-
for (let i = 0; i < input.length; ) {
11+
let count = 0;
12+
for (let i = 0; i < input.length; count++) {
1313
// If codePoint were undefined here, we would have already got out of loop
14-
const codePoint = input.codePointAt(i)!;
15-
if (codePoint <= 65535) {
14+
if (input.codePointAt(i)! <= 65535) {
1615
i++;
1716
} else {
1817
i += 2; // 2 characters (surrogate pair) in JS (UTF-16)
1918
}
20-
count++;
2119
}
2220
return count;
2321
}

0 commit comments

Comments
 (0)