* Processes the whole queue by executing the callback on each component, * while also imposing restrictions on how many times a component may be processed. * * @param callback - function with one argument (the web component to be processed)
(callback: (el: UI5Element) => void)
| 52 | * @param callback - function with one argument (the web component to be processed) |
| 53 | */ |
| 54 | process(callback: (el: UI5Element) => void) { |
| 55 | let webComponent; |
| 56 | const stats = new Map<UI5Element, number>(); |
| 57 | |
| 58 | webComponent = this.shift(); |
| 59 | while (webComponent) { |
| 60 | const timesProcessed = stats.get(webComponent) || 0; |
| 61 | if (timesProcessed > MAX_PROCESS_COUNT) { |
| 62 | throw new Error(`Web component processed too many times this task, max allowed is: ${MAX_PROCESS_COUNT}`); |
| 63 | } |
| 64 | callback(webComponent); |
| 65 | stats.set(webComponent, timesProcessed + 1); |
| 66 | webComponent = this.shift(); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | export default RenderQueue; |
no test coverage detected