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