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

cdb-converter

v0.1.0

Published

Convert Pro Cycling Manager CDB files to/from SQLite and other formats. TypeScript library with zero configuration.

Readme

cdb-converter

TypeScript library for converting Pro Cycling Manager CDB database files to/from SQLite and other formats. Lightweight, isomorphic (works in Node.js and browser), and zero-configuration.

Features

  • CDB ↔ SQLite - Convert between binary CDB format and SQLite databases
  • TypeScript - Native type definitions, full IDE support
  • Isomorphic - Works in Node.js and browser environments (via sql.js)
  • Lightweight - Minimal dependencies (pako, sql.js only)
  • Tree-shakeable - Pure functions, no side effects
  • Preserves metadata - Round-trip conversion maintains all table/column information
  • 🔜 JSON export - Phase 2
  • 🔜 CSV export - Phase 3

Installation

npm install cdb-converter

Samples

Example projects are available in the samples folder:

Quick Start

Convert CDB to SQLite

import { cdbToSql } from "cdb-converter";
import initSqlJs from "sql.js";

const SQL = await initSqlJs();

// Read CDB file
const cdbBuffer = fs.readFileSync("save.cdb");

// Convert to SQLite
const db = cdbToSql(cdbBuffer, SQL);

// Query the database
const result = db.exec("SELECT * FROM Teams LIMIT 5");
console.log(result[0].values);

// Export to SQLite file
const sqliteData = db.export();
fs.writeFileSync("save.db", sqliteData);

Convert SQLite back to CDB

import initSqlJs from "sql.js";
import { sqlToCdb } from "cdb-converter";

const SQL = await initSqlJs({
  locateFile: (filename) =>
    `https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.10.2/${filename}`,
});

// Load SQLite database
const sqliteBuffer = fs.readFileSync("save.db");
const db = new SQL.Database(sqliteBuffer);

// Convert back to CDB
const cdbBuffer = sqlToCdb(db);

// Save as CDB
fs.writeFileSync("save.cdb", cdbBuffer);

Compression

The library automatically handles CDB compression (zlib deflate):

import { compressCdb, decompressCdb } from "cdb-converter";

const compressed = compressCdb(cdbData);
const decompressed = decompressCdb(compressed);

Supported Data Types

The library preserves all CDB data types during conversion:

| Type | Description | Example | | ------------- | ----------------- | --------------- | | INTEGER | 32-bit signed | 42 | | FLOAT | IEEE 754 float32 | 3.14 | | STRING | UTF-8 text | "cyclist" | | BOOLEAN | Bit-packed | true/false | | INTEGER_BYTE | 8-bit signed | -128 to 127 | | INTEGER_SHORT | 16-bit unsigned | 0 to 65535 | | FLOAT_LIST | Array of floats | "(1.5,2.3,3.7)" | | INTEGER_LIST | Array of integers | "(10,20,30)" |

API Reference

cdbToSql(cdbBuffer: ArrayBuffer | Uint8Array, SQL: SqlJsStatic): Database

Convert CDB binary data to SQLite database instance.

You must pass the initialized sql.js module returned by initSqlJs(). This library does not initialize sql.js internally because that setup is asynchronous and environment-specific: the caller controls how the wasm file is loaded in Node.js or in the browser, and cdbToSql only needs the ready-to-use Database constructor exposed by that module.

  • cdbBuffer: Raw CDB binary data (compressed or uncompressed)
  • SQL: sql.js instance from initSqlJs()
  • returns: sql.js Database instance with CDB tables loaded

sqlToCdb(db: Database): ArrayBuffer

Convert SQLite database back to CDB binary format (automatically compressed).

  • db: sql.js Database instance
  • returns: Compressed CDB binary data (ArrayBuffer)

compressCdb(data: ArrayBuffer | Uint8Array): ArrayBuffer

Compress CDB data using zlib deflate.

decompressCdb(data: ArrayBuffer | Uint8Array): ArrayBuffer

Decompress CDB data (handles both compressed and uncompressed input).

Metadata Preservation

The library uses a special DB_STRUCTURE table to preserve CDB metadata:

CREATE TABLE DB_STRUCTURE (
  TableName TEXT,
  ID INTEGER
)

Table flags and column indices are preserved in the database object for round-trip conversion.

Browser Usage

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sql-wasm.js"></script>
<script type="module">
  import {
    cdbToSql,
    sqlToCdb,
  } from "https://cdn.jsdelivr.net/npm/cdb-converter";

  // Initialize sql.js
  const SQL = await initSqlJs();

  // Read CDB from file input
  const file = document.getElementById("cdb-input").files[0];
  const cdbBuffer = await file.arrayBuffer();

  // Convert and use
  const db = cdbToSql(cdbBuffer, SQL);
  console.log(
    "Tables:",
    db.exec("SELECT * FROM sqlite_master WHERE type='table'"),
  );
</script>

License

MIT - See LICENSE file for details