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

fastdb4ts

v0.0.2

Published

TypeScript bindings for fastdb running in the browser via WebAssembly.

Downloads

210

Readme

fastdb4ts

Browser-oriented TypeScript bindings for fastdb, powered by WebAssembly.

fastdb4ts brings the fastdb storage model to TypeScript with a browser-first API centered around typed schemas, structured table access, binary buffer transport, and graph serialization.

What this package provides

  • Typed schemas
    • model records with Feature subclasses and defineSchema(...)
  • Structured table access
    • use ORM, TableDefn, Table, and column accessors
  • Binary buffer roundtrips
    • import/export databases as Uint8Array / ArrayBuffer
  • Graph serialization
    • use FastSerializer for nested features, lists, and cyclic references
  • Shared native semantics
    • backed by the same C++ core as fastdb4py

Current scope

This package currently targets the browser/WebAssembly use case.

Included:

  • browser-first WASM runtime
  • Feature + defineSchema(...)
  • ORM, TableDefn, Table, column access
  • FastSerializer
  • Uint8Array / ArrayBuffer import/export

Not included in the current TS package:

  • shared-memory IPC
  • direct filesystem persistence APIs

Installation

npm install fastdb4ts

If you are working from the repository source instead of npm:

bash ts/build-wasm.sh
npm --prefix ts/fastdb4ts run build

Quick start

import {
  F64,
  Feature,
  ORM,
  TableDefn,
  defineSchema,
  initFastdb,
} from 'fastdb4ts';

await initFastdb();

class Point extends Feature {
  static schema = defineSchema({
    x: F64,
    y: F64,
  });
}

const db = ORM.truncate([new TableDefn(Point, 3)]);
const table = db.table(Point);

table.column.x.fill([1.5, 2.5, 3.5]);
table.column.y.fill([4.5, 5.5, 6.5]);

console.log(table.get(1).x); // 2.5

Defining schemas

Unlike fastdb4py, the TypeScript package uses explicit schema definitions rather than Python annotations.

You can write these schemas by hand, or auto-generate them from Python Feature classes using the fdb codegen CLI (see Generating schemas from Python below).

import {
  F64,
  Feature,
  I32,
  STR,
  defineSchema,
  listOf,
  ref,
} from 'fastdb4ts';

class Point extends Feature {
  static schema = defineSchema({
    x: F64,
    y: F64,
  });
}

class Line extends Feature {
  static schema = defineSchema({
    id: I32,
    name: STR,
    points: listOf(Point),
    first: ref(Point),
  });
}

Common field helpers:

  • U8, U16, U32, I32
  • F32, F64
  • STR, WSTR
  • BYTES
  • ref(TargetFeature)
  • listOf(...)

Working with tables

Fixed-size tables

import { F64, Feature, ORM, TableDefn, defineSchema, initFastdb } from 'fastdb4ts';

await initFastdb();

class Particle extends Feature {
  static schema = defineSchema({
    x: F64,
    y: F64,
    vx: F64,
    vy: F64,
  });
}

const db = ORM.truncate([new TableDefn(Particle, 4)]);
const table = db.table(Particle);

table.column.x.fill([0.0, 1.0, 2.0, 3.0]);
table.column.y.fill([10.0, 20.0, 30.0, 40.0]);
table.column.vx.fill([0.1, 0.1, 0.2, 0.2]);
table.column.vy.fill([0.0, 0.0, 0.0, 0.0]);

console.log(table.get(2).x); // 2.0

Buffer roundtrip

const bytes = db.toBuffer();
const copy = ORM.fromBuffer(bytes);
const copyTable = copy.table(Particle);

console.log(copyTable.get(2).x); // 2.0

FastSerializer

FastSerializer is the graph-oriented layer for feature graphs that are more naturally represented as nested objects than flat tables.

Supported scenarios include:

  • nested features
  • scalar lists
  • string lists
  • feature references
  • cyclic references
  • numeric-list columnar auxiliary layers
import {
  F64,
  FastSerializer,
  Feature,
  I32,
  defineSchema,
  initFastdb,
  listOf,
} from 'fastdb4ts';

await initFastdb();

class Point extends Feature {
  static schema = defineSchema({ x: F64, y: F64 });
}

class Line extends Feature {
  static schema = defineSchema({
    id: I32,
    points: listOf(Point),
  });
}

const line = new Line({
  id: 42,
  points: [new Point({ x: 1.0, y: 2.0 }), new Point({ x: 3.0, y: 4.0 })],
});

const bytes = FastSerializer.dumps(line);
const copy = FastSerializer.loads(bytes, Line);

console.log(copy.points[1].y); // 4.0

Cycles are preserved:

import { Feature, I32, FastSerializer, defineSchema, initFastdb, ref } from 'fastdb4ts';

await initFastdb();

class Node extends Feature {
  static schema = defineSchema({
    val: I32,
    next: ref(() => Node),
  });
}

const a = new Node({ val: 1 });
const b = new Node({ val: 2 });
a.next = b;
b.next = a;

const copy = FastSerializer.loads(FastSerializer.dumps(a), Node);
console.log(copy.next.next === copy); // true

Build

From the repository root:

npm --prefix ts/fastdb4ts run build

To rebuild the WASM module as well:

bash ts/build-wasm.sh
npm --prefix ts/fastdb4ts run build

Tests

Pure TypeScript tests live under tests/ts/.

Run them from the repository root:

npm run test:ts

Serializer interop validation is also available:

npm --prefix ts/fastdb4ts run test:serializer:interop

Generating schemas from Python

If you define your canonical Feature classes in Python (fastdb4py), you can generate the equivalent TypeScript schemas automatically using the fdb codegen CLI:

pip install fastdb4py
fdb codegen --ts ./python_features/ ./ts_features/

This generates one .ts file per .py file, with:

  • all field types mapped (F64, STR, ref(...), listOf(...), etc.)
  • cross-file imports resolved to relative paths
  • circular references using lazy refs ref(() => ClassName)
  • topological class ordering within each file

See the Python binding README for full codegen documentation.

Repository documentation

For fuller project documentation, see: