Cloudflare dmap logo

Cloudflare dmap

powered by Cloudflare

Distributed Map Functions

Execute map functions at scale using Cloudflare's global network. Break free from serverless limitations.

Simple API

const result = await dmap(
  array,
  (item) => process(item)
);

Highly Scalable

Process up to 5000 items per second with 250 concurrent operations using Cloudflare's global infrastructure.

Queue-Based Architecture

Built on Cloudflare Queues and Durable Objects for reliable distributed processing.

Example Usage

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))
);

Why Use dmap?

Memory Efficient

Break free from serverless memory constraints by processing data in chunks.

Parallel Processing

Execute operations concurrently across Cloudflare's global network.

Error Handling

Built-in retry mechanism with exponential backoff for failed operations.