@reliverse/relifso 1.4.0 → 1.4.1
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/LICENSES +16 -0
- package/README.md +48 -17
- package/bin/impl/bun.d.ts +5 -28
- package/bin/impl/bun.js +2 -126
- package/bin/impl/copy.js +8 -7
- package/bin/impl/create.d.ts +34 -0
- package/bin/impl/create.js +54 -0
- package/bin/impl/dive.d.ts +10 -0
- package/bin/impl/dive.js +89 -0
- package/bin/impl/empty.d.ts +28 -0
- package/bin/impl/empty.js +75 -0
- package/bin/impl/extras.d.ts +22 -2
- package/bin/impl/extras.js +68 -3
- package/bin/impl/json-utils.d.ts +30 -0
- package/bin/impl/json-utils.js +46 -0
- package/bin/impl/output-file.d.ts +3 -2
- package/bin/impl/output-json.d.ts +7 -2
- package/bin/impl/output-json.js +73 -11
- package/bin/impl/read-file.d.ts +11 -0
- package/bin/impl/read-file.js +82 -4
- package/bin/impl/read-json.d.ts +6 -0
- package/bin/impl/read-json.js +133 -21
- package/bin/impl/stats.d.ts +31 -0
- package/bin/impl/stats.js +141 -0
- package/bin/impl/write-file.d.ts +19 -8
- package/bin/impl/write-file.js +218 -9
- package/bin/impl/write-json.d.ts +13 -2
- package/bin/impl/write-json.js +46 -7
- package/bin/mod.d.ts +84 -36
- package/bin/mod.js +108 -39
- package/bin/utils/json/helpers/JSONRepairError.d.ts +4 -0
- package/bin/utils/json/helpers/JSONRepairError.js +7 -0
- package/bin/utils/json/helpers/JsonSchemaError.d.ts +6 -0
- package/bin/utils/json/helpers/JsonSchemaError.js +6 -0
- package/bin/utils/json/helpers/stringUtils.d.ts +64 -0
- package/bin/utils/json/helpers/stringUtils.js +87 -0
- package/bin/utils/json/regular/jsonc.d.ts +45 -0
- package/bin/utils/json/regular/jsonc.js +88 -0
- package/bin/utils/json/regular/jsonrepair.d.ts +17 -0
- package/bin/utils/json/regular/jsonrepair.js +576 -0
- package/bin/utils/json/regular/validate.d.ts +22 -0
- package/bin/utils/json/regular/validate.js +52 -0
- package/bin/utils/json/stream/JsonStreamError.d.ts +6 -0
- package/bin/utils/json/stream/JsonStreamError.js +6 -0
- package/bin/utils/json/stream/buffer/InputBuffer.d.ts +13 -0
- package/bin/utils/json/stream/buffer/InputBuffer.js +68 -0
- package/bin/utils/json/stream/buffer/OutputBuffer.d.ts +17 -0
- package/bin/utils/json/stream/buffer/OutputBuffer.js +101 -0
- package/bin/utils/json/stream/core.d.ts +10 -0
- package/bin/utils/json/stream/core.js +695 -0
- package/bin/utils/json/stream/jsonl.d.ts +21 -0
- package/bin/utils/json/stream/jsonl.js +55 -0
- package/bin/utils/json/stream/parser.d.ts +14 -0
- package/bin/utils/json/stream/parser.js +81 -0
- package/bin/utils/json/stream/stack.d.ts +19 -0
- package/bin/utils/json/stream/stack.js +43 -0
- package/bin/utils/json/stream/stream.d.ts +6 -0
- package/bin/utils/json/stream/stream.js +30 -0
- package/bin/utils/json/stream/writer.d.ts +14 -0
- package/bin/utils/json/stream/writer.js +44 -0
- package/package.json +3 -2
- package/bin/impl/create-file.d.ts +0 -2
- package/bin/impl/create-file.js +0 -21
- package/bin/impl/dive-async.d.ts +0 -11
- package/bin/impl/dive-async.js +0 -88
- package/bin/impl/empty-dir.d.ts +0 -2
- package/bin/impl/empty-dir.js +0 -24
- package/bin/impl/file-utils.d.ts +0 -20
- package/bin/impl/file-utils.js +0 -63
- /package/bin/{impl/logger.d.ts → utils/log.d.ts} +0 -0
- /package/bin/{impl/logger.js → utils/log.js} +0 -0
package/bin/mod.d.ts
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
import { renameSync as nodeRenameSync, unlinkSync as nodeUnlinkSync, accessSync, constants, readdirSync, statSync, copyFileSync, appendFileSync, chmodSync, chownSync, closeSync, createReadStream, createWriteStream, fchmodSync, fchownSync, fdatasyncSync, fstatSync, fsyncSync, ftruncateSync, futimesSync, lchmodSync, lchownSync, linkSync, lstatSync, lutimesSync, mkdtempSync, openSync, opendirSync, readSync, readlinkSync, realpathSync, rmSync, rmdirSync, statfsSync, symlinkSync, truncateSync, unwatchFile, utimesSync, watchFile, writeFileSync, writeSync, readvSync, writevSync } from "node:fs";
|
|
2
2
|
import { rename as nodeRename, unlink as nodeUnlink, access, appendFile, chmod, chown, copyFile, lchmod, lchown, link, lstat, lutimes, mkdtemp, open, opendir, readdir, readlink, realpath, rm, rmdir, stat, statfs, symlink, truncate, utimes, watch, writeFile } from "node:fs/promises";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
import { copy, copySync } from "./impl/copy
|
|
6
|
-
import { createFile, createFileSync } from "./impl/create
|
|
7
|
-
import { dive } from "./impl/dive
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { writeJson, writeJsonSync } from "./impl/write-json
|
|
4
|
+
import { getFileBun, getFileTypeBun, isBun } from "./impl/bun";
|
|
5
|
+
import { copy, copySync } from "./impl/copy";
|
|
6
|
+
import { createFile, createFileSync, createDir, createDirs, createFiles, createDirSync, createDirsSync, createFilesSync } from "./impl/create";
|
|
7
|
+
import { dive, diveSync } from "./impl/dive";
|
|
8
|
+
import { emptyDir, emptyDirSync, emptyObject, emptyFile, emptyFileSync } from "./impl/empty";
|
|
9
|
+
import { readText, readTextSync, readLines, readLinesSync, isDirectory, isDirectorySync, isSymlink, isSymlinkSync, execAsync, isDirectoryEmpty, isHiddenAttribute, rmEnsureDir, setHiddenAttribute } from "./impl/extras";
|
|
10
|
+
import { validateAndRepairJson } from "./impl/json-utils";
|
|
11
|
+
import { mkdirs, mkdirsSync } from "./impl/mkdirs";
|
|
12
|
+
import { move, moveSync } from "./impl/move";
|
|
13
|
+
import { outputFile, outputFileSync } from "./impl/output-file";
|
|
14
|
+
import { outputJson, outputJsonSync } from "./impl/output-json";
|
|
15
|
+
import { pathExists, pathExistsSync } from "./impl/path-exists";
|
|
16
|
+
import { readFile, readFileSync } from "./impl/read-file";
|
|
17
|
+
import { readJson, readJsonSync } from "./impl/read-json";
|
|
18
|
+
import { remove, removeSync } from "./impl/remove";
|
|
19
|
+
import { getFileExists, getFileLastModified, getFileSize, getStats, getStatsSync, toNodeStats } from "./impl/stats";
|
|
20
|
+
import { writeJson, writeJsonSync } from "./impl/write-json";
|
|
21
|
+
import { JSONRepairError } from "./utils/json/helpers/JSONRepairError";
|
|
22
|
+
import { JsonSchemaError } from "./utils/json/helpers/JsonSchemaError";
|
|
23
|
+
import { extractComments } from "./utils/json/regular/jsonc";
|
|
24
|
+
import { jsonrepair } from "./utils/json/regular/jsonrepair";
|
|
25
|
+
import { validateJson } from "./utils/json/regular/validate";
|
|
26
|
+
import { createInputBuffer } from "./utils/json/stream/buffer/InputBuffer";
|
|
27
|
+
import { createOutputBuffer } from "./utils/json/stream/buffer/OutputBuffer";
|
|
28
|
+
import { jsonrepairCore } from "./utils/json/stream/core";
|
|
29
|
+
import { createJsonlParser } from "./utils/json/stream/jsonl";
|
|
30
|
+
import { createJsonlWriter } from "./utils/json/stream/jsonl";
|
|
31
|
+
import { JsonStreamError } from "./utils/json/stream/JsonStreamError";
|
|
32
|
+
import { createJsonStreamParser } from "./utils/json/stream/parser";
|
|
33
|
+
import { jsonrepairTransform } from "./utils/json/stream/stream";
|
|
34
|
+
import { createJsonStreamWriter } from "./utils/json/stream/writer";
|
|
21
35
|
declare const mkdirp: typeof mkdirs;
|
|
22
36
|
declare const ensureDir: typeof mkdirs;
|
|
23
37
|
declare const ensureFile: typeof createFile;
|
|
@@ -44,15 +58,24 @@ declare const cp: typeof copy;
|
|
|
44
58
|
declare const cpSync: typeof copySync;
|
|
45
59
|
declare const exists: typeof pathExists;
|
|
46
60
|
declare const existsSync: typeof pathExistsSync;
|
|
47
|
-
|
|
48
|
-
export type {
|
|
49
|
-
export type {
|
|
50
|
-
export type {
|
|
51
|
-
export type {
|
|
52
|
-
export type {
|
|
53
|
-
export type {
|
|
54
|
-
export type {
|
|
55
|
-
export {
|
|
61
|
+
declare const jsonRepairRegular: typeof jsonrepair;
|
|
62
|
+
export type { CopyOptions } from "./impl/copy";
|
|
63
|
+
export type { MoveOptions } from "./impl/move";
|
|
64
|
+
export type { ReadFileOptions } from "./impl/read-file";
|
|
65
|
+
export type { ReadJsonOptions } from "./impl/read-json";
|
|
66
|
+
export type { JsonStringifyOptions } from "./impl/write-json";
|
|
67
|
+
export type { WriteJsonOptions } from "./impl/write-json";
|
|
68
|
+
export type { WriteFileOptions } from "./impl/write-file";
|
|
69
|
+
export type { DiveOptions } from "./impl/dive";
|
|
70
|
+
export type { JsonRepairTransformOptions } from "./utils/json/stream/stream";
|
|
71
|
+
export type { OutputJsonOptions } from "./impl/output-json";
|
|
72
|
+
export type { JSONSchema } from "./utils/json/regular/validate";
|
|
73
|
+
export type { InputBuffer } from "./utils/json/stream/buffer/InputBuffer";
|
|
74
|
+
export type { OutputBuffer, OutputBufferOptions } from "./utils/json/stream/buffer/OutputBuffer";
|
|
75
|
+
export type { JsonRepairCoreOptions, JsonRepairCore } from "./utils/json/stream/core";
|
|
76
|
+
export type { Text } from "./utils/json/helpers/stringUtils";
|
|
77
|
+
export type { JsoncParseOptions, JsoncStringifyOptions } from "./utils/json/regular/jsonc";
|
|
78
|
+
export { accessSync, appendFileSync, chmodSync, chownSync, closeSync, copyFileSync, createReadStream, createWriteStream, fchmodSync, fchownSync, fdatasyncSync, fstatSync, fsyncSync, ftruncateSync, futimesSync, lchmodSync, lchownSync, linkSync, lstatSync, lutimesSync, mkdtempSync, openSync, opendirSync, readFileSync, readlinkSync, readSync, readdirSync, realpathSync, nodeRenameSync, rmSync, rmdirSync, statSync, statfsSync, symlinkSync, truncateSync, nodeUnlinkSync, unwatchFile, utimesSync, watchFile, writeFileSync, writeSync, readvSync, writevSync, readJsonSync, writeJsonSync, createFileSync, createDirSync, createDirsSync, createFilesSync, emptyFileSync, mkdirsSync, emptyDirSync, pathExistsSync, copySync, moveSync, removeSync, outputJsonSync, outputFileSync, diveSync, cpSync, ensureDirSync as ensuredirSync, ensureDirSync, ensureFileSync, existsSync, mkdirpSync, mkdirSync, ncpSync, outputJSONSync, readJSONSync, renameSync, rimrafSync, unlinkSync, writeJSONSync, isDirectorySync, isSymlinkSync, readLinesSync, readTextSync, readJson, writeJson, createFile, createDir, createDirs, createFiles, emptyFile, mkdirs, emptyDir, pathExists, copy, move, remove, outputJson, outputFile, access, appendFile, chmod, chown, copyFile, lchmod, lchown, link, lstat, lutimes, mkdtemp, open, opendir, readFile, readdir, readlink, realpath, nodeRename, rm, rmdir, stat, statfs, symlink, truncate, nodeUnlink, utimes, watch, writeFile, constants, cp, ensureDir as ensuredir, ensureDir, ensureFile, exists, mkdir, mkdirp, ncp, outputJSON, readJSON, rename, resolve, rimraf, unlink, writeJSON, isDirectory, isSymlink, readLines, readText, execAsync, setHiddenAttribute, isHiddenAttribute, isDirectoryEmpty, rmEnsureDir, dive, getFileExists, getFileLastModified, getFileSize, getStats, getStatsSync, emptyObject, getFileBun, getFileTypeBun, toNodeStats, isBun, jsonrepair, jsonRepairRegular, createInputBuffer, createOutputBuffer, jsonrepairCore, JSONRepairError, jsonrepairTransform, validateAndRepairJson, validateJson, JsonSchemaError, createJsonStreamParser, createJsonStreamWriter, JsonStreamError, createJsonlParser, createJsonlWriter, extractComments, };
|
|
56
79
|
declare const fs: {
|
|
57
80
|
accessSync: typeof accessSync;
|
|
58
81
|
appendFileSync: typeof appendFileSync;
|
|
@@ -100,6 +123,10 @@ declare const fs: {
|
|
|
100
123
|
readJsonSync: typeof readJsonSync;
|
|
101
124
|
writeJsonSync: typeof writeJsonSync;
|
|
102
125
|
createFileSync: typeof createFileSync;
|
|
126
|
+
createDirSync: typeof createDirSync;
|
|
127
|
+
createDirsSync: typeof createDirsSync;
|
|
128
|
+
createFilesSync: typeof createFilesSync;
|
|
129
|
+
emptyFileSync: typeof emptyFileSync;
|
|
103
130
|
mkdirsSync: typeof mkdirsSync;
|
|
104
131
|
emptyDirSync: typeof emptyDirSync;
|
|
105
132
|
pathExistsSync: typeof pathExistsSync;
|
|
@@ -130,6 +157,10 @@ declare const fs: {
|
|
|
130
157
|
readJson: typeof readJson;
|
|
131
158
|
writeJson: typeof writeJson;
|
|
132
159
|
createFile: typeof createFile;
|
|
160
|
+
createDir: typeof createDir;
|
|
161
|
+
createDirs: typeof createDirs;
|
|
162
|
+
createFiles: typeof createFiles;
|
|
163
|
+
emptyFile: typeof emptyFile;
|
|
133
164
|
mkdirs: typeof mkdirs;
|
|
134
165
|
emptyDir: typeof emptyDir;
|
|
135
166
|
pathExists: typeof pathExists;
|
|
@@ -187,19 +218,36 @@ declare const fs: {
|
|
|
187
218
|
readLines: typeof readLines;
|
|
188
219
|
readText: typeof readText;
|
|
189
220
|
execAsync: typeof import("child_process").exec.__promisify__;
|
|
190
|
-
|
|
191
|
-
|
|
221
|
+
setHiddenAttribute: typeof setHiddenAttribute;
|
|
222
|
+
isHiddenAttribute: typeof isHiddenAttribute;
|
|
192
223
|
isDirectoryEmpty: typeof isDirectoryEmpty;
|
|
193
224
|
rmEnsureDir: typeof rmEnsureDir;
|
|
194
225
|
dive: typeof dive;
|
|
195
|
-
|
|
226
|
+
getFileExists: typeof getFileExists;
|
|
227
|
+
getFileLastModified: typeof getFileLastModified;
|
|
228
|
+
getFileSize: typeof getFileSize;
|
|
229
|
+
getStats: typeof getStats;
|
|
230
|
+
getStatsSync: typeof getStatsSync;
|
|
231
|
+
emptyObject: typeof emptyObject;
|
|
196
232
|
getFileBun: typeof getFileBun;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
233
|
+
getFileTypeBun: typeof getFileTypeBun;
|
|
234
|
+
toNodeStats: typeof toNodeStats;
|
|
235
|
+
isBun: string | false;
|
|
236
|
+
jsonrepair: typeof jsonrepair;
|
|
237
|
+
jsonRepairRegular: typeof jsonrepair;
|
|
238
|
+
createInputBuffer: typeof createInputBuffer;
|
|
239
|
+
createOutputBuffer: typeof createOutputBuffer;
|
|
240
|
+
jsonrepairCore: typeof jsonrepairCore;
|
|
241
|
+
JSONRepairError: typeof JSONRepairError;
|
|
242
|
+
jsonrepairTransform: typeof jsonrepairTransform;
|
|
243
|
+
validateAndRepairJson: typeof validateAndRepairJson;
|
|
244
|
+
validateJson: typeof validateJson;
|
|
245
|
+
JsonSchemaError: typeof JsonSchemaError;
|
|
246
|
+
createJsonStreamParser: typeof createJsonStreamParser;
|
|
247
|
+
createJsonStreamWriter: typeof createJsonStreamWriter;
|
|
248
|
+
JsonStreamError: typeof JsonStreamError;
|
|
249
|
+
createJsonlParser: typeof createJsonlParser;
|
|
250
|
+
createJsonlWriter: typeof createJsonlWriter;
|
|
251
|
+
extractComments: typeof extractComments;
|
|
204
252
|
};
|
|
205
253
|
export default fs;
|
package/bin/mod.js
CHANGED
|
@@ -73,23 +73,20 @@ import {
|
|
|
73
73
|
writeFile
|
|
74
74
|
} from "node:fs/promises";
|
|
75
75
|
import { resolve } from "node:path";
|
|
76
|
-
import {
|
|
77
|
-
isBun,
|
|
78
|
-
getFileBun,
|
|
79
|
-
existsBun,
|
|
80
|
-
sizeBun,
|
|
81
|
-
typeBun,
|
|
82
|
-
lastModifiedBun,
|
|
83
|
-
toNodeStatsBun,
|
|
84
|
-
getStatsBun,
|
|
85
|
-
getStatsSyncBun
|
|
86
|
-
} from "./impl/bun.js";
|
|
76
|
+
import { getFileBun, getFileTypeBun, isBun } from "./impl/bun.js";
|
|
87
77
|
import { copy, copySync } from "./impl/copy.js";
|
|
88
|
-
import {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
import {
|
|
79
|
+
createFile,
|
|
80
|
+
createFileSync,
|
|
81
|
+
createDir,
|
|
82
|
+
createDirs,
|
|
83
|
+
createFiles,
|
|
84
|
+
createDirSync,
|
|
85
|
+
createDirsSync,
|
|
86
|
+
createFilesSync
|
|
87
|
+
} from "./impl/create.js";
|
|
88
|
+
import { dive, diveSync } from "./impl/dive.js";
|
|
89
|
+
import { emptyDir, emptyDirSync, emptyObject, emptyFile, emptyFileSync } from "./impl/empty.js";
|
|
93
90
|
import {
|
|
94
91
|
readText,
|
|
95
92
|
readTextSync,
|
|
@@ -98,8 +95,14 @@ import {
|
|
|
98
95
|
isDirectory,
|
|
99
96
|
isDirectorySync,
|
|
100
97
|
isSymlink,
|
|
101
|
-
isSymlinkSync
|
|
102
|
-
|
|
98
|
+
isSymlinkSync,
|
|
99
|
+
execAsync,
|
|
100
|
+
isDirectoryEmpty,
|
|
101
|
+
isHiddenAttribute,
|
|
102
|
+
rmEnsureDir,
|
|
103
|
+
setHiddenAttribute
|
|
104
|
+
} from "./impl/extras.js";
|
|
105
|
+
import { validateAndRepairJson } from "./impl/json-utils.js";
|
|
103
106
|
import { mkdirs, mkdirsSync } from "./impl/mkdirs.js";
|
|
104
107
|
import { move, moveSync } from "./impl/move.js";
|
|
105
108
|
import { outputFile, outputFileSync } from "./impl/output-file.js";
|
|
@@ -108,7 +111,22 @@ import { pathExists, pathExistsSync } from "./impl/path-exists.js";
|
|
|
108
111
|
import { readFile, readFileSync } from "./impl/read-file.js";
|
|
109
112
|
import { readJson, readJsonSync } from "./impl/read-json.js";
|
|
110
113
|
import { remove, removeSync } from "./impl/remove.js";
|
|
114
|
+
import { getFileExists, getFileLastModified, getFileSize, getStats, getStatsSync, toNodeStats } from "./impl/stats.js";
|
|
111
115
|
import { writeJson, writeJsonSync } from "./impl/write-json.js";
|
|
116
|
+
import { JSONRepairError } from "./utils/json/helpers/JSONRepairError.js";
|
|
117
|
+
import { JsonSchemaError } from "./utils/json/helpers/JsonSchemaError.js";
|
|
118
|
+
import { extractComments } from "./utils/json/regular/jsonc.js";
|
|
119
|
+
import { jsonrepair } from "./utils/json/regular/jsonrepair.js";
|
|
120
|
+
import { validateJson } from "./utils/json/regular/validate.js";
|
|
121
|
+
import { createInputBuffer } from "./utils/json/stream/buffer/InputBuffer.js";
|
|
122
|
+
import { createOutputBuffer } from "./utils/json/stream/buffer/OutputBuffer.js";
|
|
123
|
+
import { jsonrepairCore } from "./utils/json/stream/core.js";
|
|
124
|
+
import { createJsonlParser } from "./utils/json/stream/jsonl.js";
|
|
125
|
+
import { createJsonlWriter } from "./utils/json/stream/jsonl.js";
|
|
126
|
+
import { JsonStreamError } from "./utils/json/stream/JsonStreamError.js";
|
|
127
|
+
import { createJsonStreamParser } from "./utils/json/stream/parser.js";
|
|
128
|
+
import { jsonrepairTransform } from "./utils/json/stream/stream.js";
|
|
129
|
+
import { createJsonStreamWriter } from "./utils/json/stream/writer.js";
|
|
112
130
|
const mkdirp = mkdirs;
|
|
113
131
|
const ensureDir = mkdirs;
|
|
114
132
|
const ensureFile = createFile;
|
|
@@ -135,6 +153,7 @@ const cp = copy;
|
|
|
135
153
|
const cpSync = copySync;
|
|
136
154
|
const exists = pathExists;
|
|
137
155
|
const existsSync = pathExistsSync;
|
|
156
|
+
const jsonRepairRegular = jsonrepair;
|
|
138
157
|
export {
|
|
139
158
|
accessSync,
|
|
140
159
|
appendFileSync,
|
|
@@ -182,6 +201,10 @@ export {
|
|
|
182
201
|
readJsonSync,
|
|
183
202
|
writeJsonSync,
|
|
184
203
|
createFileSync,
|
|
204
|
+
createDirSync,
|
|
205
|
+
createDirsSync,
|
|
206
|
+
createFilesSync,
|
|
207
|
+
emptyFileSync,
|
|
185
208
|
mkdirsSync,
|
|
186
209
|
emptyDirSync,
|
|
187
210
|
pathExistsSync,
|
|
@@ -212,6 +235,10 @@ export {
|
|
|
212
235
|
readJson,
|
|
213
236
|
writeJson,
|
|
214
237
|
createFile,
|
|
238
|
+
createDir,
|
|
239
|
+
createDirs,
|
|
240
|
+
createFiles,
|
|
241
|
+
emptyFile,
|
|
215
242
|
mkdirs,
|
|
216
243
|
emptyDir,
|
|
217
244
|
pathExists,
|
|
@@ -269,20 +296,37 @@ export {
|
|
|
269
296
|
readLines,
|
|
270
297
|
readText,
|
|
271
298
|
execAsync,
|
|
272
|
-
|
|
273
|
-
|
|
299
|
+
setHiddenAttribute,
|
|
300
|
+
isHiddenAttribute,
|
|
274
301
|
isDirectoryEmpty,
|
|
275
302
|
rmEnsureDir,
|
|
276
303
|
dive,
|
|
277
|
-
|
|
304
|
+
getFileExists,
|
|
305
|
+
getFileLastModified,
|
|
306
|
+
getFileSize,
|
|
307
|
+
getStats,
|
|
308
|
+
getStatsSync,
|
|
309
|
+
emptyObject,
|
|
278
310
|
getFileBun,
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
311
|
+
getFileTypeBun,
|
|
312
|
+
toNodeStats,
|
|
313
|
+
isBun,
|
|
314
|
+
jsonrepair,
|
|
315
|
+
jsonRepairRegular,
|
|
316
|
+
createInputBuffer,
|
|
317
|
+
createOutputBuffer,
|
|
318
|
+
jsonrepairCore,
|
|
319
|
+
JSONRepairError,
|
|
320
|
+
jsonrepairTransform,
|
|
321
|
+
validateAndRepairJson,
|
|
322
|
+
validateJson,
|
|
323
|
+
JsonSchemaError,
|
|
324
|
+
createJsonStreamParser,
|
|
325
|
+
createJsonStreamWriter,
|
|
326
|
+
JsonStreamError,
|
|
327
|
+
createJsonlParser,
|
|
328
|
+
createJsonlWriter,
|
|
329
|
+
extractComments
|
|
286
330
|
};
|
|
287
331
|
const fs = {
|
|
288
332
|
// Sync direct exports (node:fs)
|
|
@@ -332,6 +376,10 @@ const fs = {
|
|
|
332
376
|
readJsonSync,
|
|
333
377
|
writeJsonSync,
|
|
334
378
|
createFileSync,
|
|
379
|
+
createDirSync,
|
|
380
|
+
createDirsSync,
|
|
381
|
+
createFilesSync,
|
|
382
|
+
emptyFileSync,
|
|
335
383
|
mkdirsSync,
|
|
336
384
|
emptyDirSync,
|
|
337
385
|
pathExistsSync,
|
|
@@ -365,6 +413,10 @@ const fs = {
|
|
|
365
413
|
readJson,
|
|
366
414
|
writeJson,
|
|
367
415
|
createFile,
|
|
416
|
+
createDir,
|
|
417
|
+
createDirs,
|
|
418
|
+
createFiles,
|
|
419
|
+
emptyFile,
|
|
368
420
|
mkdirs,
|
|
369
421
|
emptyDir,
|
|
370
422
|
pathExists,
|
|
@@ -425,21 +477,38 @@ const fs = {
|
|
|
425
477
|
readText,
|
|
426
478
|
// Additional utility functions
|
|
427
479
|
execAsync,
|
|
428
|
-
|
|
429
|
-
|
|
480
|
+
setHiddenAttribute,
|
|
481
|
+
isHiddenAttribute,
|
|
430
482
|
isDirectoryEmpty,
|
|
431
483
|
rmEnsureDir,
|
|
432
|
-
// Dive functionality
|
|
433
484
|
dive,
|
|
485
|
+
getFileExists,
|
|
486
|
+
getFileLastModified,
|
|
487
|
+
getFileSize,
|
|
488
|
+
getStats,
|
|
489
|
+
getStatsSync,
|
|
490
|
+
emptyObject,
|
|
434
491
|
// Bun-specific utilities
|
|
435
|
-
isBun,
|
|
436
492
|
getFileBun,
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
493
|
+
getFileTypeBun,
|
|
494
|
+
toNodeStats,
|
|
495
|
+
isBun,
|
|
496
|
+
// JSON utilities
|
|
497
|
+
jsonrepair,
|
|
498
|
+
jsonRepairRegular,
|
|
499
|
+
createInputBuffer,
|
|
500
|
+
createOutputBuffer,
|
|
501
|
+
jsonrepairCore,
|
|
502
|
+
JSONRepairError,
|
|
503
|
+
jsonrepairTransform,
|
|
504
|
+
validateAndRepairJson,
|
|
505
|
+
validateJson,
|
|
506
|
+
JsonSchemaError,
|
|
507
|
+
createJsonStreamParser,
|
|
508
|
+
createJsonStreamWriter,
|
|
509
|
+
JsonStreamError,
|
|
510
|
+
createJsonlParser,
|
|
511
|
+
createJsonlWriter,
|
|
512
|
+
extractComments
|
|
444
513
|
};
|
|
445
514
|
export default fs;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare function isHex(char: string): boolean;
|
|
2
|
+
export declare function isDigit(char: string): boolean;
|
|
3
|
+
export declare function isValidStringCharacter(char: string): boolean;
|
|
4
|
+
export declare function isDelimiter(char: string): boolean;
|
|
5
|
+
export declare function isFunctionNameCharStart(char: string): boolean;
|
|
6
|
+
export declare function isFunctionNameChar(char: string): boolean;
|
|
7
|
+
export declare const regexUrlStart: RegExp;
|
|
8
|
+
export declare const regexUrlChar: RegExp;
|
|
9
|
+
export declare function isUnquotedStringDelimiter(char: string): boolean;
|
|
10
|
+
export declare function isStartOfValue(char: string): boolean;
|
|
11
|
+
export declare function isControlCharacter(char: string): char is "\b" | "\f" | "\n" | "\r" | "\t";
|
|
12
|
+
export interface Text {
|
|
13
|
+
charCodeAt: (index: number) => number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if the given character is a whitespace character like space, tab, or
|
|
17
|
+
* newline
|
|
18
|
+
*/
|
|
19
|
+
export declare function isWhitespace(text: Text, index: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Check if the given character is a whitespace character like space or tab,
|
|
22
|
+
* but NOT a newline
|
|
23
|
+
*/
|
|
24
|
+
export declare function isWhitespaceExceptNewline(text: Text, index: number): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check if the given character is a special whitespace character, some
|
|
27
|
+
* unicode variant
|
|
28
|
+
*/
|
|
29
|
+
export declare function isSpecialWhitespace(text: Text, index: number): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Test whether the given character is a quote or double quote character.
|
|
32
|
+
* Also tests for special variants of quotes.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isQuote(char: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Test whether the given character is a double quote character.
|
|
37
|
+
* Also tests for special variants of double quotes.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isDoubleQuoteLike(char: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Test whether the given character is a double quote character.
|
|
42
|
+
* Does NOT test for special variants of double quotes.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isDoubleQuote(char: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Test whether the given character is a single quote character.
|
|
47
|
+
* Also tests for special variants of single quotes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isSingleQuoteLike(char: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Test whether the given character is a single quote character.
|
|
52
|
+
* Does NOT test for special variants of single quotes.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isSingleQuote(char: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Strip last occurrence of textToStrip from text
|
|
57
|
+
*/
|
|
58
|
+
export declare function stripLastOccurrence(text: string, textToStrip: string, stripRemainingText?: boolean): string;
|
|
59
|
+
export declare function insertBeforeLastWhitespace(text: string, textToInsert: string): string;
|
|
60
|
+
export declare function removeAtIndex(text: string, start: number, count: number): string;
|
|
61
|
+
/**
|
|
62
|
+
* Test whether a string ends with a newline or comma character and optional whitespace
|
|
63
|
+
*/
|
|
64
|
+
export declare function endsWithCommaOrNewline(text: string): boolean;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const codeSpace = 32;
|
|
2
|
+
const codeNewline = 10;
|
|
3
|
+
const codeTab = 9;
|
|
4
|
+
const codeReturn = 13;
|
|
5
|
+
const codeNonBreakingSpace = 160;
|
|
6
|
+
const codeEnQuad = 8192;
|
|
7
|
+
const codeHairSpace = 8202;
|
|
8
|
+
const codeNarrowNoBreakSpace = 8239;
|
|
9
|
+
const codeMediumMathematicalSpace = 8287;
|
|
10
|
+
const codeIdeographicSpace = 12288;
|
|
11
|
+
export function isHex(char) {
|
|
12
|
+
return /^[0-9A-Fa-f]$/.test(char);
|
|
13
|
+
}
|
|
14
|
+
export function isDigit(char) {
|
|
15
|
+
return char >= "0" && char <= "9";
|
|
16
|
+
}
|
|
17
|
+
export function isValidStringCharacter(char) {
|
|
18
|
+
return char >= " ";
|
|
19
|
+
}
|
|
20
|
+
export function isDelimiter(char) {
|
|
21
|
+
return ",:[]/{}()\n+".includes(char);
|
|
22
|
+
}
|
|
23
|
+
export function isFunctionNameCharStart(char) {
|
|
24
|
+
return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$";
|
|
25
|
+
}
|
|
26
|
+
export function isFunctionNameChar(char) {
|
|
27
|
+
return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$" || char >= "0" && char <= "9";
|
|
28
|
+
}
|
|
29
|
+
export const regexUrlStart = /^(http|https|ftp|mailto|file|data|irc):\/\/$/;
|
|
30
|
+
export const regexUrlChar = /^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;
|
|
31
|
+
export function isUnquotedStringDelimiter(char) {
|
|
32
|
+
return ",[]/{}\n+".includes(char);
|
|
33
|
+
}
|
|
34
|
+
export function isStartOfValue(char) {
|
|
35
|
+
return isQuote(char) || regexStartOfValue.test(char);
|
|
36
|
+
}
|
|
37
|
+
const regexStartOfValue = /^[[{\w-]$/;
|
|
38
|
+
export function isControlCharacter(char) {
|
|
39
|
+
return char === "\n" || char === "\r" || char === " " || char === "\b" || char === "\f";
|
|
40
|
+
}
|
|
41
|
+
export function isWhitespace(text, index) {
|
|
42
|
+
const code = text.charCodeAt(index);
|
|
43
|
+
return code === codeSpace || code === codeNewline || code === codeTab || code === codeReturn;
|
|
44
|
+
}
|
|
45
|
+
export function isWhitespaceExceptNewline(text, index) {
|
|
46
|
+
const code = text.charCodeAt(index);
|
|
47
|
+
return code === codeSpace || code === codeTab || code === codeReturn;
|
|
48
|
+
}
|
|
49
|
+
export function isSpecialWhitespace(text, index) {
|
|
50
|
+
const code = text.charCodeAt(index);
|
|
51
|
+
return code === codeNonBreakingSpace || code >= codeEnQuad && code <= codeHairSpace || code === codeNarrowNoBreakSpace || code === codeMediumMathematicalSpace || code === codeIdeographicSpace;
|
|
52
|
+
}
|
|
53
|
+
export function isQuote(char) {
|
|
54
|
+
return isDoubleQuoteLike(char) || isSingleQuoteLike(char);
|
|
55
|
+
}
|
|
56
|
+
export function isDoubleQuoteLike(char) {
|
|
57
|
+
return char === '"' || char === "\u201C" || char === "\u201D";
|
|
58
|
+
}
|
|
59
|
+
export function isDoubleQuote(char) {
|
|
60
|
+
return char === '"';
|
|
61
|
+
}
|
|
62
|
+
export function isSingleQuoteLike(char) {
|
|
63
|
+
return char === "'" || char === "\u2018" || char === "\u2019" || char === "`" || char === "\xB4";
|
|
64
|
+
}
|
|
65
|
+
export function isSingleQuote(char) {
|
|
66
|
+
return char === "'";
|
|
67
|
+
}
|
|
68
|
+
export function stripLastOccurrence(text, textToStrip, stripRemainingText = false) {
|
|
69
|
+
const index = text.lastIndexOf(textToStrip);
|
|
70
|
+
return index !== -1 ? text.substring(0, index) + (stripRemainingText ? "" : text.substring(index + 1)) : text;
|
|
71
|
+
}
|
|
72
|
+
export function insertBeforeLastWhitespace(text, textToInsert) {
|
|
73
|
+
let index = text.length;
|
|
74
|
+
if (!isWhitespace(text, index - 1)) {
|
|
75
|
+
return text + textToInsert;
|
|
76
|
+
}
|
|
77
|
+
while (isWhitespace(text, index - 1)) {
|
|
78
|
+
index--;
|
|
79
|
+
}
|
|
80
|
+
return text.substring(0, index) + textToInsert + text.substring(index);
|
|
81
|
+
}
|
|
82
|
+
export function removeAtIndex(text, start, count) {
|
|
83
|
+
return text.substring(0, start) + text.substring(start + count);
|
|
84
|
+
}
|
|
85
|
+
export function endsWithCommaOrNewline(text) {
|
|
86
|
+
return /[,\n][ \t\r]*$/.test(text);
|
|
87
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface JsoncParseOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Whether to preserve comments in the output
|
|
4
|
+
* @default false
|
|
5
|
+
*/
|
|
6
|
+
preserveComments?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether to throw an error if the JSONC is invalid
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
throws?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface JsoncStringifyOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Whether to include comments in the output
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
includeComments?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Number of spaces to use for indentation
|
|
21
|
+
* @default 2
|
|
22
|
+
*/
|
|
23
|
+
spaces?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse a JSONC string into a JavaScript value
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseJsonc(text: string, options?: JsoncParseOptions): unknown;
|
|
29
|
+
/**
|
|
30
|
+
* Convert a JavaScript value to a JSONC string
|
|
31
|
+
*/
|
|
32
|
+
export declare function stringifyJsonc(value: unknown, options?: JsoncStringifyOptions): string;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a string is valid JSONC
|
|
35
|
+
*/
|
|
36
|
+
export declare function isValidJsonc(text: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Extract comments from a JSONC string
|
|
39
|
+
*/
|
|
40
|
+
export declare function extractComments(text: string): {
|
|
41
|
+
line: number;
|
|
42
|
+
column: number;
|
|
43
|
+
text: string;
|
|
44
|
+
type: "line" | "block";
|
|
45
|
+
}[];
|