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-symbols
Advanced tools
Determine if the JS environment has Symbol support. Supports spec, or shams.
The has-symbols npm package is used to determine if the JavaScript environment has native support for ES6/ES2015 symbols. Symbols are a new primitive type introduced in ES6 that enable the creation of unique identifiers for object properties. The has-symbols package provides a simple way to check for symbol support, which is useful for library authors who want to create code that is compatible with both modern and older environments.
Check for native Symbol support
This feature allows you to check if the current JavaScript environment supports ES6 symbols natively. The function `hasSymbols()` returns a boolean indicating the presence of native symbol support.
var hasSymbols = require('has-symbols');
if (hasSymbols()) {
console.log('Environment has native Symbol support');
} else {
console.log('Environment does not have native Symbol support');
}
Check for well-known symbols
This feature allows you to check for the presence of specific well-known symbols like `Symbol.hasInstance`, `Symbol.iterator`, etc. The function `hasSymbols(shim)` takes a string argument representing the well-known symbol and returns a boolean indicating its presence.
var hasSymbols = require('has-symbols');
if (hasSymbols('hasInstance')) {
console.log('Environment has Symbol.hasInstance');
} else {
console.log('Environment does not have Symbol.hasInstance');
}
The es-abstract package provides utility functions for ECMAScript language abstract operations. It includes checks for symbol support similar to has-symbols but goes beyond that by offering a wide range of ECMAScript compliance-related utilities.
The is-symbol package is used to check if a value is an ES6 Symbol or not. While has-symbols checks for the existence of Symbol support in the environment, is-symbol is used to verify if a given value is of the Symbol type.
Determine if the JS environment has Symbol support. Supports spec, or shams.
var hasSymbols = require('has-symbols');
hasSymbols() === true; // if the environment has native Symbol support. Not polyfillable, not forgeable.
var hasSymbolsKinda = require('has-symbols/shams');
hasSymbolsKinda() === true; // if the environment has a Symbol sham that mostly follows the spec.
Simply clone the repo, npm install
, and run npm test
v1.1.0 - 2024-12-02
548c0bf
bec56bb
npmignore
to autogenerate an npmignore file ac81032
6469cbf
9c9d4d0
eslint
, @ljharb/eslint-config
, aud
, tape
adb5887
@ljharb/eslint-config
, aud
, tape
13ec198
auto-changelog
, core-js
, tape
941be52
aud
with npm audit
74f49e9
npmignore
9c0ac04
52337a5
FAQs
Determine if the JS environment has Symbol support. Supports spec, or shams.
The npm package has-symbols receives a total of 44,080,268 weekly downloads. As such, has-symbols popularity was classified as popular.
We found that has-symbols 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.