Add _.isSymbol.

This commit is contained in:
John-David Dalton
2016-01-02 11:04:25 -06:00
parent 167fad9649
commit f7c7dee8b0
2 changed files with 27 additions and 3 deletions

View File

@@ -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;

View File

@@ -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([]));