mirror of https://github.com/lukechilds/node.git
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.
37 lines
905 B
37 lines
905 B
9 years ago
|
var isObjectLike = require('./isObjectLike');
|
||
10 years ago
|
|
||
|
/** `Object#toString` result references. */
|
||
9 years ago
|
var symbolTag = '[object Symbol]';
|
||
10 years ago
|
|
||
9 years ago
|
/** Used for built-in method references. */
|
||
10 years ago
|
var objectProto = Object.prototype;
|
||
|
|
||
|
/**
|
||
9 years ago
|
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
||
10 years ago
|
* of values.
|
||
|
*/
|
||
9 years ago
|
var objectToString = objectProto.toString;
|
||
10 years ago
|
|
||
|
/**
|
||
9 years ago
|
* Checks if `value` is classified as a `Symbol` primitive or object.
|
||
10 years ago
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||
|
* @example
|
||
|
*
|
||
9 years ago
|
* _.isSymbol(Symbol.iterator);
|
||
10 years ago
|
* // => true
|
||
|
*
|
||
9 years ago
|
* _.isSymbol('abc');
|
||
10 years ago
|
* // => false
|
||
|
*/
|
||
9 years ago
|
function isSymbol(value) {
|
||
|
return typeof value == 'symbol' ||
|
||
|
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
module.exports = isSymbol;
|