import { Options as CosmiconfigOptions } from "cosmiconfig"; import chalk from "chalk"; import type DataFile from "./data-file"; import { PredicateFunction, DataPath, FileFormat, ValueFunction, Key, Logger } from "./types"; /** @ignore */ declare let prettier: any; export { prettier }; /** @ignore */ export declare const supportedFileExtensions: Record; /** * Returns given string after making it's first letter uppercase. * * @ignore * @param string is input to make first letter uppercase. */ export declare function ucFirst(string: string): string; /** * Returns `input` if it is an array, otherwise an array containing `input` as only element. * * @ignore */ export declare function arrify(input: T | T[]): T[]; /** * Determines file format from file name. * * @ignore * @param path is the path of the file * @returns file format. */ export declare function getFormatFromFileName(path: string): FileFormat; /** * Reads and parses data and determines it's format. * * @ignore * @param path is the path of the file. * @param defaultFormat Default data to be used if file does not exist. * @param defaultData Default data to be used if file does not exist. * @param rootDataPath is the path to return data from. * @returns data and format. * @throws if file cannot be parsed, content is empty, number or string. */ export declare function readData(path: string, defaultData: object, rootDataPath?: DataPath): Promise<{ format: FileFormat; data: any; found: boolean; }>; /** * Returns given string or array path as a string. * * @ignore * @param path is the path to return as a string. * @returns stringified path. */ export declare function getStringPath(path: DataPath): Key; /** * Returns given string or array path as a string. * * @ignore * @param path is the path to return as an array. * @returns arrified path. */ export declare function getArrayPath(path: DataPath): Key[]; /** * Returns `rootDataPath` and `path` of file for cosmiconfig. * * @ignore * @param module is the module to load config for. * @param config are options for cosmiconfig. See {@link https://www.npmjs.com/package/cosmiconfig#cosmiconfigoptions cosmiconfig options}. */ export declare function getCosmiconfigResult(module: string, defaultData: object, options?: CosmiconfigOptions, searchFrom?: string, rootDataPath?: DataPath): Promise<{ format: FileFormat; data: object; path: string; rootDataPath?: DataPath; found: boolean; }>; /** * Returns prettier configuration for given file path. * * @ignore * @param path is the file path to get prettier configuration. * @returns prettier configuration. */ export declare function getPrettierConfig(path: string): Promise | undefined>; /** * If given value is a function, execute it with related data and return result of it. If it is a value, return it. * * @ignore * @param valueOrFunction is the function to execute or value to return. * @param dataFile is the data file object * @param path is the path of the the value. * @returns value or result of the function. */ export declare function evaluate(valueOrFunction: ValueFunction | any, dataFile: DataFile, path?: DataPath): any; /** * If given value is a function, execute it with related data and return result of it. If it is a value, return it. * * @ignore * @param valueOrFunction is the function to test whether operation should be performed. If result is false, operation is not performed. * @param dataFile is the data file object * @param path is the path of the the value. * @returns whether given operation should be done. * * @example * const predicator = (val, key, path, data) => path === "pass" || val.length > 4; * const shouldPass = predictae(predicator, "George", data, "name") */ export declare function predicate(fn: PredicateFunction | undefined, dataFile: DataFile, path?: DataPath): boolean; /** * Tests whether given value is a DataPath * * @ignore */ export declare function isManipulationOptions(value: any): value is { if?: PredicateFunction; }; /** * Tests whether given value is empty. Empty values are empty objects, maps, sets, string, `undefined` and `null`. * * @ignore * @returns whether given value is empty. */ export declare function isEmpty(value: any): boolean; /** * To disable logging, use this logger. * @ignore * */ export declare const noLogger: Logger; /** @ignore */ export declare const em: chalk.Chalk; //# sourceMappingURL=helper.d.ts.map