@reliverse/relifso 1.4.5 → 2.2.8
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/README.md +365 -447
- package/dist/copy.d.ts +3 -0
- package/dist/copy.js +95 -0
- package/dist/dir.d.ts +13 -0
- package/dist/dir.js +113 -0
- package/dist/file.d.ts +12 -0
- package/dist/file.js +169 -0
- package/dist/helpers.d.ts +3 -0
- package/dist/helpers.js +38 -0
- package/dist/internal/fs.d.ts +16 -0
- package/dist/internal/fs.js +32 -0
- package/dist/internal/path.d.ts +3 -0
- package/dist/internal/path.js +11 -0
- package/dist/links.d.ts +3 -0
- package/dist/links.js +74 -0
- package/dist/mod.d.ts +40 -0
- package/dist/mod.js +77 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.js +0 -0
- package/package.json +15 -42
- package/LICENSE +0 -21
- package/LICENSES +0 -16
- package/bin/impl/bun.d.ts +0 -11
- package/bin/impl/bun.js +0 -23
- package/bin/impl/copy.d.ts +0 -40
- package/bin/impl/copy.js +0 -229
- package/bin/impl/create.d.ts +0 -34
- package/bin/impl/create.js +0 -54
- package/bin/impl/dive.d.ts +0 -27
- package/bin/impl/dive.js +0 -145
- package/bin/impl/empty.d.ts +0 -28
- package/bin/impl/empty.js +0 -75
- package/bin/impl/extras.d.ts +0 -35
- package/bin/impl/extras.js +0 -112
- package/bin/impl/json-utils.d.ts +0 -30
- package/bin/impl/json-utils.js +0 -46
- package/bin/impl/mkdirs.d.ts +0 -7
- package/bin/impl/mkdirs.js +0 -28
- package/bin/impl/move.d.ts +0 -28
- package/bin/impl/move.js +0 -140
- package/bin/impl/output-file.d.ts +0 -17
- package/bin/impl/output-file.js +0 -15
- package/bin/impl/output-json.d.ts +0 -21
- package/bin/impl/output-json.js +0 -77
- package/bin/impl/path-exists.d.ts +0 -2
- package/bin/impl/path-exists.js +0 -16
- package/bin/impl/read-file.d.ts +0 -31
- package/bin/impl/read-file.js +0 -165
- package/bin/impl/read-json.d.ts +0 -31
- package/bin/impl/read-json.js +0 -241
- package/bin/impl/remove.d.ts +0 -2
- package/bin/impl/remove.js +0 -8
- package/bin/impl/stats.d.ts +0 -31
- package/bin/impl/stats.js +0 -141
- package/bin/impl/write-file.d.ts +0 -31
- package/bin/impl/write-file.js +0 -177
- package/bin/impl/write-json.d.ts +0 -41
- package/bin/impl/write-json.js +0 -135
- package/bin/mod.d.ts +0 -253
- package/bin/mod.js +0 -514
- package/bin/utils/json/helpers/JSONRepairError.d.ts +0 -4
- package/bin/utils/json/helpers/JSONRepairError.js +0 -7
- package/bin/utils/json/helpers/JsonSchemaError.d.ts +0 -6
- package/bin/utils/json/helpers/JsonSchemaError.js +0 -6
- package/bin/utils/json/helpers/stringUtils.d.ts +0 -64
- package/bin/utils/json/helpers/stringUtils.js +0 -87
- package/bin/utils/json/regular/jsonc.d.ts +0 -45
- package/bin/utils/json/regular/jsonc.js +0 -88
- package/bin/utils/json/regular/jsonrepair.d.ts +0 -17
- package/bin/utils/json/regular/jsonrepair.js +0 -576
- package/bin/utils/json/regular/validate.d.ts +0 -22
- package/bin/utils/json/regular/validate.js +0 -52
- package/bin/utils/json/stream/JsonStreamError.d.ts +0 -6
- package/bin/utils/json/stream/JsonStreamError.js +0 -6
- package/bin/utils/json/stream/buffer/InputBuffer.d.ts +0 -13
- package/bin/utils/json/stream/buffer/InputBuffer.js +0 -68
- package/bin/utils/json/stream/buffer/OutputBuffer.d.ts +0 -17
- package/bin/utils/json/stream/buffer/OutputBuffer.js +0 -101
- package/bin/utils/json/stream/core.d.ts +0 -10
- package/bin/utils/json/stream/core.js +0 -695
- package/bin/utils/json/stream/jsonl.d.ts +0 -21
- package/bin/utils/json/stream/jsonl.js +0 -55
- package/bin/utils/json/stream/parser.d.ts +0 -14
- package/bin/utils/json/stream/parser.js +0 -81
- package/bin/utils/json/stream/stack.d.ts +0 -19
- package/bin/utils/json/stream/stack.js +0 -43
- package/bin/utils/json/stream/stream.d.ts +0 -6
- package/bin/utils/json/stream/stream.js +0 -30
- package/bin/utils/json/stream/writer.d.ts +0 -14
- package/bin/utils/json/stream/writer.js +0 -44
- package/bin/utils/log.d.ts +0 -1
- package/bin/utils/log.js +0 -7
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Transform } from "node:stream";
|
|
2
|
-
import { JsonStreamError } from "./JsonStreamError.js";
|
|
3
|
-
export function createJsonlParser(options = {}) {
|
|
4
|
-
const {
|
|
5
|
-
chunkSize = 1024 * 1024,
|
|
6
|
-
// 1MB default chunk size
|
|
7
|
-
reviver
|
|
8
|
-
} = options;
|
|
9
|
-
let buffer = "";
|
|
10
|
-
return new Transform({
|
|
11
|
-
transform(chunk, _encoding, callback) {
|
|
12
|
-
try {
|
|
13
|
-
const text = chunk.toString();
|
|
14
|
-
buffer += text;
|
|
15
|
-
const lines = buffer.split("\n");
|
|
16
|
-
buffer = lines.pop() || "";
|
|
17
|
-
for (const line of lines) {
|
|
18
|
-
if (line.trim()) {
|
|
19
|
-
try {
|
|
20
|
-
const parsed = JSON.parse(line, reviver);
|
|
21
|
-
this.push(parsed);
|
|
22
|
-
} catch (error) {
|
|
23
|
-
const parseError = error;
|
|
24
|
-
throw new JsonStreamError(`Failed to parse JSONL line: ${parseError.message}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (buffer.length > chunkSize) {
|
|
29
|
-
throw new JsonStreamError("Chunk size exceeded without finding complete JSONL line");
|
|
30
|
-
}
|
|
31
|
-
callback();
|
|
32
|
-
} catch (error) {
|
|
33
|
-
callback(error instanceof Error ? error : new JsonStreamError(String(error)));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
export function createJsonlWriter(options = {}) {
|
|
39
|
-
const { replacer } = options;
|
|
40
|
-
return new Transform({
|
|
41
|
-
transform(chunk, _encoding, callback) {
|
|
42
|
-
try {
|
|
43
|
-
const jsonStr = JSON.stringify(chunk, replacer);
|
|
44
|
-
if (jsonStr === void 0) {
|
|
45
|
-
throw new JsonStreamError("Failed to stringify JSON object");
|
|
46
|
-
}
|
|
47
|
-
this.push(`${jsonStr}
|
|
48
|
-
`);
|
|
49
|
-
callback();
|
|
50
|
-
} catch (error) {
|
|
51
|
-
callback(error instanceof Error ? error : new JsonStreamError(String(error)));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Transform } from "node:stream";
|
|
2
|
-
interface ParserOptions {
|
|
3
|
-
chunkSize?: number;
|
|
4
|
-
maxDepth?: number;
|
|
5
|
-
reviver?: (key: string, value: unknown) => unknown;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Creates a transform stream that parses JSON data chunk by chunk.
|
|
9
|
-
*
|
|
10
|
-
* @param options - Parser options
|
|
11
|
-
* @returns A transform stream that emits parsed JSON objects
|
|
12
|
-
*/
|
|
13
|
-
export declare function createJsonStreamParser(options?: ParserOptions): Transform;
|
|
14
|
-
export {};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Transform } from "node:stream";
|
|
2
|
-
import { JsonStreamError } from "./JsonStreamError.js";
|
|
3
|
-
export function createJsonStreamParser(options = {}) {
|
|
4
|
-
const {
|
|
5
|
-
chunkSize = 1024 * 1024,
|
|
6
|
-
// 1MB default chunk size
|
|
7
|
-
maxDepth = 100,
|
|
8
|
-
reviver
|
|
9
|
-
} = options;
|
|
10
|
-
let buffer = "";
|
|
11
|
-
let depth = 0;
|
|
12
|
-
let inString = false;
|
|
13
|
-
let escapeNext = false;
|
|
14
|
-
return new Transform({
|
|
15
|
-
transform(chunk, _encoding, callback) {
|
|
16
|
-
try {
|
|
17
|
-
const text = chunk.toString();
|
|
18
|
-
buffer += text;
|
|
19
|
-
while (buffer.length > 0) {
|
|
20
|
-
const start = buffer.indexOf("{");
|
|
21
|
-
if (start === -1) {
|
|
22
|
-
buffer = "";
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
buffer = buffer.slice(start);
|
|
26
|
-
depth = 0;
|
|
27
|
-
inString = false;
|
|
28
|
-
escapeNext = false;
|
|
29
|
-
let end = -1;
|
|
30
|
-
for (let i = 0; i < buffer.length; i++) {
|
|
31
|
-
const char = buffer[i];
|
|
32
|
-
if (escapeNext) {
|
|
33
|
-
escapeNext = false;
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (char === "\\") {
|
|
37
|
-
escapeNext = true;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (char === '"' && !escapeNext) {
|
|
41
|
-
inString = !inString;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (!inString) {
|
|
45
|
-
if (char === "{") {
|
|
46
|
-
depth++;
|
|
47
|
-
if (depth > maxDepth) {
|
|
48
|
-
throw new JsonStreamError(`Maximum nesting depth of ${maxDepth} exceeded`);
|
|
49
|
-
}
|
|
50
|
-
} else if (char === "}") {
|
|
51
|
-
depth--;
|
|
52
|
-
if (depth === 0) {
|
|
53
|
-
end = i + 1;
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (end === -1) {
|
|
60
|
-
if (buffer.length > chunkSize) {
|
|
61
|
-
throw new JsonStreamError("Chunk size exceeded without finding complete JSON object");
|
|
62
|
-
}
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
const jsonStr = buffer.slice(0, end);
|
|
66
|
-
try {
|
|
67
|
-
const parsed = JSON.parse(jsonStr, reviver);
|
|
68
|
-
this.push(parsed);
|
|
69
|
-
} catch (error) {
|
|
70
|
-
const parseError = error;
|
|
71
|
-
throw new JsonStreamError(`Failed to parse JSON: ${parseError.message}`);
|
|
72
|
-
}
|
|
73
|
-
buffer = buffer.slice(end);
|
|
74
|
-
}
|
|
75
|
-
callback();
|
|
76
|
-
} catch (error) {
|
|
77
|
-
callback(error instanceof Error ? error : new JsonStreamError(String(error)));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare enum Caret {
|
|
2
|
-
beforeValue = "beforeValue",
|
|
3
|
-
afterValue = "afterValue",
|
|
4
|
-
beforeKey = "beforeKey"
|
|
5
|
-
}
|
|
6
|
-
export declare enum StackType {
|
|
7
|
-
root = "root",
|
|
8
|
-
object = "object",
|
|
9
|
-
array = "array",
|
|
10
|
-
ndJson = "ndJson",
|
|
11
|
-
functionCall = "dataType"
|
|
12
|
-
}
|
|
13
|
-
export declare function createStack(): {
|
|
14
|
-
readonly type: StackType | undefined;
|
|
15
|
-
readonly caret: Caret;
|
|
16
|
-
pop(): true;
|
|
17
|
-
push(type: StackType, newCaret: Caret): true;
|
|
18
|
-
update(newCaret: Caret): true;
|
|
19
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export var Caret = /* @__PURE__ */ ((Caret2) => {
|
|
2
|
-
Caret2["beforeValue"] = "beforeValue";
|
|
3
|
-
Caret2["afterValue"] = "afterValue";
|
|
4
|
-
Caret2["beforeKey"] = "beforeKey";
|
|
5
|
-
return Caret2;
|
|
6
|
-
})(Caret || {});
|
|
7
|
-
export var StackType = /* @__PURE__ */ ((StackType2) => {
|
|
8
|
-
StackType2["root"] = "root";
|
|
9
|
-
StackType2["object"] = "object";
|
|
10
|
-
StackType2["array"] = "array";
|
|
11
|
-
StackType2["ndJson"] = "ndJson";
|
|
12
|
-
StackType2["functionCall"] = "dataType";
|
|
13
|
-
return StackType2;
|
|
14
|
-
})(StackType || {});
|
|
15
|
-
export function createStack() {
|
|
16
|
-
const stack = ["root" /* root */];
|
|
17
|
-
let caret = "beforeValue" /* beforeValue */;
|
|
18
|
-
return {
|
|
19
|
-
get type() {
|
|
20
|
-
return last(stack);
|
|
21
|
-
},
|
|
22
|
-
get caret() {
|
|
23
|
-
return caret;
|
|
24
|
-
},
|
|
25
|
-
pop() {
|
|
26
|
-
stack.pop();
|
|
27
|
-
caret = "afterValue" /* afterValue */;
|
|
28
|
-
return true;
|
|
29
|
-
},
|
|
30
|
-
push(type, newCaret) {
|
|
31
|
-
stack.push(type);
|
|
32
|
-
caret = newCaret;
|
|
33
|
-
return true;
|
|
34
|
-
},
|
|
35
|
-
update(newCaret) {
|
|
36
|
-
caret = newCaret;
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function last(array) {
|
|
42
|
-
return array[array.length - 1];
|
|
43
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Transform } from "node:stream";
|
|
2
|
-
import { jsonrepairCore } from "./core.js";
|
|
3
|
-
export function jsonrepairTransform(options) {
|
|
4
|
-
const repair = jsonrepairCore({
|
|
5
|
-
onData: (chunk) => transform.push(chunk),
|
|
6
|
-
bufferSize: options?.bufferSize,
|
|
7
|
-
chunkSize: options?.chunkSize
|
|
8
|
-
});
|
|
9
|
-
const transform = new Transform({
|
|
10
|
-
transform(chunk, _encoding, callback) {
|
|
11
|
-
try {
|
|
12
|
-
repair.transform(chunk.toString());
|
|
13
|
-
} catch (err) {
|
|
14
|
-
this.emit("error", err);
|
|
15
|
-
} finally {
|
|
16
|
-
callback();
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
flush(callback) {
|
|
20
|
-
try {
|
|
21
|
-
repair.flush();
|
|
22
|
-
} catch (err) {
|
|
23
|
-
this.emit("error", err);
|
|
24
|
-
} finally {
|
|
25
|
-
callback();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
return transform;
|
|
30
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Transform } from "node:stream";
|
|
2
|
-
interface WriterOptions {
|
|
3
|
-
chunkSize?: number;
|
|
4
|
-
replacer?: (key: string, value: unknown) => unknown | (number | string)[] | null;
|
|
5
|
-
spaces?: string | number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Creates a transform stream that writes JSON data chunk by chunk.
|
|
9
|
-
*
|
|
10
|
-
* @param options - Writer options
|
|
11
|
-
* @returns A transform stream that accepts objects and outputs JSON strings
|
|
12
|
-
*/
|
|
13
|
-
export declare function createJsonStreamWriter(options?: WriterOptions): Transform;
|
|
14
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Transform } from "node:stream";
|
|
2
|
-
import { JsonStreamError } from "./JsonStreamError.js";
|
|
3
|
-
export function createJsonStreamWriter(options = {}) {
|
|
4
|
-
const {
|
|
5
|
-
chunkSize = 1024 * 1024,
|
|
6
|
-
// 1MB default chunk size
|
|
7
|
-
replacer,
|
|
8
|
-
spaces
|
|
9
|
-
} = options;
|
|
10
|
-
let isFirst = true;
|
|
11
|
-
let buffer = "";
|
|
12
|
-
return new Transform({
|
|
13
|
-
transform(chunk, _encoding, callback) {
|
|
14
|
-
try {
|
|
15
|
-
const jsonStr = JSON.stringify(chunk, replacer, spaces);
|
|
16
|
-
if (jsonStr === void 0) {
|
|
17
|
-
throw new JsonStreamError("Failed to stringify JSON object");
|
|
18
|
-
}
|
|
19
|
-
if (!isFirst) {
|
|
20
|
-
buffer += ",";
|
|
21
|
-
}
|
|
22
|
-
isFirst = false;
|
|
23
|
-
buffer += jsonStr;
|
|
24
|
-
if (buffer.length >= chunkSize) {
|
|
25
|
-
this.push(buffer);
|
|
26
|
-
buffer = "";
|
|
27
|
-
}
|
|
28
|
-
callback();
|
|
29
|
-
} catch (error) {
|
|
30
|
-
callback(error instanceof Error ? error : new JsonStreamError(String(error)));
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
flush(callback) {
|
|
34
|
-
try {
|
|
35
|
-
if (buffer.length > 0) {
|
|
36
|
-
this.push(buffer);
|
|
37
|
-
}
|
|
38
|
-
callback();
|
|
39
|
-
} catch (error) {
|
|
40
|
-
callback(error instanceof Error ? error : new JsonStreamError(String(error)));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
package/bin/utils/log.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const logInternal: (msg: string | (() => string)) => void;
|