We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a3ac319 commit 7acd483Copy full SHA for 7acd483
lib/tree-q/path/p.ts
@@ -20,7 +20,11 @@ interface Item {
20
function p<T extends Item = Item>(id: string, { data }: { data: T }): string[] {
21
let path: string[] = [];
22
23
- function search(node: T, currentPath: string[]): boolean {
+ function search(node: T | undefined | null, currentPath: string[]): boolean {
24
+ if (node == null) {
25
+ return false;
26
+ }
27
+
28
if (node.id === id) {
29
path = [...currentPath, node.id];
30
return true;
@@ -36,6 +40,7 @@ function p<T extends Item = Item>(id: string, { data }: { data: T }): string[] {
36
40
37
41
}
38
42
43
39
44
return false;
45
46
0 commit comments