2020-03-31 20:42:07 +08:00
|
|
|
/*!
|
|
|
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
|
|
* Released under the MIT License.
|
|
|
|
*/
|
|
|
|
|
2020-06-06 22:11:37 +08:00
|
|
|
import isObject from 'isobject';
|
2020-03-31 20:42:07 +08:00
|
|
|
|
|
|
|
function isObjectObject(o) {
|
|
|
|
return isObject(o) === true
|
|
|
|
&& Object.prototype.toString.call(o) === '[object Object]';
|
|
|
|
}
|
|
|
|
|
2020-06-06 22:11:37 +08:00
|
|
|
export default function isPlainObject(o) {
|
2020-03-31 20:42:07 +08:00
|
|
|
var ctor,prot;
|
|
|
|
|
|
|
|
if (isObjectObject(o) === false) return false;
|
|
|
|
|
|
|
|
// If has modified constructor
|
|
|
|
ctor = o.constructor;
|
|
|
|
if (typeof ctor !== 'function') return false;
|
|
|
|
|
|
|
|
// If has modified prototype
|
|
|
|
prot = ctor.prototype;
|
|
|
|
if (isObjectObject(prot) === false) return false;
|
|
|
|
|
|
|
|
// If constructor does not have an Object-specific method
|
|
|
|
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Most likely a plain Object
|
|
|
|
return true;
|
|
|
|
};
|