This repository has been archived on 2023-08-31. You can view files and clone it, but cannot push or open issues or pull requests.
relay-plugin-registry/src/storage/factory.ts

19 lines
478 B
TypeScript

import { RegistryStorage, RegistryStorageConstructor } from "../types.js";
const backends = new Map<string, RegistryStorageConstructor>();
export function register(
type: string,
instance: new (opts?: any) => RegistryStorage
): void {
backends.set(type, instance);
}
export function get(type: string, opts = {}): RegistryStorage {
const ctor = backends.get(type);
return new ctor(opts);
}
export function has(type: string): boolean {
return backends.has(type);
}