(...args)
| 16 | let queued: Parameters<T> | undefined; |
| 17 | |
| 18 | const callback: QueueOneWrapper<T> = (...args) => { |
| 19 | if (isBusy) { |
| 20 | queued = args; |
| 21 | } else { |
| 22 | isBusy = true; |
| 23 | |
| 24 | fn(...args) |
| 25 | .catch(error => { |
| 26 | console.error('queueOne - Error thrown in wrapped function!', error); |
| 27 | }) |
| 28 | .finally(() => { |
| 29 | isBusy = false; |
| 30 | |
| 31 | if (queued) { |
| 32 | const next = queued; |
| 33 | queued = undefined; |
| 34 | callback(...next); |
| 35 | } |
| 36 | }); |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | return callback; |
| 41 | } |
no outgoing calls
no test coverage detected