From 28f2fe340c2622735fb9fca7193235b52aa69231 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 24 Aug 2020 10:19:43 +0800 Subject: [PATCH] chore: add pick utils --- src/utils/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils/index.ts b/src/utils/index.ts index cac1c5ce2..03976bbd3 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -33,3 +33,10 @@ export function get(object: any, path: string): any { return result; } + +export function pick(obj: Record, keys: string[]) { + return keys.reduce((ret, key) => { + ret[key] = obj[key]; + return ret; + }, {} as Record); +}