/** `\r`. */ export const CR = 0x0d; /** `\n`. */ export const LF = 0x0a; /** Whether `code` is the first UTF-16 unit of a surrogate pair. */ export const isHighSurrogate = (code: number): boolean => code >= 0xd800 && code <= 0xdbff; /** Whether `code` is the second UTF-16 unit of a surrogate pair. */ export const isLowSurrogate = (code: number): boolean => code >= 0xdc00 && code <= 0xdfff; /** Whether splitting `text` at UTF-16 offset `offset` would cut a surrogate pair in half. */ export const splitsPair = (text: string, offset: number): boolean => offset > 0 && offset < text.length && isHighSurrogate(text.charCodeAt(offset - 1)) && isLowSurrogate(text.charCodeAt(offset)); /** Whether splitting `text` at UTF-16 offset `offset` would fall between the `\r` and `\n` of a `\r\n`. */ export const splitsCrlf = (text: string, offset: number): boolean => offset > 0 && offset < text.length && text.charCodeAt(offset - 1) === CR && text.charCodeAt(offset) === LF;