window.kaolin
    Preparing search index...

    Function toBinary

    • 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.