All files / json-crdt-extensions/peritext/editor util.ts

100% Statements 11/11
100% Branches 2/2
100% Functions 3/3
100% Lines 5/5

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    57x 57x   1290x 57x 57x  
import type {CharPredicate} from './types';
 
const LETTER_REGEX = /(\p{Letter}|\d)/u;
const WHITESPACE_REGEX = /\s/;
 
export const isLetter: CharPredicate<string> = (char: string) => LETTER_REGEX.test(char[0]);
export const isWhitespace: CharPredicate<string> = (char: string) => WHITESPACE_REGEX.test(char[0]);
export const isPunctuation: CharPredicate<string> = (char: string) => !isLetter(char) && !isWhitespace(char);