source: node_modules/es-toolkit/dist/compat/predicate/isPlainObject.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 851 bytes
Line 
1function isPlainObject(object) {
2 if (typeof object !== 'object') {
3 return false;
4 }
5 if (object == null) {
6 return false;
7 }
8 if (Object.getPrototypeOf(object) === null) {
9 return true;
10 }
11 if (Object.prototype.toString.call(object) !== '[object Object]') {
12 const tag = object[Symbol.toStringTag];
13 if (tag == null) {
14 return false;
15 }
16 const isTagReadonly = !Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable;
17 if (isTagReadonly) {
18 return false;
19 }
20 return object.toString() === `[object ${tag}]`;
21 }
22 let proto = object;
23 while (Object.getPrototypeOf(proto) !== null) {
24 proto = Object.getPrototypeOf(proto);
25 }
26 return Object.getPrototypeOf(object) === proto;
27}
28
29export { isPlainObject };
Note: See TracBrowser for help on using the repository browser.