From 74cd5536af05d4fa583a46d62db2ad90f0a35612 Mon Sep 17 00:00:00 2001 From: Ladd Date: Mon, 23 Dec 2024 23:34:28 -0600 Subject: [PATCH] comments --- src/lossy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lossy.ts b/src/lossy.ts index 83f1b66..2a0b363 100644 --- a/src/lossy.ts +++ b/src/lossy.ts @@ -10,7 +10,8 @@ import {DeltaFilter} from "./types"; type Resolver = (losslessView: LosslessViewMany) => unknown; -export function firstValueFromCollapsedDelta(delta: CollapsedDelta, key: string): string | undefined { +// Extract a particular value from a delta's pointers +export function valueFromCollapsedDelta(delta: CollapsedDelta, key: string): string | undefined { const pointers = delta.pointers; for (const pointer of pointers || []) { const [[k, value]] = Object.entries(pointer); @@ -20,6 +21,7 @@ export function firstValueFromCollapsedDelta(delta: CollapsedDelta, key: string) } } +// Example function for resolving a value for an entity by taking the first value we find export function firstValueFromLosslessViewOne(ent: LosslessViewOne, key: string): {delta: CollapsedDelta, value: string} | undefined { for (const delta of ent.properties[key] || []) { const value = firstValueFromCollapsedDelta(delta, key);