Skip to content

Commit

Permalink
add Object.omit() (used by spec)
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Feb 28, 2022
1 parent e60c4cc commit af0c3ef
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ export function fromEntries(arr: [string | undefined, any][]) {
}
return o
}

export function omit<T extends Record<string, any>, S extends keyof T>(
t: T,
...keysToOmit: S[]
): Omit<T, S> {
const result = { ...t }
for (const ea of keysToOmit) {
delete result[ea]
}
return result
}

0 comments on commit af0c3ef

Please sign in to comment.