summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/string-width/index.js
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2017-12-07 14:05:23 -0800
committerMyles Borins <mylesborins@google.com>2018-01-19 11:32:08 -0500
commitd3b1c971bcf0177b17c649c3aeca1a94cbc3fff5 (patch)
tree321928c015be00cdbe11715297d2d2fc45802263 /deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/string-width/index.js
parentbfe41fe88e7421f441067a79fb7512cf5935a2bb (diff)
downloadandroid-node-v8-d3b1c971bcf0177b17c649c3aeca1a94cbc3fff5.tar.gz
android-node-v8-d3b1c971bcf0177b17c649c3aeca1a94cbc3fff5.tar.bz2
android-node-v8-d3b1c971bcf0177b17c649c3aeca1a94cbc3fff5.zip
deps: upgrade npm to 5.6.0
PR-URL: https://github.com/nodejs/node/pull/17777 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/string-width/index.js')
-rw-r--r--deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/string-width/index.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/string-width/index.js b/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/string-width/index.js
index 1f8a1f1134..bbc49d29b1 100644
--- a/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/string-width/index.js
+++ b/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/string-width/index.js
@@ -7,10 +7,10 @@ module.exports = str => {
return 0;
}
- let width = 0;
-
str = stripAnsi(str);
+ let width = 0;
+
for (let i = 0; i < str.length; i++) {
const code = str.codePointAt(i);
@@ -19,16 +19,17 @@ module.exports = str => {
continue;
}
+ // Ignore combining characters
+ if (code >= 0x300 && code <= 0x36F) {
+ continue;
+ }
+
// Surrogates
- if (code >= 0x10000) {
+ if (code > 0xFFFF) {
i++;
}
- if (isFullwidthCodePoint(code)) {
- width += 2;
- } else {
- width++;
- }
+ width += isFullwidthCodePoint(code) ? 2 : 1;
}
return width;