1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-25 04:51:29 +02:00

refactoring and cleanup

This commit is contained in:
Thomas Wilkerling
2025-03-08 09:06:42 +01:00
parent 281fc9288b
commit 7c064696ee
86 changed files with 2923 additions and 3026 deletions

1
dist/module-min/cache.js vendored Normal file
View File

@@ -0,0 +1 @@
import Index from"./index.js";import Document from"./document.js";export function searchCache(a,b,c){a=("object"==typeof a?""+a.query:""+a).toLowerCase();let d=this.cache.get(a);if(!d){if(d=this.search(a,b,c),d instanceof Promise){const b=this;d.then(function(c){b.cache.set(a,c)})}this.cache.set(a,d)}return d}export default function CacheClass(a){this.limit=a&&!0!==a?a:1000,this.cache=new Map,this.last=""}CacheClass.prototype.set=function(a,b){this.cache.has(a)||(this.cache.set(this.last=a,b),this.limit&&this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value))},CacheClass.prototype.get=function(a){const b=this.cache.get(a);return b&&this.limit&&this.last!==a&&(this.cache.delete(a),this.cache.set(this.last=a,b)),b},CacheClass.prototype.remove=function(a){for(const b of this.cache){const c=b[0],d=b[1];d.includes(a)&&this.cache.delete(c)}},CacheClass.prototype.clear=function(){this.cache.clear(),this.last=""};