Socket
Socket
Sign inDemoInstall

string-width

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-width - npm Package Compare versions

Comparing version 7.0.0 to 7.1.0

7

index.js

@@ -5,2 +5,4 @@ import stripAnsi from 'strip-ansi';

const segmenter = new Intl.Segmenter();
export default function stringWidth(string, options = {}) {

@@ -25,4 +27,5 @@ if (typeof string !== 'string' || string.length === 0) {

let width = 0;
const eastAsianWidthOptions = {ambiguousAsWide: !ambiguousIsNarrow};
for (const {segment: character} of new Intl.Segmenter().segment(string)) {
for (const {segment: character} of segmenter.segment(string)) {
const codePoint = character.codePointAt(0);

@@ -45,3 +48,3 @@

width += eastAsianWidth(codePoint, {ambiguousAsWide: !ambiguousIsNarrow});
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
}

@@ -48,0 +51,0 @@

{
"name": "string-width",
"version": "7.0.0",
"version": "7.1.0",
"description": "Get the visual width of a string - the number of columns required to display it",

@@ -18,2 +18,3 @@ "license": "MIT",

},
"sideEffects": false,
"engines": {

@@ -20,0 +21,0 @@ "node": ">=18"

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc