UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

28 lines (27 loc) 730 B
/** * 解析带注释的 json 文件 * @param content 原始文件内容 * @returns json数据 * @example * ```ts * const text = `{ * // 这是一个注释 * "name": "foo", * "version": "1.0.0" // 末尾注释 * }`; * parseCommentJson(text); // { name: 'foo', version: '1.0.0' } * ``` */ export declare function parseCommentJson(content: string): Record<string, any>; /** * 获取带注释的 json 文件内容 * @param file 文件路径 * @returns json数据 * @example * ```ts * // tsconfig.json 中可能含有 // 注释 * const config = readCommentJson('./tsconfig.json'); * console.log(config.compilerOptions); * ``` */ export declare function readCommentJson(file: string): Record<string, any>;