Skip to content
1 min read · 177 words

Type Alias: CodecMode

ts
type CodecMode =
  | "auto"
  | "raw"
  | "encoded"
  | {
      decode: (encoded: string) => unknown | Promise<unknown>;
      encode: (value: unknown) => string | Promise<string>;
    };

Defined in: src/batteries/isolation/types.ts:30

Serialization strategy for a single method/stream call's arguments — see codec.ts for the tiered codec this selects. 'auto' (the default when omitted) traverses each argument and escalates only the exotic leaves it finds; 'raw' skips traversal entirely (trust the caller — cheapest, but unsafe for values containing functions/Errors/custom-encodables); 'encoded' whole-value encodes every argument via the optional @nhtio/encoder peer. A caller may also inject a literal { encode, decode } pair to bring their own codec, bypassing both the traversal and the encoder peer entirely.

Union Members

"auto"


"raw"


"encoded"


Type Literal

ts
{
  decode: (encoded: string) => unknown | Promise<unknown>;
  encode: (value: unknown) => string | Promise<string>;
}
NameTypeDescriptionDefined in
decode()(encoded: string) => unknown | Promise<unknown>Reconstruct a value from a string produced by this codec's encode. May be sync or async.src/batteries/isolation/types.ts:38
encode()(value: unknown) => string | Promise<string>Serialize a single value to a wire-safe string. May be sync or async.src/batteries/isolation/types.ts:36