diff --git a/package.json b/package.json index 4b834da..c2126d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spitroast", - "version": "2.0.1", + "version": "2.0.2", "description": "A simple JavaScript function patcher.", "main": "dist/cjs.js", "module": "dist/esm/index.js", diff --git a/src/hook.ts b/src/hook.ts index e402890..5bb46dd 100644 --- a/src/hook.ts +++ b/src/hook.ts @@ -31,8 +31,8 @@ export default function ( // This calls the original function (...args: unknown[]) => isConstruct - ? Reflect.construct(patch.o, args, ctxt) - : patch.o.apply(ctxt, args) + ? Reflect.construct(origFunc, args, ctxt) + : origFunc.apply(ctxt, args) )(...funcArgs); // After patches @@ -40,7 +40,7 @@ export default function ( workingRetVal = hook.call(ctxt, funcArgs, workingRetVal) ?? workingRetVal; // Cleanups (one-times) - patch.c.forEach((c) => c()); + for (const cleanup of patch.c) cleanup() patch.c = []; return workingRetVal;