···11-/**
22- * useful types and utilities that don't belong elsewhere.
33- *
44- * @module common
55- */
11+/** @module common */
6273/**
44+ * A callback function, with arbitrary arguments; use {Parameters} to extract them.
55+ *
86 * @typedef {function(...*): void} Callback
99- * A callback function, with arbitrary arguments; use {Parameters} to extract them.
107 */
118129/**
1010+ * A callback function with no arguments.
1111+ *
1312 * @typedef {function(): void} VoidCallback
1414- * A callback function with no arguments.
1513 */
+4-1
src/common/async/aborts.js
···3232 * Create an abort signal that aborts if any of the passed signals aborts.
3333 * Better than managing them manually because we do proper cleanup of non-triggered aborts.
3434 *
3535- * @param {...AbortSignal} signals - the signals to combine
3535+ * @param {...(AbortSignal | undefined)} signals - the signals to combine
3636 * @returns {AbortSignal} the combined signal
3737 */
3838export function combineSignals(...signals) {
···4141 const cleanups = []
42424343 for (const signal of signals) {
4444+ if (!signal)
4545+ continue
4646+4447 if (signal.aborted) {
4548 controller.abort(signal.reason)
4649 return controller.signal
···2525 this.#maxsize = maxsize ? maxsize : undefined
2626 }
27272828+ /** @returns {number} how deep is the queue? */
2929+ get depth() {
3030+ return this.#items.length
3131+ }
3232+3333+ /**
3434+ * place one or more items on the queue, to be picked up by awaiters.
3535+ *
3636+ * @param {...T} elements the items to place on the queue.
3737+ */
3838+ prequeue(...elements) {
3939+ for (const el of elements.reverse()) {
4040+ if (this.#maxsize && this.#items.length >= this.#maxsize) {
4141+ throw Error('out of room')
4242+ }
4343+4444+ this.#items.unshift(el)
4545+ this.#sema.free()
4646+ }
4747+ }
4848+2849 /**
2950 * place one or more items on the queue, to be picked up by awaiters.
3051 *