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.

63 lines
2.5 KiB

1 month ago
  1. # es-object-atoms <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
  2. [![github actions][actions-image]][actions-url]
  3. [![coverage][codecov-image]][codecov-url]
  4. [![License][license-image]][license-url]
  5. [![Downloads][downloads-image]][downloads-url]
  6. [![npm badge][npm-badge-png]][package-url]
  7. ES Object-related atoms: Object, ToObject, RequireObjectCoercible.
  8. ## Example
  9. ```js
  10. const assert = require('assert');
  11. const $Object = require('es-object-atoms');
  12. const isObject = require('es-object-atoms/isObject');
  13. const ToObject = require('es-object-atoms/ToObject');
  14. const RequireObjectCoercible = require('es-object-atoms/RequireObjectCoercible');
  15. assert.equal($Object, Object);
  16. assert.throws(() => ToObject(null), TypeError);
  17. assert.throws(() => ToObject(undefined), TypeError);
  18. assert.throws(() => RequireObjectCoercible(null), TypeError);
  19. assert.throws(() => RequireObjectCoercible(undefined), TypeError);
  20. assert.equal(isObject(undefined), false);
  21. assert.equal(isObject(null), false);
  22. assert.equal(isObject({}), true);
  23. assert.equal(isObject([]), true);
  24. assert.equal(isObject(function () {}), true);
  25. assert.deepEqual(RequireObjectCoercible(true), true);
  26. assert.deepEqual(ToObject(true), Object(true));
  27. const obj = {};
  28. assert.equal(RequireObjectCoercible(obj), obj);
  29. assert.equal(ToObject(obj), obj);
  30. ```
  31. ## Tests
  32. Simply clone the repo, `npm install`, and run `npm test`
  33. ## Security
  34. Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report.
  35. [package-url]: https://npmjs.org/package/es-object-atoms
  36. [npm-version-svg]: https://versionbadg.es/ljharb/es-object-atoms.svg
  37. [deps-svg]: https://david-dm.org/ljharb/es-object-atoms.svg
  38. [deps-url]: https://david-dm.org/ljharb/es-object-atoms
  39. [dev-deps-svg]: https://david-dm.org/ljharb/es-object-atoms/dev-status.svg
  40. [dev-deps-url]: https://david-dm.org/ljharb/es-object-atoms#info=devDependencies
  41. [npm-badge-png]: https://nodei.co/npm/es-object-atoms.png?downloads=true&stars=true
  42. [license-image]: https://img.shields.io/npm/l/es-object-atoms.svg
  43. [license-url]: LICENSE
  44. [downloads-image]: https://img.shields.io/npm/dm/es-object.svg
  45. [downloads-url]: https://npm-stat.com/charts.html?package=es-object-atoms
  46. [codecov-image]: https://codecov.io/gh/ljharb/es-object-atoms/branch/main/graphs/badge.svg
  47. [codecov-url]: https://app.codecov.io/gh/ljharb/es-object-atoms/
  48. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/es-object-atoms
  49. [actions-url]: https://github.com/ljharb/es-object-atoms/actions