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

    Function encode

    • Encodes a value back to .dxn text. Single-line, minimal-whitespace by default; pass pretty: true for multi-line, indented output instead: the top-level collection one entry per line, a nested one on one line when it fits (indent: then sets spaces per nesting level, default 2, and width: the columns that line must fit in, default 80). Both produce the exact same value on the way back through decode — pretty/indent/width are a rendering choice, never a semantic one. Throws DXNError for a value with no DXN representation, or that fails schema validation.

      Automatically validates every DXNStruct or registered application class instance found anywhere in value against its own schema (registry:'s compiled schemas) — set validate: false to skip. A schema: opt additionally validates value itself against that specific schema — the one case the automatic walk can't cover on its own, a nameless top-level plain object or unregistered struct.

      Nothing is converted to make a value match its declared type (DXN.md §4.7): a host value always means the same DXN type, schema or not, so a number for a :rational field is refused rather than turned into a DXNRational. Use the DXN* classes to say which type a value is.

      Parameters

      • value: unknown
      • Optionalopts: {
            indent?: number;
            pretty?: boolean;
            registry?: export=;
            schema?: string;
            validate?: boolean;
            width?: number;
        } = {}

      Returns string