Skip to content

@web-engine-dev/resources


@web-engine-dev/resources / deltaEncode

Function: deltaEncode()

deltaEncode(value, fields): Record<string, unknown>

Returns only the fields whose values differ from their schema defaults.

This is the serialization step: instead of storing every field, we store only the delta (non-default values). This produces compact scene files and makes forward-compatibility straightforward -- new fields with sensible defaults are automatically applied on load without needing stored data.

Parameters

value

Readonly<Record<string, unknown>>

The full resource value object

fields

Readonly<Record<string, ResourceFieldDescriptor>>

The field descriptor map

Returns

Record<string, unknown>

An object containing only non-default field values (deep-cloned)

Proprietary software. All rights reserved.