Cotton code
18 lines · 670 B · TypeScriptRaw
/** * Where a looked-up row's details came from (books.ts, films.ts): `filled_from` is a JSON object of column to * source, each new fill said over the ones the row held. *//** The row's `filled_from` with `more` said over it. */export function filledFrom(held: unknown, more: Record<string, string>): string {  let was: Record<string, unknown> = {};  if (typeof held === "string" && held.trim()) {    try {      const parsed = JSON.parse(held) as unknown;      if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) was = parsed as Record<string, unknown>;    } catch {      was = {};    }  }  return JSON.stringify({ ...was, ...more });}