refactor: extract hasOwn helper

This commit is contained in:
Evan You
2019-09-05 20:48:14 -04:00
parent 7eed0df3c2
commit 891f21b010
5 changed files with 23 additions and 20 deletions

View File

@@ -15,6 +15,12 @@ export const extend = <T extends object, U extends object>(
return a as any
}
const hasOwnProperty = Object.prototype.hasOwnProperty
export const hasOwn = (
val: object,
key: string | symbol
): key is keyof typeof val => hasOwnProperty.call(val, key)
export const isArray = Array.isArray
export const isFunction = (val: any): val is Function =>
typeof val === 'function'