namesIn

tcmts.cli.diff.namesIn · #2frsbxki · term · runs anywhere

import { keyPath } from "#codebase/tcmts/cli/diff";
import type { NameState } from "#codebase/tcmts/cli/diff";

export function namesIn(state: NameState): (hash: string) => string | undefined {
  const byHash = new Map<string, string>();
  for (const [k, hs] of [...state].sort(([a], [b]) => a.localeCompare(b))) for (const h of hs) if (!byHash.has(h)) byHash.set(h, keyPath(k));
  return (h) => byHash.get(h);
}

uses

used by