string-length
Advanced tools
Comparing version 1.0.0 to 1.0.1
'use strict'; | ||
var stripAnsi = require('strip-ansi'); | ||
var reAstral = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; | ||
module.exports = function (str) { | ||
var reAstral = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; | ||
return stripAnsi(str).replace(reAstral, ' ').length; | ||
}; |
{ | ||
"name": "string-length", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Get the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes", | ||
@@ -10,3 +10,3 @@ "license": "MIT", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
"url": "sindresorhus.com" | ||
}, | ||
@@ -36,3 +36,3 @@ "engines": { | ||
"dependencies": { | ||
"strip-ansi": "^2.0.0" | ||
"strip-ansi": "^3.0.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "devDependencies": { |
@@ -10,25 +10,17 @@ # string-length [![Build Status](https://travis-ci.org/sindresorhus/string-length.svg?branch=master)](https://travis-ci.org/sindresorhus/string-length) | ||
```sh | ||
``` | ||
$ npm install --save string-length | ||
``` | ||
```sh | ||
$ bower install --save string-length | ||
``` | ||
```sh | ||
$ component install sindresorhus/string-length | ||
``` | ||
## Usage | ||
```js | ||
'𐌢'.length; | ||
'🐴'.length; | ||
//=> 2 | ||
stringLength('𐌢'); | ||
stringLength('🐴'); | ||
//=> 1 | ||
stringLength('\x1b[1municorn\x1b[22m'); | ||
stringLength('\u001b[1municorn\u001b[22m'); | ||
//=> 7 | ||
@@ -35,0 +27,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2745
4
32
+ Addedansi-regex@2.1.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
- Removedansi-regex@1.1.1(transitive)
- Removedstrip-ansi@2.0.1(transitive)
Updatedstrip-ansi@^3.0.0