string-length (4.0.2)
Published 2026-02-24 14:05:35 +00:00 by atheaadmin
Installation
registry=npm install string-length@4.0.2"string-length": "4.0.2"About this package
string-length
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.
Install
$ npm install string-length
Usage
const stringLength = require('string-length');
'🐴'.length;
//=> 2
stringLength('🐴');
//=> 1
stringLength('\u001B[1municorn\u001B[22m');
//=> 7
Related
- string-length-cli - CLI for this module
- string-width - Get visual width of a string
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
Dependencies
Dependencies
| ID | Version |
|---|---|
| char-regex | ^1.0.2 |
| strip-ansi | ^6.0.0 |
Development Dependencies
| ID | Version |
|---|---|
| ava | ^3.1.0 |
| tsd | ^0.11.0 |
| xo | ^0.25.3 |
Keywords
unicode
string
length
size
count
astral
symbol
surrogates
codepoints
ansi
escape
codes
Details
Assets (1)
Versions (2)
View all
string-length-4.0.2.tgz
1.9 KiB