UNPKG

@mnrendra/read-stacked-json

Version:

Read the stacked JSON file from any sub-directory in your project.

79 lines (73 loc) 2.43 kB
import { SkippedStacks } from '@mnrendra/read-stacked-file'; export { SkippedStacks, ValidSkippedStacks, validateSkippedStacks } from '@mnrendra/read-stacked-file'; /** * `JSON` type (an alias for `Record<string, any>`). * * @see https://github.com/mnrendra/read-stacked-json#readme */ type JSONType = Record<string, any>; /** * The options interface. * * @see https://github.com/mnrendra/read-stacked-json#readme */ interface Options { /** * To tell the parser to parse using native `JSON` or `JSON5`. * * @default false * * @see https://github.com/mnrendra/read-stacked-json#readme */ isJSON5?: boolean; /** * A name or a list of names of stack traces that need to be skipped. * * @default [] * * @see https://github.com/mnrendra/read-stacked-json#readme */ skippedStacks?: SkippedStacks; /** * The `Error.stackTraceLimit` property specifies the number of stack frames * to be collected by a stack trace. * * @default 10 * * @see https://github.com/mnrendra/read-stacked-json#readme */ stackTraceLimit?: number; /** * If set to `true`, it will use `process.cwd()` instead of * `@mnrendra/stack-trace` to get the target path. * * @default false * * @see https://github.com/mnrendra/read-stacked-json#readme */ useCWD?: boolean; } /** * Parse the stacked JSON file asynchronously. * * @param {string} fileName - Targeted JSON file to be obtained. * @param {Options} [options] - Optional params. * * @returns {Promise<Record<string, any>>} Obtained value. * * @see https://github.com/mnrendra/read-stacked-json#readme */ declare const main$1: <ParsedJSON extends JSONType = JSONType>(fileName: string, { isJSON5, skippedStacks, stackTraceLimit, useCWD }?: Options) => Promise<ParsedJSON>; /** * Parse the stacked JSON file synchronously. * * @param {string} fileName - Targeted JSON file to be obtained. * @param {Options} [options] - Optional params. * * @returns {Record<string, any>} Obtained value. * * @see https://github.com/mnrendra/read-stacked-json#readme */ declare const main: <ParsedJSON extends JSONType = JSONType>(fileName: string, { isJSON5, skippedStacks, stackTraceLimit, useCWD }?: Options) => ParsedJSON; export { type JSONType, type Options, main$1 as read, main as readSync }; //# sourceMappingURL=index.d.ts.map