feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -16,7 +16,7 @@ const arraySum = array => {
};
/**
* @param {any[]} args items to be truncated
* @param {EXPECTED_ANY[]} args items to be truncated
* @param {number} maxLength maximum length of args including spaces between
* @returns {string[]} truncated args
*/
@@ -28,17 +28,15 @@ const truncateArgs = (args, maxLength) => {
if (availableLength >= args[0].length) {
return args;
} else if (availableLength > 3) {
return ["..." + args[0].slice(-availableLength + 3)];
} else {
return [args[0].slice(-availableLength)];
return [`...${args[0].slice(-availableLength + 3)}`];
}
return [args[0].slice(-availableLength)];
}
// Check if there is space for at least 4 chars per arg
if (availableLength < arraySum(lengths.map(i => Math.min(i, 6)))) {
// remove args
if (args.length > 1)
return truncateArgs(args.slice(0, args.length - 1), maxLength);
if (args.length > 1) return truncateArgs(args.slice(0, -1), maxLength);
return [];
}
@@ -74,12 +72,11 @@ const truncateArgs = (args, maxLength) => {
if (str.length === length) {
return str;
} else if (length > 5) {
return "..." + str.slice(-length + 3);
return `...${str.slice(-length + 3)}`;
} else if (length > 0) {
return str.slice(-length);
} else {
return "";
}
return "";
});
};