Library API
    Preparing search index...

    Function stringify

    • Serializes objects for string-safe stashing in WebStorage, Cache, etc. Uses compact tagged strings (~n, ~t, ~u, ~y) by default for primitive types, or oneKey object envelopes when compact: false.

      Type Parameters

      • T

      Parameters

      • obj: T

        The object to stringify

      • Optionaloptions: StringifyOptions

        Optional serialization options (e.g. { signed: true, secret: 'key', compact: true })

      Returns string

      The safely stringified representation

      stringify(123n); // '"~n123"'
      stringify(new Date()); // '"~t1704067200000"'
      stringify(Symbol.for('app')); // '"~y@@(app)"'
      stringify(data, { signed: true, secret: 'my-secret' }); // '$sig:e8b7...:{"id":"~n123"}'