chore: add pick utils

This commit is contained in:
chenjiahan 2020-08-24 10:19:43 +08:00
parent ddce2afb4d
commit 28f2fe340c

View File

@ -33,3 +33,10 @@ export function get(object: any, path: string): any {
return result;
}
export function pick(obj: Record<string, any>, keys: string[]) {
return keys.reduce((ret, key) => {
ret[key] = obj[key];
return ret;
}, {} as Record<string, any>);
}