UNPKG

mimic-tree

Version:

mimic-tree is a Node.js library for creating dynamic data trees that mimic the structure of source data. It reproduces the original folder paths and file structures like JSON or YAML with different values, maintaining the integrity of the original structu

93 lines (90 loc) 1.35 kB
type Extension = 'json' | 'yaml'; type Primitive = string | number | boolean | null | undefined; type Pattern = string; /** * * @params value * @params context * @returns Primitive | Promise<Primitive> */ type Converter = (value: Primitive, context: ConvertContext) => Primitive | Promise<Primitive>; /** * */ interface Config { /** * * @default process.cwd() */ cwd?: string; /** * */ src: string; /** * */ dist: string; /** * */ ignore?: Pattern[]; /** * * @param value * @param context */ convert: Converter; /** * * @default ['json'] */ extensions?: Extension[]; /** * * @default true */ cache?: boolean; /** * @default false */ parallel?: number | false; } interface ConvertContext { /** * */ key: string; /** * */ value: Primitive; /** * */ file: FileContext; } interface FileContext { /** * */ filePath: string; /** * */ fileName: string; /** * */ extension: Extension; /** * */ outputFile: string; /** * */ json: unknown; } declare function mimicTree(config: Config): Promise<void>; export { Config as Option, mimicTree };