Skip to content

Commit

Permalink
Resolve all change requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Davilarek committed Feb 20, 2024
1 parent 30779b6 commit 59bb527
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export function createJavaScriptFromObject(obj_: any, intend = false) {
return final.join("\n");
}

export type Tree = Record<string, Function | any> | undefined | null;
export type TreeFilter = string | ((tree: Tree) => boolean | Boolean); // whats the difference :)
export type Tree = Record<string, () => any | any> | undefined | null;
export type TreeFilter = string | ((tree: Tree) => boolean); // whats the difference :)

export function findInTree(
tree: Tree,
Expand All @@ -108,9 +108,7 @@ export function findInTree(

if (maxRecursion <= 0 || !tree) return undefined;

// @ts-ignore
// yeah I get all expressions arent callable. that's why IM CHECKING IF IT CAN BE.
if ((typeof searchFilter === "string" && tree?.[searchFilter]) || searchFilter(tree))
if ((typeof searchFilter === "string" && typeof tree?.[searchFilter] === "function") || (typeof searchFilter === "function" && searchFilter(tree)))
return tree;

if (!Array.isArray(tree) && typeof tree !== "object")
Expand Down

0 comments on commit 59bb527

Please sign in to comment.