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 5.0.1 to 6.0.0

4

index.d.ts

@@ -1,2 +0,2 @@

export interface Options {
export type Options = {
/**

@@ -8,3 +8,3 @@ Whether [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) should be counted. They are ignored by default.

readonly countAnsiEscapeCodes?: boolean;
}
};

@@ -11,0 +11,0 @@ /**

import stripAnsi from 'strip-ansi';
import charRegex from 'char-regex';
const segmenter = new Intl.Segmenter();
export default function stringLength(string, {countAnsiEscapeCodes = false} = {}) {

@@ -17,3 +18,9 @@ if (string === '') {

return string.match(charRegex()).length;
let length = 0;
for (const _ of segmenter.segment(string)) { // eslint-disable-line no-unused-vars
length++;
}
return length;
}
{
"name": "string-length",
"version": "5.0.1",
"version": "6.0.0",
"description": "Get the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes",

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

"engines": {
"node": ">=12.20"
"node": ">=16"
},

@@ -41,10 +41,9 @@ "type": "module",

"dependencies": {
"char-regex": "^2.0.0",
"strip-ansi": "^7.0.1"
"strip-ansi": "^7.1.0"
},
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.44.0"
"ava": "^5.3.0",
"tsd": "^0.28.1",
"xo": "^0.54.2"
}
}

@@ -9,5 +9,5 @@ # string-length

```sh
npm install string-length
```
$ npm install string-length
```

@@ -48,13 +48,1 @@ ## Usage

- [string-width](https://github.com/sindresorhus/string-width) - Get visual width of a string
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-string-length?utm_source=npm-string-length&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
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