MCPcopy
hub / github.com/layui/layui / createCache

Function createCache

src/modules/jquery.js:959–972  ·  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

957 * deleting the oldest entry
958 */
959 function createCache() {
960 var keys = [];
961
962 function cache(key, value) {
963 // Use (key + " ") to avoid collision with native prototype properties
964 // (see https://github.com/jquery/sizzle/issues/157)
965 if (keys.push(key + ' ') > Expr.cacheLength) {
966 // Only keep the most recent entries
967 delete cache[keys.shift()];
968 }
969 return (cache[key + ' '] = value);
970 }
971 return cache;
972 }
973
974 /**
975 * Mark a function for special use by jQuery selector module

Callers 1

jquery.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected