Skip to content

Function: init() ​

init(options?): Promise<void>

Defined in: runtime.ts:53

Initialises the WASM module. Idempotent and safe to call concurrently.

  • Node.js (import 'quantum-safe-ts'): initialises automatically; init() is a no-op.
  • Browsers, Deno, Bun, edge runtimes: call await init() once before using the library.
  • Cloudflare Workers (which forbid compiling WASM from bytes): pass the precompiled module: await init({ wasm: (await import('quantum-safe-ts/quantum_safe_wasm_bg.wasm')).default }).

Once the module is ready, later calls return immediately. While a load is in progress, the options of further calls are ignored and they wait for that load. After a failed load the next call starts a new one.

Parameters ​

options? ​

wasm? ​

InitSource

Optional custom source: bytes, a WebAssembly.Module, a Response, or a URL.

Returns ​

Promise<void>

A promise that resolves when the module is ready.

Throws ​

if no source is given and the entry point registered none (for example the slim entry without options.wasm).

Throws ​

if instantiating the module fails (code QS_INTERNAL_ERROR).

Example ​

ts
import { init } from 'quantum-safe-ts';
await init(); // no-op on Node.js

Apache-2.0.