mirror of
https://github.com/YunoHost/yunohost-portal.git
synced 2024-09-03 20:06:23 +02:00
22 lines
504 B
TypeScript
22 lines
504 B
TypeScript
export function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K> {
|
|
const filtered = {} as Pick<T, K>
|
|
keys.forEach((key) => {
|
|
filtered[key] = obj[key]
|
|
})
|
|
return filtered
|
|
}
|
|
|
|
export function exclude<T, K extends keyof T>(
|
|
obj: T,
|
|
...keys: K[]
|
|
): Omit<T, K> {
|
|
const filtered = { ...obj }
|
|
keys.forEach((key) => {
|
|
delete filtered[key]
|
|
})
|
|
return filtered
|
|
}
|
|
|
|
export function keysOf<T extends Record<string, string>>(obj: T) {
|
|
return Object.keys(obj) as Array<keyof T>
|
|
}
|