mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-21 11:01:36 +02:00
update index.d.ts
This commit is contained in:
2
dist/module-min/cache.js
vendored
2
dist/module-min/cache.js
vendored
@@ -1 +1 @@
|
||||
import Index from"./index.js";import Document from"./document.js";import{SearchOptions,DocumentSearchOptions}from"./type.js";export function searchCache(a,b,c){const d=("object"==typeof a?""+a.query:""+a).toLowerCase();this.cache||(this.cache=new CacheClass);let e=this.cache.get(d);if(!e){if(e=this.search(a,b,c),e.then){const a=this;e.then(function(b){return a.cache.set(d,b),b})}this.cache.set(d,e)}return e}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.set(this.last=a,b),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.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=""};
|
||||
import Index from"./index.js";import Document from"./document.js";import{SearchOptions,DocumentSearchOptions}from"./type.js";export function searchCache(a,b,c){const d=(b?""+a:"object"==typeof a?""+a.query:a).toLowerCase();this.cache||(this.cache=new CacheClass);let e=this.cache.get(d);if(!e){if(e=this.search(a,b,c),e.then){const a=this;e.then(function(b){return a.cache.set(d,b),b})}this.cache.set(d,e)}return e}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.set(this.last=a,b),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.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=""};
|
Reference in New Issue
Block a user