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

Function createCache

dist-module/jquery.factory.slim.module.js:567–582  ·  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

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

Callers 1

jQueryFactoryWrapperFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected