@reliverse/relifso 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/impl/mkdirs.d.ts +2 -1
- package/bin/impl/output-json.d.ts +2 -2
- package/bin/impl/write-json.d.ts +2 -2
- package/bin/impl/write-json.js +4 -4
- package/bin/mod.d.ts +13 -1
- package/bin/mod.js +21 -2
- package/package.json +1 -1
package/bin/impl/mkdirs.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
interface MakeDirectoryOptions {
|
|
2
2
|
recursive?: boolean;
|
|
3
3
|
mode?: number | string;
|
|
4
4
|
}
|
|
5
5
|
export declare function mkdirsSync(dir: string, options?: MakeDirectoryOptions): string | undefined;
|
|
6
6
|
export declare function mkdirs(dir: string, options?: MakeDirectoryOptions): Promise<string | undefined>;
|
|
7
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param file - The path to the file.
|
|
5
5
|
* @param data - The JSON data to write.
|
|
6
|
-
* @param options - Options for writing the JSON file (e.g., replacer,
|
|
6
|
+
* @param options - Options for writing the JSON file (e.g., replacer, spaces).
|
|
7
7
|
*/
|
|
8
8
|
export declare function outputJsonSync(file: string, data: unknown, options?: unknown): void;
|
|
9
9
|
/**
|
|
@@ -11,6 +11,6 @@ export declare function outputJsonSync(file: string, data: unknown, options?: un
|
|
|
11
11
|
*
|
|
12
12
|
* @param file - The path to the file.
|
|
13
13
|
* @param data - The JSON data to write.
|
|
14
|
-
* @param options - Options for writing the JSON file (e.g., replacer,
|
|
14
|
+
* @param options - Options for writing the JSON file (e.g., replacer, spaces).
|
|
15
15
|
*/
|
|
16
16
|
export declare function outputJson(file: string, data: unknown, options?: unknown): Promise<void>;
|
package/bin/impl/write-json.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Mode, OpenMode } from "node:fs";
|
|
2
2
|
export interface JsonStringifyOptions {
|
|
3
3
|
replacer?: (key: string, value: unknown) => unknown | (number | string)[] | null;
|
|
4
|
-
|
|
4
|
+
spaces?: string | number;
|
|
5
5
|
}
|
|
6
6
|
export interface WriteJsonOptions {
|
|
7
7
|
encoding?: BufferEncoding | null;
|
|
8
8
|
mode?: Mode;
|
|
9
9
|
flag?: OpenMode;
|
|
10
10
|
replacer?: (key: string, value: unknown) => unknown | (number | string)[] | null;
|
|
11
|
-
|
|
11
|
+
spaces?: string | number;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Synchronously writes an object to a JSON file.
|
package/bin/impl/write-json.js
CHANGED
|
@@ -2,21 +2,21 @@ import { writeFileSync } from "./write-file.js";
|
|
|
2
2
|
import { writeFile } from "./write-file.js";
|
|
3
3
|
export function writeJsonSync(file, object, options = {}) {
|
|
4
4
|
const replacer = options.replacer === void 0 ? null : options.replacer;
|
|
5
|
-
const
|
|
5
|
+
const spaces = options.spaces === void 0 ? 2 : options.spaces;
|
|
6
6
|
const fileWriteOpts = {};
|
|
7
7
|
if (options.encoding !== void 0) fileWriteOpts.encoding = options.encoding;
|
|
8
8
|
if (options.mode !== void 0) fileWriteOpts.mode = options.mode;
|
|
9
9
|
if (options.flag !== void 0) fileWriteOpts.flag = options.flag.toString();
|
|
10
|
-
const str = JSON.stringify(object, replacer,
|
|
10
|
+
const str = JSON.stringify(object, replacer, spaces);
|
|
11
11
|
writeFileSync(file, str, fileWriteOpts);
|
|
12
12
|
}
|
|
13
13
|
export async function writeJson(file, object, options = {}) {
|
|
14
14
|
const replacer = options.replacer === void 0 ? null : options.replacer;
|
|
15
|
-
const
|
|
15
|
+
const spaces = options.spaces === void 0 ? 2 : options.spaces;
|
|
16
16
|
const fileWriteOpts = {};
|
|
17
17
|
if (options.encoding !== void 0) fileWriteOpts.encoding = options.encoding;
|
|
18
18
|
if (options.mode !== void 0) fileWriteOpts.mode = options.mode;
|
|
19
19
|
if (options.flag !== void 0) fileWriteOpts.flag = options.flag.toString();
|
|
20
|
-
const str = JSON.stringify(object, replacer,
|
|
20
|
+
const str = JSON.stringify(object, replacer, spaces);
|
|
21
21
|
await writeFile(file, str, fileWriteOpts);
|
|
22
22
|
}
|
package/bin/mod.d.ts
CHANGED
|
@@ -34,13 +34,19 @@ declare const unlink: typeof remove;
|
|
|
34
34
|
declare const unlinkSync: typeof removeSync;
|
|
35
35
|
declare const rename: typeof move;
|
|
36
36
|
declare const renameSync: typeof moveSync;
|
|
37
|
+
declare const readJSON: typeof readJson;
|
|
38
|
+
declare const readJSONSync: typeof readJsonSync;
|
|
39
|
+
declare const writeJSON: typeof writeJson;
|
|
40
|
+
declare const writeJSONSync: typeof writeJsonSync;
|
|
41
|
+
declare const outputJSON: typeof outputJson;
|
|
42
|
+
declare const outputJSONSync: typeof outputJsonSync;
|
|
37
43
|
export type { CopyOptions } from "./impl/copy.js";
|
|
38
44
|
export type { MoveOptions } from "./impl/move.js";
|
|
39
45
|
export type { ReadFileOptions } from "./impl/read-file.js";
|
|
40
46
|
export type { ReadJsonOptions } from "./impl/read-json.js";
|
|
41
47
|
export type { JsonStringifyOptions } from "./impl/write-json.js";
|
|
42
48
|
export type { WriteJsonOptions } from "./impl/write-json.js";
|
|
43
|
-
export { readJson, writeJson, createFile, writeFile, readFile, mkdirs, emptyDir, pathExists, copy, move, remove, readdir, stat, access, copyFile, readJsonSync, writeJsonSync, createFileSync, writeFileSync, readFileSync, mkdirsSync, emptyDirSync, pathExistsSync, copySync, moveSync, removeSync, readdirSync, statSync, accessSync, constants, copyFileSync, mkdirp, mkdirpSync, rimraf, rimrafSync, ncp, ncpSync, ensureDir, ensureDirSync, ensureFile, ensureFileSync, outputJson, outputJsonSync, outputFile, outputFileSync, diveSync, mkdir, mkdirSync, unlink, unlinkSync, rename, renameSync, };
|
|
49
|
+
export { readJson, writeJson, createFile, writeFile, readFile, mkdirs, emptyDir, pathExists, copy, move, remove, readdir, stat, access, copyFile, readJsonSync, writeJsonSync, createFileSync, writeFileSync, readFileSync, mkdirsSync, emptyDirSync, pathExistsSync, copySync, moveSync, removeSync, readdirSync, statSync, accessSync, constants, copyFileSync, mkdirp, mkdirpSync, rimraf, rimrafSync, ncp, ncpSync, ensureDir, ensureDirSync, ensureFile, ensureFileSync, outputJson, outputJsonSync, outputFile, outputFileSync, diveSync, mkdir, mkdirSync, unlink, unlinkSync, rename, renameSync, readJSON, readJSONSync, writeJSON, writeJSONSync, outputJSON, outputJSONSync, };
|
|
44
50
|
declare const fs: {
|
|
45
51
|
readJson: typeof readJson;
|
|
46
52
|
writeJson: typeof writeJson;
|
|
@@ -95,5 +101,11 @@ declare const fs: {
|
|
|
95
101
|
unlinkSync: typeof removeSync;
|
|
96
102
|
rename: typeof move;
|
|
97
103
|
renameSync: typeof moveSync;
|
|
104
|
+
readJSON: typeof readJson;
|
|
105
|
+
readJSONSync: typeof readJsonSync;
|
|
106
|
+
writeJSON: typeof writeJson;
|
|
107
|
+
writeJSONSync: typeof writeJsonSync;
|
|
108
|
+
outputJSON: typeof outputJson;
|
|
109
|
+
outputJSONSync: typeof outputJsonSync;
|
|
98
110
|
};
|
|
99
111
|
export default fs;
|
package/bin/mod.js
CHANGED
|
@@ -115,6 +115,12 @@ const unlink = remove;
|
|
|
115
115
|
const unlinkSync = removeSync;
|
|
116
116
|
const rename = move;
|
|
117
117
|
const renameSync = moveSync;
|
|
118
|
+
const readJSON = readJson;
|
|
119
|
+
const readJSONSync = readJsonSync;
|
|
120
|
+
const writeJSON = writeJson;
|
|
121
|
+
const writeJSONSync = writeJsonSync;
|
|
122
|
+
const outputJSON = outputJson;
|
|
123
|
+
const outputJSONSync = outputJsonSync;
|
|
118
124
|
export {
|
|
119
125
|
readJson,
|
|
120
126
|
writeJson,
|
|
@@ -167,7 +173,13 @@ export {
|
|
|
167
173
|
unlink,
|
|
168
174
|
unlinkSync,
|
|
169
175
|
rename,
|
|
170
|
-
renameSync
|
|
176
|
+
renameSync,
|
|
177
|
+
readJSON,
|
|
178
|
+
readJSONSync,
|
|
179
|
+
writeJSON,
|
|
180
|
+
writeJSONSync,
|
|
181
|
+
outputJSON,
|
|
182
|
+
outputJSONSync
|
|
171
183
|
};
|
|
172
184
|
const fs = {
|
|
173
185
|
// async methods
|
|
@@ -225,6 +237,13 @@ const fs = {
|
|
|
225
237
|
unlink,
|
|
226
238
|
unlinkSync,
|
|
227
239
|
rename,
|
|
228
|
-
renameSync
|
|
240
|
+
renameSync,
|
|
241
|
+
// ADDED JSON Aliases
|
|
242
|
+
readJSON,
|
|
243
|
+
readJSONSync,
|
|
244
|
+
writeJSON,
|
|
245
|
+
writeJSONSync,
|
|
246
|
+
outputJSON,
|
|
247
|
+
outputJSONSync
|
|
229
248
|
};
|
|
230
249
|
export default fs;
|