945edde08fd1916892302e0323144fff3935cf59fd43f55cf4b7f3507c8efb44f3ac830db5ca5a94df78e8c192ea62caa64603d054a11647775e68c852c786 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # es-set-tostringtag <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. A helper to optimistically set Symbol.toStringTag, when possible.
  8. ## Example
  9. Most common usage:
  10. ```js
  11. var assert = require('assert');
  12. var setToStringTag = require('es-set-tostringtag');
  13. var obj = {};
  14. assert.equal(Object.prototype.toString.call(obj), '[object Object]');
  15. setToStringTag(obj, 'tagged!');
  16. assert.equal(Object.prototype.toString.call(obj), '[object tagged!]');
  17. ```
  18. ## Options
  19. An optional options argument can be provided as the third argument. The available options are:
  20. ### `force`
  21. If the `force` option is set to `true`, the toStringTag will be set even if it is already set.
  22. ### `nonConfigurable`
  23. If the `nonConfigurable` option is set to `true`, the toStringTag will be defined as non-configurable when possible.
  24. ## Tests
  25. Simply clone the repo, `npm install`, and run `npm test`
  26. [package-url]: https://npmjs.com/package/es-set-tostringtag
  27. [npm-version-svg]: https://versionbadg.es/es-shims/es-set-tostringtag.svg
  28. [deps-svg]: https://david-dm.org/es-shims/es-set-tostringtag.svg
  29. [deps-url]: https://david-dm.org/es-shims/es-set-tostringtag
  30. [dev-deps-svg]: https://david-dm.org/es-shims/es-set-tostringtag/dev-status.svg
  31. [dev-deps-url]: https://david-dm.org/es-shims/es-set-tostringtag#info=devDependencies
  32. [npm-badge-png]: https://nodei.co/npm/es-set-tostringtag.png?downloads=true&stars=true
  33. [license-image]: https://img.shields.io/npm/l/es-set-tostringtag.svg
  34. [license-url]: LICENSE
  35. [downloads-image]: https://img.shields.io/npm/dm/es-set-tostringtag.svg
  36. [downloads-url]: https://npm-stat.com/charts.html?package=es-set-tostringtag
  37. [codecov-image]: https://codecov.io/gh/es-shims/es-set-tostringtag/branch/main/graphs/badge.svg
  38. [codecov-url]: https://app.codecov.io/gh/es-shims/es-set-tostringtag/
  39. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/es-set-tostringtag
  40. [actions-url]: https://github.com/es-shims/es-set-tostringtag/actions