import { type MaybeMap } from '../value/maybe.type'; import { type ObjectFieldEqualityChecker } from './object.equal'; import { type EmptyArray } from '../array/array'; /** * A partial "delta" of the given entry. It only contains values that changed from the last entry. * * - Undefined field values mean the entry should inherit the previous entry's values. * - Null field values in a field mean the value has been cleared and should be excluded from future entries. */ export type CompressedObjectDeltaArrayDeltaEntry = MaybeMap; /** * A compressed object array. * * The first object is always fully expanded. Objects are in order of the delta changes. */ export type CompressedObjectDeltaArray = [T, ...CompressedObjectDeltaArrayDeltaEntry[]]; /** * Compresses the input objects array to a CompressedObjectDeltaArray. */ export type ObjectDeltaArrayCompressorCompressFunction = ((uncompressed: T[]) => CompressedObjectDeltaArray) & ((uncompressed: EmptyArray) => EmptyArray); /** * Expands a CompressedObjectDeltaArray to an array of objects. */ export type ObjectDeltaArrayCompressorExpandFunction = ((compressed: CompressedObjectDeltaArray) => T[]) & ((compressed: EmptyArray) => EmptyArray); /** * Configuration for an object delta array compressor. */ export interface ObjectDeltaArrayCompressorConfig { /** * Fields to capture as part of the compressor. */ readonly equalityChecker: ObjectFieldEqualityChecker; } /** * An object delta array compressor. */ export interface ObjectDeltaArrayCompressor { readonly _equalityChecker: ObjectFieldEqualityChecker; readonly compress: ObjectDeltaArrayCompressorCompressFunction; readonly expand: ObjectDeltaArrayCompressorExpandFunction; } /** * Creates an {@link ObjectDeltaArrayCompressor} that can compress and expand arrays of objects using delta encoding. * * The first object is stored fully. Subsequent objects store only fields that changed from the previous entry. * Null in a delta entry means the field was cleared. Undefined (missing key) means no change. * * @param config - Configuration with the equality checker that defines which fields to track * @returns A compressor with `compress` and `expand` methods */ export declare function objectDeltaArrayCompressor(config: ObjectDeltaArrayCompressorConfig): ObjectDeltaArrayCompressor;