2021-07-29 04:54:38 -05:00
|
|
|
function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {
|
|
|
|
const result: any = {}
|
2021-07-29 03:27:24 -05:00
|
|
|
|
|
|
|
for (const key of keys) {
|
|
|
|
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
|
|
result[key] = object[key]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
pick
|
|
|
|
}
|