npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dotdo/colo

v0.1.5

Published

Location-aware Durable Objects - create, target, and manage DOs in specific Cloudflare colocations

Readme

@dotdo/colo

Location-aware Durable Objects for Cloudflare Workers.

Create, target, and manage Durable Objects in specific Cloudflare colocations.

Installation

npm install @dotdo/colo

Features

  • Target specific colos - Create DOs in LAX, IAD, LHR, or any other Cloudflare colo
  • Find nearest colo - Route requests to the nearest DO from a list of replicas
  • Calculate distances - Get distance and latency estimates between colos
  • Colo-aware DOs - Base class that tracks location and provides migration hints
  • Sharding - Distribute data across colos with consistent hashing

Quick Start

import { createInColo, findNearestColo, createReplicas } from '@dotdo/colo'

// Create a DO in a specific colo
const stub = createInColo(env.MY_DO, {
  colo: 'LAX',
  id: 'my-instance'
})

// Create replicas across multiple colos
const replicas = createReplicas(env.MY_DO, {
  id: 'shared-data',
  colos: ['IAD', 'ORD', 'SFO', 'LHR']
})

// Route to the nearest replica
const nearest = findNearestColo(request, ['IAD', 'ORD', 'SFO', 'LHR'])
const result = await replicas[nearest].getData()

API

Location Detection

import { getLocation, getCurrentColo } from '@dotdo/colo'

// Get full location info from a request
const location = getLocation(request)
console.log(location.colo)      // 'IAD'
console.log(location.city)      // 'Ashburn'
console.log(location.country)   // 'US'

// Just get the colo
const colo = getCurrentColo(request)

Distance & Latency

import { coloDistance, estimateLatency, sortByDistance, nearestColo } from '@dotdo/colo'

// Distance between colos in kilometers
const km = coloDistance('IAD', 'LAX')  // ~3700

// Estimated round-trip latency in milliseconds
const ms = estimateLatency('IAD', 'LAX')  // ~42

// Sort colos by distance from a reference point
const sorted = sortByDistance('IAD', ['LAX', 'ORD', 'SFO', 'LHR'])
// [{ colo: 'ORD', distance: 956, latency: 15 }, ...]

// Find nearest colo from a list
const nearest = nearestColo('IAD', ['LAX', 'ORD', 'SFO'])  // 'ORD'

DO Targeting

import { targetColo, createInColo, createReplicas } from '@dotdo/colo'

// Get the name to use for idFromName
const { name, colo } = targetColo({ colo: 'LAX', id: 'my-instance' })
const doId = env.MY_DO.idFromName(name)

// Or create the stub directly
const stub = createInColo(env.MY_DO, { colo: 'LAX', id: 'my-instance' })

// Create replicas in multiple colos
const replicas = createReplicas(env.MY_DO, {
  id: 'my-data',
  colos: ['IAD', 'ORD', 'SFO', 'LHR']
})

Sharding

import { getShard } from '@dotdo/colo'

// Get the shard for a key
const { colo, shardId, name } = getShard({
  key: 'user-12345',
  colos: ['IAD', 'ORD', 'SFO', 'LHR'],
  shardsPerColo: 16
})

const stub = env.USER_DO.get(env.USER_DO.idFromName(name))

Colo-Aware DO Base Class

import { ColoAwareDO, type ColoContext } from '@dotdo/colo'

export class MyDO extends ColoAwareDO {
  async fetch(request: Request): Promise<Response> {
    const ctx = this.getColoContext(request)

    console.log(`DO running in ${ctx.colo}`)
    console.log(`Worker called from ${ctx.workerColo}`)
    console.log(`Estimated latency: ${ctx.latencyMs}ms`)

    return new Response(JSON.stringify(ctx))
  }
}

Colo Data

import { COLOS, getColo, getAllColos, getColosByRegion, getDOColos } from '@dotdo/colo'

// Get info for a specific colo
const lax = getColo('LAX')
// { iata: 'LAX', city: 'Los Angeles', country: 'US', region: 'wnam', lat: 33.94, lon: -118.41, hasDO: true }

// Get all IATA codes
const allColos = getAllColos()  // ['SJC', 'LAX', 'SEA', ...]

// Get colos in a region
const westCoast = getColosByRegion('wnam')

// Get only colos that support DOs
const doColos = getDOColos()

Live API

Visit colo.do for a live API:

  • GET /api - Your location info and nearest colos
  • GET /api/colos - List all colos
  • GET /api/colos/LAX - Get specific colo info
  • GET /api/nearest?colos=IAD,ORD,SFO - Find nearest from list
  • GET /api/distance?from=IAD&to=LAX - Calculate distance

License

MIT