string-width
Advanced tools
+24
-15
@@ -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; |
+1
-0
@@ -42,2 +42,3 @@ 'use strict'; | ||
| module.exports = stringWidth; | ||
| // TODO: remove this in the next major version | ||
| module.exports.default = stringWidth; |
+5
-5
| { | ||
| "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" | ||
| } | ||
| } |
4871
5.94%54
17.39%Updated