index.d.ts 673 B

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