@enspirit/emb
Version:
A replacement for our Makefile-for-monorepos
26 lines (25 loc) • 787 B
TypeScript
import { DepList } from './types.js';
export type CollectionConfig<IDK extends PropertyKey, DPK extends PropertyKey> = {
idField: IDK;
depField: DPK;
};
export declare class EMBCollection<T extends Partial<Record<DPK, DepList>> & Record<IDK, string> & {
name: string;
}, IDK extends keyof T, DPK extends keyof T> {
private items;
readonly idField: IDK;
readonly depField: DPK;
private byId;
private byName;
constructor(items: Iterable<T>, cfg: CollectionConfig<IDK, DPK>);
/** All items (stable array iteration) */
get all(): Iterable<T>;
idOf(t: T): string;
depsOf(t: T): readonly string[];
matches(ref: string, opts?: {
multiple?: false;
}): T;
matches(ref: string, opts: {
multiple: true;
}): T[];
}