Skip to content

Commit

Permalink
Finish: use generic in emit function
Browse files Browse the repository at this point in the history
  • Loading branch information
leftstick committed Apr 4, 2018
1 parent fe373b7 commit 05c1772
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/helpers/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ export function isFunction(obj: any): obj is boolean {
return Object.prototype.toString.call(obj) === '[object Function]'
}

export function omit(obj: object, ...keys: Array<string>) {
export function omit<T>(obj: T, ...keys: Array<string>): T {
const rawKeys = Object.keys(obj)
const finalKeys = rawKeys.filter(k => !keys.includes(k))
return finalKeys.reduce((p, v) => {
p[v] = obj[v]
return p
}, {})
return finalKeys.reduce(
(p, v) => {
p[v] = obj[v]
return p
},
<T>{}
)
}

0 comments on commit 05c1772

Please sign in to comment.