fix lazyWebpack.construct, lint uwuify

This commit is contained in:
Vendicated 2022-10-08 21:11:14 +02:00
parent b101e643d5
commit e0bbdd89bd
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3
2 changed files with 38 additions and 39 deletions

View file

@ -47,62 +47,61 @@ const words = [
// uwuify command
function uwuify(message: string): string {
let isowo = false;
return message
.split(" ")
.map(element => {
isowo = false;
let lowerCase = element.toLowerCase();
.map(w => {
let owofied = false;
let lowerCase = w.toLowerCase();
// return if the word is too short - uwuifying short words makes them unreadable
if (element.length < 4) {
return element;
if (w.length < 4) {
return w;
}
// replacing the words based on the array on line 29
for (let [find, replace] of words) {
if (element.includes(find)) {
element = element.replace(find, replace);
isowo = true;
if (w.includes(find)) {
w = w.replace(find, replace);
owofied = true;
}
}
// these are the biggest word changes. if any of these are done we dont do the
// ones after the isowo check. to keep the words somewhat readable
if (lowerCase.includes("u") && !lowerCase.includes("uwu")) {
element = element.replace("u", "UwU");
isowo = true;
w = w.replace("u", "UwU");
owofied = true;
}
if (lowerCase.includes("o") && !lowerCase.includes("owo")) {
element = element.replace("o", "OwO");
isowo = true;
w = w.replace("o", "OwO");
owofied = true;
}
if (lowerCase.endsWith("y") && element.length < 7) {
element = element + " " + "w" + element.slice(1);
isowo = true;
if (lowerCase.endsWith("y") && w.length < 7) {
w = w + " " + "w" + w.slice(1);
owofied = true;
}
// returning if word has been already uwuified - to prevent over-uwuifying
if (isowo) {
return element;
if (owofied) {
return w;
}
// more tiny changes - to keep the words that passed through the latter changes uwuified
if (!lowerCase.endsWith("n")) {
element = element.replace("n", "ny");
w = w.replace("n", "ny");
}
if (Math.floor(Math.random() * 2) == 1) {
element.replace("s", "sh");
if (Math.floor(Math.random() * 2) === 1) {
w.replace("s", "sh");
}
if (Math.floor(Math.random() * 5) == 3 && !isowo) {
element = element[0] + "-" + element[0] + "-" + element;
if (Math.floor(Math.random() * 5) === 3 && !owofied) {
w = w[0] + "-" + w[0] + "-" + w;
}
if (Math.floor(Math.random() * 5) == 3) {
element =
element +
if (Math.floor(Math.random() * 5) === 3) {
w =
w +
" " +
endings[Math.floor(Math.random() * endings.length)];
}
element = element.replace("r", "w").replace("l", "w");
return element;
w = w.replaceAll("r", "w").replaceAll("l", "w");
return w;
}).join(" ");
}

View file

@ -25,7 +25,7 @@ export function lazyWebpack<T = any>(filter: FilterFn): T {
has: (_, prop) => prop in getMod(),
apply: (_, $this, args) => (getMod() as Function).apply($this, args),
ownKeys: () => Reflect.ownKeys(getMod()),
construct: (_, args, newTarget) => new newTarget(...args),
construct: (_, args, newTarget) => Reflect.construct(getMod(), args, newTarget),
deleteProperty: (_, prop) => delete getMod()[prop],
defineProperty: (_, property, attributes) => !!Object.defineProperty(getMod(), property, attributes)
}) as T;