|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
953 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | function isPlainObject(object) {
|
|---|
| 6 | if (typeof object !== 'object') {
|
|---|
| 7 | return false;
|
|---|
| 8 | }
|
|---|
| 9 | if (object == null) {
|
|---|
| 10 | return false;
|
|---|
| 11 | }
|
|---|
| 12 | if (Object.getPrototypeOf(object) === null) {
|
|---|
| 13 | return true;
|
|---|
| 14 | }
|
|---|
| 15 | if (Object.prototype.toString.call(object) !== '[object Object]') {
|
|---|
| 16 | const tag = object[Symbol.toStringTag];
|
|---|
| 17 | if (tag == null) {
|
|---|
| 18 | return false;
|
|---|
| 19 | }
|
|---|
| 20 | const isTagReadonly = !Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable;
|
|---|
| 21 | if (isTagReadonly) {
|
|---|
| 22 | return false;
|
|---|
| 23 | }
|
|---|
| 24 | return object.toString() === `[object ${tag}]`;
|
|---|
| 25 | }
|
|---|
| 26 | let proto = object;
|
|---|
| 27 | while (Object.getPrototypeOf(proto) !== null) {
|
|---|
| 28 | proto = Object.getPrototypeOf(proto);
|
|---|
| 29 | }
|
|---|
| 30 | return Object.getPrototypeOf(object) === proto;
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | exports.isPlainObject = isPlainObject;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.