UNPKG

721 BJavaScriptView Raw
1import isObjectLike from './is-object-like';
2import isType from './is-type';
3var isPlainObject = function (value) {
4 /**
5 * isObjectLike(new Foo) => false
6 * isObjectLike([1, 2, 3]) => false
7 * isObjectLike({ x: 0, y: 0 }) => true
8 * isObjectLike(Object.create(null)) => true
9 */
10 if (!isObjectLike(value) || !isType(value, 'Object')) {
11 return false;
12 }
13 if (Object.getPrototypeOf(value) === null) {
14 return true;
15 }
16 var proto = value;
17 while (Object.getPrototypeOf(proto) !== null) {
18 proto = Object.getPrototypeOf(proto);
19 }
20 return Object.getPrototypeOf(value) === proto;
21};
22export default isPlainObject;
23//# sourceMappingURL=is-plain-object.js.map
\No newline at end of file