mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +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) : '',
|
var mapCtorString = Map ? funcToString.call(Map) : '',
|
||||||
setCtorString = Set ? funcToString.call(Set) : '';
|
setCtorString = Set ? funcToString.call(Set) : '';
|
||||||
|
|
||||||
/** Used to convert symbol objects to primitives. */
|
/** Used to convert symbols to primitives and strings. */
|
||||||
var symbolValueOf = Symbol ? Symbol.prototype.valueOf : undefined;
|
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||||
|
symbolValueOf = Symbol ? symbolProto.valueOf : undefined,
|
||||||
|
symbolToString = Symbol ? symbolProto.toString : undefined;
|
||||||
|
|
||||||
/** Used to lookup unminified function names. */
|
/** Used to lookup unminified function names. */
|
||||||
var realNames = {};
|
var realNames = {};
|
||||||
@@ -10018,6 +10020,27 @@
|
|||||||
(!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
|
(!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.
|
* Checks if `value` is classified as a typed array.
|
||||||
*
|
*
|
||||||
@@ -14093,6 +14116,7 @@
|
|||||||
lodash.isRegExp = isRegExp;
|
lodash.isRegExp = isRegExp;
|
||||||
lodash.isSafeInteger = isSafeInteger;
|
lodash.isSafeInteger = isSafeInteger;
|
||||||
lodash.isString = isString;
|
lodash.isString = isString;
|
||||||
|
lodash.isSymbol = isSymbol;
|
||||||
lodash.isTypedArray = isTypedArray;
|
lodash.isTypedArray = isTypedArray;
|
||||||
lodash.isUndefined = isUndefined;
|
lodash.isUndefined = isUndefined;
|
||||||
lodash.join = join;
|
lodash.join = join;
|
||||||
|
|||||||
@@ -22972,7 +22972,7 @@
|
|||||||
var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey);
|
var acceptFalsey = lodashStable.difference(allMethods, rejectFalsey);
|
||||||
|
|
||||||
QUnit.test('should accept falsey arguments', function(assert) {
|
QUnit.test('should accept falsey arguments', function(assert) {
|
||||||
assert.expect(286);
|
assert.expect(287);
|
||||||
|
|
||||||
var emptyArrays = lodashStable.map(falsey, lodashStable.constant([]));
|
var emptyArrays = lodashStable.map(falsey, lodashStable.constant([]));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user