@graffy/testing 0.16.0-alpha.1 → 0.16.0-alpha.10
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/index.cjs +2 -45
- package/index.mjs +2 -45
- package/package.json +2 -2
- package/types/index.d.ts +1 -2
- package/types/format.d.ts +0 -2
package/index.cjs
CHANGED
|
@@ -21,47 +21,6 @@ function mockBackend(options = {}) {
|
|
|
21
21
|
};
|
|
22
22
|
return backend;
|
|
23
23
|
}
|
|
24
|
-
function escape(string) {
|
|
25
|
-
if (string === "")
|
|
26
|
-
return "''";
|
|
27
|
-
return string.replace(/\uffff/g, "\u{1D58B}\u{1D58B}").replace(/\0/g, "\u{1D594}\u{1D594}");
|
|
28
|
-
}
|
|
29
|
-
function interval(key, end) {
|
|
30
|
-
if (key === end)
|
|
31
|
-
return `${key} \xD7`;
|
|
32
|
-
return [
|
|
33
|
-
escape(key),
|
|
34
|
-
" \u22EF ",
|
|
35
|
-
escape(end)
|
|
36
|
-
].join("");
|
|
37
|
-
}
|
|
38
|
-
let lastPrintedVersion;
|
|
39
|
-
function format(graph, indent = "") {
|
|
40
|
-
if (!graph)
|
|
41
|
-
return graph;
|
|
42
|
-
if (indent === "")
|
|
43
|
-
lastPrintedVersion = null;
|
|
44
|
-
if (!Array.isArray(graph))
|
|
45
|
-
graph = [graph];
|
|
46
|
-
if (!graph.length)
|
|
47
|
-
return "[]";
|
|
48
|
-
return "\n" + graph.map(
|
|
49
|
-
({ key, end, children, version, path, value, ...rest }) => [
|
|
50
|
-
lastPrintedVersion === version ? "" : "<@" + (lastPrintedVersion = version) + ">\n",
|
|
51
|
-
indent,
|
|
52
|
-
end ? interval(key, end) : escape(key),
|
|
53
|
-
path ? ` \u279A${path.join(".")}` : "",
|
|
54
|
-
value ? ` ${JSON.stringify(value)}` : "",
|
|
55
|
-
Object.keys(rest).length > 0 ? " " + JSON.stringify(rest) : "",
|
|
56
|
-
children ? " {" : "",
|
|
57
|
-
children ? format(children, indent + " ") : "",
|
|
58
|
-
children ? " }" : ""
|
|
59
|
-
].join("")
|
|
60
|
-
).join("\n");
|
|
61
|
-
}
|
|
62
|
-
function inspect() {
|
|
63
|
-
return format(this);
|
|
64
|
-
}
|
|
65
24
|
function pretty(query) {
|
|
66
25
|
return JSON.stringify(query, null, 4).replace(
|
|
67
26
|
/\[(\s*)([\s\S]*?)\},*/g,
|
|
@@ -71,8 +30,8 @@ function pretty(query) {
|
|
|
71
30
|
(char) => "\\u" + char.charCodeAt(0).toString(16).padStart(4)
|
|
72
31
|
);
|
|
73
32
|
}
|
|
74
|
-
const put = (obj) => {
|
|
75
|
-
Object.defineProperty(obj, "$put", { value:
|
|
33
|
+
const put = (obj, $put = true) => {
|
|
34
|
+
Object.defineProperty(obj, "$put", { value: $put });
|
|
76
35
|
return obj;
|
|
77
36
|
};
|
|
78
37
|
const ref = ($ref, obj = {}) => {
|
|
@@ -84,8 +43,6 @@ const keyref = ($key, $ref, obj = {}) => {
|
|
|
84
43
|
ref($ref, obj);
|
|
85
44
|
return obj;
|
|
86
45
|
};
|
|
87
|
-
exports.format = format;
|
|
88
|
-
exports.inspect = inspect;
|
|
89
46
|
exports.keyref = keyref;
|
|
90
47
|
exports.mockBackend = mockBackend;
|
|
91
48
|
exports.pretty = pretty;
|
package/index.mjs
CHANGED
|
@@ -19,47 +19,6 @@ function mockBackend(options = {}) {
|
|
|
19
19
|
};
|
|
20
20
|
return backend;
|
|
21
21
|
}
|
|
22
|
-
function escape(string) {
|
|
23
|
-
if (string === "")
|
|
24
|
-
return "''";
|
|
25
|
-
return string.replace(/\uffff/g, "\u{1D58B}\u{1D58B}").replace(/\0/g, "\u{1D594}\u{1D594}");
|
|
26
|
-
}
|
|
27
|
-
function interval(key, end) {
|
|
28
|
-
if (key === end)
|
|
29
|
-
return `${key} \xD7`;
|
|
30
|
-
return [
|
|
31
|
-
escape(key),
|
|
32
|
-
" \u22EF ",
|
|
33
|
-
escape(end)
|
|
34
|
-
].join("");
|
|
35
|
-
}
|
|
36
|
-
let lastPrintedVersion;
|
|
37
|
-
function format(graph, indent = "") {
|
|
38
|
-
if (!graph)
|
|
39
|
-
return graph;
|
|
40
|
-
if (indent === "")
|
|
41
|
-
lastPrintedVersion = null;
|
|
42
|
-
if (!Array.isArray(graph))
|
|
43
|
-
graph = [graph];
|
|
44
|
-
if (!graph.length)
|
|
45
|
-
return "[]";
|
|
46
|
-
return "\n" + graph.map(
|
|
47
|
-
({ key, end, children, version, path, value, ...rest }) => [
|
|
48
|
-
lastPrintedVersion === version ? "" : "<@" + (lastPrintedVersion = version) + ">\n",
|
|
49
|
-
indent,
|
|
50
|
-
end ? interval(key, end) : escape(key),
|
|
51
|
-
path ? ` \u279A${path.join(".")}` : "",
|
|
52
|
-
value ? ` ${JSON.stringify(value)}` : "",
|
|
53
|
-
Object.keys(rest).length > 0 ? " " + JSON.stringify(rest) : "",
|
|
54
|
-
children ? " {" : "",
|
|
55
|
-
children ? format(children, indent + " ") : "",
|
|
56
|
-
children ? " }" : ""
|
|
57
|
-
].join("")
|
|
58
|
-
).join("\n");
|
|
59
|
-
}
|
|
60
|
-
function inspect() {
|
|
61
|
-
return format(this);
|
|
62
|
-
}
|
|
63
22
|
function pretty(query) {
|
|
64
23
|
return JSON.stringify(query, null, 4).replace(
|
|
65
24
|
/\[(\s*)([\s\S]*?)\},*/g,
|
|
@@ -69,8 +28,8 @@ function pretty(query) {
|
|
|
69
28
|
(char) => "\\u" + char.charCodeAt(0).toString(16).padStart(4)
|
|
70
29
|
);
|
|
71
30
|
}
|
|
72
|
-
const put = (obj) => {
|
|
73
|
-
Object.defineProperty(obj, "$put", { value:
|
|
31
|
+
const put = (obj, $put = true) => {
|
|
32
|
+
Object.defineProperty(obj, "$put", { value: $put });
|
|
74
33
|
return obj;
|
|
75
34
|
};
|
|
76
35
|
const ref = ($ref, obj = {}) => {
|
|
@@ -83,8 +42,6 @@ const keyref = ($key, $ref, obj = {}) => {
|
|
|
83
42
|
return obj;
|
|
84
43
|
};
|
|
85
44
|
export {
|
|
86
|
-
format,
|
|
87
|
-
inspect,
|
|
88
45
|
keyref,
|
|
89
46
|
mockBackend,
|
|
90
47
|
pretty,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/testing",
|
|
3
3
|
"description": "Testing and debugging utilities for Graffy.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.16.0-alpha.
|
|
5
|
+
"version": "0.16.0-alpha.10",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@graffy/common": "0.16.0-alpha.
|
|
19
|
+
"@graffy/common": "0.16.0-alpha.10"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { default as mockBackend } from "./mockBackend.js";
|
|
2
2
|
export { default as pretty } from "./pretty.js";
|
|
3
|
-
export function put(obj: any): any;
|
|
3
|
+
export function put(obj: any, $put?: boolean | any): any;
|
|
4
4
|
export function ref($ref: any, obj?: {}): {};
|
|
5
5
|
export function keyref($key: any, $ref: any, obj?: {}): {};
|
|
6
|
-
export { default as format, inspect } from "./format.js";
|
package/types/format.d.ts
DELETED