From d10bddaa14df0d3cf14c9fd4602a4e430bed5fc9 Mon Sep 17 00:00:00 2001 From: James P Date: Fri, 19 Apr 2024 10:37:20 -0500 Subject: [PATCH] Added readonly to keys for pick and omit --- src/objects.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objects.ts b/src/objects.ts index 3dae12a..f3bb2ea 100644 --- a/src/objects.ts +++ b/src/objects.ts @@ -5,11 +5,11 @@ export function filterObject(object: O, pred return Object.fromEntries(entries.filter(([key, value]) => predicate(key, value))); } -export function pick(object: T, ...keys: K[] | K[][]): Pick { +export function pick(object: T, ...keys: readonly K[] | readonly K[][]): Pick { return filterObject>(object, (key: K) => keys.flat().includes(key)); } -export function omit(object: T, ...keys: K[] | K[][]): Omit { +export function omit(object: T, ...keys: readonly K[] | readonly K[][]): Omit { return filterObject>(object, (key: K) => !keys.flat().includes(key)); }