@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,45 +0,0 @@
|
|
|
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
|
-
}[];
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { JSONRepairError } from "../helpers/JSONRepairError.js";
|
|
2
|
-
import { jsonrepair } from "./jsonrepair.js";
|
|
3
|
-
export function parseJsonc(text, options = {}) {
|
|
4
|
-
const { throws = true } = options;
|
|
5
|
-
try {
|
|
6
|
-
return JSON.parse(text);
|
|
7
|
-
} catch (_error) {
|
|
8
|
-
try {
|
|
9
|
-
const repaired = jsonrepair(text);
|
|
10
|
-
return JSON.parse(repaired);
|
|
11
|
-
} catch (_error2) {
|
|
12
|
-
if (throws) {
|
|
13
|
-
throw new JSONRepairError("Failed to parse JSONC", -1);
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export function stringifyJsonc(value, options = {}) {
|
|
20
|
-
const { spaces = 2 } = options;
|
|
21
|
-
return JSON.stringify(value, null, spaces);
|
|
22
|
-
}
|
|
23
|
-
export function isValidJsonc(text) {
|
|
24
|
-
try {
|
|
25
|
-
parseJsonc(text, { throws: true });
|
|
26
|
-
return true;
|
|
27
|
-
} catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export function extractComments(text) {
|
|
32
|
-
const comments = [];
|
|
33
|
-
let line = 1;
|
|
34
|
-
let column = 0;
|
|
35
|
-
let i = 0;
|
|
36
|
-
while (i < text.length) {
|
|
37
|
-
const char = text[i];
|
|
38
|
-
if (char === "/" && text[i + 1] === "/") {
|
|
39
|
-
const startColumn = column;
|
|
40
|
-
const startLine = line;
|
|
41
|
-
let commentText = "";
|
|
42
|
-
i += 2;
|
|
43
|
-
while (i < text.length && text[i] !== "\n") {
|
|
44
|
-
commentText += text[i];
|
|
45
|
-
i++;
|
|
46
|
-
}
|
|
47
|
-
comments.push({
|
|
48
|
-
line: startLine,
|
|
49
|
-
column: startColumn,
|
|
50
|
-
text: commentText.trim(),
|
|
51
|
-
type: "line"
|
|
52
|
-
});
|
|
53
|
-
} else if (char === "/" && text[i + 1] === "*") {
|
|
54
|
-
const startColumn = column;
|
|
55
|
-
const startLine = line;
|
|
56
|
-
let commentText = "";
|
|
57
|
-
i += 2;
|
|
58
|
-
while (i < text.length - 1 && !(text[i] === "*" && text[i + 1] === "/")) {
|
|
59
|
-
if (text[i] === "\n") {
|
|
60
|
-
line++;
|
|
61
|
-
column = 0;
|
|
62
|
-
} else {
|
|
63
|
-
column++;
|
|
64
|
-
}
|
|
65
|
-
commentText += text[i];
|
|
66
|
-
i++;
|
|
67
|
-
}
|
|
68
|
-
if (i < text.length - 1) {
|
|
69
|
-
i += 2;
|
|
70
|
-
}
|
|
71
|
-
comments.push({
|
|
72
|
-
line: startLine,
|
|
73
|
-
column: startColumn,
|
|
74
|
-
text: commentText.trim(),
|
|
75
|
-
type: "block"
|
|
76
|
-
});
|
|
77
|
-
} else {
|
|
78
|
-
if (char === "\n") {
|
|
79
|
-
line++;
|
|
80
|
-
column = 0;
|
|
81
|
-
} else {
|
|
82
|
-
column++;
|
|
83
|
-
}
|
|
84
|
-
i++;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return comments;
|
|
88
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repair a string containing an invalid JSON document.
|
|
3
|
-
* For example changes JavaScript notation into JSON notation.
|
|
4
|
-
*
|
|
5
|
-
* Example:
|
|
6
|
-
*
|
|
7
|
-
* try {
|
|
8
|
-
* const json = "{name: 'John'}"
|
|
9
|
-
* const repaired = jsonrepair(json)
|
|
10
|
-
* console.log(repaired)
|
|
11
|
-
* // '{"name": "John"}'
|
|
12
|
-
* } catch (err) {
|
|
13
|
-
* console.error(err)
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export declare function jsonrepair(text: string): string;
|