API reference › @evolu/common › local‑first/Protocol › encodeSqliteValue
function encodeSqliteValue(
buffer: Buffer,
value:
| string
| Uint8Array<ArrayBufferLike>
| (number & Brand<"NonNaN"> & Brand<"Finite">)
| null,
): void;
Defined in: packages/common/src/local-first/Protocol.ts:2719
Writes a SqliteValue as a ProtocolValueType code followed by its payload.
A string is encoded as UTF-8 reads it, with each lone surrogate as U+FFFD, in
the first form that reproduces that text exactly: empty; a DateIso as
its time; an Id as its 16 bytes; JSON text as MessagePack, when
JSON.stringify writes exactly that text, it nests no deeper than decoding
allows, and it contains no \ud, which begins the escape of a lone
surrogate; or Base64Url as its bytes. Any other string is UTF-8. A
non-negative safe integer other than -0 is a varint, and any other number is
MessagePack, which writes a negative integer from -2^31 as an int and the
rest as a float64.