UNPKG

fs-nextra

Version:

Node.js fs next-gen extra (nextra) methods.

31 lines (30 loc) 1.26 kB
export declare type BufferEncoding = 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'; /** * @typedef {Object} ReadJSONOptions * @memberof fsn/nextra * @property {string} [encoding] The file encoding to use while reading * @property {Function} [reviver] The reviver function to pass to JSON.parse() */ export interface ReadJSONOptions { encoding?: BufferEncoding; reviver?: (key: any, value: any) => any; flag?: string | number; } /** * Reads a file and parses it into a javascript object. * @function readJson * @memberof fsn/nextra * @param {string} file The file path to the json file * @param {ReadJSONOptions|string} [options = {}] The options for reading json or the encoding string * @returns {Promise<Object>} */ /** * Reads a file and parses it into a javascript object. * @function readJSON * @memberof fsn/nextra * @param {string} file The file path to the json file * @param {ReadJSONOptions|string} [options = {}] The options for reading json or the encoding string * @returns {Promise<Object>} */ export declare function readJSON(file: string, options?: ReadJSONOptions | BufferEncoding): Promise<any>; export declare const readJson: typeof readJSON;