package/.eslintrc000644 0000000244 3560116604 011104 0ustar00000000 000000 { "root": true, "extends": "@ljharb", "rules": { "max-statements-per-line": [2, { "max": 2 }], "no-magic-numbers": 0, "multiline-comment-style": 0, } } package/LICENSE000644 0000002053 3560116604 010265 0ustar00000000 000000 MIT License Copyright (c) 2021 Inspect JS Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/test/shams/core-js.js000644 0000001455 3560116604 013257 0ustar00000000 000000 'use strict'; var test = require('tape'); if (typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol') { test('has native Symbol.toStringTag support', function (t) { t.equal(typeof Symbol, 'function'); t.equal(typeof Symbol.toStringTag, 'symbol'); t.end(); }); return; } var hasSymbolToStringTag = require('../../shams'); test('polyfilled Symbols', function (t) { /* eslint-disable global-require */ t.equal(hasSymbolToStringTag(), false, 'hasSymbolToStringTag is false before polyfilling'); require('core-js/fn/symbol'); require('core-js/fn/symbol/to-string-tag'); require('../tests')(t); var hasToStringTagAfter = hasSymbolToStringTag(); t.equal(hasToStringTagAfter, true, 'hasSymbolToStringTag is true after polyfilling'); /* eslint-enable global-require */ t.end(); }); package/test/shams/get-own-property-symbols.js000644 0000001350 3560116604 016637 0ustar00000000 000000 'use strict'; var test = require('tape'); if (typeof Symbol === 'function' && typeof Symbol() === 'symbol') { test('has native Symbol support', function (t) { t.equal(typeof Symbol, 'function'); t.equal(typeof Symbol(), 'symbol'); t.end(); }); return; } var hasSymbolToStringTag = require('../../shams'); test('polyfilled Symbols', function (t) { /* eslint-disable global-require */ t.equal(hasSymbolToStringTag(), false, 'hasSymbolToStringTag is false before polyfilling'); require('get-own-property-symbols'); require('../tests')(t); var hasToStringTagAfter = hasSymbolToStringTag(); t.equal(hasToStringTagAfter, true, 'hasSymbolToStringTag is true after polyfilling'); /* eslint-enable global-require */ t.end(); }); package/index.js000644 0000000251 3560116604 010723 0ustar00000000 000000 'use strict'; var hasSymbols = require('has-symbols'); module.exports = function hasToStringTag() { return hasSymbols() && typeof Symbol.toStringTag === 'symbol'; }; package/test/index.js000644 0000001247 3560116604 011710 0ustar00000000 000000 'use strict'; var test = require('tape'); var hasSymbolToStringTag = require('../'); var runSymbolTests = require('./tests'); test('interface', function (t) { t.equal(typeof hasSymbolToStringTag, 'function', 'is a function'); t.equal(typeof hasSymbolToStringTag(), 'boolean', 'returns a boolean'); t.end(); }); test('Symbol.toStringTag exists', { skip: !hasSymbolToStringTag() }, function (t) { runSymbolTests(t); t.end(); }); test('Symbol.toStringTag does not exist', { skip: hasSymbolToStringTag() }, function (t) { t.equal(typeof Symbol === 'undefined' ? 'undefined' : typeof Symbol.toStringTag, 'undefined', 'global Symbol.toStringTag is undefined'); t.end(); }); package/shams.js000644 0000000242 3560116604 010727 0ustar00000000 000000 'use strict'; var hasSymbols = require('has-symbols/shams'); module.exports = function hasToStringTagShams() { return hasSymbols() && !!Symbol.toStringTag; }; package/test/tests.js000644 0000000653 3560116604 011743 0ustar00000000 000000 'use strict'; // eslint-disable-next-line consistent-return module.exports = function runSymbolTests(t) { t.equal(typeof Symbol, 'function', 'global Symbol is a function'); t.ok(Symbol.toStringTag, 'Symbol.toStringTag exists'); if (typeof Symbol !== 'function' || !Symbol.toStringTag) { return false; } var obj = {}; obj[Symbol.toStringTag] = 'test'; t.equal(Object.prototype.toString.call(obj), '[object test]'); }; package/package.json000644 0000004564 3560116604 011557 0ustar00000000 000000 { "name": "has-tostringtag", "version": "1.0.0", "author": { "name": "Jordan Harband", "email": "ljharb@gmail.com", "url": "http://ljharb.codes" }, "funding": { "url": "https://github.com/sponsors/ljharb" }, "contributors": [ { "name": "Jordan Harband", "email": "ljharb@gmail.com", "url": "http://ljharb.codes" } ], "description": "Determine if the JS environment has `Symbol.toStringTag` support. Supports spec, or shams.", "license": "MIT", "main": "index.js", "exports": { ".": "./index.js", "./shams": "./shams.js", "./package.json": "./package.json" }, "scripts": { "prepublishOnly": "safe-publish-latest", "prepublish": "not-in-publish || npm run prepublishOnly", "pretest": "npm run --silent lint", "test": "npm run tests-only", "posttest": "aud --production", "tests-only": "npm run test:stock && npm run test:staging && npm run test:shams", "test:stock": "nyc node test", "test:staging": "nyc node --harmony --es-staging test", "test:shams": "npm run --silent test:shams:getownpropertysymbols && npm run --silent test:shams:corejs", "test:shams:corejs": "nyc node test/shams/core-js.js", "test:shams:getownpropertysymbols": "nyc node test/shams/get-own-property-symbols.js", "lint": "eslint --ext=js,mjs .", "version": "auto-changelog && git add CHANGELOG.md", "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" }, "repository": { "type": "git", "url": "git+https://github.com/inspect-js/has-tostringtag.git" }, "bugs": { "url": "https://github.com/inspect-js/has-tostringtag/issues" }, "homepage": "https://github.com/inspect-js/has-tostringtag#readme", "keywords": [ "javascript", "ecmascript", "symbol", "symbols", "tostringtag", "Symbol.toStringTag" ], "dependencies": { "has-symbols": "^1.0.2" }, "devDependencies": { "@ljharb/eslint-config": "^17.6.0", "aud": "^1.1.5", "auto-changelog": "^2.3.0", "core-js": "^2.6.12", "eslint": "^7.32.0", "get-own-property-symbols": "^0.9.5", "nyc": "^10.3.2", "safe-publish-latest": "^1.1.4", "tape": "^5.3.0" }, "engines": { "node": ">= 0.4" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true } } package/CHANGELOG.md000644 0000002672 3560116604 011100 0ustar00000000 000000 # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## v1.0.0 - 2021-08-05 ### Commits - Tests [`6b6f573`](https://github.com/inspect-js/has-tostringtag/commit/6b6f5734dc2058badb300ff0783efdad95fe1a65) - Initial commit [`2f8190e`](https://github.com/inspect-js/has-tostringtag/commit/2f8190e799fac32ba9b95a076c0255e01d7ce475) - [meta] do not publish github action workflow files [`6e08cc4`](https://github.com/inspect-js/has-tostringtag/commit/6e08cc4e0fea7ec71ef66e70734b2af2c4a8b71b) - readme [`94bed6c`](https://github.com/inspect-js/has-tostringtag/commit/94bed6c9560cbbfda034f8d6c260bb7b0db33c1a) - npm init [`be67840`](https://github.com/inspect-js/has-tostringtag/commit/be67840ab92ee7adb98bcc65261975543f815fa5) - Implementation [`c4914ec`](https://github.com/inspect-js/has-tostringtag/commit/c4914ecc51ddee692c85b471ae0a5d8123030fbf) - [meta] use `auto-changelog` [`4aaf768`](https://github.com/inspect-js/has-tostringtag/commit/4aaf76895ae01d7b739f2b19f967ef2372506cd7) - Only apps should have lockfiles [`bc4d99e`](https://github.com/inspect-js/has-tostringtag/commit/bc4d99e4bf494afbaa235c5f098df6e642edf724) - [meta] add `safe-publish-latest` [`6523c05`](https://github.com/inspect-js/has-tostringtag/commit/6523c05c9b87140f3ae74c9daf91633dd9ff4e1f) package/README.md000644 0000004216 3560116604 010542 0ustar00000000 000000 # has-tostringtag [![Version Badge][2]][1] [![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![dependency status][5]][6] [![dev dependency status][7]][8] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][11]][1] Determine if the JS environment has `Symbol.toStringTag` support. Supports spec, or shams. ## Example ```js var hasSymbolToStringTag = require('has-tostringtag'); hasSymbolToStringTag() === true; // if the environment has native Symbol.toStringTag support. Not polyfillable, not forgeable. var hasSymbolToStringTagKinda = require('has-tostringtag/shams'); hasSymbolToStringTagKinda() === true; // if the environment has a Symbol.toStringTag sham that mostly follows the spec. ``` ## Supported Symbol shams - get-own-property-symbols [npm](https://www.npmjs.com/package/get-own-property-symbols) | [github](https://github.com/WebReflection/get-own-property-symbols) - core-js [npm](https://www.npmjs.com/package/core-js) | [github](https://github.com/zloirock/core-js) ## Tests Simply clone the repo, `npm install`, and run `npm test` [1]: https://npmjs.org/package/has-tostringtag [2]: https://versionbadg.es/inspect-js/has-tostringtag.svg [5]: https://david-dm.org/inspect-js/has-tostringtag.svg [6]: https://david-dm.org/inspect-js/has-tostringtag [7]: https://david-dm.org/inspect-js/has-tostringtag/dev-status.svg [8]: https://david-dm.org/inspect-js/has-tostringtag#info=devDependencies [11]: https://nodei.co/npm/has-tostringtag.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/has-tostringtag.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/has-tostringtag.svg [downloads-url]: https://npm-stat.com/charts.html?package=has-tostringtag [codecov-image]: https://codecov.io/gh/inspect-js/has-tostringtag/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/inspect-js/has-tostringtag/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/has-tostringtag [actions-url]: https://github.com/inspect-js/has-tostringtag/actions package/.github/FUNDING.yml000644 0000001112 3560116604 012430 0ustar00000000 000000 # These are supported funding model platforms github: [ljharb] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: npm/has-tostringtag community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']