Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
cr
Browse files Browse the repository at this point in the history
  • Loading branch information
SupaJoon committed Mar 26, 2024
1 parent 6575d3e commit d4e1924
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/utils/object/deleteNestedKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function deleteNestedKey<T extends object>(
keyToUpdate: string | string[],
redactedString?: string,
): Partial<T> {
const deleteKey = (currentObject: any) => {
const deleteKey = (currentObject: { [key: string]: any }) => {
Object.keys(currentObject).forEach((key) => {
if (key === keyToUpdate || keyToUpdate?.includes(key)) {
if (redactedString) {
Expand Down
4 changes: 1 addition & 3 deletions src/utils/object/omit.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { deleteNestedKey } from "./deleteNestedKey";

export const omit = <T extends object, K extends [...(keyof T)[]]>(
obj: T,
params: K,
) => {
const newObj = { ...obj };
deleteNestedKey(newObj, params as string[]);
params.forEach((param) => delete newObj[param]);
return newObj as Omit<T, K[number]>;
};

0 comments on commit d4e1924

Please sign in to comment.