Skip to content

Commit

Permalink
fix: broken types
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhdaware committed Nov 19, 2023
1 parent 4b68e60 commit ffedda3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/blade/src/utils/lodashButBetter/get.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
function getIn(obj: Record<string, any>, path: string): any {
function getIn(obj: Record<string, any>, path: string, defaultValue?: any): any {
if (!path) {
return undefined;
return defaultValue;
}

const keys = path.split('.');
Expand All @@ -10,11 +10,11 @@ function getIn(obj: Record<string, any>, path: string): any {
for (const key of keys) {
result = result?.[key];
if (result === undefined) {
return undefined;
return defaultValue;
}
}

return result;
return result !== undefined ? result : defaultValue;
}

export default getIn;

0 comments on commit ffedda3

Please sign in to comment.