Skip to main content
Version: Next

serializeValue

Callable

  • serializeValue(value, contentType): { contentType: string; value: Buffer | ArrayBuffer | ArrayBufferView | string | NodeJS.ReadableStream | ReadableStream }

  • Canonical write path for key-value store records.

    When a content type is provided, the value passes through unchanged — it is the caller's responsibility to supply a String/Buffer/Stream (the frontend validates this).

    When no content type is provided, it is inferred from the value's shape:

    • Buffer / typed array / ArrayBuffer / stream → application/octet-stream (passthrough)
    • stringtext/plain; charset=utf-8 (passthrough)
    • anything else → application/json; charset=utf-8 (serialized via jsonStringifyExtended)

    Does NOT drain streams — that is storage mechanics and stays in the storage backend.

    Backend-independent.


    Parameters

    • value: unknown
    • optionalcontentType: string

    Returns { contentType: string; value: Buffer | ArrayBuffer | ArrayBufferView | string | NodeJS.ReadableStream | ReadableStream }

    • contentType: string
    • value: Buffer | ArrayBuffer | ArrayBufferView | string | NodeJS.ReadableStream | ReadableStream