|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
583 bytes
|
| Line | |
|---|
| 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).
|
|---|
| 3 |
|
|---|
| 4 | `String#length` erroneously counts [astral symbols](https://web.archive.org/web/20150721114550/http://www.tlg.uci.edu/~opoudjis/unicode/unicode_astral.html) as two characters.
|
|---|
| 5 |
|
|---|
| 6 | @example
|
|---|
| 7 | ```
|
|---|
| 8 | import stringLength = require('string-length');
|
|---|
| 9 |
|
|---|
| 10 | '🐴'.length;
|
|---|
| 11 | //=> 2
|
|---|
| 12 |
|
|---|
| 13 | stringLength('🐴');
|
|---|
| 14 | //=> 1
|
|---|
| 15 |
|
|---|
| 16 | stringLength('\u001B[1municorn\u001B[22m');
|
|---|
| 17 | //=> 7
|
|---|
| 18 | ```
|
|---|
| 19 | */
|
|---|
| 20 | declare function stringLength(string: string): number;
|
|---|
| 21 |
|
|---|
| 22 | export = stringLength;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.