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