API reference
seniority/lilconfig
Every export of seniority/lilconfig, with its signature and doc comment: lilconfig, lilconfigSync, defaultLoadersSync, defaultLoaders, plus 11 types.
import { lilconfig, lilconfigSync, defaultLoadersSync, … } from 'seniority/lilconfig';Functions
lilconfig
The async explorer. Its five keys, in this order, are asserted against cosmiconfig's.
function lilconfig(name: string, options?: Options): AsyncSearcher;| Parameter | Type |
|---|---|
name | string |
options (optional) | Options |
Returns AsyncSearcher
lilconfigSync
The sync explorer. Same walk, fs.accessSync/fs.readFileSync, and require for scripts.
function lilconfigSync(name: string, options?: OptionsSync): SyncSearcher;| Parameter | Type |
|---|---|
name | string |
options (optional) | OptionsSync |
Returns SyncSearcher
Constants
defaultLoaders
lilconfig's async table: import() for the three script extensions, JSON.parse for data.
const defaultLoaders: Loaders;defaultLoadersSync
lilconfig's sync table. .json is require, not JSON.parse — that difference is graded.
const defaultLoadersSync: LoadersSync;Interfaces
AsyncSearcher
interface AsyncSearcher extends ClearCaches {
search: (searchFrom?: string) => Promise<LilconfigResult>;
load: (filepath: string) => Promise<LilconfigResult>;
}Options
interface Options extends OptionsBase {
loaders?: Loaders;
transform?: Transform;
}OptionsSync
interface OptionsSync extends OptionsBase {
loaders?: LoadersSync;
transform?: TransformSync;
}SyncSearcher
interface SyncSearcher extends ClearCaches {
search: (searchFrom?: string) => LilconfigResult;
load: (filepath: string) => LilconfigResult;
}Types
LilconfigResult
type LilconfigResult = null | {
filepath: string;
config: unknown;
isEmpty?: boolean;
};Loader
type Loader = LoaderSync | ((filepath: string, content: string) => Promise<unknown>);Loaders
type Loaders = Record<string, Loader>;LoadersSync
type LoadersSync = Record<string, LoaderSync>;LoaderSync
type LoaderSync = (filepath: string, content: string) => unknown;Transform
type Transform = TransformSync | ((result: LilconfigResult) => Promise<LilconfigResult>);TransformSync
type TransformSync = (result: LilconfigResult) => LilconfigResult;