Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
{"version":3,"file":"RenderQueue.js","sourceRoot":"","sources":["../src/RenderQueue.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,WAAW;IAIhB;QACC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,4CAA4C;QAC5D,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,yBAAyB;IACnD,CAAC;IAED,GAAG,CAAC,YAAwB;QAC3B,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YAClC,OAAO;SACP;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,YAAwB;QAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACnC,OAAO;SACP;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,KAAK;QACJ,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,YAAY,EAAE;YACjB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACjC,OAAO,YAAY,CAAC;SACpB;IACF,CAAC;IAED,OAAO;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,CAAC,YAAwB;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAkC;QACzC,IAAI,YAAY,CAAC;QACjB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;QAE5C,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC5B,OAAO,YAAY,EAAE;YACpB,MAAM,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACpD,IAAI,cAAc,GAAG,iBAAiB,EAAE;gBACvC,MAAM,IAAI,KAAK,CAAC,qEAAqE,iBAAiB,EAAE,CAAC,CAAC;aAC1G;YACD,QAAQ,CAAC,YAAY,CAAC,CAAC;YACvB,KAAK,CAAC,GAAG,CAAC,YAAY,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC;YAC5C,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;SAC5B;IACF,CAAC;CACD;AAED,eAAe,WAAW,CAAC","sourcesContent":["import type UI5Element from \"./UI5Element.js\";\n\nconst MAX_PROCESS_COUNT = 10;\n\nclass RenderQueue {\n\tlist: Array;\n\tlookup: Set;\n\n\tconstructor() {\n\t\tthis.list = []; // Used to store the web components in order\n\t\tthis.lookup = new Set(); // Used for faster search\n\t}\n\n\tadd(webComponent: UI5Element) {\n\t\tif (this.lookup.has(webComponent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.list.push(webComponent);\n\t\tthis.lookup.add(webComponent);\n\t}\n\n\tremove(webComponent: UI5Element) {\n\t\tif (!this.lookup.has(webComponent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.list = this.list.filter(item => item !== webComponent);\n\t\tthis.lookup.delete(webComponent);\n\t}\n\n\tshift() {\n\t\tconst webComponent = this.list.shift();\n\t\tif (webComponent) {\n\t\t\tthis.lookup.delete(webComponent);\n\t\t\treturn webComponent;\n\t\t}\n\t}\n\n\tisEmpty() {\n\t\treturn this.list.length === 0;\n\t}\n\n\tisAdded(webComponent: UI5Element) {\n\t\treturn this.lookup.has(webComponent);\n\t}\n\n\t/**\n\t * Processes the whole queue by executing the callback on each component,\n\t * while also imposing restrictions on how many times a component may be processed.\n\t *\n\t * @param callback - function with one argument (the web component to be processed)\n\t */\n\tprocess(callback: (el: UI5Element) => void) {\n\t\tlet webComponent;\n\t\tconst stats = new Map();\n\n\t\twebComponent = this.shift();\n\t\twhile (webComponent) {\n\t\t\tconst timesProcessed = stats.get(webComponent) || 0;\n\t\t\tif (timesProcessed > MAX_PROCESS_COUNT) {\n\t\t\t\tthrow new Error(`Web component processed too many times this task, max allowed is: ${MAX_PROCESS_COUNT}`);\n\t\t\t}\n\t\t\tcallback(webComponent);\n\t\t\tstats.set(webComponent, timesProcessed + 1);\n\t\t\twebComponent = this.shift();\n\t\t}\n\t}\n}\n\nexport default RenderQueue;\n"]}