Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
has-tostringtag
Advanced tools
Determine if the JS environment has `Symbol.toStringTag` support. Supports spec, or shams.
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.
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 31,830,351 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.