1 | # es-set-tostringtag <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
2 |
|
---|
3 | [![github actions][actions-image]][actions-url]
|
---|
4 | [![coverage][codecov-image]][codecov-url]
|
---|
5 | [![License][license-image]][license-url]
|
---|
6 | [![Downloads][downloads-image]][downloads-url]
|
---|
7 |
|
---|
8 | [![npm badge][npm-badge-png]][package-url]
|
---|
9 |
|
---|
10 | A helper to optimistically set Symbol.toStringTag, when possible.
|
---|
11 |
|
---|
12 | Most common usage:
|
---|
13 | ```js
|
---|
14 | var assert = require('assert');
|
---|
15 | var setToStringTag = require('es-set-tostringtag');
|
---|
16 |
|
---|
17 | var obj = {};
|
---|
18 |
|
---|
19 | assert.equal(Object.prototype.toString.call(obj), '[object Object]');
|
---|
20 |
|
---|
21 | setToStringTag(obj, 'tagged!');
|
---|
22 |
|
---|
23 | assert.equal(Object.prototype.toString.call(obj), '[object tagged!]');
|
---|
24 | ```
|
---|
25 |
|
---|
26 | ## Tests
|
---|
27 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
28 |
|
---|
29 | [package-url]: https://npmjs.com/package/es-set-tostringtag
|
---|
30 | [npm-version-svg]: https://versionbadg.es/es-shims/es-set-tostringtag.svg
|
---|
31 | [deps-svg]: https://david-dm.org/es-shims/es-set-tostringtag.svg
|
---|
32 | [deps-url]: https://david-dm.org/es-shims/es-set-tostringtag
|
---|
33 | [dev-deps-svg]: https://david-dm.org/es-shims/es-set-tostringtag/dev-status.svg
|
---|
34 | [dev-deps-url]: https://david-dm.org/es-shims/es-set-tostringtag#info=devDependencies
|
---|
35 | [npm-badge-png]: https://nodei.co/npm/es-set-tostringtag.png?downloads=true&stars=true
|
---|
36 | [license-image]: https://img.shields.io/npm/l/es-set-tostringtag.svg
|
---|
37 | [license-url]: LICENSE
|
---|
38 | [downloads-image]: https://img.shields.io/npm/dm/es-set-tostringtag.svg
|
---|
39 | [downloads-url]: https://npm-stat.com/charts.html?package=es-set-tostringtag
|
---|
40 | [codecov-image]: https://codecov.io/gh/es-shims/es-set-tostringtag/branch/main/graphs/badge.svg
|
---|
41 | [codecov-url]: https://app.codecov.io/gh/es-shims/es-set-tostringtag/
|
---|
42 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/es-set-tostringtag
|
---|
43 | [actions-url]: https://github.com/es-shims/es-set-tostringtag/actions
|
---|