node-dextrin - v0.1.0
    Preparing search index...

    Class export=

    Extension point for both struct and custom-tag decoding/encoding, mirroring Dextrin.Registry. No entry for a given name → decode falls back to an opaque DXNStruct/ DXNCustomTag — never a hard failure, since neither type requires a registration to be representable at all.

    Struct entries only ever come from a compiled .dxns schema (schema/compiler.cjs) plus an optional materializer layered on top — there is no putStruct that hand-writes a struct's shape directly, because struct is schema-dependent by design: the schema supplies field names/order/types, a materializer only decides what nicer decoded shape to produce from an already-schema-validated field map.

    Registry instances are plain, immutable-by-convention data — every put* method returns a new Registry, never mutates this — threaded explicitly through decode/encode/ schema.compile, never a global or a class with hidden state.

    Index
    materializers: Map<string, (fields: { [k: string]: unknown }) => unknown>
    resolver: ((name: string) => Compiled | undefined) | null
    structModules: Map<string, Function>
    structs: Map<string, Compiled>
    tagEncoders: Map<Function, [string, (value: unknown) => unknown]>
    tags: Map<string, (value: unknown) => unknown>
    trusted: boolean
    typeAliases: Map<string, unknown>
    • Parameters

      • name: string

      Returns ((fields: { [k: string]: unknown }) => unknown) | undefined

    • The reverse of fetchStructModule: given an application value's own class, finds the schema name it was registered under (if any) — what lets automatic encode-time validation recognize a plain JS class instance as "this is a Foo" without being told so explicitly.

      Parameters

      • klass: Function

      Returns string | undefined

    • Parameters

      • name: string

      Returns Function | undefined

    • Looks up a compiled schema by struct name, consulting the lazy resolver (if any) on a miss and caching the result. Whether schemas are all compiled up front or resolved on demand (a resolver reading a file, calling a schema service, ...) is entirely the caller's choice — this is what makes both paths look identical to everything else, which never needs to know which one is in play.

      Parameters

      • name: string

      Returns { compiled: Compiled; registry: export= } | undefined

    • Parameters

      • name: string

      Returns ((value: unknown) => unknown) | undefined

    • Parameters

      • klass: Function

      Returns [string, (value: unknown) => unknown] | undefined

    • Parameters

      • name: string

      Returns unknown

    • Parameters

      • resolver: (name: string) => Compiled | undefined

      Returns export=

    • Parameters

      • name: string
      • materializer: (fields: { [k: string]: unknown }) => unknown

      Returns export=

    • Declares which JS class a schema's data is expected to be — used only for {:reference, name} checks during encode-time validation. Decode-time reference checks don't need this: they carry an internal provenance marker regardless of materializer shape (schema/validated.cjs).

      Parameters

      • name: string
      • klass: Function

      Returns export=

    • Parameters

      • name: string
      • decoder: (value: unknown) => unknown

      Returns export=

    • The reverse of putTag: registers how to turn an application value (keyed by its constructor) back into @name value on encode — decode-side dispatch happens by wire tag name, encode needs to dispatch by JS class instead, so the two directions need separate tables.

      Parameters

      • klass: Function
      • name: string
      • encoder: (value: unknown) => unknown

      Returns export=

    • Marks (or unmarks) this registry as decoding a trusted source — the default. Currently the one thing this affects is keyword: trusted (the default) decodes it as a real, global Symbol.for; untrusted decodes it as DXNKeyword instead, so no decode path is ever forced through the global symbol registry's own never-garbage-collected interning for attacker-controlled text. symbol is deliberately unaffected either way.

      Parameters

      • trusted: boolean

      Returns export=