1 | /**
|
2 | Get the visual width of a string - the number of columns required to display it.
|
3 |
|
4 | Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
5 |
|
6 | @example
|
7 | ```
|
8 | import stringWidth from 'string-width';
|
9 |
|
10 | stringWidth('a');
|
11 | //=> 1
|
12 |
|
13 | stringWidth('古');
|
14 | //=> 2
|
15 |
|
16 | stringWidth('\u001B[1m古\u001B[22m');
|
17 | //=> 2
|
18 | ```
|
19 | */
|
20 | export default function stringWidth(string: string): number;
|