Socket
Socket
Sign inDemoInstall

has-symbols

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

has-symbols

Determine if the JS environment has Symbol support. Supports spec, or shams.

    1.0.3latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
37,093,065
decreased by-13.77%

Weekly downloads

Package description

What is has-symbols?

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.

What are has-symbols's main functionalities?

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');
}

Other packages similar to has-symbols

Changelog

Source

v1.0.3 - 2022-03-01

Commits

  • [actions] use node/install instead of node/run; use codecov action 518b28f
  • [meta] add bugs and homepage fields; reorder package.json c480b13
  • [actions] reuse common workflows 01d0ee0
  • [actions] update codecov uploader 6424ebe
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, tape dfa7e7f
  • [Dev Deps] update eslint, @ljharb/eslint-config, safe-publish-latest, tape 0c8d436
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, tape 9026554
  • [readme] add actions and codecov badges eaa9682
  • [Dev Deps] update eslint, tape bc7a3ba
  • [Dev Deps] update eslint, auto-changelog 0ace00a
  • [meta] use prepublishOnly script for npm 7+ 093f72b
  • [Tests] test on all 16 minors 9b80d3d

Readme

Source

has-symbols Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Determine if the JS environment has Symbol support. Supports spec, or shams.

Example

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.

Supported Symbol shams

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

Last updated on 01 Mar 2022

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc