@contentful/experiences-core 1.37.1 → 1.37.2-beta.0
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/index.d.ts +1 -0
- package/dist/index.js +42 -21
- package/dist/index.js.map +1 -1
- package/dist/utils/treeTraversal.d.ts +17 -0
- package/package.json +3 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type NodeWithChildren<T> = {
|
|
2
|
+
children: T[];
|
|
3
|
+
};
|
|
4
|
+
declare function treeVisit<T extends NodeWithChildren<T>>(initialNode: T, onNode: (node: T, index: number, depth: number) => void): void;
|
|
5
|
+
/**
|
|
6
|
+
* Traverses all nodes of a tree and maps all of them.
|
|
7
|
+
* Intuitively works similarly to Array.map().
|
|
8
|
+
* When returning mapped object from the mapper function
|
|
9
|
+
* you _do not_ need to return about `.children[]` field.
|
|
10
|
+
* This field is automatically managed by the treeMap() function.
|
|
11
|
+
*
|
|
12
|
+
* You can map each node to whatever you want, but shouldn't
|
|
13
|
+
* modify the structure of the tree from the mapping function.
|
|
14
|
+
*/
|
|
15
|
+
declare function treeMap<T extends NodeWithChildren<T>, U>(node: T, onNode: (node: T) => Omit<U, 'children'>): U;
|
|
16
|
+
|
|
17
|
+
export { treeMap, treeVisit };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-core",
|
|
3
|
-
"version": "1.37.
|
|
3
|
+
"version": "1.37.2-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
"vitest": "^2.1.1"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@contentful/experiences-validators": "1.37.
|
|
73
|
+
"@contentful/experiences-validators": "1.37.2-beta.0",
|
|
74
74
|
"@contentful/rich-text-types": "^17.0.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"contentful": ">=10.6.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "d3182ea50ed459f05071d91aeaf5c2b642353726"
|
|
80
80
|
}
|