UNPKG

@xcrap/factory

Version:

Xcrap Factory is a set of utilities for dynamically creating instances of clients, extractors, and parsing models, making it easier to configure and extend scraping and parsing pipelines.

12 lines (11 loc) 653 B
export type ClientConstructor<T> = new (options: any) => T; export type CreateClientConfig<TClients extends Record<string, ClientConstructor<any>>> = { allowedClients: TClients; }; export type CreateClientOptions<TClients extends Record<string, ClientConstructor<any>>> = { config: CreateClientConfig<TClients>; type: keyof TClients; options: ConstructorParameters<TClients[keyof TClients]>[0]; }; export declare function createClient<TClients extends Record<string, ClientConstructor<any>>>({ config: { allowedClients }, type, options }: CreateClientOptions<TClients>): InstanceType<TClients[typeof type]>; export default createClient;