What is @stdlib/assert-has-symbol-support?
@stdlib/assert-has-symbol-support is a package that allows you to check if the runtime environment supports ES6 symbols. This can be useful for ensuring compatibility and feature detection in JavaScript applications.
What are @stdlib/assert-has-symbol-support's main functionalities?
Check Symbol Support
This feature allows you to check if the current environment supports ES6 symbols. The function returns a boolean value indicating the presence or absence of symbol support.
const hasSymbolSupport = require('@stdlib/assert-has-symbol-support');
if (hasSymbolSupport()) {
console.log('Symbols are supported.');
} else {
console.log('Symbols are not supported.');
}
Other packages similar to @stdlib/assert-has-symbol-support
has-symbols
The 'has-symbols' package checks for native Symbol support in the runtime environment. It provides similar functionality to @stdlib/assert-has-symbol-support by returning a boolean value indicating whether symbols are supported.
is-symbol
The 'is-symbol' package checks if a given value is a symbol. While it does not directly check for symbol support in the environment, it can be used in conjunction with other packages to achieve similar goals.
core-js
The 'core-js' package is a comprehensive polyfill library that includes support for ES6 symbols among many other features. It can be used to ensure compatibility across different environments, but it is more heavyweight compared to @stdlib/assert-has-symbol-support.
Symbol Support
Detect native Symbol
support.
Installation
npm install @stdlib/assert-has-symbol-support
Usage
var hasSymbolSupport = require( '@stdlib/assert-has-symbol-support' );
hasSymbolSupport()
Detects if a runtime environment supports ES2015 Symbol
.
var bool = hasSymbolSupport();
Examples
var hasSymbolSupport = require( '@stdlib/assert-has-symbol-support' );
var bool = hasSymbolSupport();
if ( bool ) {
console.log( 'Environment has Symbol support.' );
} else {
console.log( 'Environment lacks Symbol support.' );
}
CLI
Installation
To use the module as a general utility, install the module globally
npm install -g @stdlib/assert-has-symbol-support
Usage
Usage: has-symbol-support [options]
Options:
-h, --help Print this message.
-V, --version Print the package version.
Examples
$ has-symbol-support
<boolean>
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
License
See LICENSE.
Copyright
Copyright © 2016-2021. The Stdlib Authors.
0.0.4 (2021-06-27)
No changes reported for this release.
</section>
<!-- /.release -->
<section class="release" id="v0.0.3">