summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/libnpx/node_modules/yargs/node_modules/string-width/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/libnpx/node_modules/yargs/node_modules/string-width/index.js')
-rw-r--r--deps/npm/node_modules/libnpx/node_modules/yargs/node_modules/string-width/index.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/deps/npm/node_modules/libnpx/node_modules/yargs/node_modules/string-width/index.js b/deps/npm/node_modules/libnpx/node_modules/yargs/node_modules/string-width/index.js
index 1f8a1f1134..bbc49d29b1 100644
--- a/deps/npm/node_modules/libnpx/node_modules/yargs/node_modules/string-width/index.js
+++ b/deps/npm/node_modules/libnpx/node_modules/yargs/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;