JavaScript SDK Overview
The ion.webcore.js package provides the browser-side runtime for IonPath — binary I/O, CBOR codec, formatter storage, and typed HTTP/WebSocket clients.
Architecture
The SDK is layered as follows:
1 IonBinaryReader / IonBinaryWriter — low-level byte I/O over ArrayBuffer
2 IonCBOR — CBOR encoding/decoding (RFC 8949)
3 IonFormatterStorage — type serialization registry
4 IonUnaryRequest / IonWsClient — HTTP POST (unary) / WebSocket (streaming)
Installation
# The package is typically added as a dependency alongside generated code
npm install @nicurt/ion.webcore.js Binary I/O
IonBinaryReader and IonBinaryWriter operate on ArrayBuffer for efficient byte-level I/O:
import { IonBinaryWriter, IonBinaryReader } from '@nicurt/ion.webcore.js'; // Write const writer = new IonBinaryWriter(); writer.writeUInt32(42); writer.writeString("hello"); const buffer = writer.toArrayBuffer(); // Read const reader = new IonBinaryReader(buffer); const num = reader.readUInt32(); // 42 const str = reader.readString(); // "hello"
CBOR Codec
IonCBOR handles CBOR encoding on top of the binary writer/reader. All IonPath messages are encoded as CBOR arrays:
import { IonCBOR } from '@nicurt/ion.webcore.js'; // Encode a value const encoded = IonCBOR.encode([42, "hello", true]); // Decode a value const decoded = IonCBOR.decode(encoded); // [42, "hello", true]