import { ObjWithProto } from '../../../../typings'
import { isNil } from '../../primitive/nil'
import { hasOwnProp } from '../../attributes/properties/hasOwnProperty'
import { isObj } from '../../obj'
/**
* @desc check if it has prototype property
* @param {*} x value to check
*
* @return {Boolean}
*
* {Number | undefined} 1 | 2 could put enum options for checking
*
* @example
* hasPrototype(class {})
* //=> true
*
* hasPrototype(new class {})
* //=> true
*
* hasPrototype(function() {})
* //=> true
*
* hasPrototype(() => {})
* //=> false || true // babel MAY add one, but it isn't there in ecmascript
*
* hasPrototype(Object.create(null))
* //=> false
*
* hasPrototype({})
* //=> true
*
* hasPrototype(undefined)
* //=> false
*
* hasPrototype(true)
* //=> true // try in browser `true.__proto__`
*/
function hasPrototype(x: any): x is ObjWithProto {
if (isNil(x)) {
return false
} else if (isObj(x.prototype)) {
return true
} else if (isObj(x.__proto__)) {
return true
} else {
return false
}
// if (Object.prototype.hasOwnProperty.call(x, 'prototype')) {
// return true
// }
// else if (Object.prototype.hasOwnProperty.call(x, '__proto__')) {
// return true
// }
}
export { hasPrototype }
export default hasPrototype