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

Function createCache

dist-module/jquery.slim.module.js:562–577  ·  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

560 * deleting the oldest entry
561 */
562function createCache() {
563 var keys = [];
564
565 function cache( key, value ) {
566
567 // Use (key + " ") to avoid collision with native prototype properties
568 // (see https://github.com/jquery/sizzle/issues/157)
569 if ( keys.push( key + " " ) > jQuery.expr.cacheLength ) {
570
571 // Only keep the most recent entries
572 delete cache[ keys.shift() ];
573 }
574 return ( cache[ key + " " ] = value );
575 }
576 return cache;
577}
578
579/**
580 * Checks a node for validity as a jQuery selector context

Callers 1

jQueryFactoryFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected