mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
586 B
20 lines
586 B
10 years ago
|
var isObject = require('../lang/isObject');
|
||
|
|
||
|
/**
|
||
|
* Checks if `value` is in `cache` mimicking the return signature of
|
||
|
* `_.indexOf` by returning `0` if the value is found, else `-1`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} cache The cache to search.
|
||
|
* @param {*} value The value to search for.
|
||
|
* @returns {number} Returns `0` if `value` is found, else `-1`.
|
||
|
*/
|
||
|
function cacheIndexOf(cache, value) {
|
||
|
var data = cache.data,
|
||
|
result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];
|
||
|
|
||
|
return result ? 0 : -1;
|
||
|
}
|
||
|
|
||
|
module.exports = cacheIndexOf;
|