index.d.ts 583 B

12345678910111213141516171819202122
  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. `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.
  4. @example
  5. ```
  6. import stringLength = require('string-length');
  7. '🐴'.length;
  8. //=> 2
  9. stringLength('🐴');
  10. //=> 1
  11. stringLength('\u001B[1municorn\u001B[22m');
  12. //=> 7
  13. ```
  14. */
  15. declare function stringLength(string: string): number;
  16. export = stringLength;