@plurid/plurid-engine
Version:
Plurid Engine and Utility Functions
45 lines (44 loc) • 1.43 kB
TypeScript
import { IsoMatcherData, IsoMatcherIndexedPlane, IsoMatcherPlaneResult, IsoMatcherRouteResult } from '@plurid/plurid-data';
/**
* The `IsoMatcher` gathers all the known information about `routes` and `planes`
* and matches client-side or server-side, in-browser or in-plurid.
*/
declare class IsoMatcher<C> {
private origin;
private routesIndex;
private planesIndex;
private routesKeys;
private planesKeys;
constructor(data: IsoMatcherData<C>, origin?: string);
/**
* Matches a `path` with a known `route` or `plane`,
* based on the strategy imposed by the `context`.
*
* @param path
* @param context
*/
match(path: string, context: 'route'): IsoMatcherRouteResult<C> | undefined;
match(path: string): IsoMatcherPlaneResult<C> | undefined;
match(path: string, context: 'plane'): IsoMatcherPlaneResult<C> | undefined;
/**
* Dynammically update the planes and routes indexes.
*
* @param data
*/
index(data: IsoMatcherData<C>): void;
/**
* Clear all data.
*
*/
clear(): void;
getPlanesIndex(): Map<string, IsoMatcherIndexedPlane<C>>;
/**
* Creates a common data structure able to match and route accordingly.
*
*/
private updateIndexes;
private indexPlanes;
private matchPlane;
private matchRoute;
}
export default IsoMatcher;