releaseHas

tcmts.share.releaseHas · #gp7r3gl7 · term · runs anywhere

Whether a release (by its history entry) has a definition, by any name: what's in a release is read once.

import type { Share } from "#codebase/tcmts/share";

export function releaseHas(s: Pick<Share, "cb" | "cache">, causal: string, hash: string): boolean {
  let hashes = s.cache.releases.get(causal);
  if (!hashes) {
    const c = s.cb.store.causal(causal);
    hashes = new Set(c ? s.cb.store.namespaceRows(c.namespace).map((r) => r.hash) : []);
    s.cache.releases.set(causal, hashes);
  }
  return hashes.has(hash);
}

uses

used by