UNPKG

@hyperlane-xyz/utils

Version:

General utilities and types for the Hyperlane network

37 lines 1.6 kB
/** * Reads and parses a JSON file. */ export declare function readJson<T>(filepath: string): T; /** * Attempts to read and parse a JSON file, returning null if it fails. */ export declare function tryReadJson<T>(filepath: string): T | null; /** * Writes an object as JSON to a file with a trailing newline. * Uses stringifyObject to properly handle ethers BigNumber serialization. */ export declare function writeJson(filepath: string, obj: unknown): void; /** * Merges an object with existing JSON file content and writes the result. * If the file doesn't exist, writes the object directly. */ export declare function mergeJson<T extends Record<string, unknown>>(filepath: string, obj: T): void; /** * Reads JSON from a directory with the specified filename. */ export declare function readJsonFromDir<T>(directory: string, filename: string): T; /** * Writes JSON to a directory with the specified filename. */ export declare function writeJsonToDir(directory: string, filename: string, obj: unknown): void; /** * Merges JSON in a directory with the specified filename. */ export declare function mergeJsonInDir<T extends Record<string, unknown>>(directory: string, filename: string, obj: T): void; /** * Write JSON to file, optionally preserving existing values for keys. * If appendMode is true, preserves all existing keys and their values, * only adding new keys from newData that don't exist in the file. */ export declare function writeJsonWithAppendMode(filepath: string, newData: Record<string, unknown>, appendMode: boolean): void; //# sourceMappingURL=json.d.ts.map