e70856226395de2c43050fc834e6643070b4beaa
[yaffs-website] / cacheHas.js
1 var isKeyable = require('./isKeyable');
2
3 /** Used to stand-in for `undefined` hash values. */
4 var HASH_UNDEFINED = '__lodash_hash_undefined__';
5
6 /**
7  * Checks if `value` is in `cache`.
8  *
9  * @private
10  * @param {Object} cache The set cache to search.
11  * @param {*} value The value to search for.
12  * @returns {number} Returns `true` if `value` is found, else `false`.
13  */
14 function cacheHas(cache, value) {
15   var map = cache.__data__;
16   if (isKeyable(value)) {
17     var data = map.__data__,
18         hash = typeof value == 'string' ? data.string : data.hash;
19
20     return hash[value] === HASH_UNDEFINED;
21   }
22   return map.has(value);
23 }
24
25 module.exports = cacheHas;