Skip to content

Commit

Permalink
guard omit() from null objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Apr 19, 2024
1 parent 69df040 commit e71836a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Expand Up @@ -2705,6 +2705,7 @@ export function pick(o:any, keys:string[]) {
}
export function omit(o:any, keys:string[]) {
const to = {}
if (!o) return to
for (const k in o) {
if (o.hasOwnProperty(k) && keys.indexOf(k) < 0) {
to[k] = o[k]
Expand All @@ -2714,6 +2715,7 @@ export function omit(o:any, keys:string[]) {
}
export function omitEmpty(o:any) {
const to = {}
if (!o) return to
for (const k in o) {
const v = o[k]
if (v != null && v !== '') {
Expand Down

0 comments on commit e71836a

Please sign in to comment.