MCPcopy
hub / github.com/jquery/jquery / createCache

Function createCache

test/data/jquery-3.7.1.js:948–963  ·  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

946 * deleting the oldest entry
947 */
948function createCache() {
949 var keys = [];
950
951 function cache( key, value ) {
952
953 // Use (key + " ") to avoid collision with native prototype properties
954 // (see https://github.com/jquery/sizzle/issues/157)
955 if ( keys.push( key + " " ) > Expr.cacheLength ) {
956
957 // Only keep the most recent entries
958 delete cache[ keys.shift() ];
959 }
960 return ( cache[ key + " " ] = value );
961 }
962 return cache;
963}
964
965/**
966 * Mark a function for special use by jQuery selector module

Callers 1

jquery-3.7.1.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected