string-length
Get the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes
Last updated 4 months ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install string-length 
SYNC missed versions from official npm registry.

string-length Build Status

Get the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes

String#length errornously 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


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.

Current Tags

  • 4.0.1                                ...           latest (4 months ago)

10 Versions

  • 4.0.1                                ...           4 months ago
  • 4.0.0                                ...           5 months ago
  • 3.1.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.0.0                                ...           3 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 4,277
This Week 4,277
This Month 158,194
Last Day 5,747
Last Week 98,351
Last Month 353,222
Dependencies (2)
Dev Dependencies (3)
Dependents (225)

Copyright 2014 - 2016 © taobao.org |