You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get the real length of a string - by correctly counting astral symbols and ignoring [ansi escape codes](https://github.com/sindresorhus/strip-ansi).
1
+
/**
2
+
Get the real length of a string - by correctly counting astral symbols and ignoring [ansi escape codes](https://github.com/sindresorhus/strip-ansi).
4
3
5
-
`String#length` errornously counts [astral symbols](https://web.archive.org/web/20150721114550/http://www.tlg.uci.edu/~opoudjis/unicode/unicode_astral.html) as two characters.
4
+
`String#length` errornously counts [astral symbols](https://web.archive.org/web/20150721114550/http://www.tlg.uci.edu/~opoudjis/unicode/unicode_astral.html) as two characters.
6
5
7
-
@example
8
-
```
9
-
import stringLength = require('string-length');
6
+
@example
7
+
```
8
+
import stringLength = require('string-length');
10
9
11
-
'🐴'.length;
12
-
//=> 2
10
+
'🐴'.length;
11
+
//=> 2
13
12
14
-
stringLength('🐴');
15
-
//=> 1
13
+
stringLength('🐴');
14
+
//=> 1
16
15
17
-
stringLength('\u001B[1municorn\u001B[22m');
18
-
//=> 7
19
-
```
20
-
*/
21
-
(string: string): number;
22
-
23
-
// TODO: Remove this for the next major release, refactor the whole definition to:
24
-
// declare function stringLength(string: string): number;
0 commit comments