MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / cacheIndexOf

Function cacheIndexOf

MathBox/mathbox-bundle.js:35325–35341  ·  view source on GitHub ↗

* An implementation of `_.contains` for cache objects that mimics the return * signature of `_.indexOf` by returning `0` if the value is found, else `-1`. * * @private * @param {Object} cache The cache object to inspect. * @param {*} value The value to search for. * @returns {numbe

(cache, value)

Source from the content-addressed store, hash-verified

35323 * @returns {number} Returns `0` if `value` is found, else `-1`.
35324 */
35325 function cacheIndexOf(cache, value) {
35326 var type = typeof value;
35327 cache = cache.cache;
35328
35329 if (type == 'boolean' || value == null) {
35330 return cache[value] ? 0 : -1;
35331 }
35332 if (type != 'number' && type != 'string') {
35333 type = 'object';
35334 }
35335 var key = type == 'number' ? value : keyPrefix + value;
35336 cache = (cache = cache[type]) && cache[key];
35337
35338 return type == 'object'
35339 ? (cache && baseIndexOf(cache, value) > -1 ? 0 : -1)
35340 : (cache ? 0 : -1);
35341 }
35342
35343 /**
35344 * Adds a given value to the corresponding cache object.

Callers 1

intersectionFunction · 0.85

Calls 1

baseIndexOfFunction · 0.85

Tested by

no test coverage detected