mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
/**
|
|
* lodash 4.0.0 (Custom Build) <https://lodash.com/>
|
|
* Build: `lodash modularize exports="npm" -o ./`
|
|
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
* Available under MIT license <https://lodash.com/license>
|
|
*/
|
|
|
|
/** 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);
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is suitable for use as unique object key.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
*/
|
|
function isKeyable(value) {
|
|
var type = typeof value;
|
|
return type == 'number' || type == 'boolean' ||
|
|
(type == 'string' && value !== '__proto__') || value == null;
|
|
}
|
|
|
|
module.exports = cacheHas;
|