Skip to content

Commit

Permalink
refactor: simplify with find
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Jul 31, 2024
1 parent a99cf45 commit ca57633
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,7 @@ export function accessPathDepth(path: string) {
* This is a replacement for chained || for numeric properties or properties that respect null so that 0 will be included.
*/
export function getFirstDefined<T>(...args: readonly T[]): T | undefined {
for (const arg of args) {
if (arg !== undefined) {
return arg;
}
}
return undefined;
return args.find(a => a !== undefined);
}

// variable used to generate id
Expand Down

0 comments on commit ca57633

Please sign in to comment.