Socket
Socket
Sign inDemoInstall

string-length

Package Overview
Dependencies
3
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.1.0

39

index.d.ts

@@ -1,20 +0,29 @@

/**
Get the real length of a string - by correctly counting astral symbols and ignoring [ansi escape codes](https://github.com/sindresorhus/strip-ansi).
declare const stringLength: {
/**
Get the real length of a string - by correctly counting astral symbols and ignoring [ansi escape codes](https://github.com/sindresorhus/strip-ansi).
`String#length` errornously counts [astral symbols](https://web.archive.org/web/20150721114550/http://www.tlg.uci.edu/~opoudjis/unicode/unicode_astral.html) as two characters.
`String#length` errornously counts [astral symbols](https://web.archive.org/web/20150721114550/http://www.tlg.uci.edu/~opoudjis/unicode/unicode_astral.html) as two characters.
@example
```
import stringLength from 'string-length';
@example
```
import stringLength = require('string-length');
'🐴'.length;
//=> 2
'🐴'.length;
//=> 2
stringLength('🐴');
//=> 1
stringLength('🐴');
//=> 1
stringLength('\u001B[1municorn\u001B[22m');
//=> 7
```
*/
export default function stringLength(string: string): number;
stringLength('\u001B[1municorn\u001B[22m');
//=> 7
```
*/
(string: string): number;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function stringLength(string: string): number;
// export = stringLength;
default: typeof stringLength;
};
export = stringLength;

@@ -8,2 +8,3 @@ 'use strict';

module.exports = stringLength;
// TODO: Remove this for the next major release
module.exports.default = stringLength;
{
"name": "string-length",
"version": "3.0.0",
"version": "3.1.0",
"description": "Get the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},

@@ -39,9 +39,9 @@ "files": [

"astral-regex": "^1.0.0",
"strip-ansi": "^5.1.0"
"strip-ansi": "^5.2.0"
},
"devDependencies": {
"ava": "^1.3.1",
"tsd-check": "^0.5.0",
"ava": "^1.4.1",
"tsd": "^0.7.1",
"xo": "^0.24.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