@cloud-copilot/iam-lens
Version:
Visibility in IAM in and across AWS accounts
31 lines • 810 B
JavaScript
export class ArrayStreamingWorkQueue {
constructor(options = {}) {
this.notifyScheduled = false;
this.work = [];
}
setWorkAvailableCallback(callback) {
this.onWorkAvailable = callback;
}
enqueue(item) {
this.work.push(item);
this.scheduleNotify();
}
dequeue() {
return this.work.shift();
}
length() {
return this.work.length;
}
scheduleNotify() {
if (this.notifyScheduled || !this.onWorkAvailable) {
return;
}
this.notifyScheduled = true;
// Use a microtask to debounce notifications
queueMicrotask(() => {
this.notifyScheduled = false;
this.onWorkAvailable?.();
});
}
}
//# sourceMappingURL=ArrayStreamingWorkQueue.js.map