You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 767B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. var toStr = Object.prototype.toString;
  3. var hasSymbols = require('has-symbols')();
  4. if (hasSymbols) {
  5. var symToStr = Symbol.prototype.toString;
  6. var symStringRegex = /^Symbol\(.*\)$/;
  7. var isSymbolObject = function isRealSymbolObject(value) {
  8. if (typeof value.valueOf() !== 'symbol') {
  9. return false;
  10. }
  11. return symStringRegex.test(symToStr.call(value));
  12. };
  13. module.exports = function isSymbol(value) {
  14. if (typeof value === 'symbol') {
  15. return true;
  16. }
  17. if (toStr.call(value) !== '[object Symbol]') {
  18. return false;
  19. }
  20. try {
  21. return isSymbolObject(value);
  22. } catch (e) {
  23. return false;
  24. }
  25. };
  26. } else {
  27. module.exports = function isSymbol(value) {
  28. // this environment does not support Symbols.
  29. return false && value;
  30. };
  31. }