feat: init
This commit is contained in:
5
node_modules/@isaacs/cliui/dist/commonjs/string-width/index.d.ts
generated
vendored
Normal file
5
node_modules/@isaacs/cliui/dist/commonjs/string-width/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export type Options = {
|
||||
ambiguousIsNarrow?: boolean;
|
||||
};
|
||||
export declare function stringWidth(str: string, options?: Options): number;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@isaacs/cliui/dist/commonjs/string-width/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@isaacs/cliui/dist/commonjs/string-width/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/string-width/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,OAAY,UAqD7D"}
|
||||
49
node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js
generated
vendored
Normal file
49
node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.stringWidth = stringWidth;
|
||||
const index_js_1 = require("../strip-ansi/index.js");
|
||||
const index_js_2 = require("../eastasianwidth/index.js");
|
||||
const index_js_3 = require("../emoji-regex/index.js");
|
||||
function stringWidth(str, options = {}) {
|
||||
if (typeof str !== "string" || str.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
options = {
|
||||
ambiguousIsNarrow: true,
|
||||
...options,
|
||||
};
|
||||
str = (0, index_js_1.stripAnsi)(str);
|
||||
if (str.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
str = str.replace((0, index_js_3.emojiRegex)(), " ");
|
||||
const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
|
||||
let width = 0;
|
||||
for (const character of str) {
|
||||
const codePoint = character.codePointAt(0);
|
||||
// Ignore control characters
|
||||
if (!codePoint ||
|
||||
codePoint <= 0x1f ||
|
||||
(codePoint >= 0x7f && codePoint <= 0x9f)) {
|
||||
continue;
|
||||
}
|
||||
// Ignore combining characters
|
||||
if (codePoint >= 0x300 && codePoint <= 0x36f) {
|
||||
continue;
|
||||
}
|
||||
const code = (0, index_js_2.eastAsianWidth)(character);
|
||||
switch (code) {
|
||||
case "F":
|
||||
case "W":
|
||||
width += 2;
|
||||
break;
|
||||
case "A":
|
||||
width += ambiguousCharacterWidth;
|
||||
break;
|
||||
default:
|
||||
width += 1;
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js.map
generated
vendored
Normal file
1
node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string-width/index.ts"],"names":[],"mappings":";;AAQA,kCAqDC;AA7DD,qDAAmD;AACnD,yDAA4D;AAC5D,sDAAqD;AAMrD,SAAgB,WAAW,CAAC,GAAW,EAAE,UAAmB,EAAE;IAC5D,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,GAAG;QACR,iBAAiB,EAAE,IAAI;QACvB,GAAG,OAAO;KACX,CAAC;IAEF,GAAG,GAAG,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAC;IAErB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAA,qBAAU,GAAE,EAAE,IAAI,CAAC,CAAC;IAEtC,MAAM,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,MAAM,SAAS,IAAI,GAAG,EAAE,CAAC;QAC5B,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAE3C,4BAA4B;QAC5B,IACE,CAAC,SAAS;YACV,SAAS,IAAI,IAAI;YACjB,CAAC,SAAS,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC,EACxC,CAAC;YACD,SAAS;QACX,CAAC;QAED,8BAA8B;QAC9B,IAAI,SAAS,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;YAC7C,SAAS;QACX,CAAC;QAED,MAAM,IAAI,GAAG,IAAA,yBAAc,EAAC,SAAS,CAAC,CAAC;QACvC,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,GAAG,CAAC;YACT,KAAK,GAAG;gBACN,KAAK,IAAI,CAAC,CAAC;gBACX,MAAM;YACR,KAAK,GAAG;gBACN,KAAK,IAAI,uBAAuB,CAAC;gBACjC,MAAM;YACR;gBACE,KAAK,IAAI,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { stripAnsi } from \"../strip-ansi/index.js\";\nimport { eastAsianWidth } from \"../eastasianwidth/index.js\";\nimport { emojiRegex } from \"../emoji-regex/index.js\";\n\nexport type Options = {\n ambiguousIsNarrow?: boolean;\n};\n\nexport function stringWidth(str: string, options: Options = {}) {\n if (typeof str !== \"string\" || str.length === 0) {\n return 0;\n }\n\n options = {\n ambiguousIsNarrow: true,\n ...options,\n };\n\n str = stripAnsi(str);\n\n if (str.length === 0) {\n return 0;\n }\n\n str = str.replace(emojiRegex(), \" \");\n\n const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;\n let width = 0;\n\n for (const character of str) {\n const codePoint = character.codePointAt(0);\n\n // Ignore control characters\n if (\n !codePoint ||\n codePoint <= 0x1f ||\n (codePoint >= 0x7f && codePoint <= 0x9f)\n ) {\n continue;\n }\n\n // Ignore combining characters\n if (codePoint >= 0x300 && codePoint <= 0x36f) {\n continue;\n }\n\n const code = eastAsianWidth(character);\n switch (code) {\n case \"F\":\n case \"W\":\n width += 2;\n break;\n case \"A\":\n width += ambiguousCharacterWidth;\n break;\n default:\n width += 1;\n }\n }\n\n return width;\n}\n"]}
|
||||
Reference in New Issue
Block a user