/** * Compression utilities for BalanceHistoryCache * * This module provides compression/decompression functions to reduce * the storage size of balance history cache in app.json. * * Strategy: Run-Length Encoding (RLE) on absolute values * - If a value repeats 2+ times: store as [value, count] * - Otherwise: store the value directly * * Format: * - balances array contains numbers or RLE tuples [value, count] * - All values are absolute (no delta encoding to preserve precision) */ import type { BalanceHistoryCache, BalanceHistoryDataCache, CompressedBalanceHistoryCache, CompressedBalanceHistoryDataCache, CompressedBalanceEntry } from "@ledgerhq/types-live"; export type { CompressedBalanceHistoryCache, CompressedBalanceHistoryDataCache, CompressedBalanceEntry, }; /** * Compress a single BalanceHistoryDataCache using RLE on absolute values * * @param cache - The cache to compress * @returns Compressed cache with RLE-compressed balances * @example * // Input: [1000000, 1000000, 1000000, 1000500, 1000500] * // Output: [[1000000, 3], [1000500, 2]] * compressBalanceHistoryDataCache({ * latestDate: 1234567890, * balances: [1000000, 1000000, 1000000, 1000500, 1000500] * }) */ export declare function compressBalanceHistoryDataCache(cache: BalanceHistoryDataCache): CompressedBalanceHistoryDataCache; /** * Decompress a CompressedBalanceHistoryDataCache back to BalanceHistoryDataCache * Handles backward compatibility with uncompressed format (array of absolute numbers) * * @param data - The compressed cache (or uncompressed for backward compatibility) * @returns Decompressed cache with absolute balances * @example * // Input: [[1000000, 3], [1000500, 2]] * // Output: [1000000, 1000000, 1000000, 1000500, 1000500] * decompressBalanceHistoryDataCache({ * latestDate: 1234567890, * balances: [[1000000, 3], [1000500, 2]] * }) */ export declare function decompressBalanceHistoryDataCache(data: CompressedBalanceHistoryDataCache | BalanceHistoryDataCache | null | undefined): BalanceHistoryDataCache; export declare function compressBalanceHistoryCache(cache: BalanceHistoryCache | null | undefined): CompressedBalanceHistoryCache; /** * Decompress a CompressedBalanceHistoryCache back to BalanceHistoryCache * * @param data - The compressed cache (or uncompressed for backward compatibility) * @returns Decompressed cache * @example * decompressBalanceHistoryCache({ * HOUR: { latestDate: 1000, balances: [[100, 3]] }, * DAY: { latestDate: 2000, balances: [200, 200] }, * WEEK: { latestDate: 3000, balances: [300] } * }) * // Returns: { * // HOUR: { latestDate: 1000, balances: [100, 100, 100] }, * // DAY: { latestDate: 2000, balances: [200, 200] }, * // WEEK: { latestDate: 3000, balances: [300] } * // } */ export declare function decompressBalanceHistoryCache(data: CompressedBalanceHistoryCache | BalanceHistoryCache | null | undefined): BalanceHistoryCache; //# sourceMappingURL=balanceHistoryCacheCompression.d.ts.map