MCPcopy Create free account
hub / github.com/JsAaron/jQuery / createCache

Function createCache

2.0.3/Sizzle.js:301–313  ·  view source on GitHub ↗

* Create key-value caches of limited size * @returns {Function(string, Object)} Returns the Object data after storing it on itself with * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) * deleting the oldest entry

()

Source from the content-addressed store, hash-verified

299 */
300
301 function createCache() {
302 var keys = [];
303
304 function cache(key, value) {
305 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
306 if (keys.push(key += " ") > Expr.cacheLength) {
307 // Only keep the most recent entries
308 delete cache[keys.shift()];
309 }
310 return (cache[key] = value);
311 }
312 return cache;
313 }
314
315 /**
316 * Mark a function for special use by Sizzle

Callers 1

Sizzle.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected