Skip to main content
Module

x/cav/serial.ts>Serializer

A server framework for Deno
Go to Latest
interface Serializer
import { type Serializer } from "https://deno.land/x/cav@0.2.0-alpha.7/serial.ts";

Interface for serializing and deserializing arbitrary non-JSON primitive values into JSON.

Type Parameters

optional
I = unknown
optional
O = unknown

Methods

check(value: unknown): boolean

Checks if this serializer applies to the value.

serialize(value: I): O

Transforms the value into its JSON-compatible format. The value returned by this function will be re-serialized, i.e. not every nested value needs to be JSON compatible.

deserialize(raw: unknown, whenDone: (fn: (ready: O) => void) => void): I

Transforms serialized values into their original input. Any nested serialized values will still be serialized when this function is called initially. Use the whenDone registration function to finish setting up the resulting output only when each of the nested values is finished deserializing, i.e. "ready".