Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
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
4.0.0
to
4.1.0
+24
-15
index.d.ts

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

/**
Get the visual width of a string - the number of columns required to display it.
declare const stringWidth: {
/**
Get the visual width of a string - the number of columns required to display it.
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
@example
```
import stringWidth from 'string-width';
@example
```
import stringWidth = require('string-width');
stringWidth('a');
//=> 1
stringWidth('a');
//=> 1
stringWidth('古');
//=> 2
stringWidth('古');
//=> 2
stringWidth('\u001B[1m古\u001B[22m');
//=> 2
```
*/
export default function stringWidth(string: string): number;
stringWidth('\u001B[1m古\u001B[22m');
//=> 2
```
*/
(string: string): number;
// TODO: remove this in the next major version, refactor the whole definition to:
// declare function stringWidth(string: string): number;
// export = stringWidth;
default: typeof stringWidth;
}
export = stringWidth;

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

module.exports = stringWidth;
// TODO: remove this in the next major version
module.exports.default = stringWidth;
{
"name": "string-width",
"version": "4.0.0",
"version": "4.1.0",
"description": "Get the visual width of a string - the number of columns required to display it",

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

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

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

"is-fullwidth-code-point": "^3.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"
}
}