You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2 KiB

3 months ago
  1. # is-plain-obj [![Build Status](https://travis-ci.com/sindresorhus/is-plain-obj.svg?branch=master)](https://travis-ci.com/github/sindresorhus/is-plain-obj)
  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. ## Install
  5. ```
  6. $ npm install is-plain-obj
  7. ```
  8. ## Usage
  9. ```js
  10. const isPlainObject = require('is-plain-obj');
  11. isPlainObject({foo: 'bar'});
  12. //=> true
  13. isPlainObject(new Object());
  14. //=> true
  15. isPlainObject(Object.create(null));
  16. //=> true
  17. isPlainObject([1, 2, 3]);
  18. //=> false
  19. class Unicorn {}
  20. isPlainObject(new Unicorn());
  21. //=> false
  22. ```
  23. ## Related
  24. - [is-obj](https://github.com/sindresorhus/is-obj) - Check if a value is an object
  25. - [is](https://github.com/sindresorhus/is) - Type check values
  26. ---
  27. <div align="center">
  28. <b>
  29. <a href="https://tidelift.com/subscription/pkg/npm-is-plain-obj?utm_source=npm-is-plain-obj&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
  30. </b>
  31. <br>
  32. <sub>
  33. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  34. </sub>
  35. </div>