recurram
v0.1.0
Published
Node.js and TypeScript implementation of a fast, compact binary wire format for modern data transport.
Maintainers
Readme
Recurram (JS)
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).
Requirements
- Node.js 24+
- Rust stable
wasm-packfor WASM builds
Build
pnpm install
pnpm buildBuild steps:
- Build N-API addon (
native/recurram_napi.node) - Build WASM package (
wasm/pkg/*) - Build TypeScript output (
dist/*)
Formatting
pnpm format
pnpm format:checkTest
pnpm 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
Usage (Node)
import {
init,
encode,
decode,
createSessionEncoder,
toTransportJson,
encodeTransportJson,
type RecurramValue,
} from "recurram";
await init({ prefer: "napi" });
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" });
const prepared = toTransportJson(value);
const fastest = encodeTransportJson(prepared);High-throughput transport JSON APIs
For hot paths where you can prepare payloads ahead of time, use transport JSON APIs to reduce JS-side conversion overhead:
toTransportJson(value)/fromTransportJson(json)toTransportJsonBatch(values)encodeTransportJson(valueJson)/decodeToTransportJson(bytes)encodeBatchTransportJson(valuesJson)
SessionEncoder also supports raw methods:
encodeTransportJson(valueJson)encodeBatchTransportJson(valuesJson)encodePatchTransportJson(valueJson)encodeMicroBatchTransportJson(valuesJson)
Usage (Browser)
import { init, encode, decode } from "recurram";
await init({ prefer: "wasm" });
const bytes = encode({ id: 1n, role: "admin" });
const value = decode(bytes);If you want to pass a custom WASM source, use wasmInput:
await init({ prefer: "wasm", wasmInput: "/assets/recurram_wasm_bg.wasm" });TypeScript types
Main exported types:
RecurramValueSchema,SchemaFieldSessionOptions
RecurramValue includes bigint and Uint8Array support:
type RecurramValue =
| null
| boolean
| number
| bigint
| string
| Uint8Array
| RecurramValue[]
| { [key: string]: RecurramValue };Publish to npm
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.
License
This project is licensed under the MIT License - see the LICENSE file for details.
