Files
lodash/internal/cacheHas.js
John-David Dalton 8c26e6fd4c Bump to v4.0.0.
2016-01-13 01:10:19 -08:00

27 lines
697 B
JavaScript

define(['./isKeyable'], function(isKeyable) {
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/**
* Checks if `value` is in `cache`.
*
* @private
* @param {Object} cache The set cache to search.
* @param {*} value The value to search for.
* @returns {number} Returns `true` if `value` is found, else `false`.
*/
function cacheHas(cache, value) {
var map = cache.__data__;
if (isKeyable(value)) {
var data = map.__data__,
hash = typeof value == 'string' ? data.string : data.hash;
return hash[value] === HASH_UNDEFINED;
}
return map.has(value);
}
return cacheHas;
});