Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
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
FAQs
Determine if the JS environment has Symbol support. Supports spec, or shams.
The npm package has-symbols receives a total of 48,453,103 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.