@speedy/json-extends
Version:
Extend a JSON file with one or many existing files.
48 lines (47 loc) • 1.46 kB
TypeScript
export declare namespace json {
/**
* Retrieve a JSON file asynchronous. Supports `extends` with one or many existing JSON files.
*
* @template T
* @param {string} filePath path to a JSON file.
* @param {{ [id: string]: string }} [namedExtends] A key value pair of named extends paths.
*
* @example
* import { json } from "@speedy/json-extends";
*
* const named = {
* "@speedy/commit-msg-hook:latest": "./node_modules/config/config.json"
* };
*
* json.read("local-config.json", named)
* .then(content => {
* // json content
* });
*
* @returns {Promise<T>}
*/
function read<T>(filePath: string, namedExtends?: {
[id: string]: string;
}): Promise<T>;
/**
* Retrieve a JSON file synchronously. Supports `extends` with one or many existing JSON files.
*
* @template T
* @param {string} filePath path to a JSON file.
* @param {{ [id: string]: string }} [namedExtends] A key value pair of named extends paths.
*
* @example
* import { json } from "@speedy/json-extends";
*
* const named = {
* "@speedy/commit-msg-hook:latest": "./node_modules/config/config.json"
* };
*
* const content = json.readSync("local-config.json", named);
*
* @returns {T}
*/
function readSync<T>(filePath: string, namedExtends?: {
[id: string]: string;
}): T;
}