move helpers to new workspace folder
This commit is contained in:
15
packages/helpers/pick.ts
Normal file
15
packages/helpers/pick.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { LoosePick, UnknownRecord } from "./types"
|
||||
|
||||
export function pick<T, K extends keyof T | PropertyKey>(
|
||||
object: T,
|
||||
keys: K[],
|
||||
): LoosePick<T, K> {
|
||||
const result: any = {}
|
||||
for (const key of keys) {
|
||||
const value = (object as UnknownRecord)[key]
|
||||
if (value !== undefined) {
|
||||
result[key] = value
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user