silverwolf-x/project / packages /next /src /server /lib /async-callback-set.ts
silverwolf-x's picture
download
raw
507 Bytes
export class AsyncCallbackSet {
private callbacks: (() => Promise<void>)[] = []
public add(callback: () => Promise<void>) {
this.callbacks.push(callback)
}
public async runAll(): Promise<void> {
if (!this.callbacks.length) {
return
}
const callbacks = this.callbacks
this.callbacks = []
await Promise.allSettled(
callbacks.map(
// NOTE: wrapped in an async function to protect against synchronous exceptions
async (f) => f()
)
)
}
}

Xet Storage Details

Size:
507 Bytes
·
Xet hash:
41ef264c596d2e7a860b8d8fa19f645ff1d2083dc8904f9d92d85dc3d4883e66

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.