recordText

tcmts.cli.libraries.recordText · #gwq2d5ii · term · runs anywhere

A record's text: its entries by name, one field a line, so a merge or a diff reads it line by line.

import type { LibraryEntry } from "#codebase/tcmts/cli/libraries";

export function recordText(entries: Record<string, LibraryEntry>): string {
  const sorted = Object.entries(entries).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
  return `${JSON.stringify(Object.fromEntries(sorted), null, 2)}\n`;
}

uses

used by