in src/RegExpI18n.ts [65:92]
validator: createRegExp(pattern)
};
regexpCache[pattern] = record;
}
return text.replace(record.matchRegexp, (ch) => {
return record.validator.test(ch) ? ch : replaceValue;
});
}
const MIN_SUPPLEMENTARY_CODE_POINT = 0x010000;
/**
* Trims the text from all codepoints out of given range.
*
* @param text
* @param range
*/
export function trim(text: string, range: Range): string {
let firstOutOfRange = -1;
let lastOutOfRange = -1;
for (let offset = 0; offset < text.length; ) {
const codePoint = text.charCodeAt(offset);
const outOfRange = range.out(codePoint);
const charCount = codePoint >= MIN_SUPPLEMENTARY_CODE_POINT ? 2 : 1;
if (firstOutOfRange === -1 && outOfRange) {