1 function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {
4 for (const key of keys) {
5 if (Object.prototype.hasOwnProperty.call(object, key)) {
6 result[key] = object[key]
13 function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
14 return (Object.keys(object) as K[]).filter(k => keys.includes(k))
17 function sortObjectComparator (key: string, order: 'asc' | 'desc') {
18 return (a: any, b: any) => {
19 if (a[key] < b[key]) {
20 return order === 'asc' ? -1 : 1
23 if (a[key] > b[key]) {
24 return order === 'asc' ? 1 : -1