UNPKG

json-fusion

Version:

Json-Fusion is a Node.js library designed to streamline the process of loading, merging, and reflecting directory hierarchies in JSON files. With Json-Fusion, you can consolidate information scattered across different JSON files, and reflect your filesyst

66 lines (62 loc) 1.37 kB
type Pattern = string; type Extension = 'json' | 'yaml'; type ExportType = 'json' | 'yaml' | 'object'; interface Config { /** * specify the method return type * @default 'json' */ exportType?: ExportType; /** * ignore files * @default: undefined */ ignore?: Pattern[]; /** * set the current working directory * @default: './' */ cwd?: string; /** * set the output file path * @example 'dist/index.json' * @default undefined */ export?: string; /** * set the input file extensions * @example ['json', 'yaml'] * @default ['json'] */ extensions?: Extension[]; /** * if true, index.json will not be spread * @default false */ noSpreadIndex?: boolean; } interface ErrorReason { message: string; filePath: string; } declare class JsonFusionError extends Error { name: string; constructor(message: string, reasons: ErrorReason[]); } /** * * @param baseDir * @param config */ declare function jsonFusion(baseDir: string, config?: Config & { exportType?: 'json' | 'yaml'; }): Promise<string>; /** * * @param baseDir * @param config */ declare function jsonFusion<T = unknown>(baseDir: string, config: Config & { exportType: 'object'; }): Promise<T>; export { Config, JsonFusionError, jsonFusion };