src/core/grapheme-splitter.js
// Returns the next grapheme break in the string after the given index
Returns the next grapheme break in the string after the given index
Returns the next grapheme break in the string after the given index
function nextBreak(string, index) {
    index = index || 0;
    if (index < 0) {
        return 0;
    }
    if (index >= string.length - 1) {
        return string.length;
    }
    let prev = getGraphemeBreakProperty(codePointAt(string, index));
    for (let i = index + 1; i < string.length; i++) {
        if (
            0xd800 <= string.charCodeAt(i - 1) &&
            string.charCodeAt(i - 1) <= 0xdbff &&
            0xdc00 <= string.charCodeAt(i) &&
            string.charCodeAt(i) <= 0xdfff
        ) {
            continue;
        }
        const next = getGraphemeBreakProperty(codePointAt(string, i));
        if (shouldBreak(prev, next)) {
            return i;
        }
        prev = next;
    }
    return string.length;
}
function nextBreak ( string , index ) { index = index || 0 ; if ( index < 0 ) { return 0 ; } if ( index >= string . length - 1 ) { return string . length ; } let prev = getGraphemeBreakProperty ( codePointAt ( string , index ) ) ; for ( let i = index + 1 ; i < string . length ; i ++ ) { if ( 0xd800 <= string . charCodeAt ( i - 1 ) && string . charCodeAt ( i - 1 ) <= 0xdbff && 0xdc00 <= string . charCodeAt ( i ) && string . charCodeAt ( i ) <= 0xdfff ) { continue ; } const next = getGraphemeBreakProperty ( codePointAt ( string , i ) ) ; if ( shouldBreak ( prev , next ) ) { return i ; } prev = next ; } return string . length ; }
Returns the next grapheme break in the string after the given index
Returns the next grapheme break in the string after the given index
// check for already processed low surrogates