layerchart 0.3.1 → 0.3.2
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/package.json +2 -1
- package/utils/hierarchy.d.ts +6 -0
- package/utils/hierarchy.js +13 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "techniq/layerchart",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.2",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@sveltejs/adapter-vercel": "^1.0.0-next.47",
|
|
9
9
|
"@sveltejs/kit": "^1.0.0-next.303",
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"./utils/event": "./utils/event.js",
|
|
92
92
|
"./utils/genData": "./utils/genData.js",
|
|
93
93
|
"./utils/graph": "./utils/graph.js",
|
|
94
|
+
"./utils/hierarchy": "./utils/hierarchy.js",
|
|
94
95
|
"./utils": "./utils/index.js",
|
|
95
96
|
"./utils/math": "./utils/math.js",
|
|
96
97
|
"./utils/path": "./utils/path.js",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HierarchyNode } from 'd3-hierarchy';
|
|
2
|
+
/**
|
|
3
|
+
* Find first ancestor matching filter, including node.
|
|
4
|
+
* Similar to `node.find()` (https://github.com/d3/d3-hierarchy#node_find) but checks ancestors instead of descendants
|
|
5
|
+
*/
|
|
6
|
+
export declare function findAncestor<T = any>(node: HierarchyNode<T>, filter: (node: any) => boolean): HierarchyNode<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find first ancestor matching filter, including node.
|
|
3
|
+
* Similar to `node.find()` (https://github.com/d3/d3-hierarchy#node_find) but checks ancestors instead of descendants
|
|
4
|
+
*/
|
|
5
|
+
export function findAncestor(node, filter) {
|
|
6
|
+
while (node) {
|
|
7
|
+
if (filter(node)) {
|
|
8
|
+
return node;
|
|
9
|
+
}
|
|
10
|
+
node = node.parent;
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|