What is has-to-string-tag-x?
The has-to-string-tag-x npm package is a utility that checks if an object has the `@@toStringTag` property. This property is used to customize the default string description of an object.
What are has-to-string-tag-x's main functionalities?
Check if an object has a toStringTag property
This feature allows you to check if an object has the `@@toStringTag` property. In the example, the object `obj` has a custom `toStringTag` property, so the function returns `true`.
const hasToStringTag = require('has-to-string-tag-x');
const obj = { [Symbol.toStringTag]: 'Custom' };
console.log(hasToStringTag(obj)); // true
Check if an object does not have a toStringTag property
This feature allows you to check if an object does not have the `@@toStringTag` property. In the example, the object `obj` does not have a `toStringTag` property, so the function returns `false`.
const hasToStringTag = require('has-to-string-tag-x');
const obj = {};
console.log(hasToStringTag(obj)); // false
Other packages similar to has-to-string-tag-x
has-symbols
The has-symbols package checks if the runtime environment supports ES6 symbols, which includes the `@@toStringTag` symbol. While it does not specifically check for the presence of the `@@toStringTag` property on an object, it is useful for determining if symbols can be used in the environment.
is-symbol
The is-symbol package checks if a given value is a symbol. This can be used in conjunction with other utilities to determine if an object has a `@@toStringTag` property by checking if the property key is a symbol.
get-intrinsic
The get-intrinsic package provides access to ECMAScript intrinsic objects, including `Symbol.toStringTag`. It can be used to retrieve the `@@toStringTag` symbol and check if an object has this property.
has-to-string-tag-x
hasToStringTag tests if @@toStringTag is supported. true
if supported.
ECMAScript compatibility shims for legacy JavaScript engines
`es5-shim.js` monkey-patches a JavaScript context to contain all EcmaScript 5
methods that can be faithfully emulated with a legacy JavaScript engine.
es5-sham.js
monkey-patches other ES5 methods as closely as possible.
For these methods, as closely as possible to ES5 is not very close.
Many of these shams are intended only to allow code to be written to ES5
without causing run-time errors in older engines. In many cases,
this means that these shams cause many ES5 methods to silently fail.
Decide carefully whether this is what you want. Note: es5-sham.js requires
es5-shim.js to be able to work properly.
json3.js
monkey-patches the EcmaScript 5 JSON implimentation faithfully.
es6.shim.js
provides compatibility shims so that legacy JavaScript engines
behave as closely as possible to ECMAScript 6 (Harmony).
Version: 1.0.6
Author: Xotic750 Xotic750@gmail.com
License: MIT
Copyright: Xotic750
module.exports
: boolean
⏏
Indicates if Symbol.toStringTag
exists and is the correct type.
true
, if it exists and is the correct type, otherwise false
.
Kind: Exported member