@augment-vir/node-js
Advanced tools
Comparing version 10.0.0 to 11.0.0
@@ -0,5 +1,9 @@ | ||
import { PartialAndNullable } from '@augment-vir/common'; | ||
import { JsonArray, JsonObject, JsonValue } from 'type-fest'; | ||
export declare function readJson<T extends JsonValue>(path: string): Promise<T>; | ||
export declare function writeJson<T extends JsonObject | JsonArray>(path: string, data: T): Promise<void>; | ||
export declare function appendJson<T extends JsonObject | JsonArray>(path: string, data: T): Promise<void>; | ||
export type WriteJsonOptions = PartialAndNullable<{ | ||
includeTrailingNewLine: boolean; | ||
}>; | ||
export declare function writeJson<T extends JsonObject | JsonArray>(path: string, data: T, options?: WriteJsonOptions | undefined): Promise<void>; | ||
export declare function appendJson<T extends JsonObject | JsonArray>(path: string, data: T, options?: WriteJsonOptions | undefined): Promise<void>; | ||
//# sourceMappingURL=json.d.ts.map |
@@ -18,8 +18,9 @@ "use strict"; | ||
exports.readJson = readJson; | ||
async function writeJson(path, data) { | ||
async function writeJson(path, data, options) { | ||
await (0, fs_extra_1.ensureDir)((0, path_1.dirname)(path)); | ||
await (0, promises_1.writeFile)(path, JSON.stringify(data, null, 4)); | ||
const trailingNewLine = (options === null || options === void 0 ? void 0 : options.includeTrailingNewLine) ? '\n' : ''; | ||
await (0, promises_1.writeFile)(path, JSON.stringify(data, null, 4) + trailingNewLine); | ||
} | ||
exports.writeJson = writeJson; | ||
async function appendJson(path, data) { | ||
async function appendJson(path, data, options) { | ||
let currentJson = await readJson(path); | ||
@@ -50,4 +51,4 @@ if (typeof currentJson !== 'object') { | ||
} | ||
await writeJson(path, withAppendedData); | ||
await writeJson(path, withAppendedData, options); | ||
} | ||
exports.appendJson = appendJson; |
{ | ||
"name": "@augment-vir/node-js", | ||
"version": "10.0.0", | ||
"version": "11.0.0", | ||
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/node-js", | ||
@@ -5,0 +5,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37944
908