Skip to content

Commit

Permalink
fix(reactivePick): allow nested keys
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 6, 2022
1 parent 3141788 commit 80c1648
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/shared/reactiveOmit/index.ts
Expand Up @@ -10,5 +10,6 @@ export function reactiveOmit<T extends object, K extends keyof T>(
obj: T,
...keys: (K | K[])[]
): Omit<T, K> {
return reactiveComputed<any>(() => Object.fromEntries(Object.entries(toRefs(obj)).filter(e => !keys.includes(e[0] as any))))
const flatKeys = keys.flat() as K[]
return reactiveComputed<any>(() => Object.fromEntries(Object.entries(toRefs(obj)).filter(e => !flatKeys.includes(e[0] as any))))
}
3 changes: 2 additions & 1 deletion packages/shared/reactivePick/index.ts
Expand Up @@ -10,5 +10,6 @@ export function reactivePick<T extends object, K extends keyof T>(
obj: T,
...keys: (K | K[])[]
): { [S in K]: UnwrapRef<T[S]> } {
return reactive(Object.fromEntries(keys.map(k => [k, toRef(obj, k)]))) as any
const flatKeys = keys.flat() as K[]
return reactive(Object.fromEntries(flatKeys.map(k => [k, toRef(obj, k)]))) as any
}

0 comments on commit 80c1648

Please sign in to comment.