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/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 nodeDepthMap(tree: TreeData, fieldNames?: FieldNames): Record<string, number>;
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 isEmptyTree(tree: TreeData): boolean;
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 isSingleTree(data: any, fieldNames?: FieldNames): boolean;
27
- export declare function isMultipleTrees(data: any, fieldNames?: FieldNames): boolean;
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
- nodeDepthMap: typeof nodeDepthMap;
50
+ getNodeDepthMap: typeof getNodeDepthMap;
51
+ getNodeDepth: typeof getNodeDepth;
42
52
  dedupTree: typeof dedupTree;
43
53
  removeTree: typeof removeTree;
44
54
  forEachTree: typeof forEachTree;
45
- isEmptyTree: typeof isEmptyTree;
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
- isSingleTree: typeof isSingleTree;
49
- isMultipleTrees: typeof isMultipleTrees;
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.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AAU,GAAE,UAAgC,GAC3C,QAAQ,GAAG,IAAI,CAqBjB;AASD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,GAAG,EACb,UAAU,GAAE,UAAgC,GAC3C,OAAO,CAaT;AAQD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,GAAG,EACT,UAAU,GAAE,UAAgC,GAC3C,OAAO,CA8BT;AAQD,wBAAgB,UAAU,CACxB,IAAI,EAAE,GAAG,EACT,UAAU,GAAE,UAAgC,GAC3C,OAAO,CAcT;AAQD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,EACd,UAAU,GAAE,UAAgC,GAC3C,KAAK,IAAI,QAAQ,CAWnB;AASD,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,EACd,UAAU,GAAE,UAAgC,EAC5C,OAAO,GAAE,OAAO,CAAC,MAAM,CAAiB,GACvC,OAAO,CAsCT;AASD,wBAAgB,eAAe,CAC7B,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,MAAM,EAChB,UAAU,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.esm.js","children":[{"name":"src/index.ts","uid":"3fa892f6-1"}]}],"isRoot":true},"nodeParts":{"3fa892f6-1":{"renderedLength":12266,"gzipLength":1681,"brotliLength":1475,"metaUid":"3fa892f6-0"}},"nodeMetas":{"3fa892f6-0":{"id":"\\src\\index.ts","moduleParts":{"tree-processor.esm.js":"3fa892f6-1"},"imported":[],"importedBy":[],"isEntry":true}},"env":{"rollup":"4.56.0"},"options":{"gzip":true,"brotli":true,"sourcemap":false}};
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 n(n,e,t=r){const i=[]
5
- return function r(n){for(const o of n){i.push(e(o))
6
- const n=o[t.children]
7
- Array.isArray(n)&&n.length>0&&r(n)}}(n),i}function e(n,e,t=r){const i=[]
8
- return function r(n){n.forEach((n,o)=>{e(n,o)&&i.push(n)
9
- const s=n[t.children]
10
- Array.isArray(s)&&s.length>0&&r(s,o)})}(n),i}function t(n,e,i=r){for(const r of n){if(e(r))return r
11
- const n=r[i.children]
12
- if(Array.isArray(n)&&n.length>0){const r=t(n,e,i)
13
- if(r)return r}}return null}function i(n,e,t,i=r){return function r(n){for(const o of n){if(o[i.id]===e)return o[i.children]||(o[i.children]=[]),o[i.children].push(t),!0
14
- const n=o[i.children]
15
- if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function o(n,e,t,i=r){return function r(n){for(const o of n){if(o[i.id]===e)return o[i.children]||(o[i.children]=[]),o[i.children].unshift(t),!0
16
- const n=o[i.children]
17
- if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function s(n,e,t=r){return function r(n){for(const i of n){if(i[t.id]===e){const r=i[t.children]
18
- return!!(Array.isArray(r)&&r.length>0)&&(r.pop(),!0)}const n=i[t.children]
19
- if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function u(n,e,t=r){return function r(n){for(const i of n){if(i[t.id]===e){const r=i[t.children]
20
- return!!(Array.isArray(r)&&r.length>0)&&(r.shift(),!0)}const n=i[t.children]
21
- if(Array.isArray(n)&&n.length>0&&r(n))return!0}return!1}(n)}function f(n,e,t=r){for(const r of n){if(e(r))return!0
22
- const n=r[t.children]
23
- if(Array.isArray(n)&&n.length>0&&f(n,e,t))return!0}return!1}function c(n,e,t=r){for(const r of n){if(!e(r))return!1
24
- const n=r[t.children]
25
- if(Array.isArray(n)&&n.length>0&&!c(n,e,t))return!1}return!0}function l(n,e,t,i=r){const o=function r(n){for(const t of n){if(t[i.id]===e)return t
26
- const n=t[i.children]
27
- if(Array.isArray(n)&&n.length>0){const e=r(n)
28
- if(e)return e}}return null}(n)
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 s=o[i.children]
31
- if(!Array.isArray(s)||0===s.length)return null
32
- const u=t>=0?t:s.length+t
33
- return u>=0&&u<s.length?s[u]:null}function h(n,e,t=r){return function r(n,i=[]){for(let o=0;o<n.length;o++){const s=n[o],u=[...i,o]
34
- if(s[t.id]===e)return u
35
- const f=s[t.children]
36
- if(Array.isArray(f)&&f.length>0){const n=r(f,u)
37
- if(n)return n}}return null}(n)}function a(n,e,t=r){if(!Array.isArray(e)||0===e.length)return null
38
- let i=n
39
- for(let r=0;r<e.length;r++){const n=e[r]
40
- if(!Array.isArray(i)||n<0||n>=i.length)return null
41
- const o=i[n]
42
- if(r===e.length-1)return o
43
- const s=o[t.children]
44
- if(!Array.isArray(s))return null
45
- i=s}return null}function d(n,e=r){const t={}
46
- return function r(n,i=1){for(const o of n){t[o[e.id]]=i
47
- const n=o[e.children]
48
- Array.isArray(n)&&n.length>0&&r(n,i+1)}}(n),t}function y(n,e,t=r){const i=new Set
49
- return function r(n){const o=[]
50
- for(const s of n){const n=s[e]
51
- if(null!=n){if(i.has(n))continue
52
- i.add(n)}const u={...s},f=s[t.children]
53
- Array.isArray(f)&&f.length>0&&(u[t.children]=r(f)),o.push(u)}return o}(n)}function A(n,e,t=r){return function r(n){for(let i=0;i<n.length;i++){const o=n[i]
54
- if(o[t.id]===e)return n.splice(i,1),!0
55
- const s=o[t.children]
56
- if(Array.isArray(s)&&s.length>0&&r(s))return!0}return!1}(n)}function p(n,e,t=r){!function r(n){for(const i of n){e(i)
57
- const n=i[t.children]
58
- Array.isArray(n)&&n.length>0&&r(n)}}(n)}function T(r){return!Array.isArray(r)||0===r.length}function g(n,e,t=r){return function r(n,i=null){for(const o of n){if(o[t.id]===e)return i
59
- const n=o[t.children]
60
- if(Array.isArray(n)&&n.length>0){const e=r(n,o)
61
- if(null!==e)return e}}return null}(n)}function x(n,e,t=r){for(const r of n){if(r[t.id]===e)return!0
62
- const n=r[t.children]
63
- if(Array.isArray(n)&&n.length>0&&x(n,e,t))return!0}return!1}function m(n,e=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
64
- const t=n[e.children]
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(!m(r,e))return!1}return!0}function v(n,e=r){if(!Array.isArray(n))return!1
68
- for(const r of n)if(!m(r,e))return!1
69
- return!0}const M={mapTree:n,filterTree:e,findTree:t,pushTree:i,unshiftTree:o,popTree:s,shiftTree:u,someTree:f,everyTree:c,atTree:l,indexOfTree:h,atIndexOfTree:a,nodeDepthMap:d,dedupTree:y,removeTree:A,forEachTree:p,isEmptyTree:T,getParentTree:g,includesTree:x,isSingleTree:m,isMultipleTrees:v}
70
- exports.atIndexOfTree=a,exports.atTree=l,exports.dedupTree=y,exports.default=M,exports.everyTree=c,exports.filterTree=e,exports.findTree=t,exports.forEachTree=p,exports.getParentTree=g,exports.includesTree=x,exports.indexOfTree=h,exports.isEmptyTree=T,exports.isMultipleTrees=v,exports.isSingleTree=m,exports.mapTree=n,exports.nodeDepthMap=d,exports.popTree=s,exports.pushTree=i,exports.removeTree=A,exports.shiftTree=u,exports.someTree=f,exports.unshiftTree=o
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 c=n[e.children]
8
- Array.isArray(c)&&c.length>0&&r(c,o)})}(n),i}function e(n,t,i=r){for(const r of n){if(t(r))return r
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 c=o[i.children]
29
- if(!Array.isArray(c)||0===c.length)return null
30
- const u=e>=0?e:c.length+e
31
- return u>=0&&u<c.length?c[u]:null}function h(n,t,e=r){return function r(n,i=[]){for(let o=0;o<n.length;o++){const c=n[o],u=[...i,o]
32
- if(c[e.id]===t)return u
33
- const f=c[e.children]
34
- if(Array.isArray(f)&&f.length>0){const n=r(f,u)
35
- if(n)return n}}return null}(n)}function a(n,t,e=r){if(!Array.isArray(t)||0===t.length)return null
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 c=o[e.children]
42
- if(!Array.isArray(c))return null
43
- i=c}return null}function y(n,t=r){const e={}
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){const i=new Set
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 c of n){const n=c[t]
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 u={...c},f=c[e.children]
51
- Array.isArray(f)&&f.length>0&&(u[e.children]=r(f)),o.push(u)}return o}(n)}function A(n,t,e=r){return function r(n){for(let i=0;i<n.length;i++){const o=n[i]
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 c=o[e.children]
54
- if(Array.isArray(c)&&c.length>0&&r(c))return!0}return!1}(n)}function g(n,t,e=r){!function r(n){for(const i of n){t(i)
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 T(r){return!Array.isArray(r)||0===r.length}function p(n,t,e=r){return function r(n,i=null){for(const o of n){if(o[e.id]===t)return i
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 v(n,t=r){if(!n||"object"!=typeof n||Array.isArray(n))return!1
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(!v(r,t))return!1}return!0}function x(n,t=r){if(!Array.isArray(n))return!1
66
- for(const r of n)if(!v(r,t))return!1
67
- return!0}const E={mapTree:n,filterTree:t,findTree:e,pushTree:i,unshiftTree:o,popTree:c,shiftTree:u,someTree:f,everyTree:l,atTree:s,indexOfTree:h,atIndexOfTree:a,nodeDepthMap:y,dedupTree:d,removeTree:A,forEachTree:g,isEmptyTree:T,getParentTree:p,includesTree:m,isSingleTree:v,isMultipleTrees:x}
68
- export{a as atIndexOfTree,s as atTree,d as dedupTree,E as default,l as everyTree,t as filterTree,e as findTree,g as forEachTree,p as getParentTree,m as includesTree,h as indexOfTree,T as isEmptyTree,x as isMultipleTrees,v as isSingleTree,n as mapTree,y as nodeDepthMap,c as popTree,i as pushTree,A as removeTree,u as shiftTree,f as someTree,o as unshiftTree}
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 h(r,e,t,i=n){const o=function r(n){for(const t of n){if(t[i.id]===e)return t
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 a(r,e,t=n){return function r(n,i=[]){for(let o=0;o<n.length;o++){const f=n[o],u=[...i,o]
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){const i=new Set
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 T(r,e,t=n){return function r(n){for(let i=0;i<n.length;i++){const o=n[i]
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 g(r,e,t=n){!function r(n){for(const i of n){e(i)
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&&r(n)}}(r)}function p(r){return!Array.isArray(r)||0===r.length}function m(r,e,t=n){return function r(n,i=null){for(const o of n){if(o[t.id]===e)return i
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)}function v(r,e,t=n){for(const n of r){if(n[t.id]===e)return!0
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&&v(r,e,t))return!0}return!1}function x(r,e=n){if(!r||"object"!=typeof r||Array.isArray(r))return!1
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 b(r,e=n){if(!Array.isArray(r))return!1
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}const M={mapTree:e,filterTree:t,findTree:i,pushTree:o,unshiftTree:f,popTree:u,shiftTree:c,someTree:s,everyTree:l,atTree:h,indexOfTree:a,atIndexOfTree:d,nodeDepthMap:y,dedupTree:A,removeTree:T,forEachTree:g,isEmptyTree:p,getParentTree:m,includesTree:v,isSingleTree:x,isMultipleTrees:b}
69
- r.atIndexOfTree=d,r.atTree=h,r.dedupTree=A,r.default=M,r.everyTree=l,r.filterTree=t,r.findTree=i,r.forEachTree=g,r.getParentTree=m,r.includesTree=v,r.indexOfTree=a,r.isEmptyTree=p,r.isMultipleTrees=b,r.isSingleTree=x,r.mapTree=e,r.nodeDepthMap=y,r.popTree=u,r.pushTree=o,r.removeTree=T,r.shiftTree=c,r.someTree=s,r.unshiftTree=f,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})
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.6.2",
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": "",