You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
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

Comparing version 6.0.0 to 6.1.0

18

index.js

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

let segmenter;
function * splitString(string) {
segmenter ??= new Intl.Segmenter();
for (const {segment: character} of segmenter.segment(string)) {
yield character;
}
}
export default function stringWidth(string, options) {

@@ -34,8 +25,6 @@ if (typeof string !== 'string' || string.length === 0) {

string = string.replace(emojiRegex(), ' ');
const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
let width = 0;
for (const character of splitString(string)) {
for (const {segment: character} of new Intl.Segmenter().segment(string)) {
const codePoint = character.codePointAt(0);

@@ -53,2 +42,7 @@

if (emojiRegex().test(character)) {
width += 2;
continue;
}
const code = eastAsianWidth.eastAsianWidth(character);

@@ -55,0 +49,0 @@ switch (code) {

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

@@ -5,0 +5,0 @@ "license": "MIT",

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