2 var stripAnsi = require('strip-ansi');
3 var codePointAt = require('code-point-at');
4 var isFullwidthCodePoint = require('is-fullwidth-code-point');
6 // https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345
7 module.exports = function (str) {
8 if (typeof str !== 'string' || str.length === 0) {
16 for (var i = 0; i < str.length; i++) {
17 var code = codePointAt(str, i);
19 // ignore control characters
20 if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
25 if (code >= 0x10000) {
29 if (isFullwidthCodePoint(code)) {