npm.io
1.0.0 • Published 10 years ago

charcount

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0
Stars
2

charcount

Build Status NPM version

Count visual length of javascript string.

Some symbols in JavaScript can occupy 2 characters (surrogate pair). This package count string length as you see it in browser:

var charcount = require('charcount');

console.log(charcount('😀')); // => 1
console.log('😀'.length);     // => 2

If you works with strings for terminal output, you may wish to ignore ASCII escape sequences. See those projects then:

License

MIT

Keywords