Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 1x 7x 7x 7x 7x 7x 7x | /** * Options for {@link isSurrogate} * @group Unicode * @category Is Surrogate */ export type IsSurrogateOptions = { /** test for high surrogates (D800-DBFF) */ high?: boolean; /** test for low surrogates (DC00-DFFF) */ low?: boolean; }; /** * Determine is a character is a surrogate * @param input - the character to test * @param options - see {@link IsSurrogateOptions} * @defaultValue high true * @defaultValue low true * @returns true if the specified character is a unicode surrogate * @group Unicode * @category Is Surrogate */ export function isSurrogate( input: string, { high = true, low = true }: IsSurrogateOptions = {}, ): boolean { // eslint-disable-next-line unicorn/prefer-code-point const cc = input.charCodeAt(0); return (high && cc >= 0xd800 && cc <= 0xdbff) || (low && cc >= 0xdc00 && cc <= 0xdfff); } |