Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
792 bytes
|
Line | |
---|
1 | declare const stringWidth: {
|
---|
2 | /**
|
---|
3 | Get the visual width of a string - the number of columns required to display it.
|
---|
4 |
|
---|
5 | 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.
|
---|
6 |
|
---|
7 | @example
|
---|
8 | ```
|
---|
9 | import stringWidth = require('string-width');
|
---|
10 |
|
---|
11 | stringWidth('a');
|
---|
12 | //=> 1
|
---|
13 |
|
---|
14 | stringWidth('古');
|
---|
15 | //=> 2
|
---|
16 |
|
---|
17 | stringWidth('\u001B[1m古\u001B[22m');
|
---|
18 | //=> 2
|
---|
19 | ```
|
---|
20 | */
|
---|
21 | (string: string): number;
|
---|
22 |
|
---|
23 | // TODO: remove this in the next major version, refactor the whole definition to:
|
---|
24 | // declare function stringWidth(string: string): number;
|
---|
25 | // export = stringWidth;
|
---|
26 | default: typeof stringWidth;
|
---|
27 | }
|
---|
28 |
|
---|
29 | export = stringWidth;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.