UNPKG

messageformat

Version:

Intl.MessageFormat / Unicode MessageFormat 2 parser, runtime and polyfill

17 lines (16 loc) 494 B
const bidiChars = new Set('\u061C\u200E\u200F\u2066\u2067\u2068\u2069'); const whitespaceChars = new Set('\t\n\r \u3000'); export function whitespaces(src, start) { let hasWS = false; let pos = start; let ch = src[pos]; while (bidiChars.has(ch)) ch = src[++pos]; while (whitespaceChars.has(ch)) { hasWS = true; ch = src[++pos]; } while (bidiChars.has(ch) || whitespaceChars.has(ch)) ch = src[++pos]; return { hasWS, end: pos }; }