1 | /**
|
2 | Check if a value is a plain object.
|
3 |
|
4 | An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
|
5 |
|
6 | @example
|
7 | ```
|
8 | import isPlainObject from 'is-plain-obj';
|
9 | import {runInNewContext} from 'node:vm';
|
10 |
|
11 | isPlainObject({foo: 'bar'});
|
12 | //=> true
|
13 |
|
14 | isPlainObject(new Object());
|
15 | //=> true
|
16 |
|
17 | isPlainObject(Object.create(null));
|
18 | //=> true
|
19 |
|
20 | // This works across realms
|
21 | isPlainObject(runInNewContext('({})'));
|
22 | //=> true
|
23 |
|
24 | isPlainObject([1, 2, 3]);
|
25 | //=> false
|
26 |
|
27 | class Unicorn {}
|
28 | isPlainObject(new Unicorn());
|
29 | //=> false
|
30 |
|
31 | isPlainObject(Math);
|
32 | //=> false
|
33 | ```
|
34 | */
|
35 | export default function isPlainObject<Value>(value: unknown): value is Record<PropertyKey, Value>;
|