(item: T)
| 15 | private resolveWaitingPop?: (value: T) => void; |
| 16 | |
| 17 | push(item: T) { |
| 18 | this.queue.push(item); |
| 19 | if (this.resolveWaitingPop) { |
| 20 | // Since TypeScript now expects queue.shift() to always return a T, |
| 21 | // we need to assure it's not called on an empty array. |
| 22 | // The logic ensures it's never empty at this point, but TypeScript doesn't know that. |
| 23 | const shiftedItem = this.queue.shift(); |
| 24 | if (shiftedItem !== undefined) { |
| 25 | this.resolveWaitingPop(shiftedItem); |
| 26 | } |
| 27 | this.resolveWaitingPop = undefined; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | count() { |
| 32 | return this.queue.length; |
no outgoing calls
no test coverage detected