Security News
OpenJS: “XZ Utils Cyberattack Likely Not an Isolated Incident”
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
has-tostringtag
Advanced tools
Weekly downloads
Package description
The `has-tostringtag` npm package is designed to check if the environment has `Symbol.toStringTag` support. This is particularly useful for identifying and working with built-in object tags in a way that's consistent with the ECMAScript specification, especially in environments where this feature might not be available or fully implemented.
Checking `Symbol.toStringTag` support
This code checks if the current environment supports `Symbol.toStringTag`. It's useful for determining if you can rely on `Symbol.toStringTag` for identifying object types.
"use strict";\nvar hasToStringTag = require('has-tostringtag');\n\nif (hasToStringTag) {\n console.log('Environment supports Symbol.toStringTag');\n} else {\n console.log('Environment does not support Symbol.toStringTag');\n}
While `core-js` is a much broader polyfill library that includes support for `Symbol.toStringTag` among a vast array of other ECMAScript features, it serves a similar purpose in ensuring environments have access to `Symbol.toStringTag`. Compared to `has-tostringtag`, `core-js` is more comprehensive but also larger in size.
The `es-abstract` package provides utility functions for working with ECMAScript language abstract operations. It includes methods that indirectly relate to `Symbol.toStringTag` by providing a way to work with language internals. Unlike `has-tostringtag`, which is focused on feature detection, `es-abstract` is more about enabling operations that are defined in the ECMAScript specification.
Readme
Determine if the JS environment has Symbol.toStringTag
support. Supports spec, or shams.
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.
Simply clone the repo, npm install
, and run npm test
FAQs
Determine if the JS environment has `Symbol.toStringTag` support. Supports spec, or shams.
The npm package has-tostringtag receives a total of 29,114,401 weekly downloads. As such, has-tostringtag popularity was classified as popular.
We found that has-tostringtag demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Company News
Come meet the Socket team at BSidesSF and RSA! We're sponsoring several fun networking events and we would love to see you there.
Security News
OSI is starting a conversation aimed at removing the excuse of the SaaS loophole for companies navigating licensing and the complexities of doing business with open source.