Interface IBlobCodec

Binary BLOB codec for encoding/decoding vectors and computing hashes.

Node.js implementations use Buffer. Browser implementations use Uint8Array + DataView.

interface IBlobCodec {
    encode(vec: number[]): Uint8Array;
    decode(blob: Uint8Array | ArrayBufferLike): number[];
    sha256(input: string): Promise<string>;
}

Implemented by

Methods

  • Encode a number[] vector to a binary BLOB value (Float32 little-endian).

    Parameters

    • vec: number[]

    Returns Uint8Array

  • Decode a BLOB column value back to number[].

    Parameters

    • blob: Uint8Array | ArrayBufferLike

    Returns number[]

  • SHA-256 hex digest. Async to support crypto.subtle in browsers.

    Parameters

    • input: string

    Returns Promise<string>