package
Get the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes
npm install string-lengthGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
4.3 kB
Includes dependencies.
Get the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes
String#length erroneously counts astral symbols as two characters.
npm install string-lengthimport stringLength from 'string-length';
'🐴'.length;
//=> 2
stringLength('🐴');
//=> 1
stringLength('\u001B[1municorn\u001B[22m');
//=> 7Type: object
Type: boolean
Default: false
Whether ANSI escape codes should be counted. They are ignored by default.