(
type: QueuedCommandType,
wrappedCommand: () => Promise<R>,
)
| 29 | currentCalls: CallCounter = { process: 0, probe: 0 }; |
| 30 | |
| 31 | queueCommand<R>( |
| 32 | type: QueuedCommandType, |
| 33 | wrappedCommand: () => Promise<R>, |
| 34 | ): Promise<R> { |
| 35 | return new Promise((resolve, reject) => { |
| 36 | const runCommand = async () => { |
| 37 | try { |
| 38 | const result = await wrappedCommand(); |
| 39 | this.currentCalls[type]--; |
| 40 | this.possiblyRunCommands(); |
| 41 | resolve(result); |
| 42 | } catch (e) { |
| 43 | reject(e); |
| 44 | } |
| 45 | }; |
| 46 | this.queue.push({ type, runCommand }); |
| 47 | this.possiblyRunCommands(); |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | possiblyRunCommands() { |
| 52 | let openSlots: { [string]: number } = {}; |
no test coverage detected