@reliverse/relifso 1.3.1 → 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.
Files changed (90) hide show
  1. package/LICENSES +16 -0
  2. package/README.md +106 -20
  3. package/bin/impl/bun.d.ts +11 -0
  4. package/bin/impl/bun.js +23 -0
  5. package/bin/impl/{node/copy.d.ts → copy.d.ts} +15 -3
  6. package/bin/impl/copy.js +229 -0
  7. package/bin/impl/create.d.ts +34 -0
  8. package/bin/impl/create.js +54 -0
  9. package/bin/impl/{node/dive.d.ts → dive.d.ts} +10 -0
  10. package/bin/impl/dive.js +145 -0
  11. package/bin/impl/empty.d.ts +28 -0
  12. package/bin/impl/empty.js +75 -0
  13. package/bin/impl/extras.d.ts +35 -0
  14. package/bin/impl/extras.js +112 -0
  15. package/bin/impl/json-utils.d.ts +30 -0
  16. package/bin/impl/json-utils.js +46 -0
  17. package/bin/impl/{node/mkdirs.js → mkdirs.js} +10 -3
  18. package/bin/impl/{node/move.d.ts → move.d.ts} +10 -0
  19. package/bin/impl/move.js +140 -0
  20. package/bin/impl/{node/output-file.d.ts → output-file.d.ts} +3 -2
  21. package/bin/impl/{node/output-json.d.ts → output-json.d.ts} +7 -2
  22. package/bin/impl/output-json.js +77 -0
  23. package/bin/impl/read-file.d.ts +31 -0
  24. package/bin/impl/read-file.js +165 -0
  25. package/bin/impl/{node/read-json.d.ts → read-json.d.ts} +9 -0
  26. package/bin/impl/read-json.js +241 -0
  27. package/bin/impl/stats.d.ts +31 -0
  28. package/bin/impl/stats.js +141 -0
  29. package/bin/impl/write-file.d.ts +31 -0
  30. package/bin/impl/write-file.js +257 -0
  31. package/bin/impl/write-json.d.ts +41 -0
  32. package/bin/impl/write-json.js +135 -0
  33. package/bin/mod.d.ts +89 -57
  34. package/bin/mod.js +131 -164
  35. package/bin/utils/json/helpers/JSONRepairError.d.ts +4 -0
  36. package/bin/utils/json/helpers/JSONRepairError.js +7 -0
  37. package/bin/utils/json/helpers/JsonSchemaError.d.ts +6 -0
  38. package/bin/utils/json/helpers/JsonSchemaError.js +6 -0
  39. package/bin/utils/json/helpers/stringUtils.d.ts +64 -0
  40. package/bin/utils/json/helpers/stringUtils.js +87 -0
  41. package/bin/utils/json/regular/jsonc.d.ts +45 -0
  42. package/bin/utils/json/regular/jsonc.js +88 -0
  43. package/bin/utils/json/regular/jsonrepair.d.ts +17 -0
  44. package/bin/utils/json/regular/jsonrepair.js +576 -0
  45. package/bin/utils/json/regular/validate.d.ts +22 -0
  46. package/bin/utils/json/regular/validate.js +52 -0
  47. package/bin/utils/json/stream/JsonStreamError.d.ts +6 -0
  48. package/bin/utils/json/stream/JsonStreamError.js +6 -0
  49. package/bin/utils/json/stream/buffer/InputBuffer.d.ts +13 -0
  50. package/bin/utils/json/stream/buffer/InputBuffer.js +68 -0
  51. package/bin/utils/json/stream/buffer/OutputBuffer.d.ts +17 -0
  52. package/bin/utils/json/stream/buffer/OutputBuffer.js +101 -0
  53. package/bin/utils/json/stream/core.d.ts +10 -0
  54. package/bin/utils/json/stream/core.js +695 -0
  55. package/bin/utils/json/stream/jsonl.d.ts +21 -0
  56. package/bin/utils/json/stream/jsonl.js +55 -0
  57. package/bin/utils/json/stream/parser.d.ts +14 -0
  58. package/bin/utils/json/stream/parser.js +81 -0
  59. package/bin/utils/json/stream/stack.d.ts +19 -0
  60. package/bin/utils/json/stream/stack.js +43 -0
  61. package/bin/utils/json/stream/stream.d.ts +6 -0
  62. package/bin/utils/json/stream/stream.js +30 -0
  63. package/bin/utils/json/stream/writer.d.ts +14 -0
  64. package/bin/utils/json/stream/writer.js +44 -0
  65. package/bin/utils/log.d.ts +1 -0
  66. package/bin/utils/log.js +7 -0
  67. package/package.json +4 -3
  68. package/bin/impl/node/copy.js +0 -94
  69. package/bin/impl/node/create-file.d.ts +0 -2
  70. package/bin/impl/node/create-file.js +0 -21
  71. package/bin/impl/node/dive.js +0 -56
  72. package/bin/impl/node/empty-dir.d.ts +0 -2
  73. package/bin/impl/node/empty-dir.js +0 -24
  74. package/bin/impl/node/move.js +0 -93
  75. package/bin/impl/node/output-json.js +0 -15
  76. package/bin/impl/node/read-file.d.ts +0 -30
  77. package/bin/impl/node/read-file.js +0 -30
  78. package/bin/impl/node/read-json.js +0 -50
  79. package/bin/impl/node/write-file.d.ts +0 -20
  80. package/bin/impl/node/write-file.js +0 -23
  81. package/bin/impl/node/write-json.d.ts +0 -28
  82. package/bin/impl/node/write-json.js +0 -22
  83. package/bin/impl/utils/additional.d.ts +0 -15
  84. package/bin/impl/utils/additional.js +0 -47
  85. /package/bin/impl/{node/mkdirs.d.ts → mkdirs.d.ts} +0 -0
  86. /package/bin/impl/{node/output-file.js → output-file.js} +0 -0
  87. /package/bin/impl/{node/path-exists.d.ts → path-exists.d.ts} +0 -0
  88. /package/bin/impl/{node/path-exists.js → path-exists.js} +0 -0
  89. /package/bin/impl/{node/remove.d.ts → remove.d.ts} +0 -0
  90. /package/bin/impl/{node/remove.js → remove.js} +0 -0
