(key, operation)
| 8 | } |
| 9 | |
| 10 | enqueue(key, operation) { |
| 11 | const tuple = this.beforeOp(key); |
| 12 | const toAwait = tuple[1]; |
| 13 | const nextOperation = toAwait.then(operation); |
| 14 | const wrappedOperation = nextOperation.then(result => { |
| 15 | this.afterOp(key); |
| 16 | return result; |
| 17 | }); |
| 18 | tuple[1] = wrappedOperation; |
| 19 | return wrappedOperation; |
| 20 | } |
| 21 | |
| 22 | beforeOp(key) { |
| 23 | let tuple = this.queue[key]; |