mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Add _.isSymbol.
This commit is contained in:
28
lodash.js
28
lodash.js
@@ -1367,8 +1367,10 @@
|
||||
var mapCtorString = Map ? funcToString.call(Map) : '',
|
||||
setCtorString = Set ? funcToString.call(Set) : '';
|
||||
|
||||
/** Used to convert symbol objects to primitives. */
|
||||
var symbolValueOf = Symbol ? Symbol.prototype.valueOf : undefined;
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
symbolValueOf = Symbol ? symbolProto.valueOf : undefined,
|
||||
symbolToString = Symbol ? symbolProto.toString : undefined;
|
||||
|
||||
/** Used to lookup unminified function names. */
|
||||
var realNames = {};
|
||||
@@ -10018,6 +10020,27 @@
|
||||
(!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `Symbol` primitive or object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isSymbol(Symbol.iterator);
|
||||
* // => true
|
||||
*
|
||||
* _.isSymbol('abc');
|
||||
* // => false
|
||||
*/
|
||||
function isSymbol(value) {
|
||||
return typeof value == 'symbol' ||
|
||||
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a typed array.
|
||||
*
|
||||
@@ -14093,6 +14116,7 @@
|
||||
lodash.isRegExp = isRegExp;
|
||||
lodash.isSafeInteger = isSafeInteger;
|
||||
lodash.isString = isString;
|
||||
lodash.isSymbol = isSymbol;
|
||||
lodash.isTypedArray = isTypedArray;
|
||||
lodash.isUndefined = isUndefined;
|
||||
lodash.join = join;
|
||||
|
||||
@@ -22972,7 +22972,7 @@
|
||||
var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey);
|
||||
|
||||
QUnit.test('should accept falsey arguments', function(assert) {
|
||||
assert.expect(286);
|
||||
assert.expect(287);
|
||||
|
||||
var emptyArrays = lodashStable.map(falsey, lodashStable.constant([]));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user