|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
480 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * @param {any} obj The object to inspect.
|
|---|
| 3 | * @returns {boolean} True if the argument appears to be a plain object.
|
|---|
| 4 | */
|
|---|
| 5 | export default function isPlainObject(obj: unknown) {
|
|---|
| 6 | if (typeof obj !== 'object' || obj === null) return false
|
|---|
| 7 |
|
|---|
| 8 | const proto = Object.getPrototypeOf(obj)
|
|---|
| 9 | if (proto === null) return true
|
|---|
| 10 |
|
|---|
| 11 | let baseProto = proto
|
|---|
| 12 | while (Object.getPrototypeOf(baseProto) !== null) {
|
|---|
| 13 | baseProto = Object.getPrototypeOf(baseProto)
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | return proto === baseProto
|
|---|
| 17 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.