diff --git a/src/main/ts/safe.ts b/src/main/ts/safe.ts --- a/src/main/ts/safe.ts +++ b/src/main/ts/safe.ts @@ -346,15 +346,6 @@ export function debounce cancel(e); - fn.applyAsync = async (thisArg: This, args: T, ct: ICancellation) => { - const h = ct.register(cancel); - try { - await fn.apply(thisArg, args); - } finally { - h.destroy(); - } - }; - return fn; } diff --git a/src/test/ts/tests/SafeTests.ts b/src/test/ts/tests/SafeTests.ts --- a/src/test/ts/tests/SafeTests.ts +++ b/src/test/ts/tests/SafeTests.ts @@ -138,15 +138,15 @@ test("debounce tests", async (t, trace) let cancel: (e?: any) => void = notImplemented; const ct = new Cancellation(c => cancel = c); - const d = debounce(async (ct2: ICancellation = Cancellation.none) => { - ct2.throwIfRequested(); + const d = debounce(async () => { + ct.throwIfRequested(); trace.debug("do async increment"); await fork(); count++; return count; }, 0); - const p = d.applyAsync(null, [ct], ct).then(undefined, () => rejected++); + const p = d().then(undefined, () => rejected++); cancel(); await p;