| @@ -346,15 +346,6 export function debounce<T extends any[] | |||
|
|
346 | 346 | |
|
|
347 | 347 | fn.cancel = (e?: any) => cancel(e); |
|
|
348 | 348 | |
|
|
349 | fn.applyAsync = async (thisArg: This, args: T, ct: ICancellation) => { | |
|
|
350 | const h = ct.register(cancel); | |
|
|
351 | try { | |
|
|
352 | await fn.apply(thisArg, args); | |
|
|
353 | } finally { | |
|
|
354 | h.destroy(); | |
|
|
355 | } | |
|
|
356 | }; | |
|
|
357 | ||
|
|
358 | 349 | return fn; |
|
|
359 | 350 | } |
|
|
360 | 351 | |
| @@ -138,15 +138,15 test("debounce tests", async (t, trace) | |||
|
|
138 | 138 | let cancel: (e?: any) => void = notImplemented; |
|
|
139 | 139 | const ct = new Cancellation(c => cancel = c); |
|
|
140 | 140 | |
|
|
141 |
const d = debounce(async ( |
|
|
|
142 |
ct |
|
|
|
141 | const d = debounce(async () => { | |
|
|
142 | ct.throwIfRequested(); | |
|
|
143 | 143 | trace.debug("do async increment"); |
|
|
144 | 144 | await fork(); |
|
|
145 | 145 | count++; |
|
|
146 | 146 | return count; |
|
|
147 | 147 | }, 0); |
|
|
148 | 148 | |
|
|
149 |
const p = d |
|
|
|
149 | const p = d().then(undefined, () => rejected++); | |
|
|
150 | 150 | cancel(); |
|
|
151 | 151 | await p; |
|
|
152 | 152 | |
General Comments 0
You need to be logged in to leave comments.
Login now
