i actually hate my life

please never make me touch this motherfucking patcher again
fixing this patcher will probably be my hell
master
Drake 2 years ago
parent fbd6c28021
commit 7df2195445

@ -1,13 +1,14 @@
function monkeyPatch(name, parentObj, patches) {
const injId = Symbol()
const before = (patches["before"] === undefined) ? (...args)=>args : patches["before"];
const instead = (patches["instead"] === undefined) ? (res,...args)=>res(...args) : patches["instead"];
const after = (patches["after"] === undefined) ? (args, res)=>res : patches["after"];
const before = patches["before"];
const instead = patches["instead"];
const after = patches["after"];
const handler = {
apply: (target, thisArg, [ctx, args]) => {
before.apply(ctx, args);
res = instead(target.bind(ctx), args)
return after.apply(ctx, args.concat([res]));
if (before !== undefined) before.apply(ctx, args);
res = (patches["instead"] !== undefined) ? instead.apply(ctx, [target.bind(ctx), ...args]) : target.apply(ctx, [...args])
if (after === undefined) return res
return after.apply(ctx, [res].concat(args));
}
};
const prox = new Proxy(parentObj[name], handler);

Loading…
Cancel
Save