UNPKG

506 BJavaScriptView Raw
1import { ANSI_G, ASTRAL_G, ANSI, ASTRAL } from '@spare/regex-charset';
2
3/**
4 *
5 * @param {string} tx
6 * @returns {number}
7 */
8
9const lange = tx => tx.replace(ANSI_G, '').replace(ASTRAL_G, '_').length;
10const Lange = ansi => ansi ? lange : x => x.length;
11
12const clearAnsi = tx => tx.replace(ANSI_G, '');
13
14const clearAstral = tx => tx.replace(ASTRAL_G, '_');
15
16const hasAnsi = tx => ANSI.test(tx);
17
18const hasAstral = tx => ASTRAL.test(tx);
19
20export { Lange, clearAnsi, clearAstral, hasAnsi, hasAstral, lange };