mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
Update bing imagery key and api urls. Interval limiting for tiles vintage (#9133)
update bing imagery key, template, api url BasicMetadata for vintage handled 429 in getMetadata
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* IntervalTasksQueue
|
||||
* Enabled task execution under interval limit
|
||||
*/
|
||||
export class IntervalTasksQueue {
|
||||
|
||||
/**
|
||||
* Interval in milliseconds inside which only 1 task can execute.
|
||||
* e.g. if interval is 200ms, and 5 async tasks are unqueued,
|
||||
* they will complete in ~1s if not cleared
|
||||
* @param {number} intervalInMs
|
||||
*/
|
||||
constructor(intervalInMs) {
|
||||
this.intervalInMs = intervalInMs;
|
||||
this.pendingHandles = [];
|
||||
this.time = 0;
|
||||
}
|
||||
|
||||
enqueue(task) {
|
||||
let taskTimeout = this.time;
|
||||
this.time += this.intervalInMs;
|
||||
this.pendingHandles.push(setTimeout(() => {
|
||||
this.time -= this.intervalInMs;
|
||||
task();
|
||||
}, taskTimeout));
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.pendingHandles.forEach((timeoutHandle) => {
|
||||
clearTimeout(timeoutHandle);
|
||||
});
|
||||
this.pendingHandles = [];
|
||||
this.time = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user