mirror of
https://github.com/nodejs/node.git
synced 2025-08-18 07:08:50 +02:00

PR-URL: https://github.com/nodejs/io.js/pull/2286 Reviewed-By: Roman Reiss <me@silverwind.io>
19 lines
586 B
JavaScript
19 lines
586 B
JavaScript
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;
|