Grounds
    Preparing search index...

    Function decode

    • Decodes bytes to a raw JavaScript value using the Relish wire format.

      Convenience wrapper around Decoder for one-shot decoding. For decoding multiple values or streaming scenarios, use Decoder directly.

      Parameters

      • bytes: Uint8Array

        Binary data to decode

      Returns Result<DecodedValue, DecodeError>

      Result containing decoded value, or DecodeError on validation failure

      Basic decoding:

      import { decode } from '@grounds/core';

      const bytes = new Uint8Array([0x02, 0x2a]); // U8(42)

      decode(bytes).match(
      (value) => console.log(value), // 42
      (error) => console.error(error.message)
      );

      Returns raw JavaScript values (DecodedValue), not wrapped RelishValue objects. This differs from the encode API which accepts RelishValue wrappers. The asymmetry simplifies consumption: decoded data can be used directly without unwrapping.

      • Decoder for cursor-based decoding with position tracking
      • encode for encoding values to bytes