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

View file

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