Skip to main content
Version: v10.0.0

DbCodec

A value type the db stores as tagged JSON, beyond the ones it knows


Import
import { DbCodec } from "@hyper-fetch/db"

Preview​

type DbCodec = {
decode: (value: unknown) => unknown;
encode: (value: unknown) => unknown;
name: string;
test: (value: unknown) => boolean;
}

Structure​

DbCodec
NameTypeDescription
name
string

The tag stored with encoded values. It must stay the same across releases.

decode
(value: unknown) => unknown

Turns a stored value back

encode
(value: unknown) => unknown

Turns a value into one the serializer can store

test
(value: unknown) => boolean

Whether a value is of this type