1 import { jQuery } from "../core.js";
4 * Create key-value caches of limited size
5 * @returns {function(string, object)} Returns the Object data after storing it on itself with
6 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
7 * deleting the oldest entry
9 export function createCache() {
12 function cache( key, value ) {
14 // Use (key + " ") to avoid collision with native prototype properties
15 // (see https://github.com/jquery/sizzle/issues/157)
16 if ( keys.push( key + " " ) > jQuery.expr.cacheLength ) {
18 // Only keep the most recent entries
19 delete cache[ keys.shift() ];
21 return ( cache[ key + " " ] = value );