Skip to content

Commit

Permalink
fix(performance): improve omit (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Nov 27, 2023
1 parent 4ec784d commit d6089a4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/util/omit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ export function omit(
object: { [key: string]: any },
keysToOmit: string[],
): { [key: string]: any } {
return Object.keys(object)
.filter((option) => !keysToOmit.includes(option))
.reduce((obj: { [key: string]: any }, key) => {
obj[key] = object[key];
return obj;
}, {});
const result: { [key: string]: any } = { __proto__: null };

for (const key of Object.keys(object)) {
if (keysToOmit.indexOf(key) === -1) {
result[key] = object[key];
}
}

return result;
}

0 comments on commit d6089a4

Please sign in to comment.