You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

string-width

Package Overview
Dependencies
Maintainers
1
Versions
28
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
2.1.1
to
3.0.0
+8
-5
index.js
'use strict';
const stripAnsi = require('strip-ansi');
const isFullwidthCodePoint = require('is-fullwidth-code-point');
const emojiRegex = require('emoji-regex')();
module.exports = str => {
if (typeof str !== 'string' || str.length === 0) {
module.exports = input => {
input = input.replace(emojiRegex, ' ');
if (typeof input !== 'string' || input.length === 0) {
return 0;
}
str = stripAnsi(str);
input = stripAnsi(input);
let width = 0;
for (let i = 0; i < str.length; i++) {
const code = str.codePointAt(i);
for (let i = 0; i < input.length; i++) {
const code = input.codePointAt(i);

@@ -17,0 +20,0 @@ // Ignore control characters

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

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

"engines": {
"node": ">=4"
"node": ">=6"
},

@@ -49,9 +49,10 @@ "scripts": {

"dependencies": {
"emoji-regex": "^7.0.1",
"is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^4.0.0"
"strip-ansi": "^5.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^1.0.1",
"xo": "^0.23.0"
}
}