1 |
9bb1e829
|
cagy
|
/*!
|
2 |
|
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
3 |
|
|
*
|
4 |
|
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
5 |
|
|
* Released under the MIT License.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
'use strict';
|
9 |
|
|
|
10 |
|
|
var isObject = require('isobject');
|
11 |
|
|
|
12 |
|
|
function isObjectObject(o) {
|
13 |
|
|
return isObject(o) === true
|
14 |
|
|
&& Object.prototype.toString.call(o) === '[object Object]';
|
15 |
|
|
}
|
16 |
|
|
|
17 |
|
|
module.exports = function isPlainObject(o) {
|
18 |
|
|
var ctor,prot;
|
19 |
|
|
|
20 |
|
|
if (isObjectObject(o) === false) return false;
|
21 |
|
|
|
22 |
|
|
// If has modified constructor
|
23 |
|
|
ctor = o.constructor;
|
24 |
|
|
if (typeof ctor !== 'function') return false;
|
25 |
|
|
|
26 |
|
|
// If has modified prototype
|
27 |
|
|
prot = ctor.prototype;
|
28 |
|
|
if (isObjectObject(prot) === false) return false;
|
29 |
|
|
|
30 |
|
|
// If constructor does not have an Object-specific method
|
31 |
|
|
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
32 |
|
|
return false;
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
// Most likely a plain Object
|
36 |
|
|
return true;
|
37 |
|
|
};
|