@cloudflare/workers-response-store 0.1.0-beta.0 → 0.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +250 -45
- package/dist/binding.d.ts +32 -1
- package/dist/binding.js +485 -80
- package/dist/index.d.ts +10 -2
- package/dist/index.js +12 -3
- package/dist/isolate-negative-cache.d.ts +11 -0
- package/dist/isolate-negative-cache.js +34 -0
- package/dist/metadata-do.d.ts +48 -11
- package/dist/metadata-do.js +348 -133
- package/dist/r2-concurrency.d.ts +3 -0
- package/dist/r2-concurrency.js +25 -0
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/r2-concurrency.ts
|
|
2
|
+
const MAX_R2_CONCURRENCY = 6;
|
|
3
|
+
async function mapSettledWithR2Concurrency(values, callback) {
|
|
4
|
+
const results = [];
|
|
5
|
+
let nextIndex = 0;
|
|
6
|
+
await Promise.all(Array.from({ length: Math.min(MAX_R2_CONCURRENCY, values.length) }, async () => {
|
|
7
|
+
while (nextIndex < values.length) {
|
|
8
|
+
const index = nextIndex++;
|
|
9
|
+
try {
|
|
10
|
+
results[index] = {
|
|
11
|
+
status: "fulfilled",
|
|
12
|
+
value: await callback(values[index])
|
|
13
|
+
};
|
|
14
|
+
} catch (reason) {
|
|
15
|
+
results[index] = {
|
|
16
|
+
status: "rejected",
|
|
17
|
+
reason
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
return results;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { mapSettledWithR2Concurrency };
|
package/package.json
CHANGED