@rljson/rljson 0.0.74 → 0.0.75
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/dist/content/tree.d.ts +2 -1
- package/dist/rljson.js +14 -1
- package/package.json +10 -10
package/dist/content/tree.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export declare const exampleTreesTable: () => TreesTable;
|
|
|
47
47
|
/**
|
|
48
48
|
* Converts a plain object into a tree structure
|
|
49
49
|
* @param obj - The plain object to convert
|
|
50
|
+
* @param skipRootCreation - If true, skips creating an automatic root node (default: false)
|
|
50
51
|
* @returns An array of Tree nodes representing the tree structure
|
|
51
52
|
*/
|
|
52
|
-
export declare const treeFromObject: (obj: any) => TreeWithHash[];
|
|
53
|
+
export declare const treeFromObject: (obj: any, skipRootCreation?: boolean) => TreeWithHash[];
|
package/dist/rljson.js
CHANGED
|
@@ -643,7 +643,7 @@ const createTreesTableCfg = (treesTableKey) => ({
|
|
|
643
643
|
isShared: true
|
|
644
644
|
});
|
|
645
645
|
const exampleTreesTable = () => bakeryExample().recipesTreeTable;
|
|
646
|
-
const treeFromObject = (obj) => {
|
|
646
|
+
const treeFromObject = (obj, skipRootCreation = false) => {
|
|
647
647
|
const result = [];
|
|
648
648
|
const processedIds = /* @__PURE__ */ new Set();
|
|
649
649
|
const idToHashMap = /* @__PURE__ */ new Map();
|
|
@@ -725,13 +725,26 @@ const treeFromObject = (obj) => {
|
|
|
725
725
|
result.push(hashedNode);
|
|
726
726
|
}
|
|
727
727
|
};
|
|
728
|
+
const topLevelIds = [];
|
|
728
729
|
if (obj !== null && typeof obj === "object" && !Array.isArray(obj)) {
|
|
729
730
|
for (const key in obj) {
|
|
730
731
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
732
|
+
topLevelIds.push(key);
|
|
731
733
|
processNode(obj[key], key);
|
|
732
734
|
}
|
|
733
735
|
}
|
|
734
736
|
}
|
|
737
|
+
if (!skipRootCreation && topLevelIds.length > 0) {
|
|
738
|
+
const rootNode = {
|
|
739
|
+
id: "root",
|
|
740
|
+
isParent: true,
|
|
741
|
+
meta: null,
|
|
742
|
+
children: topLevelIds.map((id) => idToHashMap.get(id))
|
|
743
|
+
};
|
|
744
|
+
const hashedRootNode = hip(rootNode);
|
|
745
|
+
idToHashMap.set("root", hashedRootNode._hash);
|
|
746
|
+
result.push(hashedRootNode);
|
|
747
|
+
}
|
|
735
748
|
return result;
|
|
736
749
|
};
|
|
737
750
|
class Example {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/rljson",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.75",
|
|
4
4
|
"description": "The RLJSON data format specification",
|
|
5
5
|
"homepage": "https://github.com/rljson/rljson",
|
|
6
6
|
"bugs": "https://github.com/rljson/rljson/issues",
|
|
@@ -20,24 +20,24 @@
|
|
|
20
20
|
],
|
|
21
21
|
"type": "module",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "^25.0
|
|
24
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
25
|
-
"@typescript-eslint/parser": "^8.
|
|
26
|
-
"@vitest/coverage-v8": "^4.0.
|
|
23
|
+
"@types/node": "^25.1.0",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
25
|
+
"@typescript-eslint/parser": "^8.54.0",
|
|
26
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
27
27
|
"cross-env": "^10.1.0",
|
|
28
28
|
"eslint": "^9.39.2",
|
|
29
|
-
"eslint-plugin-jsdoc": "^62.
|
|
29
|
+
"eslint-plugin-jsdoc": "^62.5.0",
|
|
30
30
|
"eslint-plugin-tsdoc": "^0.5.0",
|
|
31
|
-
"globals": "^17.
|
|
31
|
+
"globals": "^17.2.0",
|
|
32
32
|
"jsdoc": "^4.0.5",
|
|
33
33
|
"read-pkg": "^10.0.0",
|
|
34
34
|
"typescript": "~5.9.3",
|
|
35
|
-
"typescript-eslint": "^8.
|
|
35
|
+
"typescript-eslint": "^8.54.0",
|
|
36
36
|
"vite": "^7.3.1",
|
|
37
37
|
"vite-node": "^5.3.0",
|
|
38
38
|
"vite-plugin-dts": "^4.5.4",
|
|
39
|
-
"vite-tsconfig-paths": "^6.0.
|
|
40
|
-
"vitest": "^4.0.
|
|
39
|
+
"vite-tsconfig-paths": "^6.0.5",
|
|
40
|
+
"vitest": "^4.0.18",
|
|
41
41
|
"vitest-dom": "^0.1.1"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|