Skip to content

Load the engine

Every query and every controller runs on the engine. It ships in separate modules, outside the initial bundle. You load it wherever it fits your app’s flow.

function ensureEngineReady(): Promise<void>;

Call it once, before the first API call. It is idempotent; a later call resolves immediately while concurrent calls share one in-flight load.

import { ensureEngineReady, parsePhoneNumber } from '@telixon/core';
await ensureEngineReady();
parsePhoneNumber('+1 (415) 555-0132').isValid(); // true

A failed load rejects with the underlying error, leaving nothing cached. The next call starts a fresh load.

class EngineNotReadyError extends Error {}

An API call before the engine is ready throws EngineNotReadyError. Once the engine is loaded, the query and controller APIs throw nothing.

import { EngineNotReadyError, parsePhoneNumber } from '@telixon/core';
try {
parsePhoneNumber('+1 (415) 555-0132');
} catch (error) {
error instanceof EngineNotReadyError; // true
}
function isEngineReady(): boolean;

Whether the engine is loaded. It returns false where a query would throw EngineNotReadyError.

import { isEngineReady } from '@telixon/core';
isEngineReady(); // false before ensureEngineReady() resolves
function ensureEngineReadySync(): void;

Initializes the engine synchronously, from tables embedded in the bundle. That weight lands only where this entry is imported; the bundle report measures it chunk by chunk.

import { ensureEngineReadySync } from '@telixon/core/sync-init';
import { parsePhoneNumber } from '@telixon/core';
ensureEngineReadySync();
parsePhoneNumber('+1 (415) 555-0132').isValid(); // true

It covers the places that cannot await, such as a synchronous constructor, a module-level default, or a migration script.

The runtime picks the build behind @telixon/core.

Runtime Build resolved
Node.js index.node.js
Deno, Bun index.node.js
Browsers and bundlers index.browser.js
Workers, edge, workerd index.edge.js

Under ensureEngineReady, the browser and edge builds import the tables as code-split modules, then inflate them with DecompressionStream, falling back to a pure-JS inflater where the API is missing. The Node build decodes with native zlib, off the event loop.

@telixon/core/sync-init resolves two builds of its own. Node decodes with native zlib; every other runtime uses the pure-JS inflater.

ensureEngineReady and ensureEngineReadySync fill the same process-wide engine. There is no instance to pass around.