All files / util/src/strings 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 91x 1x       19x 13x 8x  
const LETTER_REGEX = /(\p{Letter}|\d)/u;
const WHITESPACE_REGEX = /\s/;
 
export type CharPredicate = (char: string) => boolean;
 
export const isLetter: CharPredicate = (char: string) => LETTER_REGEX.test(char[0]);
export const isWhitespace: CharPredicate = (char: string) => WHITESPACE_REGEX.test(char[0]);
export const isPunctuation: CharPredicate = (char: string) => !isLetter(char) && !isWhitespace(char);