Execute map functions at scale using Cloudflare's global network. Break free from serverless limitations.
const result = await dmap( array, (item) => process(item) );
Process up to 5000 items per second with 250 concurrent operations using Cloudflare's global infrastructure.
Built on Cloudflare Queues and Durable Objects for reliable distributed processing.
import { dmap } from "@cfa/dmap";
// Create array of numbers
const array = new Array(100000)
.fill(null)
.map((_, index) => index);
// Process using OpenAI API
const squares = await dmap(array, (n) =>
fetch("https://api.openai.com/chat/completions", {
method: "POST",
body: JSON.stringify({
messages: [{
role: "user",
message: `What's the square of ${n}?`
}]
}),
headers: { Authorization: `Bearer ${apiKey}` }
})
.then(res => res.json())
.then(json => Number(json.choices[0].message.content))
);
Break free from serverless memory constraints by processing data in chunks.
Execute operations concurrently across Cloudflare's global network.
Built-in retry mechanism with exponential backoff for failed operations.