package/bin/mod.d.ts CHANGED
@@ -1,31 +1,37 @@
1
- import type { Stats } from "node:fs";
2
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";
3
- import { readdir as nodeReaddirInternal, stat as nodeStatInternal, 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";
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";
4
3
  import { resolve } from "node:path";
5
- import type { DiveOptions } from "./impl/node/dive.js";
6
- import { copy, copySync } from "./impl/node/copy.js";
7
- import { createFile, createFileSync } from "./impl/node/create-file.js";
8
- import { diveSync } from "./impl/node/dive.js";
9
- import { emptyDir, emptyDirSync } from "./impl/node/empty-dir.js";
10
- import { mkdirs, mkdirsSync } from "./impl/node/mkdirs.js";
11
- import { move, moveSync } from "./impl/node/move.js";
12
- import { outputFile, outputFileSync } from "./impl/node/output-file.js";
13
- import { outputJson, outputJsonSync } from "./impl/node/output-json.js";
14
- import { pathExists, pathExistsSync } from "./impl/node/path-exists.js";
15
- import { readFile, readFileSync } from "./impl/node/read-file.js";
16
- import { readJson, readJsonSync } from "./impl/node/read-json.js";
17
- import { remove, removeSync } from "./impl/node/remove.js";
18
- import { writeJson, writeJsonSync } from "./impl/node/write-json.js";
19
- import { execAsync, setHiddenAttributeOnWindows, isHidden, isDirectoryEmpty, rmEnsureDir } from "./impl/utils/additional.js";
20
- /**
21
- * Recursively dives into a directory and yields files and directories.
22
- * @param directory - The directory to dive into.
23
- * @param action - An optional callback function to execute for each file or directory.
24
- * @param options - An optional object containing options for the dive.
25
- * @returns A Promise that resolves to an array of file paths if no action is provided, or void if an action is provided.
26
- */
27
- export declare function dive(directory: string, action: (file: string, stat: Stats) => void | Promise<void>, options?: DiveOptions): Promise<void>;
28
- export declare function dive(directory: string, options?: DiveOptions): Promise<string[]>;
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";
29
35
  declare const mkdirp: typeof mkdirs;
30
36
  declare const ensureDir: typeof mkdirs;
31
37
  declare const ensureFile: typeof createFile;
@@ -52,33 +58,24 @@ declare const cp: typeof copy;
52
58
  declare const cpSync: typeof copySync;
53
59
  declare const exists: typeof pathExists;
54
60
  declare const existsSync: typeof pathExistsSync;
55
- declare function readText(filePath: string, options?: BufferEncoding | {
56
- encoding?: BufferEncoding | null;
57
- flag?: string;
58
- }): Promise<string>;
59
- declare function readTextSync(filePath: string, options?: BufferEncoding | {
60
- encoding?: BufferEncoding | null;
61
- flag?: string;
62
- }): string;
63
- declare function readLines(filePath: string, options?: BufferEncoding | {
64
- encoding?: BufferEncoding | null;
65
- flag?: string;
66
- }): Promise<any>;
67
- declare function readLinesSync(filePath: string, options?: BufferEncoding | {
68
- encoding?: BufferEncoding | null;
69
- flag?: string;
70
- }): any;
71
- declare function isDirectory(filePath: string): Promise<boolean>;
72
- declare function isDirectorySync(filePath: string): boolean;
73
- declare function isSymlink(filePath: string): Promise<boolean>;
74
- declare function isSymlinkSync(filePath: string): boolean;
75
- export type { CopyOptions } from "./impl/node/copy.js";
76
- export type { MoveOptions } from "./impl/node/move.js";
77
- export type { ReadFileOptions } from "./impl/node/read-file.js";
78
- export type { ReadJsonOptions } from "./impl/node/read-json.js";
79
- export type { JsonStringifyOptions } from "./impl/node/write-json.js";
80
- export type { WriteJsonOptions } from "./impl/node/write-json.js";
81
- 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, 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, 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, setHiddenAttributeOnWindows, isHidden, isDirectoryEmpty, rmEnsureDir, };
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, };
82
79
  declare const fs: {
83
80
  accessSync: typeof accessSync;
84
81
  appendFileSync: typeof appendFileSync;
@@ -126,6 +123,10 @@ declare const fs: {
126
123
  readJsonSync: typeof readJsonSync;
127
124
  writeJsonSync: typeof writeJsonSync;
128
125
  createFileSync: typeof createFileSync;
126
+ createDirSync: typeof createDirSync;
127
+ createDirsSync: typeof createDirsSync;
128
+ createFilesSync: typeof createFilesSync;
129
+ emptyFileSync: typeof emptyFileSync;
129
130
  mkdirsSync: typeof mkdirsSync;
130
131
  emptyDirSync: typeof emptyDirSync;
131
132
  pathExistsSync: typeof pathExistsSync;
@@ -156,6 +157,10 @@ declare const fs: {
156
157
  readJson: typeof readJson;
157
158
  writeJson: typeof writeJson;
158
159
  createFile: typeof createFile;
160
+ createDir: typeof createDir;
161
+ createDirs: typeof createDirs;
162
+ createFiles: typeof createFiles;
163
+ emptyFile: typeof emptyFile;
159
164
  mkdirs: typeof mkdirs;
160
165
  emptyDir: typeof emptyDir;
161
166
  pathExists: typeof pathExists;
@@ -178,13 +183,13 @@ declare const fs: {
178
183
  open: typeof open;
179
184
  opendir: typeof opendir;
180
185
  readFile: typeof readFile;
181
- readdir: typeof nodeReaddirInternal;
186
+ readdir: typeof readdir;
182
187
  readlink: typeof readlink;
183
188
  realpath: typeof realpath;
184
189
  nodeRename: typeof nodeRename;
185
190
  rm: typeof rm;
186
191
  rmdir: typeof rmdir;
187
- stat: typeof nodeStatInternal;
192
+ stat: typeof stat;
188
193
  statfs: typeof statfs;
189
194
  symlink: typeof symlink;
190
195
  truncate: typeof truncate;
@@ -213,9 +218,36 @@ declare const fs: {
213
218
  readLines: typeof readLines;
214
219
  readText: typeof readText;
215
220
  execAsync: typeof import("child_process").exec.__promisify__;
216
- setHiddenAttributeOnWindows: typeof setHiddenAttributeOnWindows;
217
- isHidden: typeof isHidden;
221
+ setHiddenAttribute: typeof setHiddenAttribute;
222
+ isHiddenAttribute: typeof isHiddenAttribute;
218
223
  isDirectoryEmpty: typeof isDirectoryEmpty;
219
224
  rmEnsureDir: typeof rmEnsureDir;
225
+ dive: typeof dive;
226
+ getFileExists: typeof getFileExists;
227
+ getFileLastModified: typeof getFileLastModified;
228
+ getFileSize: typeof getFileSize;
229
+ getStats: typeof getStats;
230
+ getStatsSync: typeof getStatsSync;
231
+ emptyObject: typeof emptyObject;
232
+ getFileBun: typeof getFileBun;
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;
220
252
  };
221
253
  export default fs;
package/bin/mod.js CHANGED
@@ -44,8 +44,6 @@ import {
44
44
  writevSync
45
45
  } from "node:fs";
46
46
  import {
47
- readdir as nodeReaddirInternal,
48
- stat as nodeStatInternal,
49
47
  rename as nodeRename,
50
48
  unlink as nodeUnlink,
51
49
  access,
@@ -74,104 +72,61 @@ import {
74
72
  watch,
75
73
  writeFile
76
74
  } from "node:fs/promises";
77
- import { join as pathJoin, resolve } from "node:path";
78
- import { copy, copySync } from "./impl/node/copy.js";
79
- import { createFile, createFileSync } from "./impl/node/create-file.js";
80
- import { diveSync } from "./impl/node/dive.js";
81
- import { emptyDir, emptyDirSync } from "./impl/node/empty-dir.js";
82
- import { mkdirs, mkdirsSync } from "./impl/node/mkdirs.js";
83
- import { move, moveSync } from "./impl/node/move.js";
84
- import { outputFile, outputFileSync } from "./impl/node/output-file.js";
85
- import { outputJson, outputJsonSync } from "./impl/node/output-json.js";
86
- import { pathExists, pathExistsSync } from "./impl/node/path-exists.js";
87
- import { readFile, readFileSync } from "./impl/node/read-file.js";
88
- import { readJson, readJsonSync } from "./impl/node/read-json.js";
89
- import { remove, removeSync } from "./impl/node/remove.js";
90
- import { writeJson, writeJsonSync } from "./impl/node/write-json.js";
75
+ import { resolve } from "node:path";
76
+ import { getFileBun, getFileTypeBun, isBun } from "./impl/bun.js";
77
+ import { copy, copySync } from "./impl/copy.js";
91
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";
90
+ import {
91
+ readText,
92
+ readTextSync,
93
+ readLines,
94
+ readLinesSync,
95
+ isDirectory,
96
+ isDirectorySync,
97
+ isSymlink,
98
+ isSymlinkSync,
92
99
  execAsync,
93
- setHiddenAttributeOnWindows,
94
- isHidden,
95
100
  isDirectoryEmpty,
96
- rmEnsureDir
97
- } from "./impl/utils/additional.js";
98
- async function* _diveWorker(currentPath, options, currentDepth) {
99
- const maxDepth = options.depth ?? Number.POSITIVE_INFINITY;
100
- if (currentDepth > maxDepth) {
101
- return;
102
- }
103
- let entries;
104
- try {
105
- entries = await nodeReaddirInternal(currentPath, { withFileTypes: true });
106
- } catch (_err) {
107
- return;
108
- }
109
- for (const entry of entries) {
110
- const entryPath = pathJoin(currentPath, entry.name);
111
- if (!(options.all ?? false) && entry.name.startsWith(".")) {
112
- continue;
113
- }
114
- if (options.ignore) {
115
- if (Array.isArray(options.ignore) && options.ignore.some((pattern) => entry.name.includes(pattern))) {
116
- continue;
117
- }
118
- if (options.ignore instanceof RegExp && options.ignore.test(entryPath)) {
119
- continue;
120
- }
121
- }
122
- let entryStat;
123
- try {
124
- entryStat = await nodeStatInternal(entryPath);
125
- } catch (_err) {
126
- continue;
127
- }
128
- if (entry.isDirectory()) {
129
- if (options.directories ?? false) {
130
- yield { file: entryPath, stat: entryStat };
131
- }
132
- if (options.recursive ?? true) {
133
- if (currentDepth < maxDepth) {
134
- yield* _diveWorker(entryPath, options, currentDepth + 1);
135
- }
136
- }
137
- } else if (entry.isFile()) {
138
- if (options.files ?? true) {
139
- yield { file: entryPath, stat: entryStat };
140
- }
141
- }
142
- }
143
- }
144
- export async function dive(directory, actionOrOptions, optionsOnly) {
145
- let action;
146
- let options;
147
- if (typeof actionOrOptions === "function") {
148
- action = actionOrOptions;
149
- options = optionsOnly;
150
- } else {
151
- options = actionOrOptions;
152
- }
153
- const currentOptions = {
154
- recursive: true,
155
- files: true,
156
- directories: false,
157
- all: false,
158
- depth: Number.POSITIVE_INFINITY,
159
- ...options
160
- // User options override defaults
161
- };
162
- if (action) {
163
- for await (const { file, stat: entryStat } of _diveWorker(directory, currentOptions, 0)) {
164
- await action(file, entryStat);
165
- }
166
- return;
167
- } else {
168
- const results = [];
169
- for await (const { file } of _diveWorker(directory, currentOptions, 0)) {
170
- results.push(file);
171
- }
172
- return results;
173
- }
174
- }
101
+ isHiddenAttribute,
102
+ rmEnsureDir,
103
+ setHiddenAttribute
104
+ } from "./impl/extras.js";
105
+ import { validateAndRepairJson } from "./impl/json-utils.js";
106
+ import { mkdirs, mkdirsSync } from "./impl/mkdirs.js";
107
+ import { move, moveSync } from "./impl/move.js";
108
+ import { outputFile, outputFileSync } from "./impl/output-file.js";
109
+ import { outputJson, outputJsonSync } from "./impl/output-json.js";
110
+ import { pathExists, pathExistsSync } from "./impl/path-exists.js";
111
+ import { readFile, readFileSync } from "./impl/read-file.js";
112
+ import { readJson, readJsonSync } from "./impl/read-json.js";
113
+ import { remove, removeSync } from "./impl/remove.js";
114
+ import { getFileExists, getFileLastModified, getFileSize, getStats, getStatsSync, toNodeStats } from "./impl/stats.js";
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";
175
130
  const mkdirp = mkdirs;
176
131
  const ensureDir = mkdirs;
177
132
  const ensureFile = createFile;
@@ -198,67 +153,7 @@ const cp = copy;
198
153
  const cpSync = copySync;
199
154
  const exists = pathExists;
200
155
  const existsSync = pathExistsSync;
201
- async function readText(filePath, options = "utf8") {
202
- return readFile(filePath, options);
203
- }
204
- function readTextSync(filePath, options = "utf8") {
205
- return readFileSync(filePath, options);
206
- }
207
- async function readLines(filePath, options = { encoding: "utf8" }) {
208
- const effectiveOptions = typeof options === "string" ? { encoding: options } : options;
209
- const contentBuffer = await readFile(filePath, { ...effectiveOptions, encoding: null });
210
- return contentBuffer.split(/\r?\n/);
211
- }
212
- function readLinesSync(filePath, options = { encoding: "utf8" }) {
213
- const effectiveOptions = typeof options === "string" ? { encoding: options } : options;
214
- const contentBuffer = readFileSync(filePath, { ...effectiveOptions, encoding: null });
215
- const content = contentBuffer;
216
- return content.split(/\r?\n/);
217
- }
218
- async function isDirectory(filePath) {
219
- try {
220
- const stats = await stat(filePath);
221
- return stats.isDirectory();
222
- } catch (error) {
223
- if (error.code === "ENOENT" || error.code === "ENOTDIR") {
224
- return false;
225
- }
226
- throw error;
227
- }
228
- }
229
- function isDirectorySync(filePath) {
230
- try {
231
- const stats = statSync(filePath);
232
- return stats.isDirectory();
233
- } catch (error) {
234
- if (error.code === "ENOENT" || error.code === "ENOTDIR") {
235
- return false;
236
- }
237
- throw error;
238
- }
239
- }
240
- async function isSymlink(filePath) {
241
- try {
242
- const stats = await lstat(filePath);
243
- return stats.isSymbolicLink();
244
- } catch (error) {
245
- if (error.code === "ENOENT") {
246
- return false;
247
- }
248
- throw error;
249
- }
250
- }
251
- function isSymlinkSync(filePath) {
252
- try {
253
- const stats = lstatSync(filePath);
254
- return stats.isSymbolicLink();
255
- } catch (error) {
256
- if (error.code === "ENOENT") {
257
- return false;
258
- }
259
- throw error;
260
- }
261
- }
156
+ const jsonRepairRegular = jsonrepair;
262
157
  export {
263
158
  accessSync,
264
159
  appendFileSync,
@@ -306,6 +201,10 @@ export {
306
201
  readJsonSync,
307
202
  writeJsonSync,
308
203
  createFileSync,
204
+ createDirSync,
205
+ createDirsSync,
206
+ createFilesSync,
207
+ emptyFileSync,
309
208
  mkdirsSync,
310
209
  emptyDirSync,
311
210
  pathExistsSync,
@@ -336,6 +235,10 @@ export {
336
235
  readJson,
337
236
  writeJson,
338
237
  createFile,
238
+ createDir,
239
+ createDirs,
240
+ createFiles,
241
+ emptyFile,
339
242
  mkdirs,
340
243
  emptyDir,
341
244
  pathExists,
@@ -393,10 +296,37 @@ export {
393
296
  readLines,
394
297
  readText,
395
298
  execAsync,
396
- setHiddenAttributeOnWindows,
397
- isHidden,
299
+ setHiddenAttribute,
300
+ isHiddenAttribute,
398
301
  isDirectoryEmpty,
399
- rmEnsureDir
302
+ rmEnsureDir,
303
+ dive,
304
+ getFileExists,
305
+ getFileLastModified,
306
+ getFileSize,
307
+ getStats,
308
+ getStatsSync,
309
+ emptyObject,
310
+ getFileBun,
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
400
330
  };
401
331
  const fs = {
402
332
  // Sync direct exports (node:fs)
@@ -446,6 +376,10 @@ const fs = {
446
376
  readJsonSync,
447
377
  writeJsonSync,
448
378
  createFileSync,
379
+ createDirSync,
380
+ createDirsSync,
381
+ createFilesSync,
382
+ emptyFileSync,
449
383
  mkdirsSync,
450
384
  emptyDirSync,
451
385
  pathExistsSync,
@@ -479,6 +413,10 @@ const fs = {
479
413
  readJson,
480
414
  writeJson,
481
415
  createFile,
416
+ createDir,
417
+ createDirs,
418
+ createFiles,
419
+ emptyFile,
482
420
  mkdirs,
483
421
  emptyDir,
484
422
  pathExists,
@@ -539,9 +477,38 @@ const fs = {
539
477
  readText,
540
478
  // Additional utility functions
541
479
  execAsync,
542
- setHiddenAttributeOnWindows,
543
- isHidden,
480
+ setHiddenAttribute,
481
+ isHiddenAttribute,
544
482
  isDirectoryEmpty,
545
- rmEnsureDir
483
+ rmEnsureDir,
484
+ dive,
485
+ getFileExists,
486
+ getFileLastModified,
487
+ getFileSize,
488
+ getStats,
489
+ getStatsSync,
490
+ emptyObject,
491
+ // Bun-specific utilities
492
+ getFileBun,
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
546
513
  };
547
514
  export default fs;
@@ -0,0 +1,4 @@
1
+ export declare class JSONRepairError extends Error {
2
+ position: number;
3
+ constructor(message: string, position: number);
4
+ }
@@ -0,0 +1,7 @@
1
+ export class JSONRepairError extends Error {
2
+ position;
3
+ constructor(message, position) {
4
+ super(`${message} at position ${position}`);
5
+ this.position = position;
6
+ }
7
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Custom error class for JSON Schema validation errors.
3
+ */
4
+ export declare class JsonSchemaError extends Error {
5
+ constructor(message: string);
6
+ }
@@ -0,0 +1,6 @@
1
+ export class JsonSchemaError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = "JsonSchemaError";
5
+ }
6
+ }
@@ -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;