Evolution SDK

OriginalBytes.ts

OriginalBytes overview

Keeps the exact bytes a value was decoded from.

The ledger hashes and signs the original bytes of a value, not a fresh encoding of it. A decoder records the bytes it read against the object it returns. An encoder that finds recorded bytes for the object it is given writes those bytes back unchanged. A new or edited value is a new object, so it has no recorded bytes and gets the default encoding.

Entries are held in a WeakMap, so they are released with their object.

Added in v2.0.0


Table of contents


cache

get

Get the bytes that value was decoded from, if any were recorded.

Signature

export declare const get: (value: object) => Uint8Array | undefined

Added in v2.0.0

record

Record the bytes that value was decoded from. The bytes are copied, so a caller that later changes its input buffer does not change the record.

Signature

export declare const record: <A extends object>(value: A, bytes: Uint8Array) => A

Added in v2.0.0

On this page