15 lines
268 B
TypeScript
15 lines
268 B
TypeScript
function pick <T extends object> (object: T, keys: (keyof T)[]) {
|
|
const result: Partial<T> = {}
|
|
|
|
for (const key of keys) {
|
|
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
result[key] = object[key]
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
export {
|
|
pick
|
|
}
|