diff --git a/src/objects.ts b/src/objects.ts index d28c94c..33b083f 100644 --- a/src/objects.ts +++ b/src/objects.ts @@ -5,10 +5,14 @@ export function filterObject(object: O, pred return Object.fromEntries(entries.filter(([key, value]) => predicate(key, value))); } +export function pick(object: T, ...keys: readonly K[]): Pick; +export function pick(object: T, ...keys: readonly (readonly K[])[]): Pick; export function pick(object: T, ...keys: readonly K[] | readonly (readonly K[])[]): Pick { return filterObject>(object, (key: K) => keys.flat().includes(key)); } +export function omit(object: T, ...keys: readonly K[]): Omit; +export function omit(object: T, ...keys: readonly (readonly K[])[]): Omit; export function omit(object: T, ...keys: readonly K[] | readonly (readonly K[])[]): Omit { return filterObject>(object, (key: K) => !keys.flat().includes(key)); }