From d6089a40a26905c0f1e9665e97587a8586ac951d Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 27 Nov 2023 21:46:47 +0100 Subject: [PATCH] fix(performance): improve omit (#461) --- src/util/omit.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/util/omit.ts b/src/util/omit.ts index fc8214e1..266ac980 100644 --- a/src/util/omit.ts +++ b/src/util/omit.ts @@ -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; }