searchLibraries

tcmts.registry.searchLibraries · #nwfrggcn · term · runs on the server

uses tcmts.registry.registryOpen, which uses node:crypto

Search every library's newest mirrored version: by name, words in docs, or a type (:(s: Shape) => number), as tcm find does, or as by says (matchLibraries).

import { libraries, matchLibraries, registryOpen } from "#codebase/tcmts/registry";
import type { LibraryHits } from "#codebase/tcmts/registry";
import { shareNow } from "#codebase/tcmts/share";

export async function searchLibraries(q: string, by?: string): Promise<LibraryHits[]> {
  if (!q.trim()) return [];
  registryOpen();
  return matchLibraries(
    shareNow(),
    (await libraries()).filter((l) => l.latest.mount && l.latest.state === "mirrored"),
    q,
    by,
  );
}

uses

used by