@hemjs/gather
Version:
A lightweight library for collecting and merging configuration from multiple sources
51 lines (50 loc) • 1.59 kB
TypeScript
import type { Type } from '@armscye/core';
import type { Module } from '@armscye/module';
export type ConfigProvider = Type<Module> | Record<string, any> | ((...args: any[]) => any);
/**
* Gather configuration generated by configuration providers.
*/
export declare class Gather {
private config;
/**
* Create a new Gather instance.
* @param providers the configuration providers
*/
constructor(providers?: Array<ConfigProvider>);
/**
* Returns merged configurations object
* @returns merged configurations object
*/
getMerged(): Record<string, any>;
/**
* Iterate providers, merging config from each with the previous.
* @param providers an array of configuration providers
* @returns merged configurations object
*/
private loadFromProviders;
/**
* Resolve a provider.
* @param providers an array of configuration providers
* @returns merged configurations object
*/
private resolveProvider;
/**
* Check if the given provider has the register method.
* @param provider the provider to check
* @returns whether the given provider has the register method
*/
private isModuleProvider;
/**
* Map a function to a class.
* @param instance the function to map
* @returns the resulting class
*/
private mapToClass;
/**
* Assign unique token to a metatype.
* @param metatype the metatype to assign token
* @param token the unique token
* @returns the resulting metatype
*/
private assignToken;
}