json-renderers-run-instructions 1.2.3 → 1.3.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/package.json +1 -1
- package/src/index.js +3 -2
- package/src/v3/index.js +35 -0
- package/src/v1/index.js +0 -60
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
|
|
1
|
+
export * from "./v3/index.js";
|
|
2
|
+
|
|
3
|
+
export { default } from "./v3/index.js";
|
package/src/v3/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import runSingleInstructions from "json-instruction-single";
|
|
2
|
+
import runDoubleInstructions from "json-instruction-double";
|
|
3
|
+
|
|
4
|
+
export const runInstructions = ({
|
|
5
|
+
single = [],
|
|
6
|
+
double = [],
|
|
7
|
+
registry = {},
|
|
8
|
+
showLog = false
|
|
9
|
+
} = {}) => {
|
|
10
|
+
if (showLog) console.log("runInstructions : ", single, double);
|
|
11
|
+
|
|
12
|
+
if (!Array.isArray(single)) {
|
|
13
|
+
throw new TypeError("single instructions must be an array");
|
|
14
|
+
}
|
|
15
|
+
if (!Array.isArray(double)) {
|
|
16
|
+
throw new TypeError("double instructions must be an array");
|
|
17
|
+
}
|
|
18
|
+
if (!registry || typeof registry !== "object" || Array.isArray(registry)) {
|
|
19
|
+
throw new TypeError("registry must be an object");
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
if (single.length > 0) {
|
|
23
|
+
runSingleInstructions(single, registry, showLog);
|
|
24
|
+
}
|
|
25
|
+
if (double.length > 0) {
|
|
26
|
+
runDoubleInstructions({
|
|
27
|
+
instructions: double,
|
|
28
|
+
registry
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return registry;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default runInstructions;
|
package/src/v1/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import runSingleInstructions from "json-instruction-single";
|
|
2
|
-
import runDoubleInstructions from "json-instruction-double";
|
|
3
|
-
import jsonToDom from "@keshavsoft/json-to-dom";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Executes the single- and double-target instruction lists against a shared registry.
|
|
7
|
-
* This module deliberately knows nothing about tables or table definitions.
|
|
8
|
-
*/
|
|
9
|
-
export const runInstructions = ({
|
|
10
|
-
single = [],
|
|
11
|
-
double = [],
|
|
12
|
-
registry = {},
|
|
13
|
-
showLog = false
|
|
14
|
-
} = {}) => {
|
|
15
|
-
if (!Array.isArray(single)) {
|
|
16
|
-
throw new TypeError("single instructions must be an array");
|
|
17
|
-
}
|
|
18
|
-
if (!Array.isArray(double)) {
|
|
19
|
-
throw new TypeError("double instructions must be an array");
|
|
20
|
-
}
|
|
21
|
-
if (!registry || typeof registry !== "object" || Array.isArray(registry)) {
|
|
22
|
-
throw new TypeError("registry must be an object");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (single.length > 0) {
|
|
26
|
-
runSingleInstructions(single, registry, showLog);
|
|
27
|
-
}
|
|
28
|
-
if (double.length > 0) {
|
|
29
|
-
runDoubleInstructions(double, registry);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return registry;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Mounts a generated JSON specification into the DOM.
|
|
37
|
-
* The caller owns spec generation and supplies the completed JSON spec.
|
|
38
|
-
*/
|
|
39
|
-
export const renderJsonToDom = ({
|
|
40
|
-
jsonSpec,
|
|
41
|
-
targetHtmlId,
|
|
42
|
-
appendPosition,
|
|
43
|
-
showLog = false
|
|
44
|
-
} = {}) => {
|
|
45
|
-
if (!jsonSpec || typeof jsonSpec !== "object" || Array.isArray(jsonSpec)) {
|
|
46
|
-
throw new TypeError("jsonSpec must be a JSON object");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return jsonToDom({
|
|
50
|
-
jsonSpec,
|
|
51
|
-
targetHtmlId,
|
|
52
|
-
appendPosition,
|
|
53
|
-
showLog
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export default {
|
|
58
|
-
runInstructions,
|
|
59
|
-
renderJsonToDom
|
|
60
|
-
};
|