| 271 | * (e.g. from getCommandsByMaxPriority). Logs a 'remove' operation for each. |
| 272 | */ |
| 273 | export function remove(commandsToRemove: QueuedCommand[]): void { |
| 274 | if (commandsToRemove.length === 0) { |
| 275 | return |
| 276 | } |
| 277 | |
| 278 | const before = commandQueue.length |
| 279 | for (let i = commandQueue.length - 1; i >= 0; i--) { |
| 280 | if (commandsToRemove.includes(commandQueue[i]!)) { |
| 281 | commandQueue.splice(i, 1) |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | if (commandQueue.length !== before) { |
| 286 | notifySubscribers() |
| 287 | } |
| 288 | |
| 289 | for (const _cmd of commandsToRemove) { |
| 290 | logOperation('remove') |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * Remove commands matching a predicate. |