Skip to content

Commit 381ea89

Browse files
committed
Bump to 0.4.5
1 parent e6ceee7 commit 381ea89

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vectorjson",
3-
"version": "0.4.4",
3+
"version": "0.4.5",
44
"description": "O(n) WASM SIMD JSON parser for AI agents — stream fields instantly, abort errors early, offload parsing to Workers",
55
"type": "module",
66
"main": "dist/index.js",

src/js/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ export async function init(options?: {
717717

718718
// --- Tape export/import helpers ---
719719
/** Parse a stream's buffer, export packed tape, free the temp doc slot. */
720-
function streamExportTape(streamId: number): ArrayBuffer | null {
720+
function streamExportTape(streamId: number, formatCode = 0): ArrayBuffer | null {
721721
const status = engine.stream_get_status(streamId);
722722
if (status !== 1 /* complete */ && status !== 3 /* end_early */) return null;
723723
const bufPtr = engine.stream_get_buffer_ptr(streamId) >>> 0;
@@ -730,7 +730,9 @@ export async function init(options?: {
730730
new Uint8Array(engine.memory.buffer, bufPtr, bufLen),
731731
);
732732
new Uint8Array(engine.memory.buffer, padPtr + bufLen, 64).fill(0x20);
733-
const docId = engine.doc_parse(padPtr, bufLen);
733+
const docId = formatCode === 2
734+
? engine.doc_parse_fmt(padPtr, bufLen, 2)
735+
: engine.doc_parse(padPtr, bufLen);
734736
engine.dealloc(padPtr, bufLen + 64);
735737
if (docId < 0) return null;
736738
// Export tape → JS ArrayBuffer, then free slot
@@ -1759,7 +1761,7 @@ export async function init(options?: {
17591761
},
17601762

17611763
getTapeBuffer(): ArrayBuffer | null {
1762-
return destroyed ? null : streamExportTape(streamId);
1764+
return destroyed ? null : streamExportTape(streamId, FORMAT_CODE);
17631765
},
17641766

17651767
destroy(): void {
@@ -2340,7 +2342,7 @@ export async function init(options?: {
23402342
},
23412343

23422344
getTapeBuffer(): ArrayBuffer | null {
2343-
return destroyed ? null : streamExportTape(streamId);
2345+
return destroyed ? null : streamExportTape(streamId, FORMAT_CODE);
23442346
},
23452347

23462348
destroy(): void {

0 commit comments

Comments
 (0)