From 99843b7975460b7d50e427e966a4a76896cdb09e Mon Sep 17 00:00:00 2001 From: uzlopak Date: Mon, 27 Nov 2023 01:44:03 +0100 Subject: [PATCH] chore: improve omit --- 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; }