format: prettify entire project

This commit is contained in:
Rim
2025-04-02 06:50:39 -04:00
parent 86f0782a98
commit 7ccc0be712
1711 changed files with 755867 additions and 235931 deletions

View File

@ -3,43 +3,43 @@ const stripAnsi = require('strip-ansi');
const isFullwidthCodePoint = require('is-fullwidth-code-point');
const emojiRegex = require('emoji-regex');
const stringWidth = string => {
if (typeof string !== 'string' || string.length === 0) {
return 0;
}
const stringWidth = (string) => {
if (typeof string !== 'string' || string.length === 0) {
return 0;
}
string = stripAnsi(string);
string = stripAnsi(string);
if (string.length === 0) {
return 0;
}
if (string.length === 0) {
return 0;
}
string = string.replace(emojiRegex(), ' ');
string = string.replace(emojiRegex(), ' ');
let width = 0;
let width = 0;
for (let i = 0; i < string.length; i++) {
const code = string.codePointAt(i);
for (let i = 0; i < string.length; i++) {
const code = string.codePointAt(i);
// Ignore control characters
if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) {
continue;
}
// Ignore control characters
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
continue;
}
// Ignore combining characters
if (code >= 0x300 && code <= 0x36F) {
continue;
}
// Ignore combining characters
if (code >= 0x300 && code <= 0x36f) {
continue;
}
// Surrogates
if (code > 0xFFFF) {
i++;
}
// Surrogates
if (code > 0xffff) {
i++;
}
width += isFullwidthCodePoint(code) ? 2 : 1;
}
width += isFullwidthCodePoint(code) ? 2 : 1;
}
return width;
return width;
};
module.exports = stringWidth;