core/loaders/definition.loader.ts
core/loaders/definition.loader.ts is a file in Bane's Lab Site. 28 lines of code and 7 definitions.
import { ANATOMY_TREES } from "#core/registries/anatomy.registry";
import type { DefinitionIndex } from "#types/definition.types";
import type { DefinitionLocation } from "#types/anatomy.types";
import type { EvidenceNode } from "#types/evidence.types";
import { definitionIndexOf } from "#core/converters/definition.converter";
let held: DefinitionIndex | null = null;
const index = function index(): DefinitionIndex {
held ??= definitionIndexOf(ANATOMY_TREES.map((tree) => tree.snapshot.tree));
return held;
};
export const listDefinitions = function listDefinitions(): readonly DefinitionLocation[] {
return index().listDefinitions();
};
export const resolvePath = function resolvePath(text: string, from: string | null = null): string | null {
return index().resolvePath(text, from);
};
export const resolveFolder = function resolveFolder(text: string, from: string | null = null): string | null {
return index().resolveFolder(text, from);
};
export const locateNode = function locateNode(node: EvidenceNode): string | null {
return index().locateNode(node);
};
export const citedDefinition = function citedDefinition(
name: string,
file: string | null = null,
): DefinitionLocation | null {
return index().citedDefinition(name, file);
};