Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
has-tostringtag
Advanced tools
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.
Changelog
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 28,588,442 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.