Serialize a value to binary format. Supports most basic types, like
Map or standard javascript Object {}, Array, ArrayBuffer,
TypedArray, number, string. Nesting of Map and Array instances
is also supported. PNG/JPEG Blob instances (mime types image/png /
image/jpeg) are encoded as compressed-image payloads.
Always returns a Promise because Blob bytes are only accessible
asynchronously. Internally, every Blob in the value tree is resolved
(in parallel via Promise.all) into a private byte shim before the
synchronous BinaryWriter runs. For values that contain no Blobs
this only adds a single microtask hop and the bytes are byte-identical
to a direct synchronous encoding.
The resulting buffer can be decoded using fromBinary or by its
sister python implementation in kaolin.visualize.web.
Parameters
value: any
Value to serialize.
Returns Promise<ArrayBuffer>
Promise resolving to binary data as ArrayBuffer, or null on failure.
Serialize a value to binary format. Supports most basic types, like
Mapor standard javascript Object{},Array,ArrayBuffer,TypedArray,number,string. Nesting ofMapandArrayinstances is also supported. PNG/JPEGBlobinstances (mime typesimage/png/image/jpeg) are encoded as compressed-image payloads.Always returns a
PromisebecauseBlobbytes are only accessible asynchronously. Internally, everyBlobin the value tree is resolved (in parallel viaPromise.all) into a private byte shim before the synchronous BinaryWriter runs. For values that contain no Blobs this only adds a single microtask hop and the bytes are byte-identical to a direct synchronous encoding.The resulting buffer can be decoded using fromBinary or by its sister python implementation in
kaolin.visualize.web.