@kmkf-fe-packages/kmkf-utils 0.7.8 → 0.7.10

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.
@@ -6,3 +6,4 @@ export { default as isNull } from './isNull';
6
6
  export { default as orderBackFormValues } from './orderBackFormValues';
7
7
  export * as filterFn from './filterFn';
8
8
  export * as templateFn from './template';
9
+ export * as tree from './multidimensionalFindChild';
@@ -7,4 +7,6 @@ export { default as orderBackFormValues } from "./orderBackFormValues";
7
7
  import * as _filterFn from "./filterFn";
8
8
  export { _filterFn as filterFn };
9
9
  import * as _templateFn from "./template";
10
- export { _templateFn as templateFn };
10
+ export { _templateFn as templateFn };
11
+ import * as _tree from "./multidimensionalFindChild";
12
+ export { _tree as tree };
@@ -0,0 +1,7 @@
1
+ interface Node {
2
+ label: string;
3
+ children?: Node[];
4
+ [prop: string]: any;
5
+ }
6
+ declare const findNodeByValue: (tree: Node[], targetField: string, targetValue: string) => any;
7
+ export { findNodeByValue };
@@ -0,0 +1,26 @@
1
+ var findNodeByValue = function findNodeByValue(tree, targetField, targetValue) {
2
+ var dfs = function dfs(node) {
3
+ if ((node === null || node === void 0 ? void 0 : node[targetField]) === targetValue) {
4
+ return node;
5
+ }
6
+ if (Reflect.has(node, 'children')) {
7
+ var _node$children = node.children,
8
+ children = _node$children === void 0 ? [] : _node$children;
9
+ for (var i = 0; i < children.length; i++) {
10
+ var result = dfs(children[i]);
11
+ if (result) {
12
+ return result;
13
+ }
14
+ }
15
+ }
16
+ return null;
17
+ };
18
+ for (var i = 0; i < tree.length; i++) {
19
+ var result = dfs(tree[i]);
20
+ if (result) {
21
+ return result;
22
+ }
23
+ }
24
+ return null;
25
+ };
26
+ export { findNodeByValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kmkf-fe-packages/kmkf-utils",
3
- "version": "0.7.8",
3
+ "version": "0.7.10",
4
4
  "module": "dist/esm/index.js",
5
5
  "typings": "dist/esm/index.d.ts",
6
6
  "files": [
@@ -42,5 +42,5 @@
42
42
  "gitHooks": {
43
43
  "pre-commit": "lint-staged"
44
44
  },
45
- "gitHead": "630cb0b0ae60a5af792b2cc766111838bb2deebf"
45
+ "gitHead": "427464948991348fa97699e8d1ff661630971990"
46
46
  }