mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-25 07:48:54 +00:00
⚡ Perf: enhance forEach method in Util class to handle asynchronous handlers
This commit is contained in:
+6
-1
@@ -1,9 +1,14 @@
|
||||
export default class Util {
|
||||
forEach(elements, handler) {
|
||||
elements = elements || [];
|
||||
const promises = [];
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
handler(elements[i]);
|
||||
const result = handler(elements[i], i);
|
||||
if (result instanceof Promise) {
|
||||
promises.push(result);
|
||||
}
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
getScrollTop() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- hugo.Store.Set "version" "v0.4.0-alpha-20250812032013-fe351c7e" -}}
|
||||
{{- hugo.Store.Set "version" "v0.4.0-alpha-20250812094854-45f101a4" -}}
|
||||
{{- .Store.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
Reference in New Issue
Block a user