tree-processor 0.6.2 → 0.8.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/README.md +630 -112
- package/dist/index.d.ts +26 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/stats.html +1 -1
- package/dist/tree-processor.cjs.js +94 -64
- package/dist/tree-processor.esm.js +57 -27
- package/dist/tree-processor.umd.js +41 -11
- package/package.json +10 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,15 +16,24 @@ export declare function everyTree(tree: TreeData, filterFn: (node: TreeNode) =>
|
|
|
16
16
|
export declare function atTree(tree: TreeData, parentId: any, nodeIndex: number, fieldNames?: FieldNames): TreeNode | null;
|
|
17
17
|
export declare function indexOfTree(tree: TreeData, targetId: any, fieldNames?: FieldNames): number[] | null;
|
|
18
18
|
export declare function atIndexOfTree(tree: TreeData, path: number[], fieldNames?: FieldNames): TreeNode | null;
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function getNodeDepthMap(tree: TreeData, fieldNames?: FieldNames): Record<string, number>;
|
|
20
|
+
export declare function getNodeDepth(tree: TreeData, targetId: any, fieldNames?: FieldNames): number | null;
|
|
20
21
|
export declare function dedupTree(tree: TreeData, key: string, fieldNames?: FieldNames): TreeData;
|
|
21
22
|
export declare function removeTree(tree: TreeData, targetId: any, fieldNames?: FieldNames): boolean;
|
|
22
23
|
export declare function forEachTree(tree: TreeData, callback: (node: TreeNode) => void, fieldNames?: FieldNames): void;
|
|
23
|
-
export declare function
|
|
24
|
+
export declare function isEmptyTreeData(tree: TreeData, fieldNames?: FieldNames): boolean;
|
|
25
|
+
export declare function isEmptySingleTreeData(data: any, fieldNames?: FieldNames): boolean;
|
|
26
|
+
export declare function getChildrenTree(tree: TreeData, targetId: any, fieldNames?: FieldNames): TreeNode[];
|
|
27
|
+
export declare function getSiblingsTree(tree: TreeData, targetId: any, fieldNames?: FieldNames): TreeNode[];
|
|
24
28
|
export declare function getParentTree(tree: TreeData, targetId: any, fieldNames?: FieldNames): TreeNode | null;
|
|
25
29
|
export declare function includesTree(tree: TreeData, targetId: any, fieldNames?: FieldNames): boolean;
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
30
|
+
export declare function isSingleTreeData(data: any, fieldNames?: FieldNames): boolean;
|
|
31
|
+
export declare function isTreeData(data: any, fieldNames?: FieldNames): boolean;
|
|
32
|
+
export declare function isValidTreeNode(value: unknown, fieldNames?: FieldNames): value is TreeNode;
|
|
33
|
+
export declare function isTreeNodeWithCircularCheck(value: unknown, fieldNames?: FieldNames, visited?: WeakSet<object>): boolean;
|
|
34
|
+
export declare function isSafeTreeDepth(tree: TreeData, maxDepth: number, fieldNames?: FieldNames): boolean;
|
|
35
|
+
export declare function isLeafNode(node: TreeNode, fieldNames?: FieldNames): boolean;
|
|
36
|
+
export declare function isRootNode(tree: TreeData, nodeId: any, fieldNames?: FieldNames): boolean;
|
|
28
37
|
declare const treeProcessor: {
|
|
29
38
|
mapTree: typeof mapTree;
|
|
30
39
|
filterTree: typeof filterTree;
|
|
@@ -38,15 +47,24 @@ declare const treeProcessor: {
|
|
|
38
47
|
atTree: typeof atTree;
|
|
39
48
|
indexOfTree: typeof indexOfTree;
|
|
40
49
|
atIndexOfTree: typeof atIndexOfTree;
|
|
41
|
-
|
|
50
|
+
getNodeDepthMap: typeof getNodeDepthMap;
|
|
51
|
+
getNodeDepth: typeof getNodeDepth;
|
|
42
52
|
dedupTree: typeof dedupTree;
|
|
43
53
|
removeTree: typeof removeTree;
|
|
44
54
|
forEachTree: typeof forEachTree;
|
|
45
|
-
|
|
55
|
+
isEmptyTreeData: typeof isEmptyTreeData;
|
|
56
|
+
isEmptySingleTreeData: typeof isEmptySingleTreeData;
|
|
46
57
|
getParentTree: typeof getParentTree;
|
|
58
|
+
getChildrenTree: typeof getChildrenTree;
|
|
59
|
+
getSiblingsTree: typeof getSiblingsTree;
|
|
47
60
|
includesTree: typeof includesTree;
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
isSingleTreeData: typeof isSingleTreeData;
|
|
62
|
+
isTreeData: typeof isTreeData;
|
|
63
|
+
isValidTreeNode: typeof isValidTreeNode;
|
|
64
|
+
isTreeNodeWithCircularCheck: typeof isTreeNodeWithCircularCheck;
|
|
65
|
+
isSafeTreeDepth: typeof isSafeTreeDepth;
|
|
66
|
+
isLeafNode: typeof isLeafNode;
|
|
67
|
+
isRootNode: typeof isRootNode;
|
|
50
68
|
};
|
|
51
69
|
export default treeProcessor;
|
|
52
70
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ;AAaD,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAK3C,MAAM,MAAM,QAAQ,GAAG,QAAQ,EAAE,CAAC;AASlC,wBAAgB,OAAO,CACrB,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,GAAG,EACjC,UAAU,GAAE,UAAgC,GAC3C,GAAG,EAAE,CAeP;AASD,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EACpD,UAAU,GAAE,UAAgC,GAC3C,QAAQ,CAiBV;AASD,wBAAgB,QAAQ,CACtB,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,EACxC,UAAU,GAAE,UAAgC,GAC3C,QAAQ,GAAG,IAAI,CAcjB;AAUD,wBAAgB,QAAQ,CACtB,IAAI,EAAE,QAAQ,EACd,cAAc,EAAE,GAAG,EACn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GAAE,UAAgC,GAC3C,OAAO,CA4BT;AAQD,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,EACd,UAAU,GAAE,UAAgC,GAC3C,OAAO,CAMT;AASD,wBAAgB,UAAU,CACxB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,GAAG,EACX,UAAU,GAAE,UAAgC,GAC3C,OAAO,CAQT;AAKD,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/dist/stats.html
CHANGED
|
@@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {
|
|
|
4929
4929
|
</script>
|
|
4930
4930
|
<script>
|
|
4931
4931
|
/*<!--*/
|
|
4932
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tree-processor.
|
|
4932
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tree-processor.cjs.js","children":[{"name":"src/index.ts","uid":"7eca4295-1"}]}],"isRoot":true},"nodeParts":{"7eca4295-1":{"renderedLength":17081,"gzipLength":2155,"brotliLength":1901,"metaUid":"7eca4295-0"}},"nodeMetas":{"7eca4295-0":{"id":"\\src\\index.ts","moduleParts":{"tree-processor.cjs.js":"7eca4295-1"},"imported":[],"importedBy":[],"isEntry":true}},"env":{"rollup":"4.56.0"},"options":{"gzip":true,"brotli":true,"sourcemap":false}};
|
|
4933
4933
|
|
|
4934
4934
|
const run = () => {
|
|
4935
4935
|
const width = window.innerWidth;
|
|
@@ -1,70 +1,100 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})
|
|
3
3
|
const r={children:"children",id:"id"}
|
|
4
|
-
function
|
|
5
|
-
return function r(
|
|
6
|
-
const
|
|
7
|
-
Array.isArray(
|
|
8
|
-
return function r(
|
|
9
|
-
const
|
|
10
|
-
Array.isArray(
|
|
11
|
-
const
|
|
12
|
-
if(Array.isArray(
|
|
13
|
-
if(r)return r}}return null}function i(n,
|
|
14
|
-
const
|
|
15
|
-
if(Array.isArray(
|
|
16
|
-
const
|
|
17
|
-
if(Array.isArray(
|
|
18
|
-
return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const
|
|
19
|
-
if(Array.isArray(
|
|
20
|
-
return!!(Array.isArray(r)&&r.length>0)&&(r.shift(),!0)}const
|
|
21
|
-
if(Array.isArray(
|
|
22
|
-
const
|
|
23
|
-
if(Array.isArray(
|
|
24
|
-
const
|
|
25
|
-
if(Array.isArray(
|
|
26
|
-
const
|
|
27
|
-
if(Array.isArray(
|
|
28
|
-
if(
|
|
4
|
+
function e(e,n,t=r){const i=[]
|
|
5
|
+
return function r(e){for(const o of e){i.push(n(o))
|
|
6
|
+
const e=o[t.children]
|
|
7
|
+
Array.isArray(e)&&e.length>0&&r(e)}}(e),i}function n(e,n,t=r){const i=[]
|
|
8
|
+
return function r(e){e.forEach((e,o)=>{n(e,o)&&i.push(e)
|
|
9
|
+
const u=e[t.children]
|
|
10
|
+
Array.isArray(u)&&u.length>0&&r(u,o)})}(e),i}function t(e,n,i=r){for(const r of e){if(n(r))return r
|
|
11
|
+
const e=r[i.children]
|
|
12
|
+
if(Array.isArray(e)&&e.length>0){const r=t(e,n,i)
|
|
13
|
+
if(r)return r}}return null}function i(e,n,t,i=r){return function r(e){for(const o of e){if(o[i.id]===n)return o[i.children]||(o[i.children]=[]),o[i.children].push(t),!0
|
|
14
|
+
const e=o[i.children]
|
|
15
|
+
if(Array.isArray(e)&&e.length>0&&r(e))return!0}return!1}(e)}function o(e,n,t,i=r){return function r(e){for(const o of e){if(o[i.id]===n)return o[i.children]||(o[i.children]=[]),o[i.children].unshift(t),!0
|
|
16
|
+
const e=o[i.children]
|
|
17
|
+
if(Array.isArray(e)&&e.length>0&&r(e))return!0}return!1}(e)}function u(e,n,t=r){return function r(e){for(const i of e){if(i[t.id]===n){const r=i[t.children]
|
|
18
|
+
return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const e=i[t.children]
|
|
19
|
+
if(Array.isArray(e)&&e.length>0&&r(e))return!0}return!1}(e)}function s(e,n,t=r){return function r(e){for(const i of e){if(i[t.id]===n){const r=i[t.children]
|
|
20
|
+
return!!(Array.isArray(r)&&r.length>0)&&(r.shift(),!0)}const e=i[t.children]
|
|
21
|
+
if(Array.isArray(e)&&e.length>0&&r(e))return!0}return!1}(e)}function f(e,n,t=r){for(const r of e){if(n(r))return!0
|
|
22
|
+
const e=r[t.children]
|
|
23
|
+
if(Array.isArray(e)&&e.length>0&&f(e,n,t))return!0}return!1}function c(e,n,t=r){for(const r of e){if(!n(r))return!1
|
|
24
|
+
const e=r[t.children]
|
|
25
|
+
if(Array.isArray(e)&&e.length>0&&!c(e,n,t))return!1}return!0}function l(e,n,t,i=r){const o=function r(e){for(const t of e){if(t[i.id]===n)return t
|
|
26
|
+
const e=t[i.children]
|
|
27
|
+
if(Array.isArray(e)&&e.length>0){const n=r(e)
|
|
28
|
+
if(n)return n}}return null}(e)
|
|
29
29
|
if(!o)return null
|
|
30
|
-
const
|
|
31
|
-
if(!Array.isArray(
|
|
32
|
-
const
|
|
33
|
-
return
|
|
34
|
-
if(
|
|
35
|
-
const f=
|
|
36
|
-
if(Array.isArray(f)&&f.length>0){const
|
|
37
|
-
if(
|
|
38
|
-
let i=
|
|
39
|
-
for(let r=0;r<
|
|
40
|
-
if(!Array.isArray(i)||
|
|
41
|
-
const o=i[
|
|
42
|
-
if(r===
|
|
43
|
-
const
|
|
44
|
-
if(!Array.isArray(
|
|
45
|
-
i=
|
|
46
|
-
return function r(
|
|
47
|
-
const
|
|
48
|
-
Array.isArray(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if(null
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if(
|
|
55
|
-
const s=
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const n
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
const
|
|
30
|
+
const u=o[i.children]
|
|
31
|
+
if(!Array.isArray(u)||0===u.length)return null
|
|
32
|
+
const s=t>=0?t:u.length+t
|
|
33
|
+
return s>=0&&s<u.length?u[s]:null}function a(e,n,t=r){return function r(e,i=[]){for(let o=0;o<e.length;o++){const u=e[o],s=[...i,o]
|
|
34
|
+
if(u[t.id]===n)return s
|
|
35
|
+
const f=u[t.children]
|
|
36
|
+
if(Array.isArray(f)&&f.length>0){const e=r(f,s)
|
|
37
|
+
if(e)return e}}return null}(e)}function h(e,n,t=r){if(!Array.isArray(n)||0===n.length)return null
|
|
38
|
+
let i=e
|
|
39
|
+
for(let r=0;r<n.length;r++){const e=n[r]
|
|
40
|
+
if(!Array.isArray(i)||e<0||e>=i.length)return null
|
|
41
|
+
const o=i[e]
|
|
42
|
+
if(r===n.length-1)return o
|
|
43
|
+
const u=o[t.children]
|
|
44
|
+
if(!Array.isArray(u))return null
|
|
45
|
+
i=u}return null}function d(e,n=r){const t={}
|
|
46
|
+
return function r(e,i=1){for(const o of e){t[o[n.id]]=i
|
|
47
|
+
const e=o[n.children]
|
|
48
|
+
Array.isArray(e)&&e.length>0&&r(e,i+1)}}(e),t}function y(e,n,t=r){return function r(e,i=1){for(const o of e){if(o[t.id]===n)return i
|
|
49
|
+
const e=o[t.children]
|
|
50
|
+
if(Array.isArray(e)&&e.length>0){const n=r(e,i+1)
|
|
51
|
+
if(null!==n)return n}}return null}(e)}function A(e,n,t=r){const i=new Set
|
|
52
|
+
return function r(e){const o=[]
|
|
53
|
+
for(const u of e){const e=u[n]
|
|
54
|
+
if(null!=e){if(i.has(e))continue
|
|
55
|
+
i.add(e)}const s={...u},f=u[t.children]
|
|
56
|
+
Array.isArray(f)&&f.length>0&&(s[t.children]=r(f)),o.push(s)}return o}(e)}function p(e,n,t=r){return function r(e){for(let i=0;i<e.length;i++){const o=e[i]
|
|
57
|
+
if(o[t.id]===n)return e.splice(i,1),!0
|
|
58
|
+
const u=o[t.children]
|
|
59
|
+
if(Array.isArray(u)&&u.length>0&&r(u))return!0}return!1}(e)}function g(e,n,t=r){!function r(e){for(const i of e){n(i)
|
|
60
|
+
const e=i[t.children]
|
|
61
|
+
Array.isArray(e)&&e.length>0&&r(e)}}(e)}function T(r){return!Array.isArray(r)||0===r.length}function x(e,n=r){if(!v(e,n))return!0
|
|
62
|
+
const t=e[n.children]
|
|
63
|
+
return void 0===t||(!Array.isArray(t)||0===t.length)}function D(e,n,t=r){const i=function r(e){for(const i of e){if(i[t.id]===n)return i
|
|
64
|
+
const e=i[t.children]
|
|
65
|
+
if(Array.isArray(e)&&e.length>0){const n=r(e)
|
|
66
|
+
if(null!==n)return n}}return null}(e)
|
|
67
|
+
if(!i)return[]
|
|
68
|
+
const o=i[t.children]
|
|
69
|
+
return Array.isArray(o)?o:[]}function N(e,n,t=r){const i=function r(e,i=null){for(const o of e){if(o[t.id]===n)return{node:o,parent:i}
|
|
70
|
+
const e=o[t.children]
|
|
71
|
+
if(Array.isArray(e)&&e.length>0){const n=r(e,o)
|
|
72
|
+
if(null!==n)return n}}return null}(e)
|
|
73
|
+
if(!i)return[]
|
|
74
|
+
if(null===i.parent)return e
|
|
75
|
+
const o=i.parent[t.children]
|
|
76
|
+
return Array.isArray(o)?o:[]}function S(e,n,t=r){return function r(e,i=null){for(const o of e){if(o[t.id]===n)return i
|
|
77
|
+
const e=o[t.children]
|
|
78
|
+
if(Array.isArray(e)&&e.length>0){const n=r(e,o)
|
|
79
|
+
if(null!==n)return n}}return null}(e)}function m(e,n,t=r){for(const r of e){if(r[t.id]===n)return!0
|
|
80
|
+
const e=r[t.children]
|
|
81
|
+
if(Array.isArray(e)&&e.length>0&&m(e,n,t))return!0}return!1}function v(e,n=r){if(!e||"object"!=typeof e||Array.isArray(e))return!1
|
|
82
|
+
const t=e[n.children]
|
|
65
83
|
if(void 0!==t){if(null===t)return!1
|
|
66
84
|
if(!Array.isArray(t))return!1
|
|
67
|
-
for(const r of t)if(!
|
|
68
|
-
for(const r of
|
|
69
|
-
return!0}
|
|
70
|
-
|
|
85
|
+
for(const r of t)if(!v(r,n))return!1}return!0}function b(e,n=r){if(!Array.isArray(e))return!1
|
|
86
|
+
for(const r of e)if(!v(r,n))return!1
|
|
87
|
+
return!0}function E(e,n=r){if(!e||"object"!=typeof e||Array.isArray(e))return!1
|
|
88
|
+
const t=e[n.children]
|
|
89
|
+
return void 0===t||Array.isArray(t)}function C(e,n=r,t=new WeakSet){if(!e||"object"!=typeof e||Array.isArray(e))return!1
|
|
90
|
+
if(t.has(e))return!1
|
|
91
|
+
t.add(e)
|
|
92
|
+
const i=e[n.children]
|
|
93
|
+
if(void 0!==i){if(null===i)return!1
|
|
94
|
+
if(!Array.isArray(i))return!1
|
|
95
|
+
for(const r of i)if(!C(r,n,t))return!1}return!0}function O(e,n,t=r){if(n<=0)return!1
|
|
96
|
+
return function r(e,i){if(i>n)return!1
|
|
97
|
+
for(const n of e){const e=n[t.children]
|
|
98
|
+
if(Array.isArray(e)&&e.length>0&&!r(e,i+1))return!1}return!0}(e,1)}function j(e,n=r){const t=e[n.children]
|
|
99
|
+
return void 0===t||!Array.isArray(t)||0===t.length}function M(e,n,t=r){return!!m(e,n,t)&&null===S(e,n,t)}const k={mapTree:e,filterTree:n,findTree:t,pushTree:i,unshiftTree:o,popTree:u,shiftTree:s,someTree:f,everyTree:c,atTree:l,indexOfTree:a,atIndexOfTree:h,getNodeDepthMap:d,getNodeDepth:y,dedupTree:A,removeTree:p,forEachTree:g,isEmptyTreeData:T,isEmptySingleTreeData:x,getParentTree:S,getChildrenTree:D,getSiblingsTree:N,includesTree:m,isSingleTreeData:v,isTreeData:b,isValidTreeNode:E,isTreeNodeWithCircularCheck:C,isSafeTreeDepth:O,isLeafNode:j,isRootNode:M}
|
|
100
|
+
exports.atIndexOfTree=h,exports.atTree=l,exports.dedupTree=A,exports.default=k,exports.everyTree=c,exports.filterTree=n,exports.findTree=t,exports.forEachTree=g,exports.getChildrenTree=D,exports.getNodeDepth=y,exports.getNodeDepthMap=d,exports.getParentTree=S,exports.getSiblingsTree=N,exports.includesTree=m,exports.indexOfTree=a,exports.isEmptySingleTreeData=x,exports.isEmptyTreeData=T,exports.isLeafNode=j,exports.isRootNode=M,exports.isSafeTreeDepth=O,exports.isSingleTreeData=v,exports.isTreeData=b,exports.isTreeNodeWithCircularCheck=C,exports.isValidTreeNode=E,exports.mapTree=e,exports.popTree=u,exports.pushTree=i,exports.removeTree=p,exports.shiftTree=s,exports.someTree=f,exports.unshiftTree=o
|
|
@@ -4,17 +4,17 @@ return function r(n){for(const o of n){i.push(t(o))
|
|
|
4
4
|
const n=o[e.children]
|
|
5
5
|
Array.isArray(n)&&n.length>0&&r(n)}}(n),i}function t(n,t,e=r){const i=[]
|
|
6
6
|
return function r(n){n.forEach((n,o)=>{t(n,o)&&i.push(n)
|
|
7
|
-
const
|
|
8
|
-
Array.isArray(
|
|
7
|
+
const u=n[e.children]
|
|
8
|
+
Array.isArray(u)&&u.length>0&&r(u,o)})}(n),i}function e(n,t,i=r){for(const r of n){if(t(r))return r
|
|
9
9
|
const n=r[i.children]
|
|
10
10
|
if(Array.isArray(n)&&n.length>0){const r=e(n,t,i)
|
|
11
11
|
if(r)return r}}return null}function i(n,t,e,i=r){return function r(n){for(const o of n){if(o[i.id]===t)return o[i.children]||(o[i.children]=[]),o[i.children].push(e),!0
|
|
12
12
|
const n=o[i.children]
|
|
13
13
|
if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function o(n,t,e,i=r){return function r(n){for(const o of n){if(o[i.id]===t)return o[i.children]||(o[i.children]=[]),o[i.children].unshift(e),!0
|
|
14
14
|
const n=o[i.children]
|
|
15
|
-
if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function c(n,t,e=r){return function r(n){for(const i of n){if(i[e.id]===t){const r=i[e.children]
|
|
16
|
-
return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const n=i[e.children]
|
|
17
15
|
if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function u(n,t,e=r){return function r(n){for(const i of n){if(i[e.id]===t){const r=i[e.children]
|
|
16
|
+
return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const n=i[e.children]
|
|
17
|
+
if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function c(n,t,e=r){return function r(n){for(const i of n){if(i[e.id]===t){const r=i[e.children]
|
|
18
18
|
return!!(Array.isArray(r)&&r.length>0)&&(r.shift(),!0)}const n=i[e.children]
|
|
19
19
|
if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function f(n,t,e=r){for(const r of n){if(t(r))return!0
|
|
20
20
|
const n=r[e.children]
|
|
@@ -25,44 +25,74 @@ const n=e[i.children]
|
|
|
25
25
|
if(Array.isArray(n)&&n.length>0){const t=r(n)
|
|
26
26
|
if(t)return t}}return null}(n)
|
|
27
27
|
if(!o)return null
|
|
28
|
-
const
|
|
29
|
-
if(!Array.isArray(
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
if(
|
|
33
|
-
const f=
|
|
34
|
-
if(Array.isArray(f)&&f.length>0){const n=r(f,
|
|
35
|
-
if(n)return n}}return null}(n)}function
|
|
28
|
+
const u=o[i.children]
|
|
29
|
+
if(!Array.isArray(u)||0===u.length)return null
|
|
30
|
+
const c=e>=0?e:u.length+e
|
|
31
|
+
return c>=0&&c<u.length?u[c]:null}function a(n,t,e=r){return function r(n,i=[]){for(let o=0;o<n.length;o++){const u=n[o],c=[...i,o]
|
|
32
|
+
if(u[e.id]===t)return c
|
|
33
|
+
const f=u[e.children]
|
|
34
|
+
if(Array.isArray(f)&&f.length>0){const n=r(f,c)
|
|
35
|
+
if(n)return n}}return null}(n)}function h(n,t,e=r){if(!Array.isArray(t)||0===t.length)return null
|
|
36
36
|
let i=n
|
|
37
37
|
for(let r=0;r<t.length;r++){const n=t[r]
|
|
38
38
|
if(!Array.isArray(i)||n<0||n>=i.length)return null
|
|
39
39
|
const o=i[n]
|
|
40
40
|
if(r===t.length-1)return o
|
|
41
|
-
const
|
|
42
|
-
if(!Array.isArray(
|
|
43
|
-
i=
|
|
41
|
+
const u=o[e.children]
|
|
42
|
+
if(!Array.isArray(u))return null
|
|
43
|
+
i=u}return null}function y(n,t=r){const e={}
|
|
44
44
|
return function r(n,i=1){for(const o of n){e[o[t.id]]=i
|
|
45
45
|
const n=o[t.children]
|
|
46
|
-
Array.isArray(n)&&n.length>0&&r(n,i+1)}}(n),e}function d(n,t,e=r){
|
|
46
|
+
Array.isArray(n)&&n.length>0&&r(n,i+1)}}(n),e}function d(n,t,e=r){return function r(n,i=1){for(const o of n){if(o[e.id]===t)return i
|
|
47
|
+
const n=o[e.children]
|
|
48
|
+
if(Array.isArray(n)&&n.length>0){const t=r(n,i+1)
|
|
49
|
+
if(null!==t)return t}}return null}(n)}function A(n,t,e=r){const i=new Set
|
|
47
50
|
return function r(n){const o=[]
|
|
48
|
-
for(const
|
|
51
|
+
for(const u of n){const n=u[t]
|
|
49
52
|
if(null!=n){if(i.has(n))continue
|
|
50
|
-
i.add(n)}const
|
|
51
|
-
Array.isArray(f)&&f.length>0&&(
|
|
53
|
+
i.add(n)}const c={...u},f=u[e.children]
|
|
54
|
+
Array.isArray(f)&&f.length>0&&(c[e.children]=r(f)),o.push(c)}return o}(n)}function g(n,t,e=r){return function r(n){for(let i=0;i<n.length;i++){const o=n[i]
|
|
52
55
|
if(o[e.id]===t)return n.splice(i,1),!0
|
|
53
|
-
const
|
|
54
|
-
if(Array.isArray(
|
|
56
|
+
const u=o[e.children]
|
|
57
|
+
if(Array.isArray(u)&&u.length>0&&r(u))return!0}return!1}(n)}function T(n,t,e=r){!function r(n){for(const i of n){t(i)
|
|
55
58
|
const n=i[e.children]
|
|
56
|
-
Array.isArray(n)&&n.length>0&&r(n)}}(n)}function
|
|
59
|
+
Array.isArray(n)&&n.length>0&&r(n)}}(n)}function p(r){return!Array.isArray(r)||0===r.length}function v(n,t=r){if(!b(n,t))return!0
|
|
60
|
+
const e=n[t.children]
|
|
61
|
+
return void 0===e||(!Array.isArray(e)||0===e.length)}function D(n,t,e=r){const i=function r(n){for(const i of n){if(i[e.id]===t)return i
|
|
62
|
+
const n=i[e.children]
|
|
63
|
+
if(Array.isArray(n)&&n.length>0){const t=r(n)
|
|
64
|
+
if(null!==t)return t}}return null}(n)
|
|
65
|
+
if(!i)return[]
|
|
66
|
+
const o=i[e.children]
|
|
67
|
+
return Array.isArray(o)?o:[]}function N(n,t,e=r){const i=function r(n,i=null){for(const o of n){if(o[e.id]===t)return{node:o,parent:i}
|
|
68
|
+
const n=o[e.children]
|
|
69
|
+
if(Array.isArray(n)&&n.length>0){const t=r(n,o)
|
|
70
|
+
if(null!==t)return t}}return null}(n)
|
|
71
|
+
if(!i)return[]
|
|
72
|
+
if(null===i.parent)return n
|
|
73
|
+
const o=i.parent[e.children]
|
|
74
|
+
return Array.isArray(o)?o:[]}function S(n,t,e=r){return function r(n,i=null){for(const o of n){if(o[e.id]===t)return i
|
|
57
75
|
const n=o[e.children]
|
|
58
76
|
if(Array.isArray(n)&&n.length>0){const t=r(n,o)
|
|
59
77
|
if(null!==t)return t}}return null}(n)}function m(n,t,e=r){for(const r of n){if(r[e.id]===t)return!0
|
|
60
78
|
const n=r[e.children]
|
|
61
|
-
if(Array.isArray(n)&&n.length>0&&m(n,t,e))return!0}return!1}function
|
|
79
|
+
if(Array.isArray(n)&&n.length>0&&m(n,t,e))return!0}return!1}function b(n,t=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
|
|
62
80
|
const e=n[t.children]
|
|
63
81
|
if(void 0!==e){if(null===e)return!1
|
|
64
82
|
if(!Array.isArray(e))return!1
|
|
65
|
-
for(const r of e)if(!
|
|
66
|
-
for(const r of n)if(!
|
|
67
|
-
return!0}
|
|
68
|
-
|
|
83
|
+
for(const r of e)if(!b(r,t))return!1}return!0}function E(n,t=r){if(!Array.isArray(n))return!1
|
|
84
|
+
for(const r of n)if(!b(r,t))return!1
|
|
85
|
+
return!0}function j(n,t=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
|
|
86
|
+
const e=n[t.children]
|
|
87
|
+
return void 0===e||Array.isArray(e)}function x(n,t=r,e=new WeakSet){if(!n||"object"!=typeof n||Array.isArray(n))return!1
|
|
88
|
+
if(e.has(n))return!1
|
|
89
|
+
e.add(n)
|
|
90
|
+
const i=n[t.children]
|
|
91
|
+
if(void 0!==i){if(null===i)return!1
|
|
92
|
+
if(!Array.isArray(i))return!1
|
|
93
|
+
for(const r of i)if(!x(r,t,e))return!1}return!0}function C(n,t,e=r){if(t<=0)return!1
|
|
94
|
+
return function r(n,i){if(i>t)return!1
|
|
95
|
+
for(const t of n){const n=t[e.children]
|
|
96
|
+
if(Array.isArray(n)&&n.length>0&&!r(n,i+1))return!1}return!0}(n,1)}function k(n,t=r){const e=n[t.children]
|
|
97
|
+
return void 0===e||!Array.isArray(e)||0===e.length}function w(n,t,e=r){return!!m(n,t,e)&&null===S(n,t,e)}const O={mapTree:n,filterTree:t,findTree:e,pushTree:i,unshiftTree:o,popTree:u,shiftTree:c,someTree:f,everyTree:l,atTree:s,indexOfTree:a,atIndexOfTree:h,getNodeDepthMap:y,getNodeDepth:d,dedupTree:A,removeTree:g,forEachTree:T,isEmptyTreeData:p,isEmptySingleTreeData:v,getParentTree:S,getChildrenTree:D,getSiblingsTree:N,includesTree:m,isSingleTreeData:b,isTreeData:E,isValidTreeNode:j,isTreeNodeWithCircularCheck:x,isSafeTreeDepth:C,isLeafNode:k,isRootNode:w}
|
|
98
|
+
export{h as atIndexOfTree,s as atTree,A as dedupTree,O as default,l as everyTree,t as filterTree,e as findTree,T as forEachTree,D as getChildrenTree,d as getNodeDepth,y as getNodeDepthMap,S as getParentTree,N as getSiblingsTree,m as includesTree,a as indexOfTree,v as isEmptySingleTreeData,p as isEmptyTreeData,k as isLeafNode,w as isRootNode,C as isSafeTreeDepth,b as isSingleTreeData,E as isTreeData,x as isTreeNodeWithCircularCheck,j as isValidTreeNode,n as mapTree,u as popTree,i as pushTree,g as removeTree,c as shiftTree,f as someTree,o as unshiftTree}
|
|
@@ -21,7 +21,7 @@ if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(r)}function s(r,e,t=n){
|
|
|
21
21
|
const r=n[t.children]
|
|
22
22
|
if(Array.isArray(r)&&r.length>0&&s(r,e,t))return!0}return!1}function l(r,e,t=n){for(const n of r){if(!e(n))return!1
|
|
23
23
|
const r=n[t.children]
|
|
24
|
-
if(Array.isArray(r)&&r.length>0&&!l(r,e,t))return!1}return!0}function
|
|
24
|
+
if(Array.isArray(r)&&r.length>0&&!l(r,e,t))return!1}return!0}function a(r,e,t,i=n){const o=function r(n){for(const t of n){if(t[i.id]===e)return t
|
|
25
25
|
const n=t[i.children]
|
|
26
26
|
if(Array.isArray(n)&&n.length>0){const e=r(n)
|
|
27
27
|
if(e)return e}}return null}(r)
|
|
@@ -29,7 +29,7 @@ if(!o)return null
|
|
|
29
29
|
const f=o[i.children]
|
|
30
30
|
if(!Array.isArray(f)||0===f.length)return null
|
|
31
31
|
const u=t>=0?t:f.length+t
|
|
32
|
-
return u>=0&&u<f.length?f[u]:null}function
|
|
32
|
+
return u>=0&&u<f.length?f[u]:null}function h(r,e,t=n){return function r(n,i=[]){for(let o=0;o<n.length;o++){const f=n[o],u=[...i,o]
|
|
33
33
|
if(f[t.id]===e)return u
|
|
34
34
|
const c=f[t.children]
|
|
35
35
|
if(Array.isArray(c)&&c.length>0){const n=r(c,u)
|
|
@@ -44,26 +44,56 @@ if(!Array.isArray(f))return null
|
|
|
44
44
|
i=f}return null}function y(r,e=n){const t={}
|
|
45
45
|
return function r(n,i=1){for(const o of n){t[o[e.id]]=i
|
|
46
46
|
const n=o[e.children]
|
|
47
|
-
Array.isArray(n)&&n.length>0&&r(n,i+1)}}(r),t}function A(r,e,t=n){
|
|
47
|
+
Array.isArray(n)&&n.length>0&&r(n,i+1)}}(r),t}function A(r,e,t=n){return function r(n,i=1){for(const o of n){if(o[t.id]===e)return i
|
|
48
|
+
const n=o[t.children]
|
|
49
|
+
if(Array.isArray(n)&&n.length>0){const e=r(n,i+1)
|
|
50
|
+
if(null!==e)return e}}return null}(r)}function T(r,e,t=n){const i=new Set
|
|
48
51
|
return function r(n){const o=[]
|
|
49
52
|
for(const f of n){const n=f[e]
|
|
50
53
|
if(null!=n){if(i.has(n))continue
|
|
51
54
|
i.add(n)}const u={...f},c=f[t.children]
|
|
52
|
-
Array.isArray(c)&&c.length>0&&(u[t.children]=r(c)),o.push(u)}return o}(r)}function
|
|
55
|
+
Array.isArray(c)&&c.length>0&&(u[t.children]=r(c)),o.push(u)}return o}(r)}function g(r,e,t=n){return function r(n){for(let i=0;i<n.length;i++){const o=n[i]
|
|
53
56
|
if(o[t.id]===e)return n.splice(i,1),!0
|
|
54
57
|
const f=o[t.children]
|
|
55
|
-
if(Array.isArray(f)&&f.length>0&&r(f))return!0}return!1}(r)}function
|
|
58
|
+
if(Array.isArray(f)&&f.length>0&&r(f))return!0}return!1}(r)}function p(r,e,t=n){!function r(n){for(const i of n){e(i)
|
|
59
|
+
const n=i[t.children]
|
|
60
|
+
Array.isArray(n)&&n.length>0&&r(n)}}(r)}function D(r){return!Array.isArray(r)||0===r.length}function m(r,e=n){if(!x(r,e))return!0
|
|
61
|
+
const t=r[e.children]
|
|
62
|
+
return void 0===t||(!Array.isArray(t)||0===t.length)}function N(r,e,t=n){const i=function r(n){for(const i of n){if(i[t.id]===e)return i
|
|
56
63
|
const n=i[t.children]
|
|
57
|
-
Array.isArray(n)&&n.length>0
|
|
64
|
+
if(Array.isArray(n)&&n.length>0){const e=r(n)
|
|
65
|
+
if(null!==e)return e}}return null}(r)
|
|
66
|
+
if(!i)return[]
|
|
67
|
+
const o=i[t.children]
|
|
68
|
+
return Array.isArray(o)?o:[]}function S(r,e,t=n){const i=function r(n,i=null){for(const o of n){if(o[t.id]===e)return{node:o,parent:i}
|
|
58
69
|
const n=o[t.children]
|
|
59
70
|
if(Array.isArray(n)&&n.length>0){const e=r(n,o)
|
|
60
|
-
if(null!==e)return e}}return null}(r)
|
|
71
|
+
if(null!==e)return e}}return null}(r)
|
|
72
|
+
if(!i)return[]
|
|
73
|
+
if(null===i.parent)return r
|
|
74
|
+
const o=i.parent[t.children]
|
|
75
|
+
return Array.isArray(o)?o:[]}function v(r,e,t=n){return function r(n,i=null){for(const o of n){if(o[t.id]===e)return i
|
|
76
|
+
const n=o[t.children]
|
|
77
|
+
if(Array.isArray(n)&&n.length>0){const e=r(n,o)
|
|
78
|
+
if(null!==e)return e}}return null}(r)}function b(r,e,t=n){for(const n of r){if(n[t.id]===e)return!0
|
|
61
79
|
const r=n[t.children]
|
|
62
|
-
if(Array.isArray(r)&&r.length>0&&
|
|
80
|
+
if(Array.isArray(r)&&r.length>0&&b(r,e,t))return!0}return!1}function x(r,e=n){if(!r||"object"!=typeof r||Array.isArray(r))return!1
|
|
63
81
|
const t=r[e.children]
|
|
64
82
|
if(void 0!==t){if(null===t)return!1
|
|
65
83
|
if(!Array.isArray(t))return!1
|
|
66
|
-
for(const r of t)if(!x(r,e))return!1}return!0}function
|
|
84
|
+
for(const r of t)if(!x(r,e))return!1}return!0}function E(r,e=n){if(!Array.isArray(r))return!1
|
|
67
85
|
for(const n of r)if(!x(n,e))return!1
|
|
68
|
-
return!0}
|
|
69
|
-
|
|
86
|
+
return!0}function C(r,e=n){if(!r||"object"!=typeof r||Array.isArray(r))return!1
|
|
87
|
+
const t=r[e.children]
|
|
88
|
+
return void 0===t||Array.isArray(t)}function j(r,e=n,t=new WeakSet){if(!r||"object"!=typeof r||Array.isArray(r))return!1
|
|
89
|
+
if(t.has(r))return!1
|
|
90
|
+
t.add(r)
|
|
91
|
+
const i=r[e.children]
|
|
92
|
+
if(void 0!==i){if(null===i)return!1
|
|
93
|
+
if(!Array.isArray(i))return!1
|
|
94
|
+
for(const r of i)if(!j(r,e,t))return!1}return!0}function O(r,e,t=n){if(e<=0)return!1
|
|
95
|
+
return function r(n,i){if(i>e)return!1
|
|
96
|
+
for(const e of n){const n=e[t.children]
|
|
97
|
+
if(Array.isArray(n)&&n.length>0&&!r(n,i+1))return!1}return!0}(r,1)}function M(r,e=n){const t=r[e.children]
|
|
98
|
+
return void 0===t||!Array.isArray(t)||0===t.length}function P(r,e,t=n){return!!b(r,e,t)&&null===v(r,e,t)}const k={mapTree:e,filterTree:t,findTree:i,pushTree:o,unshiftTree:f,popTree:u,shiftTree:c,someTree:s,everyTree:l,atTree:a,indexOfTree:h,atIndexOfTree:d,getNodeDepthMap:y,getNodeDepth:A,dedupTree:T,removeTree:g,forEachTree:p,isEmptyTreeData:D,isEmptySingleTreeData:m,getParentTree:v,getChildrenTree:N,getSiblingsTree:S,includesTree:b,isSingleTreeData:x,isTreeData:E,isValidTreeNode:C,isTreeNodeWithCircularCheck:j,isSafeTreeDepth:O,isLeafNode:M,isRootNode:P}
|
|
99
|
+
r.atIndexOfTree=d,r.atTree=a,r.dedupTree=T,r.default=k,r.everyTree=l,r.filterTree=t,r.findTree=i,r.forEachTree=p,r.getChildrenTree=N,r.getNodeDepth=A,r.getNodeDepthMap=y,r.getParentTree=v,r.getSiblingsTree=S,r.includesTree=b,r.indexOfTree=h,r.isEmptySingleTreeData=m,r.isEmptyTreeData=D,r.isLeafNode=M,r.isRootNode=P,r.isSafeTreeDepth=O,r.isSingleTreeData=x,r.isTreeData=E,r.isTreeNodeWithCircularCheck=j,r.isValidTreeNode=C,r.mapTree=e,r.popTree=u,r.pushTree=o,r.removeTree=g,r.shiftTree=c,r.someTree=s,r.unshiftTree=f,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-processor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "A lightweight TypeScript library for processing tree-structured data with comprehensive methods (map, filter, find, push, pop, remove, getParent, includes, etc.), supporting tree-shaking and custom field names",
|
|
5
5
|
"main": "dist/tree-processor.cjs.js",
|
|
6
6
|
"module": "dist/tree-processor.esm.js",
|
|
@@ -42,7 +42,16 @@
|
|
|
42
42
|
"every",
|
|
43
43
|
"at",
|
|
44
44
|
"indexOf",
|
|
45
|
+
"depth",
|
|
45
46
|
"deduplicate",
|
|
47
|
+
"menu",
|
|
48
|
+
"navigation",
|
|
49
|
+
"file-tree",
|
|
50
|
+
"directory",
|
|
51
|
+
"category",
|
|
52
|
+
"comment",
|
|
53
|
+
"permission",
|
|
54
|
+
"tree-select",
|
|
46
55
|
"tree-processor"
|
|
47
56
|
],
|
|
48
57
|
"author": "",
|