You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
409 B
17 lines
409 B
var stripAnsi = require('./stripAnsi'); |
|
var isFullWidth = require('./isFullWidth'); |
|
exports = function(str) { |
|
str = stripAnsi(str); |
|
var width = 0; |
|
for (var i = 0, len = str.length; i < len; i++) { |
|
var c = str.codePointAt(i); |
|
|
|
if (c <= 31 || c === 127) { |
|
continue; |
|
} |
|
width += isFullWidth(c) ? 2 : 1; |
|
} |
|
return width; |
|
}; |
|
|
|
module.exports = exports;
|
|
|