diff --git a/utils/common.ts b/utils/common.ts new file mode 100644 index 0000000..eb12cc4 --- /dev/null +++ b/utils/common.ts @@ -0,0 +1,18 @@ +export function pick(obj: T, ...keys: K[]): Pick { + const filtered = {} as Pick + keys.forEach((key) => { + filtered[key] = obj[key] + }) + return filtered +} + +export function exclude( + obj: T, + ...keys: K[] +): Omit { + const filtered = { ...obj } + keys.forEach((key) => { + delete filtered[key] + }) + return filtered +}