aboutsummaryrefslogtreecommitdiff
path: root/node_modules/string-width
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-27 19:33:54 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-27 19:34:16 +0100
commit0e6de2c31dbf8c21277481f112e99c52b913940f (patch)
tree91789032de3b8eec9d789acd1323f25fc5d08422 /node_modules/string-width
parentceda0da31ad542c598c68146ae0712ca03df3d71 (diff)
node_modules
Diffstat (limited to 'node_modules/string-width')
-rw-r--r--node_modules/string-width/index.js35
-rw-r--r--node_modules/string-width/license20
-rw-r--r--node_modules/string-width/node_modules/is-fullwidth-code-point/index.js46
-rw-r--r--node_modules/string-width/node_modules/is-fullwidth-code-point/license21
-rw-r--r--node_modules/string-width/node_modules/is-fullwidth-code-point/package.json45
-rw-r--r--node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md39
-rw-r--r--node_modules/string-width/package.json107
-rw-r--r--node_modules/string-width/readme.md4
8 files changed, 76 insertions, 241 deletions
diff --git a/node_modules/string-width/index.js b/node_modules/string-width/index.js
index b9bec6244..bbc49d29b 100644
--- a/node_modules/string-width/index.js
+++ b/node_modules/string-width/index.js
@@ -1,36 +1,35 @@
'use strict';
-var stripAnsi = require('strip-ansi');
-var codePointAt = require('code-point-at');
-var isFullwidthCodePoint = require('is-fullwidth-code-point');
+const stripAnsi = require('strip-ansi');
+const isFullwidthCodePoint = require('is-fullwidth-code-point');
-// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345
-module.exports = function (str) {
+module.exports = str => {
if (typeof str !== 'string' || str.length === 0) {
return 0;
}
- var width = 0;
-
str = stripAnsi(str);
- for (var i = 0; i < str.length; i++) {
- var code = codePointAt(str, i);
+ let width = 0;
+
+ for (let i = 0; i < str.length; i++) {
+ const code = str.codePointAt(i);
- // ignore control characters
- if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
+ // Ignore control characters
+ if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) {
continue;
}
- // surrogates
- if (code >= 0x10000) {
- i++;
+ // Ignore combining characters
+ if (code >= 0x300 && code <= 0x36F) {
+ continue;
}
- if (isFullwidthCodePoint(code)) {
- width += 2;
- } else {
- width++;
+ // Surrogates
+ if (code > 0xFFFF) {
+ i++;
}
+
+ width += isFullwidthCodePoint(code) ? 2 : 1;
}
return width;
diff --git a/node_modules/string-width/license b/node_modules/string-width/license
index 654d0bfe9..e7af2f771 100644
--- a/node_modules/string-width/license
+++ b/node_modules/string-width/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js b/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js
deleted file mode 100644
index a7d3e3855..000000000
--- a/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js
+++ /dev/null
@@ -1,46 +0,0 @@
-'use strict';
-var numberIsNan = require('number-is-nan');
-
-module.exports = function (x) {
- if (numberIsNan(x)) {
- return false;
- }
-
- // https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1369
-
- // code points are derived from:
- // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
- if (x >= 0x1100 && (
- x <= 0x115f || // Hangul Jamo
- 0x2329 === x || // LEFT-POINTING ANGLE BRACKET
- 0x232a === x || // RIGHT-POINTING ANGLE BRACKET
- // CJK Radicals Supplement .. Enclosed CJK Letters and Months
- (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) ||
- // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
- 0x3250 <= x && x <= 0x4dbf ||
- // CJK Unified Ideographs .. Yi Radicals
- 0x4e00 <= x && x <= 0xa4c6 ||
- // Hangul Jamo Extended-A
- 0xa960 <= x && x <= 0xa97c ||
- // Hangul Syllables
- 0xac00 <= x && x <= 0xd7a3 ||
- // CJK Compatibility Ideographs
- 0xf900 <= x && x <= 0xfaff ||
- // Vertical Forms
- 0xfe10 <= x && x <= 0xfe19 ||
- // CJK Compatibility Forms .. Small Form Variants
- 0xfe30 <= x && x <= 0xfe6b ||
- // Halfwidth and Fullwidth Forms
- 0xff01 <= x && x <= 0xff60 ||
- 0xffe0 <= x && x <= 0xffe6 ||
- // Kana Supplement
- 0x1b000 <= x && x <= 0x1b001 ||
- // Enclosed Ideographic Supplement
- 0x1f200 <= x && x <= 0x1f251 ||
- // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
- 0x20000 <= x && x <= 0x3fffd)) {
- return true;
- }
-
- return false;
-}
diff --git a/node_modules/string-width/node_modules/is-fullwidth-code-point/license b/node_modules/string-width/node_modules/is-fullwidth-code-point/license
deleted file mode 100644
index 654d0bfe9..000000000
--- a/node_modules/string-width/node_modules/is-fullwidth-code-point/license
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json b/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json
deleted file mode 100644
index b678d40de..000000000
--- a/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "name": "is-fullwidth-code-point",
- "version": "1.0.0",
- "description": "Check if the character represented by a given Unicode code point is fullwidth",
- "license": "MIT",
- "repository": "sindresorhus/is-fullwidth-code-point",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "scripts": {
- "test": "node test.js"
- },
- "files": [
- "index.js"
- ],
- "keywords": [
- "fullwidth",
- "full-width",
- "full",
- "width",
- "unicode",
- "character",
- "char",
- "string",
- "str",
- "codepoint",
- "code",
- "point",
- "is",
- "detect",
- "check"
- ],
- "dependencies": {
- "number-is-nan": "^1.0.0"
- },
- "devDependencies": {
- "ava": "0.0.4",
- "code-point-at": "^1.0.0"
- }
-}
diff --git a/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md b/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md
deleted file mode 100644
index 4936464b1..000000000
--- a/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point)
-
-> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms)
-
-
-## Install
-
-```
-$ npm install --save is-fullwidth-code-point
-```
-
-
-## Usage
-
-```js
-var isFullwidthCodePoint = require('is-fullwidth-code-point');
-
-isFullwidthCodePoint('谢'.codePointAt());
-//=> true
-
-isFullwidthCodePoint('a'.codePointAt());
-//=> false
-```
-
-
-## API
-
-### isFullwidthCodePoint(input)
-
-#### input
-
-Type: `number`
-
-[Code point](https://en.wikipedia.org/wiki/Code_point) of a character.
-
-
-## License
-
-MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/node_modules/string-width/package.json b/node_modules/string-width/package.json
index 5ba436166..89f0b6a6c 100644
--- a/node_modules/string-width/package.json
+++ b/node_modules/string-width/package.json
@@ -1,56 +1,55 @@
{
- "name": "string-width",
- "version": "1.0.2",
- "description": "Get the visual width of a string - the number of columns required to display it",
- "license": "MIT",
- "repository": "sindresorhus/string-width",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "scripts": {
- "test": "xo && ava"
- },
- "files": [
- "index.js"
- ],
- "keywords": [
- "string",
- "str",
- "character",
- "char",
- "unicode",
- "width",
- "visual",
- "column",
- "columns",
- "fullwidth",
- "full-width",
- "full",
- "ansi",
- "escape",
- "codes",
- "cli",
- "command-line",
- "terminal",
- "console",
- "cjk",
- "chinese",
- "japanese",
- "korean",
- "fixed-width"
- ],
- "dependencies": {
- "code-point-at": "^1.0.0",
- "is-fullwidth-code-point": "^1.0.0",
- "strip-ansi": "^3.0.0"
- },
- "devDependencies": {
- "ava": "*",
- "xo": "*"
- }
+ "name": "string-width",
+ "version": "2.1.1",
+ "description": "Get the visual width of a string - the number of columns required to display it",
+ "license": "MIT",
+ "repository": "sindresorhus/string-width",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "string",
+ "str",
+ "character",
+ "char",
+ "unicode",
+ "width",
+ "visual",
+ "column",
+ "columns",
+ "fullwidth",
+ "full-width",
+ "full",
+ "ansi",
+ "escape",
+ "codes",
+ "cli",
+ "command-line",
+ "terminal",
+ "console",
+ "cjk",
+ "chinese",
+ "japanese",
+ "korean",
+ "fixed-width"
+ ],
+ "dependencies": {
+ "is-fullwidth-code-point": "^2.0.0",
+ "strip-ansi": "^4.0.0"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ }
}
diff --git a/node_modules/string-width/readme.md b/node_modules/string-width/readme.md
index 1ab42c935..df5b7199f 100644
--- a/node_modules/string-width/readme.md
+++ b/node_modules/string-width/readme.md
@@ -2,7 +2,7 @@
> 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](http://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.
Useful to be able to measure the actual width of command-line output.
@@ -10,7 +10,7 @@ Useful to be able to measure the actual width of command-line output.
## Install
```
-$ npm install --save string-width
+$ npm install string-width
```