leanRecord

tcmts.cli.sync.leanRecord · #63aof4cy · term · runs anywhere

A definition as sent to a codebase that derives what it can itself (x-tcm-records: lean, which a tcm says it takes): its IR cut to its head (its tag, lineage salt and JSX runtime: what reading the code back takes; the rest is what the source gives, and a receiver keeps its own), and no type shape. Most of a record's bytes go. A file's IR is its content, so a file goes whole.

import { defParts } from "#codebase/tcmts/core/ir";
import type { DefRecord } from "#codebase/tcmts/core/types";

export function leanRecord(r: DefRecord): DefRecord {
  if (r.kind === "file") return r;
  const { shape: _, ...rest } = r;
  return { ...rest, ir: JSON.stringify(defParts(r.ir).head) };
}

uses

used by