Socket
Socket
Sign inDemoInstall

string-length

Package Overview
Dependencies
2
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

license

3

index.js
'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 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc