forked from lumeland/lume
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
40 lines (35 loc) · 1.01 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
export async function concurrent(iterable, iteratorFn, limit = 200) {
const executing = [];
for await (const item of iterable) {
const p = iteratorFn(item).then(() =>
executing.splice(executing.indexOf(p), 1)
);
executing.push(p);
if (executing.length >= limit) {
await Promise.race(executing);
}
}
await Promise.all(executing);
}
export const mimes = new Map([
[".html", "text/html; charset=utf-8"],
[".txt", "text/plain; charset=utf-8"],
[".js", "text/javascript; charset=utf-8"],
[".css", "text/css; charset=utf-8"],
[".json", "application/json; charset=utf-8"],
[".ico", "image/x-icon"],
[".png", "image/png"],
[".jpg", "image/jpg"],
[".jpeg", "image/jpg"],
[".gif", "image/gif"],
[".svg", "image/svg+xml"],
[".mp3", "audio/mpeg"],
[".mp4", "video/mpeg"],
[".xml", "text/xml"],
[".woff", "font/woff"],
[".woff2", "font/woff2"],
[".wasm", "application/wasm"],
[".webp", "image/webp"],
[".webm", "video/webm"],
[".zip", "application/zip"],
]);