JavaScript/TypeScript bindings for recurram-rust with two backends:
- Node.js: N-API (
recurram-napi) - Browser/JS runtime: WebAssembly (
recurram-wasm)
Integers decode as bigint by default (i64/u64 safe handling).
- Node.js 24+
- Rust stable
wasm-packfor WASM builds
pnpm install
pnpm buildBuild steps:
- Build N-API addon (
native/recurram_napi.node) - Build WASM package (
wasm/pkg/*) - Build TypeScript output (
dist/*)
pnpm format
pnpm format:checkpnpm testWhat it validates:
- Rust bridge tests (
test:rust) - Node API tests (
test:node) coveringinit,encode,decode, schema, batch, and session APIs - TypeScript API usage against built output
import {
encode,
decode,
createSessionEncoder,
type RecurramValue,
} from "recurram";
const value: RecurramValue = {
id: 1001n,
name: "alice",
active: true,
};
const bytes = encode(value);
const roundtrip = decode(bytes);
const session = createSessionEncoder();
const first = session.encode(value);
const patch = session.encodePatch({ ...value, name: "alicia" });Node.js picks the N-API backend automatically on first use. The default APIs already use the fastest benchmarked path for each operation, so you should not need to choose between transport JSON, compact JSON, or direct object modes.
If you need raw transport helpers, explicit schema encoding, or internal-format control, import the advanced entrypoint:
import {
createSessionEncoder,
encodeTransportJson,
encodeWithSchema,
toTransportJson,
} from "recurram/advanced";This entrypoint contains:
- transport JSON helpers
- compact JSON helpers
- direct object helpers
- schema encoding helpers
- full raw session encoder methods
import { init, encode, decode } from "recurram";
await init({ prefer: "wasm" });
const bytes = encode({ id: 1n, role: "admin" });
const value = decode(bytes);Browser/WASM still requires explicit async initialization. If you want to pass a custom WASM source, use wasmInput:
await init({ prefer: "wasm", wasmInput: "/assets/recurram_wasm_bg.wasm" });Main exported types:
RecurramValueSchema,SchemaFieldSessionOptions
RecurramValue includes bigint and Uint8Array support:
type RecurramValue =
| null
| boolean
| number
| bigint
| string
| Uint8Array
| RecurramValue[]
| { [key: string]: RecurramValue };The package is configured for npm publish and ships build artifacts from dist/, native/, and wasm/pkg/.
Local dry run:
pnpm build
pnpm packGitHub Actions publish:
- Add repository secret
NPM_TOKEN. - Bump
versioninpackage.json. - Create and push matching tag
v<version>.
Example:
git tag v0.1.0
git push origin v0.1.0The workflow .github/workflows/publish-npm.yml verifies tag/version match and then runs pnpm publish.
This project is licensed under the MIT License - see the LICENSE file for details.