/** * To support the `for await` pattern of `Connection` when receiving messages, we need to have some kind of queue * structure that will handle incoming packets. This isn't meant to use publicly, but could be if need be. */ export default class AsyncQueue { /** * The promise used to determine when a value is inserted into the queue. */ private _next; /** * If `_next` has already been resolved (i.e. from the `_buffer`), this will be true. This is used in `push` to * determine if `_resolve` should be called, or if the value should be pushed into `_buffer`. */ private _prepared; /** * A function that will resolve the `_next` promise. This is typically called upon when a method is `push`ed into * the queue. */ private _resolve; /** * The rejection callback incase the queue needs to be cancelled. */ private _reject; /** * A buffer that will have extra unhandled values pushed into it. */ private _buffer; constructor(); push(value: T): void; end(error: Error): void; next(): Promise; }