From 75ae9a028545d07337b726f8c55d37322a162368 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Wed, 16 Apr 2025 09:14:17 +0200 Subject: [PATCH] add term de-duplication to the encoder by also keeping the context chain --- dist/db/redis/index.cjs | 66 +- dist/flexsearch.bundle.debug.js | 1914 ++++++++++++----------- dist/flexsearch.bundle.min.js | 154 +- dist/flexsearch.bundle.module.debug.js | 1914 ++++++++++++----------- dist/flexsearch.bundle.module.min.js | 154 +- dist/flexsearch.compact.debug.js | 160 +- dist/flexsearch.compact.min.js | 56 +- dist/flexsearch.compact.module.debug.js | 160 +- dist/flexsearch.compact.module.min.js | 56 +- dist/flexsearch.es5.debug.js | 1674 ++++++++++---------- dist/flexsearch.es5.min.js | 136 +- dist/flexsearch.light.debug.js | 418 ++--- dist/flexsearch.light.min.js | 38 +- dist/flexsearch.light.module.debug.js | 418 ++--- dist/flexsearch.light.module.min.js | 38 +- dist/module-debug/db/redis/index.js | 58 +- dist/module-debug/encoder.js | 47 +- dist/module-debug/index/add.js | 4 +- dist/module-debug/index/search.js | 10 +- dist/module-debug/serialize.js | 3 +- dist/module-min/db/redis/index.js | 2 +- dist/module-min/encoder.js | 2 +- dist/module-min/index/add.js | 2 +- dist/module-min/index/search.js | 2 +- dist/module/db/redis/index.js | 58 +- dist/module/encoder.js | 47 +- dist/module/index/add.js | 4 +- dist/module/index/search.js | 10 +- dist/module/serialize.js | 3 +- doc/context-index.svg | 41 +- package-lock.json | 4 +- package.json | 2 +- src/encoder.js | 70 +- src/index/add.js | 4 +- src/index/search.js | 10 +- test/basic.js | 18 + test/persistent.js | 129 +- test/worker.js | 3 + 38 files changed, 3986 insertions(+), 3903 deletions(-) diff --git a/dist/db/redis/index.cjs b/dist/db/redis/index.cjs index 3aac402..9a6c9f5 100644 --- a/dist/db/redis/index.cjs +++ b/dist/db/redis/index.cjs @@ -59,6 +59,8 @@ function RedisDB(name, config = {}){ this.fastupdate = true; this.db = config.db || DB || null; this.support_tag_search = true; + this.resolution = 9; + this.resolution_ctx = 9; //this.trx = false; Object.assign(defaults, config); this.db && delete defaults.db; @@ -73,6 +75,8 @@ RedisDB.prototype.mount = function(flexsearch){ return flexsearch.mount(this); } flexsearch.db = this; + this.resolution = flexsearch.resolution; + this.resolution_ctx = flexsearch.resolution_ctx; // todo support //this.fastupdate = flexsearch.fastupdate; return this.open(); @@ -118,7 +122,7 @@ RedisDB.prototype.clear = function(){ ]); }; -function create_result(range, type, resolve, enrich){ +function create_result(range, type, resolve, enrich, resolution){ if(resolve){ if(type === "number"){ for(let i = 0, tmp, id; i < range.length; i++){ @@ -140,7 +144,7 @@ function create_result(range, type, resolve, enrich){ id = type === "number" ? parseInt(tmp.id || tmp, 10) : tmp.id || tmp; - score = tmp.score; + score = resolution - tmp.score; result[score] || (result[score] = []); result[score].push(id); } @@ -181,7 +185,7 @@ RedisDB.prototype.get = function(key, ctx, limit = 0, offset = 0, resolve = true return result.then(async function(range){ if(!range.length) return range; if(enrich) range = await self.enrich(range); - return create_result(range, type, resolve, enrich); + return create_result(range, type, resolve, enrich, ctx ? self.resolution_ctx : self.resolution); }); }; @@ -218,10 +222,12 @@ RedisDB.prototype.has = function(id){ RedisDB.prototype.search = function(flexsearch, query, limit = 100, offset = 0, suggest = false, resolve = true, enrich = false, tags){ + const ctx = query.length > 1 && flexsearch.depth; let result; let params = []; + let weights = []; - if(query.length > 1 && flexsearch.depth){ + if(ctx){ const key = this.id + "ctx" + this.field + ":"; let keyword = query[0]; @@ -231,6 +237,7 @@ RedisDB.prototype.search = function(flexsearch, query, limit = 100, offset = 0, term = query[i]; swap = flexsearch.bidirectional && (term > keyword); params.push(key + (swap ? term : keyword) + ":" + (swap ? keyword : term)); + weights.push(1); keyword = term; } } @@ -239,6 +246,7 @@ RedisDB.prototype.search = function(flexsearch, query, limit = 100, offset = 0, const key = this.id + "map" + this.field + ":"; for(let i = 0; i < query.length; i++){ params.push(key + query[i]); + weights.push(1); } } @@ -248,7 +256,15 @@ RedisDB.prototype.search = function(flexsearch, query, limit = 100, offset = 0, let key = this.id + "tmp:" + Math.random(); if(suggest){ - const multi = this.db.multi().zUnionStore(key, query, { AGGREGATE: "SUM" }); + const multi = this.db.multi(); + // The zStore implementation lacks of ordering by match count (occurrences). + // Unfortunately, I couldn't find an elegant way to overcome this issue completely. + // For this reason it needs additionally a zInterStore to boost at least matches + // when all terms were found + multi.zInterStore(key, query, { AGGREGATE: "SUM" }); + query.push(key); + weights.push(query.length); + multi.zUnionStore(key, query, { WEIGHTS: weights, AGGREGATE: "SUM" }); // Strict Tag Intersection: it does not put tags into union, instead it calculates the // intersection against the term match union. This was the default behavior // of Tag-Search. But putting everything into union will also provide suggestions derived @@ -261,23 +277,33 @@ RedisDB.prototype.search = function(flexsearch, query, limit = 100, offset = 0, for(let i = 0; i < tags.length; i += 2){ query.push(this.id + "tag-" + sanitize(tags[i]) + ":" + tags[i + 1]); } - multi.zInterStore(key, query, { AGGREGATE: "SUM" }); + multi.zInterStore(key, query, { AGGREGATE: "MAX" }); // .unlink(key) // key = key2; } } result = multi - [(resolve ? "zRange" : "zRangeWithScores")](key, "" + offset, "" + (offset + limit - 1), { REV: true }) + [(resolve ? "zRange" : "zRangeWithScores")]( + key, + "" + offset, + "" + (offset + limit - 1), + { REV: true } + ) .unlink(key) .exec(); } else { - if(tags) for(let i = 0; i < tags.length; i+=2){ + if(tags) for(let i = 0; i < tags.length; i += 2){ query.push(this.id + "tag-" + sanitize(tags[i]) + ":" + tags[i + 1]); } result = this.db.multi() - .zInterStore(key, query, { AGGREGATE: "MIN" }) - [(resolve ? "zRange" : "zRangeWithScores")](key, "" + offset, "" + (offset + limit - 1), { REV: true }) + .zInterStore(key, query, { AGGREGATE: "MAX" }) + [(resolve ? "zRange" : "zRangeWithScores")]( + key, + "" + offset, + "" + (offset + limit - 1), + { REV: true } + ) .unlink(key) .exec(); } @@ -286,12 +312,12 @@ RedisDB.prototype.search = function(flexsearch, query, limit = 100, offset = 0, return result.then(async function(range){ range = suggest && tags // take the 3rd result from batch return - ? range[2] + ? range[3] // take the 2nd result from batch return - : range[1]; + : range[suggest ? 2 : 1]; if(!range.length) return range; if(enrich) range = await self.enrich(range); - return create_result(range, type, resolve, enrich); + return create_result(range, type, resolve, enrich, ctx ? self.resolution_ctx : self.resolution); }); }; @@ -299,7 +325,7 @@ RedisDB.prototype.info = function(){ // todo }; -RedisDB.prototype.transaction = async function(task, callback){ +RedisDB.prototype.transaction = function(task, callback){ if(TRX){ return task.call(this, TRX); @@ -309,8 +335,9 @@ RedisDB.prototype.transaction = async function(task, callback){ let promise1 = /*await*/ task.call(this, TRX); let promise2 = TRX.exec(); TRX = null; - callback && promise.then(callback); - await Promise.all([promise1, promise2]); + return Promise.all([promise1, promise2]).then(function(){ + callback && callback(); + }); }; RedisDB.prototype.commit = async function(flexsearch, _replace, _append){ @@ -360,7 +387,7 @@ RedisDB.prototype.commit = async function(flexsearch, _replace, _append){ let result = []; for(let j = 0; j < ids.length; j++){ result.push({ - score: i, + score: this.resolution - i, value: "" + ids[j] }); } @@ -409,7 +436,10 @@ RedisDB.prototype.commit = async function(flexsearch, _replace, _append){ if((ids = arr[i]) && ids.length){ let result = []; for(let j = 0; j < ids.length; j++){ - result.push({ score: i, value: "" + ids[j] }); + result.push({ + score: this.resolution_ctx - i, + value: "" + ids[j] + }); } if(typeof ids[0] === "number"){ this.type = "number"; diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js index 2e0fdab..7baa39a 100644 --- a/dist/flexsearch.bundle.debug.js +++ b/dist/flexsearch.bundle.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.156 (Bundle/Debug) + * FlexSearch.js v0.8.157 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -7,30 +7,30 @@ */ (function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f; var t; -function z(a, c, b) { - const e = typeof b, d = typeof a; - if ("undefined" !== e) { - if ("undefined" !== d) { - if (b) { - if ("function" === d && e === d) { +function z(a, b, c) { + const d = typeof c, e = typeof a; + if ("undefined" !== d) { + if ("undefined" !== e) { + if (c) { + if ("function" === e && d === e) { return function(h) { - return a(b(h)); + return a(c(h)); }; } - c = a.constructor; - if (c === b.constructor) { - if (c === Array) { - return b.concat(a); + b = a.constructor; + if (b === c.constructor) { + if (b === Array) { + return c.concat(a); } - if (c === Map) { - var f = new Map(b); + if (b === Map) { + var f = new Map(c); for (var g of a) { f.set(g[0], g[1]); } return f; } - if (c === Set) { - g = new Set(b); + if (b === Set) { + g = new Set(c); for (f of a.values()) { g.add(f); } @@ -40,9 +40,9 @@ function z(a, c, b) { } return a; } - return b; + return c; } - return "undefined" === d ? c : a; + return "undefined" === e ? b : a; } function A() { return Object.create(null); @@ -54,28 +54,28 @@ function aa(a) { return "object" === typeof a; } function ba(a) { - const c = []; - for (const b of a.keys()) { - c.push(b); + const b = []; + for (const c of a.keys()) { + b.push(c); } - return c; + return b; } -function ca(a, c) { - if (D(c)) { - a = a[c]; +function ca(a, b) { + if (D(b)) { + a = a[b]; } else { - for (let b = 0; a && b < c.length; b++) { - a = a[c[b]]; + for (let c = 0; a && c < b.length; c++) { + a = a[b[c]]; } } return a; } function da(a) { - let c = 0; - for (let b = 0, e; b < a.length; b++) { - (e = a[b]) && c < e.length && (c = e.length); + let b = 0; + for (let c = 0, d; c < a.length; c++) { + (d = a[c]) && b < d.length && (b = d.length); } - return c; + return b; } ;const ea = /[^\p{L}\p{N}]+/u, fa = /(\d{3})/g, ha = /(\D)(\d{3})/g, ia = /(\d{3})(\D)/g, ja = /[\u0300-\u036f]/g; function G(a = {}) { @@ -93,71 +93,71 @@ function G(a = {}) { t = G.prototype; t.assign = function(a) { this.normalize = z(a.normalize, !0, this.normalize); - let c = a.include, b = c || a.exclude || a.split, e; - if (b || "" === b) { - if ("object" === typeof b && b.constructor !== RegExp) { - let d = ""; - e = !c; - c || (d += "\\p{Z}"); - b.letter && (d += "\\p{L}"); - b.number && (d += "\\p{N}", e = !!c); - b.symbol && (d += "\\p{S}"); - b.punctuation && (d += "\\p{P}"); - b.control && (d += "\\p{C}"); - if (b = b.char) { - d += "object" === typeof b ? b.join("") : b; + let b = a.include, c = b || a.exclude || a.split, d; + if (c || "" === c) { + if ("object" === typeof c && c.constructor !== RegExp) { + let e = ""; + d = !b; + b || (e += "\\p{Z}"); + c.letter && (e += "\\p{L}"); + c.number && (e += "\\p{N}", d = !!b); + c.symbol && (e += "\\p{S}"); + c.punctuation && (e += "\\p{P}"); + c.control && (e += "\\p{C}"); + if (c = c.char) { + e += "object" === typeof c ? c.join("") : c; } try { - this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); + this.split = new RegExp("[" + (b ? "^" : "") + e + "]+", "u"); } catch (f) { - console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; + console.error("Your split configuration:", c, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = b, e = !1 === b || 2 > "a1a".split(b).length; + this.split = c, d = !1 === c || 2 > "a1a".split(c).length; } - this.numeric = z(a.numeric, e); + this.numeric = z(a.numeric, d); } else { try { this.split = z(this.split, ea); - } catch (d) { + } catch (e) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } this.numeric = z(a.numeric, z(this.numeric, !0)); } this.prepare = z(a.prepare, null, this.prepare); this.finalize = z(a.finalize, null, this.finalize); - b = a.filter; - this.filter = "function" === typeof b ? b : z(b && new Set(b), null, this.filter); + c = a.filter; + this.filter = "function" === typeof c ? c : z(c && new Set(c), null, this.filter); this.dedupe = z(a.dedupe, !0, this.dedupe); - this.matcher = z((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = z((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = z((b = a.stemmer) && new Map(b), null, this.stemmer); + this.matcher = z((c = a.matcher) && new Map(c), null, this.matcher); + this.mapper = z((c = a.mapper) && new Map(c), null, this.mapper); + this.stemmer = z((c = a.stemmer) && new Map(c), null, this.stemmer); this.replacer = z(a.replacer, null, this.replacer); this.minlength = z(a.minlength, 1, this.minlength); this.maxlength = z(a.maxlength, 1024, this.maxlength); this.rtl = z(a.rtl, !1, this.rtl); - if (this.cache = b = z(a.cache, !0, this.cache)) { - this.H = null, this.S = "number" === typeof b ? b : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; + if (this.cache = c = z(a.cache, !0, this.cache)) { + this.H = null, this.S = "number" === typeof c ? c : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; } this.h = ""; this.M = null; this.A = ""; this.N = null; if (this.matcher) { - for (const d of this.matcher.keys()) { - this.h += (this.h ? "|" : "") + d; + for (const e of this.matcher.keys()) { + this.h += (this.h ? "|" : "") + e; } } if (this.stemmer) { - for (const d of this.stemmer.keys()) { - this.A += (this.A ? "|" : "") + d; + for (const e of this.stemmer.keys()) { + this.A += (this.A ? "|" : "") + e; } } return this; }; -t.addStemmer = function(a, c) { +t.addStemmer = function(a, b) { this.stemmer || (this.stemmer = new Map()); - this.stemmer.set(a, c); + this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; this.N = null; this.cache && H(this); @@ -168,42 +168,42 @@ t.addFilter = function(a) { this.cache && H(this); return this; }; -t.addMapper = function(a, c) { +t.addMapper = function(a, b) { if ("object" === typeof a) { - return this.addReplacer(a, c); + return this.addReplacer(a, b); } if (1 < a.length) { - return this.addMatcher(a, c); + return this.addMatcher(a, b); } this.mapper || (this.mapper = new Map()); - this.mapper.set(a, c); + this.mapper.set(a, b); this.cache && H(this); return this; }; -t.addMatcher = function(a, c) { +t.addMatcher = function(a, b) { if ("object" === typeof a) { - return this.addReplacer(a, c); + return this.addReplacer(a, b); } if (2 > a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, c); + return this.addMapper(a, b); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, c); + this.matcher.set(a, b); this.h += (this.h ? "|" : "") + a; this.M = null; this.cache && H(this); return this; }; -t.addReplacer = function(a, c) { +t.addReplacer = function(a, b) { if ("string" === typeof a) { - return this.addMatcher(a, c); + return this.addMatcher(a, b); } this.replacer || (this.replacer = []); - this.replacer.push(a, c); + this.replacer.push(a, b); this.cache && H(this); return this; }; -t.encode = function(a) { +t.encode = function(a, b) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.B.has(a)) { @@ -217,47 +217,47 @@ t.encode = function(a) { this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(ha, "$1 $2").replace(ia, "$1 $2").replace(fa, "$1 ")); const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let b = [], e = this.split || "" === this.split ? a.split(this.split) : a; - for (let f = 0, g, h; f < e.length; f++) { - if ((g = h = e[f]) && !(g.length < this.minlength || g.length > this.maxlength)) { + let d = [], e = A(), f = this.split || "" === this.split ? a.split(this.split) : [a]; + for (let h = 0, k, l; h < f.length; h++) { + if ((k = l = f[h]) && !(k.length < this.minlength || k.length > this.maxlength || b && e[k])) { if (c) { - b.push(g); + b && (e[k] = 1), d.push(k); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(g) : !this.filter.has(g))) { - if (this.cache && g.length <= this.L) { + if (!this.filter || ("function" === typeof this.filter ? this.filter(k) : !this.filter.has(k))) { + if (this.cache && k.length <= this.L) { if (this.H) { - var d = this.G.get(g); - if (d || "" === d) { - d && b.push(d); + var g = this.G.get(k); + if (g || "" === g) { + g && d.push(g); continue; } } else { this.H = setTimeout(H, 50, this); } } - this.stemmer && 2 < g.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), g = g.replace(this.N, k => this.stemmer.get(k))); - if (g && (this.mapper || this.dedupe && 1 < g.length)) { - d = ""; - for (let k = 0, l = "", m, n; k < g.length; k++) { - m = g.charAt(k), m === l && this.dedupe || ((n = this.mapper && this.mapper.get(m)) || "" === n ? n === l && this.dedupe || !(l = n) || (d += n) : d += l = m); + this.stemmer && 2 < k.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), k = k.replace(this.N, m => this.stemmer.get(m))); + if (k && (this.mapper || this.dedupe && 1 < k.length)) { + g = ""; + for (let m = 0, n = "", p, r; m < k.length; m++) { + p = k.charAt(m), p === n && this.dedupe || ((r = this.mapper && this.mapper.get(p)) || "" === r ? r === n && this.dedupe || !(n = r) || (g += r) : g += n = p); } - g = d; + k = g; } - this.matcher && 1 < g.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), g = g.replace(this.M, k => this.matcher.get(k))); - if (g && this.replacer) { - for (d = 0; g && d < this.replacer.length; d += 2) { - g = g.replace(this.replacer[d], this.replacer[d + 1]); + this.matcher && 1 < k.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), k = k.replace(this.M, m => this.matcher.get(m))); + if (k && this.replacer) { + for (g = 0; k && g < this.replacer.length; g += 2) { + k = k.replace(this.replacer[g], this.replacer[g + 1]); } } - this.cache && h.length <= this.L && (this.G.set(h, g), this.G.size > this.S && (this.G.clear(), this.L = this.L / 1.1 | 0)); - g && b.push(g); + this.cache && l.length <= this.L && (this.G.set(l, k), this.G.size > this.S && (this.G.clear(), this.L = this.L / 1.1 | 0)); + !k || b && e[k] || (b && (e[k] = 1), d.push(k)); } } } } - this.finalize && (b = this.finalize(b) || b); - this.cache && a.length <= this.K && (this.B.set(a, b), this.B.size > this.S && (this.B.clear(), this.K = this.K / 1.1 | 0)); - return b; + this.finalize && (d = this.finalize(d) || d); + this.cache && a.length <= this.K && (this.B.set(a, d), this.B.size > this.S && (this.B.clear(), this.K = this.K / 1.1 | 0)); + return d; }; function H(a) { a.H = null; @@ -267,32 +267,32 @@ function H(a) { ;let I, L; async function ka(a) { a = a.data; - var c = a.task; - const b = a.id; - let e = a.args; - switch(c) { + var b = a.task; + const c = a.id; + let d = a.args; + switch(b) { case "init": L = a.options || {}; - (c = a.factory) ? (Function("return " + c)()(self), I = new self.FlexSearch.Index(L), delete self.FlexSearch) : I = new N(L); - postMessage({id:b}); + (b = a.factory) ? (Function("return " + b)()(self), I = new self.FlexSearch.Index(L), delete self.FlexSearch) : I = new N(L); + postMessage({id:c}); break; default: - let d; - if ("export" === c) { + let e; + if ("export" === b) { if (!L.export || "function" !== typeof L.export) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "export".'); } - e[1] ? (e[0] = L.export, e[2] = 0, e[3] = 1) : e = null; + d[1] ? (d[0] = L.export, d[2] = 0, d[3] = 1) : d = null; } - if ("import" === c) { + if ("import" === b) { if (!L.import || "function" !== typeof L.import) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } - e[0] && (a = await L.import.call(I, e[0]), I.import(e[0], a)); + d[0] && (a = await L.import.call(I, d[0]), I.import(d[0], a)); } else { - (d = e && I[c].apply(I, e)) && d.then && (d = await d); + (e = d && I[b].apply(I, d)) && e.then && (e = await e); } - postMessage("search" === c ? {id:b, msg:d} : {id:b}); + postMessage("search" === b ? {id:c, msg:e} : {id:c}); } } ;function la(a) { @@ -308,47 +308,47 @@ function qa() { } function ma(a) { this[a + "Async"] = function() { - const c = arguments; - var b = c[c.length - 1]; - let e; - "function" === typeof b && (e = b, delete c[c.length - 1]); + const b = arguments; + var c = b[b.length - 1]; + let d; + "function" === typeof c && (d = c, delete b[b.length - 1]); na ? pa || (pa = Date.now() - oa >= this.priority * this.priority * 3) : (na = setTimeout(qa, 0), oa = Date.now()); if (pa) { const f = this; return new Promise(g => { setTimeout(function() { - g(f[a + "Async"].apply(f, c)); + g(f[a + "Async"].apply(f, b)); }, 0); }); } - const d = this[a].apply(this, c); - b = d.then ? d : new Promise(f => f(d)); - e && b.then(e); - return b; + const e = this[a].apply(this, b); + c = e.then ? e : new Promise(f => f(e)); + d && c.then(d); + return c; }; } ;let O = 0; function P(a = {}) { - function c(g) { + function b(g) { function h(k) { k = k.data || k; - const l = k.id, m = l && d.h[l]; - m && (m(k.msg), delete d.h[l]); + const l = k.id, m = l && e.h[l]; + m && (m(k.msg), delete e.h[l]); } this.worker = g; this.h = A(); if (this.worker) { - e ? this.worker.on("message", h) : this.worker.onmessage = h; + d ? this.worker.on("message", h) : this.worker.onmessage = h; if (a.config) { return new Promise(function(k) { - d.h[++O] = function() { - k(d); + e.h[++O] = function() { + k(e); 1e9 < O && (O = 0); }; - d.worker.postMessage({id:O, task:"init", factory:b, options:a}); + e.worker.postMessage({id:O, task:"init", factory:c, options:a}); }); } - this.worker.postMessage({task:"init", factory:b, options:a}); + this.worker.postMessage({task:"init", factory:c, options:a}); this.priority = a.priority || 4; return this; } @@ -356,12 +356,12 @@ function P(a = {}) { if (!this || this.constructor !== P) { return new P(a); } - let b = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; - b && (b = b.toString()); - const e = "undefined" === typeof window, d = this, f = ra(b, e, a.worker); + let c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; + c && (c = c.toString()); + const d = "undefined" === typeof window, e = this, f = ra(c, d, a.worker); return f.then ? f.then(function(g) { - return c.call(d, g); - }) : c.call(this, f); + return b.call(e, g); + }) : b.call(this, f); } Q("add"); Q("append"); @@ -374,118 +374,118 @@ Q("import"); la(P.prototype); function Q(a) { P.prototype[a] = function() { - const c = this, b = [].slice.call(arguments); - var e = b[b.length - 1]; - let d; - "function" === typeof e && (d = e, b.pop()); - e = new Promise(function(f) { - "export" === a && "function" === typeof b[0] && (b[0] = null); - c.h[++O] = f; - c.worker.postMessage({task:a, id:O, args:b}); + const b = this, c = [].slice.call(arguments); + var d = c[c.length - 1]; + let e; + "function" === typeof d && (e = d, c.pop()); + d = new Promise(function(f) { + "export" === a && "function" === typeof c[0] && (c[0] = null); + b.h[++O] = f; + b.worker.postMessage({task:a, id:O, args:c}); }); - return d ? (e.then(d), this) : e; + return e ? (d.then(e), this) : d; }; } -function ra(a, c, b) { - return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/node/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)("import.meta.dirname")+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function ra(a, b, c) { + return b ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/node/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)("import.meta.dirname")+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function sa(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 5000 | 0); - for (const d of a.entries()) { - e.push(d), e.length === c && (b.push(e), e = []); - } - e.length && b.push(e); - return b; -} -function ta(a, c) { - c || (c = new Map()); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c.set(e[0], e[1]); +;function sa(a, b = 0) { + let c = [], d = []; + b && (b = 250000 / b * 5000 | 0); + for (const e of a.entries()) { + d.push(e), d.length === b && (c.push(d), d = []); } + d.length && c.push(d); return c; } -function ua(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 1000 | 0); - for (const d of a.entries()) { - e.push([d[0], sa(d[1])[0]]), e.length === c && (b.push(e), e = []); +function ta(a, b) { + b || (b = new Map()); + for (let c = 0, d; c < a.length; c++) { + d = a[c], b.set(d[0], d[1]); } - e.length && b.push(e); return b; } -function va(a, c) { - c || (c = new Map()); - for (let b = 0, e, d; b < a.length; b++) { - e = a[b], d = c.get(e[0]), c.set(e[0], ta(e[1], d)); +function ua(a, b = 0) { + let c = [], d = []; + b && (b = 250000 / b * 1000 | 0); + for (const e of a.entries()) { + d.push([e[0], sa(e[1])[0]]), d.length === b && (c.push(d), d = []); } + d.length && c.push(d); return c; } +function va(a, b) { + b || (b = new Map()); + for (let c = 0, d, e; c < a.length; c++) { + d = a[c], e = b.get(d[0]), b.set(d[0], ta(d[1], e)); + } + return b; +} function wa(a) { - let c = [], b = []; - for (const e of a.keys()) { - b.push(e), 250000 === b.length && (c.push(b), b = []); + let b = [], c = []; + for (const d of a.keys()) { + c.push(d), 250000 === c.length && (b.push(c), c = []); } - b.length && c.push(b); - return c; + c.length && b.push(c); + return b; } -function xa(a, c) { - c || (c = new Set()); - for (let b = 0; b < a.length; b++) { - c.add(a[b]); +function xa(a, b) { + b || (b = new Set()); + for (let c = 0; c < a.length; c++) { + b.add(a[c]); } - return c; + return b; } -function ya(a, c, b, e, d, f, g = 0) { - const h = e && e.constructor === Array; - var k = h ? e.shift() : e; +function ya(a, b, c, d, e, f, g = 0) { + const h = d && d.constructor === Array; + var k = h ? d.shift() : d; if (!k) { - return this.export(a, c, d, f + 1); + return this.export(a, b, e, f + 1); } - if ((k = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(k))) && k.then) { + if ((k = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(k))) && k.then) { const l = this; return k.then(function() { - return ya.call(l, a, c, b, h ? e : null, d, f, g + 1); + return ya.call(l, a, b, c, h ? d : null, e, f, g + 1); }); } - return ya.call(this, a, c, b, h ? e : null, d, f, g + 1); + return ya.call(this, a, b, c, h ? d : null, e, f, g + 1); } -function za(a, c) { - let b = ""; - for (const e of a.entries()) { - a = e[0]; - const d = e[1]; +function za(a, b) { + let c = ""; + for (const d of a.entries()) { + a = d[0]; + const e = d[1]; let f = ""; - for (let g = 0, h; g < d.length; g++) { - h = d[g] || [""]; + for (let g = 0, h; g < e.length; g++) { + h = e[g] || [""]; let k = ""; for (let l = 0; l < h.length; l++) { - k += (k ? "," : "") + ("string" === c ? '"' + h[l] + '"' : h[l]); + k += (k ? "," : "") + ("string" === b ? '"' + h[l] + '"' : h[l]); } k = "[" + k + "]"; f += (f ? "," : "") + k; } f = '["' + a + '",[' + f + "]]"; - b += (b ? "," : "") + f; + c += (c ? "," : "") + f; } - return b; + return c; } -;function Aa(a, c, b, e) { - let d = []; +;function Aa(a, b, c, d) { + let e = []; for (let f = 0, g; f < a.index.length; f++) { - if (g = a.index[f], c >= g.length) { - c -= g.length; + if (g = a.index[f], b >= g.length) { + b -= g.length; } else { - c = g[e ? "splice" : "slice"](c, b); - const h = c.length; - if (h && (d = d.length ? d.concat(c) : c, b -= h, e && (a.length -= h), !b)) { + b = g[d ? "splice" : "slice"](b, c); + const h = b.length; + if (h && (e = e.length ? e.concat(b) : b, c -= h, d && (a.length -= h), !c)) { break; } - c = 0; + b = 0; } } - return d; + return e; } function R(a) { if (!this || this.constructor !== R) { @@ -493,30 +493,30 @@ function R(a) { } this.index = a ? [a] : []; this.length = a ? a.length : 0; - const c = this; - return new Proxy([], {get(b, e) { - if ("length" === e) { - return c.length; + const b = this; + return new Proxy([], {get(c, d) { + if ("length" === d) { + return b.length; } - if ("push" === e) { - return function(d) { - c.index[c.index.length - 1].push(d); - c.length++; + if ("push" === d) { + return function(e) { + b.index[b.index.length - 1].push(e); + b.length++; }; } - if ("pop" === e) { + if ("pop" === d) { return function() { - if (c.length) { - return c.length--, c.index[c.index.length - 1].pop(); + if (b.length) { + return b.length--, b.index[b.index.length - 1].pop(); } }; } - if ("indexOf" === e) { - return function(d) { + if ("indexOf" === d) { + return function(e) { let f = 0; - for (let g = 0, h, k; g < c.index.length; g++) { - h = c.index[g]; - k = h.indexOf(d); + for (let g = 0, h, k; g < b.index.length; g++) { + h = b.index[g]; + k = h.indexOf(e); if (0 <= k) { return f + k; } @@ -525,36 +525,36 @@ function R(a) { return -1; }; } - if ("includes" === e) { - return function(d) { - for (let f = 0; f < c.index.length; f++) { - if (c.index[f].includes(d)) { + if ("includes" === d) { + return function(e) { + for (let f = 0; f < b.index.length; f++) { + if (b.index[f].includes(e)) { return !0; } } return !1; }; } - if ("slice" === e) { - return function(d, f) { - return Aa(c, d || 0, f || c.length, !1); + if ("slice" === d) { + return function(e, f) { + return Aa(b, e || 0, f || b.length, !1); }; } - if ("splice" === e) { - return function(d, f) { - return Aa(c, d || 0, f || c.length, !0); + if ("splice" === d) { + return function(e, f) { + return Aa(b, e || 0, f || b.length, !0); }; } - if ("constructor" === e) { + if ("constructor" === d) { return Array; } - if ("symbol" !== typeof e) { - return (b = c.index[e / 2 ** 31 | 0]) && b[e]; + if ("symbol" !== typeof d) { + return (c = b.index[d / 2 ** 31 | 0]) && c[d]; } - }, set(b, e, d) { - b = e / 2 ** 31 | 0; - (c.index[b] || (c.index[b] = []))[e] = d; - c.length++; + }, set(c, d, e) { + c = d / 2 ** 31 | 0; + (b.index[c] || (b.index[c] = []))[d] = e; + b.length++; return !0; }}); } @@ -576,13 +576,13 @@ function S(a = 8) { 32 < a ? (this.B = Ba, this.A = BigInt(a)) : (this.B = Ca, this.A = a); } S.prototype.get = function(a) { - const c = this.index[this.B(a)]; - return c && c.get(a); + const b = this.index[this.B(a)]; + return b && b.get(a); }; -S.prototype.set = function(a, c) { - var b = this.B(a); - let e = this.index[b]; - e ? (b = e.size, e.set(a, c), (b -= e.size) && this.size++) : (this.index[b] = e = new Map([[a, c]]), this.h.push(e), this.size++); +S.prototype.set = function(a, b) { + var c = this.B(a); + let d = this.index[c]; + d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.h.push(d), this.size++); }; function T(a = 8) { if (!this || this.constructor !== T) { @@ -594,18 +594,18 @@ function T(a = 8) { 32 < a ? (this.B = Ba, this.A = BigInt(a)) : (this.B = Ca, this.A = a); } T.prototype.add = function(a) { - var c = this.B(a); - let b = this.index[c]; - b ? (c = b.size, b.add(a), (c -= b.size) && this.size++) : (this.index[c] = b = new Set([a]), this.h.push(b), this.size++); + var b = this.B(a); + let c = this.index[b]; + c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c), this.size++); }; t = S.prototype; t.has = T.prototype.has = function(a) { - const c = this.index[this.B(a)]; - return c && c.has(a); + const b = this.index[this.B(a)]; + return b && b.has(a); }; t.delete = T.prototype.delete = function(a) { - const c = this.index[this.B(a)]; - c && c.delete(a) && this.size--; + const b = this.index[this.B(a)]; + b && b.delete(a) && this.size--; }; t.clear = T.prototype.clear = function() { this.index = A(); @@ -614,91 +614,91 @@ t.clear = T.prototype.clear = function() { }; t.values = T.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].values()) { - yield c; + for (let b of this.h[a].values()) { + yield b; } } }; t.keys = T.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].keys()) { - yield c; + for (let b of this.h[a].keys()) { + yield b; } } }; t.entries = T.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].entries()) { - yield c; + for (let b of this.h[a].entries()) { + yield b; } } }; function Ca(a) { - let c = 2 ** this.A - 1; + let b = 2 ** this.A - 1; if ("number" == typeof a) { - return a & c; + return a & b; } - let b = 0, e = this.A + 1; - for (let d = 0; d < a.length; d++) { - b = (b * e ^ a.charCodeAt(d)) & c; + let c = 0, d = this.A + 1; + for (let e = 0; e < a.length; e++) { + c = (c * d ^ a.charCodeAt(e)) & b; } - return 32 === this.A ? b + 2 ** 31 : b; + return 32 === this.A ? c + 2 ** 31 : c; } function Ba(a) { - let c = BigInt(2) ** this.A - BigInt(1); - var b = typeof a; - if ("bigint" === b) { - return a & c; + let b = BigInt(2) ** this.A - BigInt(1); + var c = typeof a; + if ("bigint" === c) { + return a & b; } - if ("number" === b) { - return BigInt(a) & c; + if ("number" === c) { + return BigInt(a) & b; } - b = BigInt(0); - let e = this.A + BigInt(1); - for (let d = 0; d < a.length; d++) { - b = (b * e ^ BigInt(a.charCodeAt(d))) & c; + c = BigInt(0); + let d = this.A + BigInt(1); + for (let e = 0; e < a.length; e++) { + c = (c * d ^ BigInt(a.charCodeAt(e))) & b; } - return b; + return c; } -;U.prototype.add = function(a, c, b) { - aa(a) && (c = a, a = ca(c, this.key)); - if (c && (a || 0 === a)) { - if (!b && this.reg.has(a)) { - return this.update(a, c); +;U.prototype.add = function(a, b, c) { + aa(a) && (b = a, a = ca(b, this.key)); + if (b && (a || 0 === a)) { + if (!c && this.reg.has(a)) { + return this.update(a, b); } for (let h = 0, k; h < this.field.length; h++) { k = this.F[h]; - var e = this.index.get(this.field[h]); + var d = this.index.get(this.field[h]); if ("function" === typeof k) { - var d = k(c); - d && e.add(a, d, !1, !0); + var e = k(b); + e && d.add(a, e, !1, !0); } else { - if (d = k.I, !d || d(c)) { - k.constructor === String ? k = ["" + k] : D(k) && (k = [k]), Da(c, k, this.J, 0, e, a, k[0], b); + if (e = k.I, !e || e(b)) { + k.constructor === String ? k = ["" + k] : D(k) && (k = [k]), Da(b, k, this.J, 0, d, a, k[0], c); } } } if (this.tag) { - for (e = 0; e < this.D.length; e++) { - var f = this.D[e], g = this.R[e]; - d = this.tag.get(g); + for (d = 0; d < this.D.length; d++) { + var f = this.D[d], g = this.R[d]; + e = this.tag.get(g); let h = A(); if ("function" === typeof f) { - if (f = f(c), !f) { + if (f = f(b), !f) { continue; } } else { const k = f.I; - if (k && !k(c)) { + if (k && !k(b)) { continue; } f.constructor === String && (f = "" + f); - f = ca(c, f); + f = ca(b, f); } - if (d && f) { + if (e && f) { D(f) && (f = [f]); for (let k = 0, l, m; k < f.length; k++) { - if (l = f[k], !h[l] && (h[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), !b || !m.includes(a))) { + if (l = f[k], !h[l] && (h[l] = 1, (g = e.get(l)) ? m = g : e.set(l, m = []), !c || !m.includes(a))) { if (m.length === 2 ** 31 - 1) { g = new R(m); if (this.fastupdate) { @@ -706,91 +706,91 @@ function Ba(a) { n.includes(m) && (n[n.indexOf(m)] = g); } } - d.set(l, m = g); + e.set(l, m = g); } m.push(a); this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m])); } } } else { - d || console.warn("Tag '" + g + "' was not found"); + e || console.warn("Tag '" + g + "' was not found"); } } } - if (this.store && (!b || !this.store.has(a))) { + if (this.store && (!c || !this.store.has(a))) { let h; if (this.C) { h = A(); for (let k = 0, l; k < this.C.length; k++) { l = this.C[k]; - if ((b = l.I) && !b(c)) { + if ((c = l.I) && !c(b)) { continue; } let m; if ("function" === typeof l) { - m = l(c); + m = l(b); if (!m) { continue; } l = [l.V]; } else if (D(l) || l.constructor === String) { - h[l] = c[l]; + h[l] = b[l]; continue; } - Ea(c, h, l, 0, l[0], m); + Ea(b, h, l, 0, l[0], m); } } - this.store.set(a, h || c); + this.store.set(a, h || b); } this.worker && (this.fastupdate || this.reg.add(a)); } return this; }; -function Ea(a, c, b, e, d, f) { - a = a[d]; - if (e === b.length - 1) { - c[d] = f || a; +function Ea(a, b, c, d, e, f) { + a = a[e]; + if (d === c.length - 1) { + b[e] = f || a; } else if (a) { if (a.constructor === Array) { - for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { - Ea(a, c, b, e, d); + for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) { + Ea(a, b, c, d, e); } } else { - c = c[d] || (c[d] = A()), d = b[++e], Ea(a, c, b, e, d); + b = b[e] || (b[e] = A()), e = c[++d], Ea(a, b, c, d, e); } } } -function Da(a, c, b, e, d, f, g, h) { +function Da(a, b, c, d, e, f, g, h) { if (a = a[g]) { - if (e === c.length - 1) { + if (d === b.length - 1) { if (a.constructor === Array) { - if (b[e]) { - for (c = 0; c < a.length; c++) { - d.add(f, a[c], !0, !0); + if (c[d]) { + for (b = 0; b < a.length; b++) { + e.add(f, a[b], !0, !0); } return; } a = a.join(" "); } - d.add(f, a, h, !0); + e.add(f, a, h, !0); } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Da(a, c, b, e, d, f, g, h); + Da(a, b, c, d, e, f, g, h); } } else { - g = c[++e], Da(a, c, b, e, d, f, g, h); + g = b[++d], Da(a, b, c, d, e, f, g, h); } } } else { - d.db && d.remove(f); + e.db && e.remove(f); } } -;function Fa(a, c, b, e, d, f, g) { +;function Fa(a, b, c, d, e, f, g) { const h = a.length; let k = [], l, m; l = A(); - for (let n = 0, p, r, q, u; n < c; n++) { + for (let n = 0, p, r, q, u; n < b; n++) { for (let v = 0; v < h; v++) { if (q = a[v], n < q.length && (p = q[n])) { for (let w = 0; w < p.length; w++) { @@ -798,66 +798,66 @@ function Da(a, c, b, e, d, f, g, h) { (m = l[r]) ? l[r]++ : (m = 0, l[r] = 1); u = k[m] || (k[m] = []); if (!g) { - let x = n + (v || !d ? 0 : f || 0); + let x = n + (v || !e ? 0 : f || 0); u = u[x] || (u[x] = []); } u.push(r); - if (g && b && m === h - 1 && u.length - e === b) { - return e ? u.slice(e) : u; + if (g && c && m === h - 1 && u.length - d === c) { + return d ? u.slice(d) : u; } } } } } if (a = k.length) { - if (d) { - k = 1 < k.length ? Ga(k, b, e, g, f) : (k = k[0]).length > b || e ? k.slice(e, b + e) : k; + if (e) { + k = 1 < k.length ? Ga(k, c, d, g, f) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; } else { if (a < h) { return []; } k = k[a - 1]; - if (b || e) { + if (c || d) { if (g) { - if (k.length > b || e) { - k = k.slice(e, b + e); + if (k.length > c || d) { + k = k.slice(d, c + d); } } else { - d = []; + e = []; for (let n = 0, p; n < k.length; n++) { - if (p = k[n], p.length > e) { - e -= p.length; + if (p = k[n], p.length > d) { + d -= p.length; } else { - if (p.length > b || e) { - p = p.slice(e, b + e), b -= p.length, e && (e -= p.length); + if (p.length > c || d) { + p = p.slice(d, c + d), c -= p.length, d && (d -= p.length); } - d.push(p); - if (!b) { + e.push(p); + if (!c) { break; } } } - k = 1 < d.length ? [].concat.apply([], d) : d[0]; + k = 1 < e.length ? [].concat.apply([], e) : e[0]; } } } } return k; } -function Ga(a, c, b, e, d) { +function Ga(a, b, c, d, e) { const f = [], g = A(); let h; var k = a.length; let l; - if (e) { - for (d = k - 1; 0 <= d; d--) { - if (l = (e = a[d]) && e.length) { + if (d) { + for (e = k - 1; 0 <= e; e--) { + if (l = (d = a[e]) && d.length) { for (k = 0; k < l; k++) { - if (h = e[k], !g[h]) { - if (g[h] = 1, b) { - b--; + if (h = d[k], !g[h]) { + if (g[h] = 1, c) { + c--; } else { - if (f.push(h), f.length === c) { + if (f.push(h), f.length === b) { return f; } } @@ -869,15 +869,15 @@ function Ga(a, c, b, e, d) { for (let m = k - 1, n, p = 0; 0 <= m; m--) { n = a[m]; for (let r = 0; r < n.length; r++) { - if (l = (e = n[r]) && e.length) { + if (l = (d = n[r]) && d.length) { for (let q = 0; q < l; q++) { - if (h = e[q], !g[h]) { - if (g[h] = 1, b) { - b--; + if (h = d[q], !g[h]) { + if (g[h] = 1, c) { + c--; } else { - let u = (r + (m < k - 1 ? d || 0 : 0)) / (m + 1) | 0; + let u = (r + (m < k - 1 ? e || 0 : 0)) / (m + 1) | 0; (f[u] || (f[u] = [])).push(h); - if (++p === c) { + if (++p === b) { return f; } } @@ -889,72 +889,72 @@ function Ga(a, c, b, e, d) { } return f; } -function Ha(a, c, b) { - const e = A(), d = []; - for (let f = 0, g; f < c.length; f++) { - g = c[f]; +function Ha(a, b, c) { + const d = A(), e = []; + for (let f = 0, g; f < b.length; f++) { + g = b[f]; for (let h = 0; h < g.length; h++) { - e[g[h]] = 1; + d[g[h]] = 1; } } - if (b) { + if (c) { for (let f = 0, g; f < a.length; f++) { - g = a[f], e[g] && (d.push(g), e[g] = 0); + g = a[f], d[g] && (e.push(g), d[g] = 0); } } else { for (let f = 0, g, h; f < a.result.length; f++) { - for (g = a.result[f], c = 0; c < g.length; c++) { - h = g[c], e[h] && ((d[f] || (d[f] = [])).push(h), e[h] = 0); + for (g = a.result[f], b = 0; b < g.length; b++) { + h = g[b], d[h] && ((e[f] || (e[f] = [])).push(h), d[h] = 0); } } } - return d; + return e; } -;function Ia(a, c, b, e) { +;function Ia(a, b, c, d) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, e ? V.call(this, a) : a; + return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? V.call(this, a) : a; } - let d = []; + let e = []; for (let f = 0, g, h; f < a.length; f++) { if ((g = a[f]) && (h = g.length)) { - if (b) { - if (b >= h) { - b -= h; + if (c) { + if (c >= h) { + c -= h; continue; } - b < h && (g = c ? g.slice(b, b + c) : g.slice(b), h = g.length, b = 0); + c < h && (g = b ? g.slice(c, c + b) : g.slice(c), h = g.length, c = 0); } - h > c && (g = g.slice(0, c), h = c); - if (!d.length && h >= c) { - return e ? V.call(this, g) : g; + h > b && (g = g.slice(0, b), h = b); + if (!e.length && h >= b) { + return d ? V.call(this, g) : g; } - d.push(g); - c -= h; - if (!c) { + e.push(g); + b -= h; + if (!b) { break; } } } - d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? V.call(this, d) : d; + e = 1 < e.length ? [].concat.apply([], e) : e[0]; + return d ? V.call(this, e) : e; } -;function Ja(a, c, b) { - var e = b[0]; - if (e.then) { - return Promise.all(b).then(function(m) { - return a[c].apply(a, m); +;function Ja(a, b, c) { + var d = c[0]; + if (d.then) { + return Promise.all(c).then(function(m) { + return a[b].apply(a, m); }); } - if (e[0] && e[0].index) { - return a[c].apply(a, e); + if (d[0] && d[0].index) { + return a[b].apply(a, d); } - e = []; - let d = [], f = 0, g = 0, h, k, l; - for (let m = 0, n; m < b.length; m++) { - if (n = b[m]) { + d = []; + let e = [], f = 0, g = 0, h, k, l; + for (let m = 0, n; m < c.length; m++) { + if (n = c[m]) { let p; if (n.constructor === W) { p = n.result; @@ -976,99 +976,99 @@ function Ha(a, c, b) { } } if (p.then) { - d.push(p); + e.push(p); } else if (p.length) { - e[m] = p; - } else if (!l && ("and" === c || "xor" === c)) { - e = []; + d[m] = p; + } else if (!l && ("and" === b || "xor" === b)) { + d = []; break; } } } - return {O:e, P:d, limit:f, offset:g, enrich:h, resolve:k, suggest:l}; + return {O:d, P:e, limit:f, offset:g, enrich:h, resolve:k, suggest:l}; } ;W.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Ja(this, "or", arguments); - return Ka.call(this, a, c, b, e, d, f); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f} = Ja(this, "or", arguments); + return Ka.call(this, a, b, c, d, e, f); }; -function Ka(a, c, b, e, d, f) { - if (c.length) { +function Ka(a, b, c, d, e, f) { + if (b.length) { const g = this; - return Promise.all(c).then(function(h) { + return Promise.all(b).then(function(h) { a = []; for (let k = 0, l; k < h.length; k++) { (l = h[k]).length && (a[k] = l); } - return Ka.call(g, a, [], b, e, d, f); + return Ka.call(g, a, [], c, d, e, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ga(a, b, e, !1, this.h), e = 0)); - return f ? this.resolve(b, e, d) : this; + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ga(a, c, d, !1, this.h), d = 0)); + return f ? this.resolve(c, d, e) : this; } ;W.prototype.and = function() { - let a = this.result.length, c, b, e, d; + let a = this.result.length, b, c, d, e; if (!a) { const f = arguments[0]; - f && (a = !!f.suggest, d = f.resolve, c = f.limit, b = f.offset, e = f.enrich && d); + f && (a = !!f.suggest, e = f.resolve, b = f.limit, c = f.offset, d = f.enrich && e); } if (a) { const {O:f, P:g, limit:h, offset:k, enrich:l, resolve:m, suggest:n} = Ja(this, "and", arguments); return La.call(this, f, g, h, k, l, m, n); } - return d ? this.resolve(c, b, e) : this; + return e ? this.resolve(b, c, d) : this; }; -function La(a, c, b, e, d, f, g) { - if (c.length) { +function La(a, b, c, d, e, f, g) { + if (b.length) { const h = this; - return Promise.all(c).then(function(k) { + return Promise.all(b).then(function(k) { a = []; for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return La.call(h, a, [], b, e, d, f, g); + return La.call(h, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (c = da(a)) { - return this.result = Fa(a, c, b, e, g, this.h, f), f ? d ? V.call(this.index, this.result) : this.result : this; + if (b = da(a)) { + return this.result = Fa(a, b, c, d, g, this.h, f), f ? e ? V.call(this.index, this.result) : this.result : this; } this.result = []; } } else { g || (this.result = a); } - return f ? this.resolve(b, e, d) : this; + return f ? this.resolve(c, d, e) : this; } ;W.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "xor", arguments); - return Ma.call(this, a, c, b, e, d, f, g); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f, suggest:g} = Ja(this, "xor", arguments); + return Ma.call(this, a, b, c, d, e, f, g); }; -function Ma(a, c, b, e, d, f, g) { - if (c.length) { +function Ma(a, b, c, d, e, f, g) { + if (b.length) { const h = this; - return Promise.all(c).then(function(k) { + return Promise.all(b).then(function(k) { a = []; for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return Ma.call(h, a, [], b, e, d, f, g); + return Ma.call(h, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = Na.call(this, a, b, e, f, this.h), f ? d ? V.call(this.index, this.result) : this.result : this; + return this.result = Na.call(this, a, c, d, f, this.h), f ? e ? V.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } - return f ? this.resolve(b, e, d) : this; + return f ? this.resolve(c, d, e) : this; } -function Na(a, c, b, e, d) { +function Na(a, b, c, d, e) { const f = [], g = A(); let h = 0; for (let k = 0, l; k < a.length; k++) { @@ -1089,18 +1089,18 @@ function Na(a, c, b, e, d) { if (l = p[k]) { for (let r = 0, q; r < l.length; r++) { if (q = l[r], 1 === g[q]) { - if (b) { - b--; + if (c) { + c--; } else { - if (e) { - if (f.push(q), f.length === c) { + if (d) { + if (f.push(q), f.length === b) { return f; } } else { - const u = k + (n ? d : 0); + const u = k + (n ? e : 0); f[u] || (f[u] = []); f[u].push(q); - if (++m === c) { + if (++m === b) { return f; } } @@ -1114,44 +1114,44 @@ function Na(a, c, b, e, d) { return f; } ;W.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "not", arguments); - return Oa.call(this, a, c, b, e, d, f, g); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f, suggest:g} = Ja(this, "not", arguments); + return Oa.call(this, a, b, c, d, e, f, g); }; -function Oa(a, c, b, e, d, f, g) { - if (c.length) { +function Oa(a, b, c, d, e, f, g) { + if (b.length) { const h = this; - return Promise.all(c).then(function(k) { + return Promise.all(b).then(function(k) { a = []; for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return Oa.call(h, a, [], b, e, d, f, g); + return Oa.call(h, a, [], c, d, e, f, g); }); } if (a.length && this.result.length) { - this.result = Pa.call(this, a, b, e, f); + this.result = Pa.call(this, a, c, d, f); } else if (f) { - return this.resolve(b, e, d); + return this.resolve(c, d, e); } - return f ? d ? V.call(this.index, this.result) : this.result : this; + return f ? e ? V.call(this.index, this.result) : this.result : this; } -function Pa(a, c, b, e) { - const d = []; +function Pa(a, b, c, d) { + const e = []; a = new Set(a.flat().flat()); for (let f = 0, g, h = 0; f < this.result.length; f++) { if (g = this.result[f]) { for (let k = 0, l; k < g.length; k++) { if (l = g[k], !a.has(l)) { - if (b) { - b--; + if (c) { + c--; } else { - if (e) { - if (d.push(l), d.length === c) { - return d; + if (d) { + if (e.push(l), e.length === b) { + return e; } } else { - if (d[f] || (d[f] = []), d[f].push(l), ++h === c) { - return d; + if (e[f] || (e[f] = []), e[f].push(l), ++h === b) { + return e; } } } @@ -1159,7 +1159,7 @@ function Pa(a, c, b, e) { } } } - return d; + return e; } ;function W(a) { if (!this || this.constructor !== W) { @@ -1174,32 +1174,32 @@ function Pa(a, c, b, e) { } W.prototype.limit = function(a) { if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - if (e.length <= a) { - if (c[b] = e, a -= e.length, !a) { + const b = []; + for (let c = 0, d; c < this.result.length; c++) { + if (d = this.result[c]) { + if (d.length <= a) { + if (b[c] = d, a -= d.length, !a) { break; } } else { - c[b] = e.slice(0, a); + b[c] = d.slice(0, a); break; } } } - this.result = c; + this.result = b; } return this; }; W.prototype.offset = function(a) { if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - e.length <= a ? a -= e.length : (c[b] = e.slice(a), a = 0); + const b = []; + for (let c = 0, d; c < this.result.length; c++) { + if (d = this.result[c]) { + d.length <= a ? a -= d.length : (b[c] = d.slice(a), a = 0); } } - this.result = c; + this.result = b; } return this; }; @@ -1207,15 +1207,15 @@ W.prototype.boost = function(a) { this.h += a; return this; }; -W.prototype.resolve = function(a, c, b) { - const e = this.result, d = this.index; +W.prototype.resolve = function(a, b, c) { + const d = this.result, e = this.index; this.result = this.index = null; - return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), Ia.call(d, e, a || 100, c, b)) : e; + return d.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ia.call(e, d, a || 100, b, c)) : d; }; A(); -U.prototype.search = function(a, c, b, e) { - b || (!c && aa(a) ? (b = a, a = "") : aa(c) && (b = c, c = 0)); - let d = []; +U.prototype.search = function(a, b, c, d) { + c || (!b && aa(a) ? (c = a, a = "") : aa(b) && (c = b, b = 0)); + let e = []; var f = []; let g; var h; @@ -1224,15 +1224,15 @@ U.prototype.search = function(a, c, b, e) { let n = 0; var p = !0; let r; - if (b) { - b.constructor === Array && (b = {index:b}); - a = b.query || a; - g = b.pluck; - k = b.merge; - l = g || b.field || (l = b.index) && (l.index ? null : l); - m = this.tag && b.tag; - var q = b.suggest; - p = !1 !== b.resolve; + if (c) { + c.constructor === Array && (c = {index:c}); + a = c.query || a; + g = c.pluck; + k = c.merge; + l = g || c.field || (l = c.index) && (l.index ? null : l); + m = this.tag && c.tag; + var q = c.suggest; + p = !1 !== c.resolve; if (!p && !g) { if (l = l || this.field) { D(l) ? g = l : (l.constructor === Array && 1 === l.length && (l = l[0]), g = l.field || l.index); @@ -1241,12 +1241,12 @@ U.prototype.search = function(a, c, b, e) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } - this.store && b.enrich && !p && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - r = (h = this.store && b.enrich && p) && b.highlight; - c = b.limit || c; - var u = b.offset || 0; - c || (c = 100); - if (m && (!this.db || !e)) { + this.store && c.enrich && !p && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + r = (h = this.store && c.enrich && p) && c.highlight; + b = c.limit || b; + var u = c.offset || 0; + b || (b = 100); + if (m && (!this.db || !d)) { m.constructor !== Array && (m = [m]); var v = []; for (let B = 0, y; B < m.length; B++) { @@ -1290,25 +1290,25 @@ U.prototype.search = function(a, c, b, e) { console.warn("Tag '" + v[f] + ":" + v[f + 1] + "' will be skipped because there is no field '" + v[f] + "'."); continue; } - p.push(q = q.db.tag(v[f + 1], c, u, h)); + p.push(q = q.db.tag(v[f + 1], b, u, h)); } else { - q = Qa.call(this, v[f], v[f + 1], c, u, h); + q = Qa.call(this, v[f], v[f + 1], b, u, h); } - d.push({field:v[f], tag:v[f + 1], result:q}); + e.push({field:v[f], tag:v[f + 1], result:q}); } } return p.length ? Promise.all(p).then(function(B) { for (let y = 0; y < B.length; y++) { - d[y].result = B[y]; + e[y].result = B[y]; } - return d; - }) : d; + return e; + }) : e; } } l && l.constructor !== Array && (l = [l]); } l || (l = this.field); - v = !e && (this.worker || this.db) && []; + v = !d && (this.worker || this.db) && []; let F; for (let B = 0, y, C, M; B < l.length; B++) { C = l[B]; @@ -1316,30 +1316,30 @@ U.prototype.search = function(a, c, b, e) { continue; } let E; - D(C) || (E = C, C = E.field, a = E.query || a, c = E.limit || c, u = E.offset || u, q = E.suggest || q, h = this.store && (E.enrich || h)); - if (e) { - y = e[B]; + D(C) || (E = C, C = E.field, a = E.query || a, b = E.limit || b, u = E.offset || u, q = E.suggest || q, h = this.store && (E.enrich || h)); + if (d) { + y = d[B]; } else { - if (w = E || b, x = this.index.get(C), m && (this.db && (w.tag = m, F = x.db.support_tag_search, w.field = l), F || (w.enrich = !1)), v) { - v[B] = x.search(a, c, w); + if (w = E || c, x = this.index.get(C), m && (this.db && (w.tag = m, F = x.db.support_tag_search, w.field = l), F || (w.enrich = !1)), v) { + v[B] = x.search(a, b, w); w && h && (w.enrich = h); continue; } else { - y = x.search(a, c, w), w && h && (w.enrich = h); + y = x.search(a, b, w), w && h && (w.enrich = h); } } M = y && (p ? y.length : y.result.length); if (m && M) { w = []; x = 0; - if (this.db && e) { + if (this.db && d) { if (!F) { - for (let J = l.length; J < e.length; J++) { - let K = e[J]; + for (let J = l.length; J < d.length; J++) { + let K = d[J]; if (K && K.length) { x++, w.push(K); } else if (!q) { - return p ? d : new W(d); + return p ? e : new W(e); } } } @@ -1350,13 +1350,13 @@ U.prototype.search = function(a, c, b, e) { if (console.warn("Tag '" + m[J] + ":" + m[J + 1] + "' will be skipped because there is no field '" + m[J] + "'."), q) { continue; } else { - return p ? d : new W(d); + return p ? e : new W(e); } } if (rb = (K = K && K.get(m[J + 1])) && K.length) { x++, w.push(K); } else if (!q) { - return p ? d : new W(d); + return p ? e : new W(e); } } } @@ -1370,9 +1370,9 @@ U.prototype.search = function(a, c, b, e) { } } if (M) { - f[n] = C, d.push(y), n++; + f[n] = C, e.push(y), n++; } else if (1 === l.length) { - return p ? d : new W(d); + return p ? e : new W(e); } } if (v) { @@ -1383,58 +1383,58 @@ U.prototype.search = function(a, c, b, e) { if (console.warn("Tag '" + m[h] + ":" + m[h + 1] + "' was not found because there is no field '" + m[h] + "'."), q) { continue; } else { - return p ? d : new W(d); + return p ? e : new W(e); } } - v.push(f.db.tag(m[h + 1], c, u, !1)); + v.push(f.db.tag(m[h + 1], b, u, !1)); } } const B = this; return Promise.all(v).then(function(y) { - return y.length ? B.search(a, c, b, y) : y; + return y.length ? B.search(a, b, c, y) : y; }); } if (!n) { - return p ? d : new W(d); + return p ? e : new W(e); } if (g && (!h || !this.store)) { - return d[0]; + return e[0]; } v = []; for (u = 0; u < f.length; u++) { - q = d[u]; + q = e[u]; h && q.length && "undefined" === typeof q[0].doc && (this.db ? v.push(q = this.index.get(this.field[0]).db.enrich(q)) : q = V.call(this, q)); if (g) { return p ? r ? Ra(a, q, this.index, g, r) : q : new W(q); } - d[u] = {field:f[u], result:q}; + e[u] = {field:f[u], result:q}; } if (h && this.db && v.length) { const B = this; return Promise.all(v).then(function(y) { for (let C = 0; C < y.length; C++) { - d[C].result = y[C]; + e[C].result = y[C]; } - return k ? Sa(d) : r ? Ra(a, d, B.index, g, r) : d; + return k ? Sa(e) : r ? Ra(a, e, B.index, g, r) : e; }); } - return k ? Sa(d) : r ? Ra(a, d, this.index, g, r) : d; + return k ? Sa(e) : r ? Ra(a, e, this.index, g, r) : e; }; -function Ra(a, c, b, e, d) { +function Ra(a, b, c, d, e) { let f, g; - for (let k = 0, l, m, n; k < c.length; k++) { + for (let k = 0, l, m, n; k < b.length; k++) { let p; - if (e) { - p = c, n = e; + if (d) { + p = b, n = d; } else { - var h = c[k]; + var h = b[k]; n = h.field; if (!n) { continue; } p = h.result; } - m = b.get(n); + m = c.get(n); l = m.encoder; h = m.tokenize; l !== f && (f = l, g = f.encode(a)); @@ -1449,14 +1449,14 @@ function Ra(a, c, b, e, d) { for (let B = 0, y; B < g.length; B++) { if (y = g[B], "strict" === h) { if (x === y) { - q += (q ? " " : "") + d.replace("$1", w); + q += (q ? " " : "") + e.replace("$1", w); F = !0; break; } } else { const C = x.indexOf(y); if (-1 < C) { - q += (q ? " " : "") + w.substring(0, C) + d.replace("$1", w.substring(C, y.length)) + w.substring(C + y.length); + q += (q ? " " : "") + w.substring(0, C) + e.replace("$1", w.substring(C, y.length)) + w.substring(C + y.length); F = !0; break; } @@ -1467,33 +1467,33 @@ function Ra(a, c, b, e, d) { } p[r].highlight = q; } - if (e) { + if (d) { break; } } - return c; + return b; } function Sa(a) { - const c = [], b = A(); - for (let e = 0, d, f; e < a.length; e++) { - d = a[e]; - f = d.result; + const b = [], c = A(); + for (let d = 0, e, f; d < a.length; d++) { + e = a[d]; + f = e.result; for (let g = 0, h, k, l; g < f.length; g++) { - k = f[g], "object" !== typeof k && (k = {id:k}), h = k.id, (l = b[h]) ? l.push(d.field) : (k.field = b[h] = [d.field], c.push(k)); + k = f[g], "object" !== typeof k && (k = {id:k}), h = k.id, (l = c[h]) ? l.push(e.field) : (k.field = c[h] = [e.field], b.push(k)); } } - return c; + return b; } -function Qa(a, c, b, e, d) { +function Qa(a, b, c, d, e) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; } - if ((a = (f = f && f.get(c)) && f.length - e) && 0 < a) { - if (a > b || e) { - f = f.slice(e, e + b); + if ((a = (f = f && f.get(b)) && f.length - d) && 0 < a) { + if (a > c || d) { + f = f.slice(d, d + c); } - d && (f = V.call(this, f)); + e && (f = V.call(this, f)); return f; } } @@ -1501,66 +1501,66 @@ function V(a) { if (!this || !this.store) { return a; } - const c = Array(a.length); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c[b] = {id:e, doc:this.store.get(e)}; + const b = Array(a.length); + for (let c = 0, d; c < a.length; c++) { + d = a[c], b[c] = {id:d, doc:this.store.get(d)}; } - return c; + return b; } ;function U(a) { if (!this || this.constructor !== U) { return new U(a); } - const c = a.document || a.doc || a; - let b, e; + const b = a.document || a.doc || a; + let c, d; this.F = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && Ta(b, this.J) || "id"; - (e = a.keystore || 0) && (this.keystore = e); + this.key = (c = b.key || b.id) && Ta(c, this.J) || "id"; + (d = a.keystore || 0) && (this.keystore = d); this.fastupdate = !!a.fastupdate; - this.reg = !this.fastupdate || a.worker || a.db ? e ? new T(e) : new Set() : e ? new S(e) : new Map(); - this.C = (b = c.store || null) && b && !0 !== b && []; - this.store = b && (e ? new S(e) : new Map()); - this.cache = (b = a.cache || null) && new X(b); + this.reg = !this.fastupdate || a.worker || a.db ? d ? new T(d) : new Set() : d ? new S(d) : new Map(); + this.C = (c = b.store || null) && c && !0 !== c && []; + this.store = c && (d ? new S(d) : new Map()); + this.cache = (c = a.cache || null) && new X(c); a.cache = !1; this.worker = a.worker || !1; this.priority = a.priority || 4; - this.index = Ua.call(this, a, c); + this.index = Ua.call(this, a, b); this.tag = null; - if (b = c.tag) { - if ("string" === typeof b && (b = [b]), b.length) { + if (c = b.tag) { + if ("string" === typeof c && (c = [c]), c.length) { this.tag = new Map(); this.D = []; this.R = []; - for (let d = 0, f, g; d < b.length; d++) { - f = b[d]; + for (let e = 0, f, g; e < c.length; e++) { + f = c[e]; g = f.field || f; if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.D[d] = f.custom : (this.D[d] = Ta(g, this.J), f.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = f.filter)); - this.R[d] = g; + f.custom ? this.D[e] = f.custom : (this.D[e] = Ta(g, this.J), f.filter && ("string" === typeof this.D[e] && (this.D[e] = new String(this.D[e])), this.D[e].I = f.filter)); + this.R[e] = g; this.tag.set(g, new Map()); } } } if (this.worker) { this.fastupdate = !1; - const d = []; + const e = []; for (const f of this.index.values()) { - f.then && d.push(f); + f.then && e.push(f); } - if (d.length) { + if (e.length) { const f = this; - return Promise.all(d).then(function(g) { + return Promise.all(e).then(function(g) { const h = new Map(); let k = 0; for (const m of f.index.entries()) { const n = m[0]; var l = m[1]; if (l.then) { - l = d[k].encoder || {}; + l = e[k].encoder || {}; let p = h.get(l); p || (p = l.encode ? l : new G(l), h.set(l, p)); l = g[k]; @@ -1581,101 +1581,101 @@ t.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); } - let c = this.field; + let b = this.field; if (this.tag) { for (let f = 0, g; f < this.R.length; f++) { g = this.R[f]; - var b = void 0; - this.index.set(g, b = new N({}, this.reg)); - c === this.field && (c = c.slice(0)); - c.push(g); - b.tag = this.tag.get(g); + var c = void 0; + this.index.set(g, c = new N({}, this.reg)); + b === this.field && (b = b.slice(0)); + b.push(g); + c.tag = this.tag.get(g); } } - b = []; - const e = {db:a.db, type:a.type, fastupdate:a.fastupdate}; - for (let f = 0, g, h; f < c.length; f++) { - e.field = h = c[f]; + c = []; + const d = {db:a.db, type:a.type, fastupdate:a.fastupdate}; + for (let f = 0, g, h; f < b.length; f++) { + d.field = h = b[f]; g = this.index.get(h); - const k = new a.constructor(a.id, e); + const k = new a.constructor(a.id, d); k.id = a.id; - b[f] = k.mount(g); + c[f] = k.mount(g); g.document = !0; f ? g.bypass = !0 : g.store = this.store; } - const d = this; - return this.db = Promise.all(b).then(function() { - d.db = !0; + const e = this; + return this.db = Promise.all(c).then(function() { + e.db = !0; }); }; -t.commit = async function(a, c) { - const b = []; - for (const e of this.index.values()) { - b.push(e.commit(a, c)); +t.commit = async function(a, b) { + const c = []; + for (const d of this.index.values()) { + c.push(d.commit(a, b)); } - await Promise.all(b); + await Promise.all(c); this.reg.clear(); }; t.destroy = function() { const a = []; - for (const c of this.index.values()) { - a.push(c.destroy()); + for (const b of this.index.values()) { + a.push(b.destroy()); } return Promise.all(a); }; -function Ua(a, c) { - const b = new Map(); - let e = c.index || c.field || c; - D(e) && (e = [e]); - for (let d = 0, f, g; d < e.length; d++) { - f = e[d]; +function Ua(a, b) { + const c = new Map(); + let d = b.index || b.field || b; + D(d) && (d = [d]); + for (let e = 0, f, g; e < d.length; e++) { + f = d[e]; D(f) || (g = f, f = f.field); g = aa(g) ? Object.assign({}, a, g) : a; if (this.worker) { const h = new P(g); h.encoder = g.encoder; - b.set(f, h); + c.set(f, h); } - this.worker || b.set(f, new N(g, this.reg)); - g.custom ? this.F[d] = g.custom : (this.F[d] = Ta(f, this.J), g.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = g.filter)); - this.field[d] = f; + this.worker || c.set(f, new N(g, this.reg)); + g.custom ? this.F[e] = g.custom : (this.F[e] = Ta(f, this.J), g.filter && ("string" === typeof this.F[e] && (this.F[e] = new String(this.F[e])), this.F[e].I = g.filter)); + this.field[e] = f; } if (this.C) { - a = c.store; + a = b.store; D(a) && (a = [a]); - for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = Ta(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); + for (let e = 0, f, g; e < a.length; e++) { + f = a[e], g = f.field || f, f.custom ? (this.C[e] = f.custom, f.custom.V = g) : (this.C[e] = Ta(g, this.J), f.filter && ("string" === typeof this.C[e] && (this.C[e] = new String(this.C[e])), this.C[e].I = f.filter)); } } - return b; + return c; } -function Ta(a, c) { - const b = a.split(":"); - let e = 0; - for (let d = 0; d < b.length; d++) { - a = b[d], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); +function Ta(a, b) { + const c = a.split(":"); + let d = 0; + for (let e = 0; e < c.length; e++) { + a = c[e], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (b[d] = !0), a && (c[d++] = a); } - e < b.length && (b.length = e); - return 1 < e ? b : b[0]; + d < c.length && (c.length = d); + return 1 < d ? c : c[0]; } -t.append = function(a, c) { - return this.add(a, c, !0); +t.append = function(a, b) { + return this.add(a, b, !0); }; -t.update = function(a, c) { - return this.remove(a).add(a, c); +t.update = function(a, b) { + return this.remove(a).add(a, b); }; t.remove = function(a) { aa(a) && (a = ca(a, this.key)); - for (var c of this.index.values()) { - c.remove(a, !0); + for (var b of this.index.values()) { + b.remove(a, !0); } if (this.reg.has(a)) { if (this.tag && !this.fastupdate) { - for (let b of this.tag.values()) { - for (let e of b) { - c = e[0]; - const d = e[1], f = d.indexOf(a); - -1 < f && (1 < d.length ? d.splice(f, 1) : b.delete(c)); + for (let c of this.tag.values()) { + for (let d of c) { + b = d[0]; + const e = d[1], f = e.indexOf(a); + -1 < f && (1 < e.length ? e.splice(f, 1) : c.delete(b)); } } } @@ -1687,13 +1687,13 @@ t.remove = function(a) { }; t.clear = function() { const a = []; - for (const c of this.index.values()) { - const b = c.clear(); - b.then && a.push(b); + for (const b of this.index.values()) { + const c = b.clear(); + c.then && a.push(c); } if (this.tag) { - for (const c of this.tag.values()) { - c.clear(); + for (const b of this.tag.values()) { + b.clear(); } } this.store && this.store.clear(); @@ -1710,121 +1710,121 @@ t.cleanup = function() { return this; }; t.get = function(a) { - return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(c) { - return c[0] && c[0].doc || null; + return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(b) { + return b[0] && b[0].doc || null; }) : this.store.get(a) || null; }; -t.set = function(a, c) { - "object" === typeof a && (c = a, a = ca(c, this.key)); - this.store.set(a, c); +t.set = function(a, b) { + "object" === typeof a && (b = a, a = ca(b, this.key)); + this.store.set(a, b); return this; }; t.searchCache = Va; -t.export = function(a, c, b = 0, e = 0) { - if (b < this.field.length) { - const g = this.field[b]; - if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { +t.export = function(a, b, c = 0, d = 0) { + if (c < this.field.length) { + const g = this.field[c]; + if ((b = this.index.get(g).export(a, g, c, d = 1)) && b.then) { const h = this; - return c.then(function() { - return h.export(a, g, b + 1); + return b.then(function() { + return h.export(a, g, c + 1); }); } - return this.export(a, g, b + 1); + return this.export(a, g, c + 1); } - let d, f; - switch(e) { + let e, f; + switch(d) { case 0: - d = "reg"; + e = "reg"; f = wa(this.reg); - c = null; + b = null; break; case 1: - d = "tag"; + e = "tag"; f = this.tag && ua(this.tag, this.reg.size); - c = null; + b = null; break; case 2: - d = "doc"; + e = "doc"; f = this.store && sa(this.store); - c = null; + b = null; break; default: return; } - return ya.call(this, a, c, d, f, b, e); + return ya.call(this, a, b, e, f, c, d); }; -t.import = function(a, c) { - var b = a.split("."); - "json" === b[b.length - 1] && b.pop(); - const e = 2 < b.length ? b[0] : ""; - b = 2 < b.length ? b[2] : b[1]; - if (this.worker && e) { - return this.index.get(e).import(a); +t.import = function(a, b) { + var c = a.split("."); + "json" === c[c.length - 1] && c.pop(); + const d = 2 < c.length ? c[0] : ""; + c = 2 < c.length ? c[2] : c[1]; + if (this.worker && d) { + return this.index.get(d).import(a); } - if (c) { - "string" === typeof c && (c = JSON.parse(c)); - if (e) { - return this.index.get(e).import(b, c); + if (b) { + "string" === typeof b && (b = JSON.parse(b)); + if (d) { + return this.index.get(d).import(c, b); } - switch(b) { + switch(c) { case "reg": this.fastupdate = !1; - this.reg = xa(c, this.reg); - for (let d = 0, f; d < this.field.length; d++) { - f = this.index.get(this.field[d]), f.fastupdate = !1, f.reg = this.reg; + this.reg = xa(b, this.reg); + for (let e = 0, f; e < this.field.length; e++) { + f = this.index.get(this.field[e]), f.fastupdate = !1, f.reg = this.reg; } if (this.worker) { - c = []; - for (const d of this.index.values()) { - c.push(d.import(a)); + b = []; + for (const e of this.index.values()) { + b.push(e.import(a)); } - return Promise.all(c); + return Promise.all(b); } break; case "tag": - this.tag = va(c, this.tag); + this.tag = va(b, this.tag); break; case "doc": - this.store = ta(c, this.store); + this.store = ta(b, this.store); } } }; la(U.prototype); -function Va(a, c, b) { - const e = ("object" === typeof a ? "" + a.query : a).toLowerCase(); +function Va(a, b, c) { + const d = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new X()); - let d = this.cache.get(e); - if (!d) { - d = this.search(a, c, b); - if (d.then) { + let e = this.cache.get(d); + if (!e) { + e = this.search(a, b, c); + if (e.then) { const f = this; - d.then(function(g) { - f.cache.set(e, g); + e.then(function(g) { + f.cache.set(d, g); return g; }); } - this.cache.set(e, d); + this.cache.set(d, e); } - return d; + return e; } function X(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -X.prototype.set = function(a, c) { - this.cache.set(this.h = a, c); +X.prototype.set = function(a, b) { + this.cache.set(this.h = a, b); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; X.prototype.get = function(a) { - const c = this.cache.get(a); - c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c)); - return c; + const b = this.cache.get(a); + b && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, b)); + return b; }; X.prototype.remove = function(a) { - for (const c of this.cache) { - const b = c[0]; - c[1].includes(a) && this.cache.delete(b); + for (const b of this.cache) { + const c = b[0]; + b[1].includes(a) && this.cache.delete(c); } }; X.prototype.clear = function() { @@ -1837,115 +1837,117 @@ const Ya = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], const Za = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), $a = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; const ab = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; var bb = {Exact:Wa, Default:Xa, Normalize:Xa, LatinBalance:{mapper:Ya}, LatinAdvanced:{mapper:Ya, matcher:Za, replacer:$a}, LatinExtra:{mapper:Ya, replacer:$a.concat([/(?!^)[aeo]/g, ""]), matcher:Za}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (let b = 0; b < a.length; b++) { - var c = a[b]; - let e = c.charAt(0), d = ab[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = ab[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + for (let c = 0; c < a.length; c++) { + var b = a[c]; + let d = b.charAt(0), e = ab[d]; + for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = ab[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { } - a[b] = e; + a[c] = d; } }}, CJK:{split:""}, LatinExact:Wa, LatinDefault:Xa, LatinSimple:Xa}; -N.prototype.remove = function(a, c) { - const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); - if (b) { +N.prototype.remove = function(a, b) { + const c = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); + if (c) { if (this.fastupdate) { - for (let e = 0, d; e < b.length; e++) { - if (d = b[e]) { - if (2 > d.length) { - d.pop(); + for (let d = 0, e; d < c.length; d++) { + if (e = c[d]) { + if (2 > e.length) { + e.pop(); } else { - const f = d.indexOf(a); - f === b.length - 1 ? d.pop() : d.splice(f, 1); + const f = e.indexOf(a); + f === c.length - 1 ? e.pop() : e.splice(f, 1); } } } } else { cb(this.map, a), this.depth && cb(this.ctx, a); } - c || this.reg.delete(a); + b || this.reg.delete(a); } this.db && (this.commit_task.push({del:a}), this.T && db(this)); this.cache && this.cache.remove(a); return this; }; -function cb(a, c) { - let b = 0; - var e = "undefined" === typeof c; +function cb(a, b) { + let c = 0; + var d = "undefined" === typeof b; if (a.constructor === Array) { - for (let d = 0, f, g; d < a.length; d++) { - if ((f = a[d]) && f.length) { - if (e) { - b++; + for (let e = 0, f, g; e < a.length; e++) { + if ((f = a[e]) && f.length) { + if (d) { + c++; } else { - if (g = f.indexOf(c), 0 <= g) { - 1 < f.length ? (f.splice(g, 1), b++) : delete a[d]; + if (g = f.indexOf(b), 0 <= g) { + 1 < f.length ? (f.splice(g, 1), c++) : delete a[e]; break; } else { - b++; + c++; } } } } } else { - for (let d of a.entries()) { - e = d[0]; - const f = cb(d[1], c); - f ? b += f : a.delete(e); + for (let e of a.entries()) { + d = e[0]; + const f = cb(e[1], b); + f ? c += f : a.delete(d); } } - return b; + return c; } ;const eb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -N.prototype.add = function(a, c, b, e) { - if (c && (a || 0 === a)) { - if (!e && !b && this.reg.has(a)) { - return this.update(a, c); +N.prototype.add = function(a, b, c, d) { + if (b && (a || 0 === a)) { + if (!d && !c && this.reg.has(a)) { + return this.update(a, b); } - c = this.encoder.encode(c); - if (e = c.length) { - const l = A(), m = A(), n = this.depth, p = this.resolution; - for (let r = 0; r < e; r++) { - let q = c[this.rtl ? e - 1 - r : r]; - var d = q.length; - if (d && (n || !m[q])) { - var f = this.score ? this.score(c, q, r, null, 0) : fb(p, e, r), g = ""; + d = this.depth; + b = this.encoder.encode(b, !d); + const l = b.length; + if (l) { + const m = A(), n = A(), p = this.resolution; + for (let r = 0; r < l; r++) { + let q = b[this.rtl ? l - 1 - r : r]; + var e = q.length; + if (e && (d || !n[q])) { + var f = this.score ? this.score(b, q, r, null, 0) : fb(p, l, r), g = ""; switch(this.tokenize) { case "full": - if (2 < d) { - for (let u = 0, v; u < d; u++) { - for (f = d; f > u; f--) { + if (2 < e) { + for (let u = 0, v; u < e; u++) { + for (f = e; f > u; f--) { g = q.substring(u, f); - v = this.rtl ? d - 1 - u : u; - var h = this.score ? this.score(c, q, r, g, v) : fb(p, e, r, d, v); - gb(this, m, g, h, a, b); + v = this.rtl ? e - 1 - u : u; + var h = this.score ? this.score(b, q, r, g, v) : fb(p, l, r, e, v); + gb(this, n, g, h, a, c); } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (h = d - 1; 0 < h; h--) { - g = q[this.rtl ? d - 1 - h : h] + g; - var k = this.score ? this.score(c, q, r, g, h) : fb(p, e, r, d, h); - gb(this, m, g, k, a, b); + if (1 < e) { + for (h = e - 1; 0 < h; h--) { + g = q[this.rtl ? e - 1 - h : h] + g; + var k = this.score ? this.score(b, q, r, g, h) : fb(p, l, r, e, h); + gb(this, n, g, k, a, c); } g = ""; } case "forward": - if (1 < d) { - for (h = 0; h < d; h++) { - g += q[this.rtl ? d - 1 - h : h], gb(this, m, g, f, a, b); + if (1 < e) { + for (h = 0; h < e; h++) { + g += q[this.rtl ? e - 1 - h : h], gb(this, n, g, f, a, c); } break; } default: - if (gb(this, m, q, f, a, b), n && 1 < e && r < e - 1) { - for (d = A(), g = this.U, f = q, h = Math.min(n + 1, this.rtl ? r + 1 : e - r), d[f] = 1, k = 1; k < h; k++) { - if ((q = c[this.rtl ? e - 1 - r - k : r + k]) && !d[q]) { - d[q] = 1; - const u = this.score ? this.score(c, f, r, q, k - 1) : fb(g + (e / 2 > g ? 0 : 1), e, r, h - 1, k - 1), v = this.bidirectional && q > f; - gb(this, l, v ? f : q, u, a, b, v ? q : f); + if (gb(this, n, q, f, a, c), d && 1 < l && r < l - 1) { + for (e = A(), g = this.U, f = q, h = Math.min(d + 1, this.rtl ? r + 1 : l - r), e[f] = 1, k = 1; k < h; k++) { + if ((q = b[this.rtl ? l - 1 - r - k : r + k]) && !e[q]) { + e[q] = 1; + const u = this.score ? this.score(b, f, r, q, k - 1) : fb(g + (l / 2 > g ? 0 : 1), l, r, h - 1, k - 1), v = this.bidirectional && q > f; + gb(this, m, v ? f : q, u, a, c, v ? q : f); } } } @@ -1954,160 +1956,160 @@ N.prototype.add = function(a, c, b, e) { } this.fastupdate || this.reg.add(a); } else { - c = ""; + b = ""; } } - this.db && (c || this.commit_task.push({del:a}), this.T && db(this)); + this.db && (b || this.commit_task.push({del:a}), this.T && db(this)); return this; }; -function gb(a, c, b, e, d, f, g) { +function gb(a, b, c, d, e, f, g) { let h = g ? a.ctx : a.map, k; - if (!c[b] || g && !(k = c[b])[g]) { - if (g ? (c = k || (c[b] = A()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = k = []), h = h[e] || (h[e] = []), !f || !h.includes(d)) { + if (!b[c] || g && !(k = b[c])[g]) { + if (g ? (b = k || (b[c] = A()), b[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : b[c] = 1, (k = h.get(c)) ? h = k : h.set(c, h = k = []), h = h[d] || (h[d] = []), !f || !h.includes(e)) { if (h.length === 2 ** 31 - 1) { - c = new R(h); + b = new R(h); if (a.fastupdate) { for (let l of a.reg.values()) { - l.includes(h) && (l[l.indexOf(h)] = c); + l.includes(h) && (l[l.indexOf(h)] = b); } } - k[e] = h = c; + k[d] = h = b; } - h.push(d); - a.fastupdate && ((e = a.reg.get(d)) ? e.push(h) : a.reg.set(d, [h])); + h.push(e); + a.fastupdate && ((d = a.reg.get(e)) ? d.push(h) : a.reg.set(e, [h])); } } } -function fb(a, c, b, e, d) { - return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; +function fb(a, b, c, d, e) { + return c && 1 < a ? b + (d || 0) <= a ? c + (e || 0) : (a - 1) / (b + (d || 0)) * (c + (e || 0)) + 1 | 0 : 0; } -;N.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); - let e = [], d, f, g, h = 0, k, l, m, n, p; - b ? (a = b.query || a, c = b.limit || c, h = b.offset || 0, f = b.context, g = b.suggest, p = (k = !1 !== b.resolve) && b.enrich, m = b.boost, n = b.resolution, l = this.db && b.tag) : k = this.resolve; - let r = this.encoder.encode(a); - d = r.length; - c = c || (k ? 100 : 0); - if (1 === d) { - return hb.call(this, r[0], "", c, h, k, p, l); - } +;N.prototype.search = function(a, b, c) { + c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); + let d = [], e, f, g, h = 0, k, l, m, n, p; + c ? (a = c.query || a, b = c.limit || b, h = c.offset || 0, f = c.context, g = c.suggest, p = (k = !1 !== c.resolve) && c.enrich, m = c.boost, n = c.resolution, l = this.db && c.tag) : k = this.resolve; f = this.depth && !1 !== f; - if (2 === d && f && !g) { - return hb.call(this, r[1], r[0], c, h, k, p, l); + let r = this.encoder.encode(a, !f); + e = r.length; + b = b || (k ? 100 : 0); + if (1 === e) { + return hb.call(this, r[0], "", b, h, k, p, l); + } + if (2 === e && f && !g) { + return hb.call(this, r[1], r[0], b, h, k, p, l); } let q = A(), u = 0, v; f && (v = r[0], u = 1); n || 0 === n || (n = v ? this.U : this.resolution); if (this.db) { - if (this.db.search && (a = this.db.search(this, r, c, h, g, k, p, l), !1 !== a)) { + if (this.db.search && (a = this.db.search(this, r, b, h, g, k, p, l), !1 !== a)) { return a; } const w = this; return async function() { - for (let x, F; u < d; u++) { + for (let x, F; u < e; u++) { if ((F = r[u]) && !q[F]) { q[F] = 1; x = await ib(w, F, v, 0, 0, !1, !1); - if (x = jb(x, e, g, n)) { - e = x; + if (x = jb(x, d, g, n)) { + d = x; break; } - v && (g && x && e.length || (v = F)); + v && (g && x && d.length || (v = F)); } - g && v && u === d - 1 && !e.length && (n = w.resolution, v = "", u = -1, q = A()); + g && v && u === e - 1 && !d.length && (n = w.resolution, v = "", u = -1, q = A()); } - return kb(e, n, c, h, g, m, k); + return kb(d, n, b, h, g, m, k); }(); } - for (let w, x; u < d; u++) { + for (let w, x; u < e; u++) { if ((x = r[u]) && !q[x]) { q[x] = 1; w = ib(this, x, v, 0, 0, !1, !1); - if (w = jb(w, e, g, n)) { - e = w; + if (w = jb(w, d, g, n)) { + d = w; break; } - v && (g && w && e.length || (v = x)); + v && (g && w && d.length || (v = x)); } - g && v && u === d - 1 && !e.length && (n = this.resolution, v = "", u = -1, q = A()); + g && v && u === e - 1 && !d.length && (n = this.resolution, v = "", u = -1, q = A()); } - return kb(e, n, c, h, g, m, k); + return kb(d, n, b, h, g, m, k); }; -function kb(a, c, b, e, d, f, g) { +function kb(a, b, c, d, e, f, g) { let h = a.length, k = a; if (1 < h) { - k = Fa(a, c, b, e, d, f, g); + k = Fa(a, b, c, d, e, f, g); } else if (1 === h) { - return g ? Ia.call(null, a[0], b, e) : new W(a[0]); + return g ? Ia.call(null, a[0], c, d) : new W(a[0]); } return g ? k : new W(k); } -function hb(a, c, b, e, d, f, g) { - a = ib(this, a, c, b, e, d, f, g); +function hb(a, b, c, d, e, f, g) { + a = ib(this, a, b, c, d, e, f, g); return this.db ? a.then(function(h) { - return d ? h || [] : new W(h); - }) : a && a.length ? d ? Ia.call(this, a, b, e) : new W(a) : d ? [] : new W(); + return e ? h || [] : new W(h); + }) : a && a.length ? e ? Ia.call(this, a, c, d) : new W(a) : e ? [] : new W(); } -function jb(a, c, b, e) { - let d = []; +function jb(a, b, c, d) { + let e = []; if (a && a.length) { - if (a.length <= e) { - c.push(a); + if (a.length <= d) { + b.push(a); return; } - for (let f = 0, g; f < e; f++) { + for (let f = 0, g; f < d; f++) { if (g = a[f]) { - d[f] = g; + e[f] = g; } } - if (d.length) { - c.push(d); + if (e.length) { + b.push(e); return; } } - if (!b) { - return d; + if (!c) { + return e; } } -function ib(a, c, b, e, d, f, g, h) { +function ib(a, b, c, d, e, f, g, h) { let k; - b && (k = a.bidirectional && c > b) && (k = b, b = c, c = k); + c && (k = a.bidirectional && b > c) && (k = c, c = b, b = k); if (a.db) { - return a.db.get(c, b, e, d, f, g, h); + return a.db.get(b, c, d, e, f, g, h); } - a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); + a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); return a; } -;function N(a, c) { +;function N(a, b) { if (!this || this.constructor !== N) { return new N(a); } if (a) { - var b = D(a) ? a : a.preset; - b && (eb[b] || console.warn("Preset not found: " + b), a = Object.assign({}, eb[b], a)); + var c = D(a) ? a : a.preset; + c && (eb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, eb[c], a)); } else { a = {}; } - b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? bb[a.encoder] : a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new G(d) : {encode:d}; + c = a.context; + const d = !0 === c ? {depth:1} : c || {}, e = D(a.encoder) ? bb[a.encoder] : a.encode || a.encoder || {}; + this.encoder = e.encode ? e : "object" === typeof e ? new G(e) : {encode:e}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; - this.depth = "strict" === b && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.tokenize = c = (c = a.tokenize) && "default" !== c && "exact" !== c && c || "strict"; + this.depth = "strict" === c && d.depth || 0; + this.bidirectional = !1 !== d.bidirectional; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - e && e.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); - (b = a.keystore || 0) && (this.keystore = b); - this.map = b ? new S(b) : new Map(); - this.ctx = b ? new S(b) : new Map(); - this.reg = c || (this.fastupdate ? b ? new S(b) : new Map() : b ? new T(b) : new Set()); - this.U = e.resolution || 3; - this.rtl = d.rtl || a.rtl || !1; - this.cache = (b = a.cache || null) && new X(b); + d && d.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + (c = a.keystore || 0) && (this.keystore = c); + this.map = c ? new S(c) : new Map(); + this.ctx = c ? new S(c) : new Map(); + this.reg = b || (this.fastupdate ? c ? new S(c) : new Map() : c ? new T(c) : new Set()); + this.U = d.resolution || 3; + this.rtl = e.rtl || a.rtl || !1; + this.cache = (c = a.cache || null) && new X(c); this.resolve = !1 !== a.resolve; - if (b = a.db) { - this.db = this.mount(b); + if (c = a.db) { + this.db = this.mount(c); } this.T = !1 !== a.commit; this.commit_task = []; @@ -2119,9 +2121,9 @@ t.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); }; -t.commit = function(a, c) { +t.commit = function(a, b) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); - return this.db.commit(this, a, c); + return this.db.commit(this, a, b); }; t.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); @@ -2141,15 +2143,15 @@ t.clear = function() { this.db && (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [{clear:!0}]); return this; }; -t.append = function(a, c) { - return this.add(a, c, !0); +t.append = function(a, b) { + return this.add(a, b, !0); }; t.contain = function(a) { return this.db ? this.db.has(a) : this.reg.has(a); }; -t.update = function(a, c) { - const b = this, e = this.remove(a); - return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); +t.update = function(a, b) { + const c = this, d = this.remove(a); + return d && d.then ? d.then(() => c.add(a, b)) : this.add(a, b); }; t.cleanup = function() { if (!this.fastupdate) { @@ -2160,77 +2162,77 @@ t.cleanup = function() { return this; }; t.searchCache = Va; -t.export = function(a, c, b = 0, e = 0) { - let d, f; - switch(e) { +t.export = function(a, b, c = 0, d = 0) { + let e, f; + switch(d) { case 0: - d = "reg"; + e = "reg"; f = wa(this.reg); break; case 1: - d = "cfg"; + e = "cfg"; f = null; break; case 2: - d = "map"; + e = "map"; f = sa(this.map, this.reg.size); break; case 3: - d = "ctx"; + e = "ctx"; f = ua(this.ctx, this.reg.size); break; default: return; } - return ya.call(this, a, c, d, f, b, e); + return ya.call(this, a, b, e, f, c, d); }; -t.import = function(a, c) { - if (c) { - switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { +t.import = function(a, b) { + if (b) { + switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = xa(c, this.reg); + this.reg = xa(b, this.reg); break; case "map": - this.map = ta(c, this.map); + this.map = ta(b, this.map); break; case "ctx": - this.ctx = va(c, this.ctx); + this.ctx = va(b, this.ctx); } } }; t.serialize = function(a = !0) { - let c = "", b = "", e = ""; + let b = "", c = "", d = ""; if (this.reg.size) { let f; - for (var d of this.reg.keys()) { - f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); + for (var e of this.reg.keys()) { + f || (f = typeof e), b += (b ? "," : "") + ("string" === f ? '"' + e + '"' : e); } - c = "index.reg=new Set([" + c + "]);"; - b = za(this.map, f); - b = "index.map=new Map([" + b + "]);"; + b = "index.reg=new Set([" + b + "]);"; + c = za(this.map, f); + c = "index.map=new Map([" + c + "]);"; for (const g of this.ctx.entries()) { - d = g[0]; + e = g[0]; let h = za(g[1], f); h = "new Map([" + h + "])"; - h = '["' + d + '",' + h + "]"; - e += (e ? "," : "") + h; + h = '["' + e + '",' + h + "]"; + d += (d ? "," : "") + h; } - e = "index.ctx=new Map([" + e + "]);"; + d = "index.ctx=new Map([" + d + "]);"; } - return a ? "function inject(index){" + c + b + e + "}" : c + b + e; + return a ? "function inject(index){" + b + c + d + "}" : b + c + d; }; la(N.prototype); const lb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), mb = ["map", "ctx", "tag", "reg", "cfg"], Y = A(); -function nb(a, c = {}) { +function nb(a, b = {}) { if (!this || this.constructor !== nb) { - return new nb(a, c); + return new nb(a, b); } - "object" === typeof a && (c = a, a = a.name); + "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""); - this.field = c.field ? c.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; - this.type = c.type; + this.field = b.field ? b.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; + this.type = b.type; this.fastupdate = this.support_tag_search = !1; this.db = null; this.h = {}; @@ -2251,18 +2253,18 @@ t.open = function() { navigator.storage && navigator.storage.persist(); Y[a.id] || (Y[a.id] = []); Y[a.id].push(a.field); - const c = lb.open(a.id, 1); - c.onupgradeneeded = function() { - const b = a.db = this.result; - for (let e = 0, d; e < mb.length; e++) { - d = mb[e]; + const b = lb.open(a.id, 1); + b.onupgradeneeded = function() { + const c = a.db = this.result; + for (let d = 0, e; d < mb.length; d++) { + e = mb[d]; for (let f = 0, g; f < Y[a.id].length; f++) { - g = Y[a.id][f], b.objectStoreNames.contains(d + ("reg" !== d ? g ? ":" + g : "" : "")) || b.createObjectStore(d + ("reg" !== d ? g ? ":" + g : "" : "")); + g = Y[a.id][f], c.objectStoreNames.contains(e + ("reg" !== e ? g ? ":" + g : "" : "")) || c.createObjectStore(e + ("reg" !== e ? g ? ":" + g : "" : "")); } } }; - return a.db = Z(c, function(b) { - a.db = b; + return a.db = Z(b, function(c) { + a.db = c; a.db.onversionchange = function() { a.close(); }; @@ -2278,42 +2280,42 @@ t.destroy = function() { }; t.clear = function() { const a = []; - for (let b = 0, e; b < mb.length; b++) { - e = mb[b]; - for (let d = 0, f; d < Y[this.id].length; d++) { - f = Y[this.id][d], a.push(e + ("reg" !== e ? f ? ":" + f : "" : "")); + for (let c = 0, d; c < mb.length; c++) { + d = mb[c]; + for (let e = 0, f; e < Y[this.id].length; e++) { + f = Y[this.id][e], a.push(d + ("reg" !== d ? f ? ":" + f : "" : "")); } } - const c = this.db.transaction(a, "readwrite"); - for (let b = 0; b < a.length; b++) { - c.objectStore(a[b]).clear(); + const b = this.db.transaction(a, "readwrite"); + for (let c = 0; c < a.length; c++) { + b.objectStore(a[c]).clear(); } - return Z(c); + return Z(b); }; -t.get = function(a, c, b = 0, e = 0, d = !0, f = !1) { - a = this.db.transaction((c ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((c ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(c ? c + ":" + a : a); +t.get = function(a, b, c = 0, d = 0, e = !0, f = !1) { + a = this.db.transaction((b ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((b ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(b ? b + ":" + a : a); const g = this; return Z(a).then(function(h) { let k = []; if (!h || !h.length) { return k; } - if (d) { - if (!b && !e && 1 === h.length) { + if (e) { + if (!c && !d && 1 === h.length) { return h[0]; } for (let l = 0, m; l < h.length; l++) { if ((m = h[l]) && m.length) { - if (e >= m.length) { - e -= m.length; + if (d >= m.length) { + d -= m.length; continue; } - const n = b ? e + Math.min(m.length - e, b) : m.length; - for (let p = e; p < n; p++) { + const n = c ? d + Math.min(m.length - d, c) : m.length; + for (let p = d; p < n; p++) { k.push(m[p]); } - e = 0; - if (k.length === b) { + d = 0; + if (k.length === c) { break; } } @@ -2323,78 +2325,78 @@ t.get = function(a, c, b = 0, e = 0, d = !0, f = !1) { return h; }); }; -t.tag = function(a, c = 0, b = 0, e = !1) { +t.tag = function(a, b = 0, c = 0, d = !1) { a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a); - const d = this; + const e = this; return Z(a).then(function(f) { - if (!f || !f.length || b >= f.length) { + if (!f || !f.length || c >= f.length) { return []; } - if (!c && !b) { + if (!b && !c) { return f; } - f = f.slice(b, b + c); - return e ? d.enrich(f) : f; + f = f.slice(c, c + b); + return d ? e.enrich(f) : f; }); }; t.enrich = function(a) { "object" !== typeof a && (a = [a]); - const c = this.db.transaction("reg", "readonly").objectStore("reg"), b = []; - for (let e = 0; e < a.length; e++) { - b[e] = Z(c.get(a[e])); + const b = this.db.transaction("reg", "readonly").objectStore("reg"), c = []; + for (let d = 0; d < a.length; d++) { + c[d] = Z(b.get(a[d])); } - return Promise.all(b).then(function(e) { - for (let d = 0; d < e.length; d++) { - e[d] = {id:a[d], doc:e[d] ? JSON.parse(e[d]) : null}; + return Promise.all(c).then(function(d) { + for (let e = 0; e < d.length; e++) { + d[e] = {id:a[e], doc:d[e] ? JSON.parse(d[e]) : null}; } - return e; + return d; }); }; t.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); - return Z(a).then(function(c) { - return !!c; + return Z(a).then(function(b) { + return !!b; }); }; t.search = null; t.info = function() { }; -t.transaction = function(a, c, b) { +t.transaction = function(a, b, c) { a += "reg" !== a ? this.field ? ":" + this.field : "" : ""; - let e = this.h[a + ":" + c]; - if (e) { - return b.call(this, e); + let d = this.h[a + ":" + b]; + if (d) { + return c.call(this, d); } - let d = this.db.transaction(a, c); - this.h[a + ":" + c] = e = d.objectStore(a); - const f = b.call(this, e); - this.h[a + ":" + c] = null; - return Z(d).finally(function() { - d = e = null; + let e = this.db.transaction(a, b); + this.h[a + ":" + b] = d = e.objectStore(a); + const f = c.call(this, d); + this.h[a + ":" + b] = null; + return Z(e).finally(function() { + e = d = null; return f; }); }; -t.commit = async function(a, c, b) { - if (c) { +t.commit = async function(a, b, c) { + if (b) { await this.clear(), a.commit_task = []; } else { - let e = a.commit_task; + let d = a.commit_task; a.commit_task = []; - for (let d = 0, f; d < e.length; d++) { - if (f = e[d], f.clear) { + for (let e = 0, f; e < d.length; e++) { + if (f = d[e], f.clear) { await this.clear(); - c = !0; + b = !0; break; } else { - e[d] = f.del; + d[e] = f.del; } } - c || (b || (e = e.concat(ba(a.reg))), e.length && await this.remove(e)); + b || (c || (d = d.concat(ba(a.reg))), d.length && await this.remove(d)); } - a.reg.size && (await this.transaction("map", "readwrite", function(e) { - for (const d of a.map) { - const f = d[0], g = d[1]; - g.length && (c ? e.put(g, f) : e.get(f).onsuccess = function() { + a.reg.size && (await this.transaction("map", "readwrite", function(d) { + for (const e of a.map) { + const f = e[0], g = e[1]; + g.length && (b ? d.put(g, f) : d.get(f).onsuccess = function() { let h = this.result; var k; if (h && h.length) { @@ -2414,15 +2416,15 @@ t.commit = async function(a, c, b) { } else { h = g, k = 1; } - k && e.put(h, f); + k && d.put(h, f); }); } - }), await this.transaction("ctx", "readwrite", function(e) { - for (const d of a.ctx) { - const f = d[0], g = d[1]; + }), await this.transaction("ctx", "readwrite", function(d) { + for (const e of a.ctx) { + const f = e[0], g = e[1]; for (const h of g) { const k = h[0], l = h[1]; - l.length && (c ? e.put(l, f + ":" + k) : e.get(f + ":" + k).onsuccess = function() { + l.length && (b ? d.put(l, f + ":" + k) : d.get(f + ":" + k).onsuccess = function() { let m = this.result; var n; if (m && m.length) { @@ -2442,85 +2444,85 @@ t.commit = async function(a, c, b) { } else { m = l, n = 1; } - n && e.put(m, f + ":" + k); + n && d.put(m, f + ":" + k); }); } } - }), a.store ? await this.transaction("reg", "readwrite", function(e) { - for (const d of a.store) { - const f = d[0], g = d[1]; - e.put("object" === typeof g ? JSON.stringify(g) : 1, f); + }), a.store ? await this.transaction("reg", "readwrite", function(d) { + for (const e of a.store) { + const f = e[0], g = e[1]; + d.put("object" === typeof g ? JSON.stringify(g) : 1, f); } - }) : a.bypass || await this.transaction("reg", "readwrite", function(e) { - for (const d of a.reg.keys()) { - e.put(1, d); + }) : a.bypass || await this.transaction("reg", "readwrite", function(d) { + for (const e of a.reg.keys()) { + d.put(1, e); } - }), a.tag && await this.transaction("tag", "readwrite", function(e) { - for (const d of a.tag) { - const f = d[0], g = d[1]; - g.length && (e.get(f).onsuccess = function() { + }), a.tag && await this.transaction("tag", "readwrite", function(d) { + for (const e of a.tag) { + const f = e[0], g = e[1]; + g.length && (d.get(f).onsuccess = function() { let h = this.result; h = h && h.length ? h.concat(g) : g; - e.put(h, f); + d.put(h, f); }); } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function ob(a, c, b) { - const e = a.value; - let d, f = 0; - for (let g = 0, h; g < e.length; g++) { - if (h = b ? e : e[g]) { - for (let k = 0, l, m; k < c.length; k++) { - if (m = c[k], l = h.indexOf(m), 0 <= l) { - if (d = 1, 1 < h.length) { +function ob(a, b, c) { + const d = a.value; + let e, f = 0; + for (let g = 0, h; g < d.length; g++) { + if (h = c ? d : d[g]) { + for (let k = 0, l, m; k < b.length; k++) { + if (m = b[k], l = h.indexOf(m), 0 <= l) { + if (e = 1, 1 < h.length) { h.splice(l, 1); } else { - e[g] = []; + d[g] = []; break; } } } f += h.length; } - if (b) { + if (c) { break; } } - f ? d && a.update(e) : a.delete(); + f ? e && a.update(d) : a.delete(); a.continue(); } t.remove = function(a) { "object" !== typeof a && (a = [a]); - return Promise.all([this.transaction("map", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && ob(b, a); + return Promise.all([this.transaction("map", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && ob(c, a); }; - }), this.transaction("ctx", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && ob(b, a); + }), this.transaction("ctx", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && ob(c, a); }; - }), this.transaction("tag", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && ob(b, a, !0); + }), this.transaction("tag", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && ob(c, a, !0); }; - }), this.transaction("reg", "readwrite", function(c) { - for (let b = 0; b < a.length; b++) { - c.delete(a[b]); + }), this.transaction("reg", "readwrite", function(b) { + for (let c = 0; c < a.length; c++) { + b.delete(a[c]); } })]); }; -function Z(a, c) { - return new Promise((b, e) => { +function Z(a, b) { + return new Promise((c, d) => { a.onsuccess = a.oncomplete = function() { - c && c(this.result); - c = null; - b(this.result); + b && b(this.result); + b = null; + c(this.result); }; - a.onerror = a.onblocked = e; + a.onerror = a.onblocked = d; a = null; }); } diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index 634a2b5..87f50d5 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -1,94 +1,94 @@ /**! - * FlexSearch.js v0.8.156 (Bundle) + * FlexSearch.js v0.8.157 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var t;function z(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function A(){return Object.create(null)}function D(a){return"string"===typeof a} -function G(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function ba(a,b){if(D(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,da)}catch(d){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:z(c&&new Set(c),null,this.filter);this.dedupe=z(a.dedupe,!0,this.dedupe);this.matcher=z((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=z((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=z((c=a.stemmer)&&new Map(c), -null,this.stemmer);this.replacer=z(a.replacer,null,this.replacer);this.minlength=z(a.minlength,1,this.minlength);this.maxlength=z(a.maxlength,1024,this.maxlength);this.rtl=z(a.rtl,!1,this.rtl);if(this.cache=c=z(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.A+= -(this.A?"|":"")+d;return this};t.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&I(this);return this};t.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&I(this);return this}; +(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var t;function z(a,b,c){const d=typeof c,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(c){if("function"===e&&d===e)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===e?b:a}function A(){return Object.create(null)}function D(a){return"string"===typeof a} +function G(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function ba(a,b){if(D(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; +this.numeric=z(a.numeric,d)}else{try{this.split=z(this.split,da)}catch(e){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:z(c&&new Set(c),null,this.filter);this.dedupe=z(a.dedupe,!0,this.dedupe);this.matcher=z((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=z((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=z((c=a.stemmer)&&new Map(c), +null,this.stemmer);this.replacer=z(a.replacer,null,this.replacer);this.minlength=z(a.minlength,1,this.minlength);this.maxlength=z(a.maxlength,1024,this.maxlength);this.rtl=z(a.rtl,!1,this.rtl);if(this.cache=c=z(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const e of this.matcher.keys())this.h+=(this.h?"|":"")+e;if(this.stemmer)for(const e of this.stemmer.keys())this.A+= +(this.A?"|":"")+e;return this};t.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&I(this);return this};t.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&I(this);return this}; t.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&I(this);return this}; t.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&I(this);return this}; -t.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(I,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ia?a.normalize("NFKD").replace(ia,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength))if(b)c.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.L)if(this.H){var d=this.G.get(g);if(d||""===d){d&&c.push(d);continue}}else this.H=setTimeout(I,50,this);this.stemmer&&2this.stemmer.get(k))); -if(g&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(g&&this.replacer)for(d=0;g&&dthis.S&& -(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function I(a){a.H=null;a.B.clear();a.G.clear()};let K,ja;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":ja=a.options||{};(b=a.factory)?(Function("return "+b)()(self),K=new self.FlexSearch.Index(ja),delete self.FlexSearch):K=new M(ja);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=ja.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await ja.import.call(K,e[0]),K.import(e[0],a)):(d=e&&K[b].apply(K,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} -function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);na?pa||(pa=Date.now()-oa>=this.priority*this.priority*3):(na=setTimeout(qa,0),oa=Date.now());if(pa){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let N=0; -function P(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&d.h[l];m&&(m(k.msg),delete d.h[l])}this.worker=g;this.h=A();if(this.worker){e?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){d.h[++N]=function(){k(d);1E9this.maxlength||b&&e[k]))if(c)b&&(e[k]=1),d.push(k);else if(!this.filter||("function"===typeof this.filter?this.filter(k):!this.filter.has(k))){if(this.cache&&k.length<=this.L)if(this.H){var g=this.G.get(k);if(g||""===g){g&&d.push(g);continue}}else this.H=setTimeout(I,50,this);this.stemmer&&2this.stemmer.get(m)));if(k&&(this.mapper||this.dedupe&&1this.matcher.get(m)));if(k&&this.replacer)for(g=0;k&&gthis.S&&(this.G.clear(),this.L=this.L/1.1|0));!k||b&&e[k]||(b&&(e[k]=1),d.push(k))}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.K&&(this.B.set(a,d),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return d};function I(a){a.H=null;a.B.clear();a.G.clear()};let K,ja;async function ka(a){a=a.data;var b=a.task;const c=a.id;let d=a.args;switch(b){case "init":ja=a.options||{};(b=a.factory)?(Function("return "+b)()(self),K=new self.FlexSearch.Index(ja),delete self.FlexSearch):K=new M(ja);postMessage({id:c});break;default:let e;"export"===b&&(d[1]?(d[0]=ja.export,d[2]=0,d[3]=1):d=null);"import"===b?d[0]&&(a=await ja.import.call(K,d[0]),K.import(d[0],a)):(e=d&&K[b].apply(K,d))&&e.then&&(e=await e);postMessage("search"===b?{id:c,msg:e}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} +function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let d;"function"===typeof c&&(d=c,delete b[b.length-1]);na?pa||(pa=Date.now()-oa>=this.priority*this.priority*3):(na=setTimeout(qa,0),oa=Date.now());if(pa){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const e=this[a].apply(this,b);c=e.then?e:new Promise(f=>f(e));d&&c.then(d);return c}};let N=0; +function P(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=g;this.h=A();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++N]=function(){k(e);1E9=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const h=b.length;if(h&&(d=d.length?d.concat(b):b,c-=h,e&&(a.length-=h),!c))break;b=0}return d} -function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,h,k;g=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} +function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){let f=0;for(let g=0,h,k;gc||e?k.slice(e,c+e):k;else{if(ac||e)k=k.slice(e,c+e)}else{d= -[];for(let n=0,p;ne)e-=p.length;else{if(p.length>c||e)p=p.slice(e,c+e),c-=p.length,e&&(e-=p.length);d.push(p);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,e?V.call(this,a):a;let d=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!d.length&&h>=b)return e?V.call(this,g):g;d.push(g);b-=h;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ga(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};W.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:h,offset:k,enrich:l,resolve:m,suggest:n}=Ja(this,"and",arguments);return La.call(this,f,g,h,k,l,m,n)}return d?this.resolve(b,c,e):this}; -function La(a,b,c,e,d,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Fa(a,b,c,e,g,this.h,f),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};W.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,e,d,f,g)}; -function Ma(a,b,c,e,d,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function Na(a,b,c,e,d){const f=[],g=A();let h=0;for(let k=0,l;kc||e)a=a.slice(e,e+c);d&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;cc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e= +[];for(let n=0,p;nd)d-=p.length;else{if(p.length>c||d)p=p.slice(d,c+d),c-=p.length,d&&(d-=p.length);e.push(p);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,d?V.call(this,a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!e.length&&h>=b)return d?V.call(this,g):g;e.push(g);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=Ga(a,c,d,!1,this.h),d=0));return f?this.resolve(c,d,e):this};W.prototype.and=function(){let a=this.result.length,b,c,d,e;if(!a){const f=arguments[0];f&&(a=!!f.suggest,e=f.resolve,b=f.limit,c=f.offset,d=f.enrich&&e)}if(a){const {O:f,P:g,limit:h,offset:k,enrich:l,resolve:m,suggest:n}=Ja(this,"and",arguments);return La.call(this,f,g,h,k,l,m,n)}return e?this.resolve(b,c,d):this}; +function La(a,b,c,d,e,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Fa(a,b,c,d,g,this.h,f),f?e?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,d,e):this};W.prototype.xor=function(){const {O:a,P:b,limit:c,offset:d,enrich:e,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,d,e,f,g)}; +function Ma(a,b,c,d,e,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,d,f,this.h),f?e?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,d,e):this} +function Na(a,b,c,d,e){const f=[],g=A();let h=0;for(let k=0,l;kc||d)a=a.slice(d,d+c);e&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -X.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:!1,numeric:!1,dedupe:!1};const Xa={};const Ya=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Za=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),$a=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ab={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var bb={Exact:Wa,Default:Xa,Normalize:Xa,LatinBalance:{mapper:Ya},LatinAdvanced:{mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cd.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else cb(this.map,a),this.depth&&cb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&db(this));this.cache&&this.cache.remove(a);return this}; -function cb(a,b){let c=0;var e="undefined"===typeof b;if(a.constructor===Array)for(let d=0,f,g;du;f--){g=q.substring(u,f);v=this.rtl?d-1-u:u;var h=this.score?this.score(b,q,r,g,v):fb(p,e,r,d,v); -gb(this,m,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1), -e,r,h-1,k-1),v=this.bidirectional&&q>f;gb(this,l,v?f:q,u,a,c,v?q:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&db(this));return this}; -function gb(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=A()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){b=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[e]=h=b}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} -function fb(a,b,c,e,d){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,e,d,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=D(a)?a:a.preset;c&&(a=Object.assign({},eb[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=D(a.encoder)?bb[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new H(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.U=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new X(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}t=M.prototype; +t.export=function(a,b,c=0,d=0){if(cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +X.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:!1,numeric:!1,dedupe:!1};const Xa={};const Ya=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Za=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),$a=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ab={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var bb={Exact:Wa,Default:Xa,Normalize:Xa,LatinBalance:{mapper:Ya},LatinAdvanced:{mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;ce.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else cb(this.map,a),this.depth&&cb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&db(this));this.cache&&this.cache.remove(a);return this}; +function cb(a,b){let c=0;var d="undefined"===typeof b;if(a.constructor===Array)for(let e=0,f,g;eu;f--){g=q.substring(u,f);v=this.rtl?e-1-u:u;var h=this.score?this.score(b,q,r,g,v):fb(p, +l,r,e,v);gb(this,n,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1),l,r,h-1,k-1),v=this.bidirectional&&q>f;gb(this,m,v?f:q,u,a,c,v?q:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&db(this));return this}; +function gb(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=A()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} +function fb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=D(a)?a:a.preset;c&&(a=Object.assign({},eb[c],a))}else a={};c=a.context;const d=!0===c?{depth:1}:c||{},e=D(a.encoder)?bb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new H(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.U=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new X(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}t=M.prototype; t.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};t.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};t.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function db(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} -t.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};t.append=function(a,b){return this.add(a,b,!0)};t.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};t.update=function(a,b){const c=this,e=this.remove(a);return e&&e.then?e.then(()=>c.add(a,b)):this.add(a,b)}; -t.cleanup=function(){if(!this.fastupdate)return this;cb(this.map);this.depth&&cb(this.ctx);return this};t.searchCache=Va;t.export=function(a,b,c=0,e=0){let d,f;switch(e){case 0:d="reg";f=wa(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=sa(this.map,this.reg.size);break;case 3:d="ctx";f=ua(this.ctx,this.reg.size);break;default:return}return ya.call(this,a,b,d,f,c,e)}; +t.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};t.append=function(a,b){return this.add(a,b,!0)};t.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};t.update=function(a,b){const c=this,d=this.remove(a);return d&&d.then?d.then(()=>c.add(a,b)):this.add(a,b)}; +t.cleanup=function(){if(!this.fastupdate)return this;cb(this.map);this.depth&&cb(this.ctx);return this};t.searchCache=Va;t.export=function(a,b,c=0,d=0){let e,f;switch(d){case 0:e="reg";f=wa(this.reg);break;case 1:e="cfg";f=null;break;case 2:e="map";f=sa(this.map,this.reg.size);break;case 3:e="ctx";f=ua(this.ctx,this.reg.size);break;default:return}return ya.call(this,a,b,e,f,c,d)}; t.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length){e-=m.length;continue}const n=c?e+Math.min(m.length-e,c):m.length;for(let p=e;p=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; -t.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e=m.length){d-=m.length;continue}const n=c?d+Math.min(m.length-d,c):m.length;for(let p=d;p=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})}; +t.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let d=0;d{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};const pb={Index:M,Charset:bb,Encoder:H,Document:U,Worker:P,Resolver:W,IndexedDB:nb,Language:{}},rb="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let sb;(sb=rb.define)&&sb.amd?sb([],function(){return pb}):"object"===typeof rb.exports?rb.exports=pb:rb.FlexSearch=pb;}(this||self)); +function Z(a,b){return new Promise((c,d)=>{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=d;a=null})};const pb={Index:M,Charset:bb,Encoder:H,Document:U,Worker:P,Resolver:W,IndexedDB:nb,Language:{}},rb="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let sb;(sb=rb.define)&&sb.amd?sb([],function(){return pb}):"object"===typeof rb.exports?rb.exports=pb:rb.FlexSearch=pb;}(this||self)); diff --git a/dist/flexsearch.bundle.module.debug.js b/dist/flexsearch.bundle.module.debug.js index fe1f0cd..cf05961 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -1,35 +1,35 @@ /**! - * FlexSearch.js v0.8.156 (Bundle/Module/Debug) + * FlexSearch.js v0.8.157 (Bundle/Module/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ var t; -function z(a, c, b) { - const e = typeof b, d = typeof a; - if ("undefined" !== e) { - if ("undefined" !== d) { - if (b) { - if ("function" === d && e === d) { +function z(a, b, c) { + const d = typeof c, e = typeof a; + if ("undefined" !== d) { + if ("undefined" !== e) { + if (c) { + if ("function" === e && d === e) { return function(h) { - return a(b(h)); + return a(c(h)); }; } - c = a.constructor; - if (c === b.constructor) { - if (c === Array) { - return b.concat(a); + b = a.constructor; + if (b === c.constructor) { + if (b === Array) { + return c.concat(a); } - if (c === Map) { - var f = new Map(b); + if (b === Map) { + var f = new Map(c); for (var g of a) { f.set(g[0], g[1]); } return f; } - if (c === Set) { - g = new Set(b); + if (b === Set) { + g = new Set(c); for (f of a.values()) { g.add(f); } @@ -39,9 +39,9 @@ function z(a, c, b) { } return a; } - return b; + return c; } - return "undefined" === d ? c : a; + return "undefined" === e ? b : a; } function A() { return Object.create(null); @@ -53,28 +53,28 @@ function aa(a) { return "object" === typeof a; } function ba(a) { - const c = []; - for (const b of a.keys()) { - c.push(b); + const b = []; + for (const c of a.keys()) { + b.push(c); } - return c; + return b; } -function ca(a, c) { - if (D(c)) { - a = a[c]; +function ca(a, b) { + if (D(b)) { + a = a[b]; } else { - for (let b = 0; a && b < c.length; b++) { - a = a[c[b]]; + for (let c = 0; a && c < b.length; c++) { + a = a[b[c]]; } } return a; } function da(a) { - let c = 0; - for (let b = 0, e; b < a.length; b++) { - (e = a[b]) && c < e.length && (c = e.length); + let b = 0; + for (let c = 0, d; c < a.length; c++) { + (d = a[c]) && b < d.length && (b = d.length); } - return c; + return b; } ;const ea = /[^\p{L}\p{N}]+/u, fa = /(\d{3})/g, ha = /(\D)(\d{3})/g, ia = /(\d{3})(\D)/g, ja = /[\u0300-\u036f]/g; function G(a = {}) { @@ -92,71 +92,71 @@ function G(a = {}) { t = G.prototype; t.assign = function(a) { this.normalize = z(a.normalize, !0, this.normalize); - let c = a.include, b = c || a.exclude || a.split, e; - if (b || "" === b) { - if ("object" === typeof b && b.constructor !== RegExp) { - let d = ""; - e = !c; - c || (d += "\\p{Z}"); - b.letter && (d += "\\p{L}"); - b.number && (d += "\\p{N}", e = !!c); - b.symbol && (d += "\\p{S}"); - b.punctuation && (d += "\\p{P}"); - b.control && (d += "\\p{C}"); - if (b = b.char) { - d += "object" === typeof b ? b.join("") : b; + let b = a.include, c = b || a.exclude || a.split, d; + if (c || "" === c) { + if ("object" === typeof c && c.constructor !== RegExp) { + let e = ""; + d = !b; + b || (e += "\\p{Z}"); + c.letter && (e += "\\p{L}"); + c.number && (e += "\\p{N}", d = !!b); + c.symbol && (e += "\\p{S}"); + c.punctuation && (e += "\\p{P}"); + c.control && (e += "\\p{C}"); + if (c = c.char) { + e += "object" === typeof c ? c.join("") : c; } try { - this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); + this.split = new RegExp("[" + (b ? "^" : "") + e + "]+", "u"); } catch (f) { - console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; + console.error("Your split configuration:", c, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { - this.split = b, e = !1 === b || 2 > "a1a".split(b).length; + this.split = c, d = !1 === c || 2 > "a1a".split(c).length; } - this.numeric = z(a.numeric, e); + this.numeric = z(a.numeric, d); } else { try { this.split = z(this.split, ea); - } catch (d) { + } catch (e) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } this.numeric = z(a.numeric, z(this.numeric, !0)); } this.prepare = z(a.prepare, null, this.prepare); this.finalize = z(a.finalize, null, this.finalize); - b = a.filter; - this.filter = "function" === typeof b ? b : z(b && new Set(b), null, this.filter); + c = a.filter; + this.filter = "function" === typeof c ? c : z(c && new Set(c), null, this.filter); this.dedupe = z(a.dedupe, !0, this.dedupe); - this.matcher = z((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = z((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = z((b = a.stemmer) && new Map(b), null, this.stemmer); + this.matcher = z((c = a.matcher) && new Map(c), null, this.matcher); + this.mapper = z((c = a.mapper) && new Map(c), null, this.mapper); + this.stemmer = z((c = a.stemmer) && new Map(c), null, this.stemmer); this.replacer = z(a.replacer, null, this.replacer); this.minlength = z(a.minlength, 1, this.minlength); this.maxlength = z(a.maxlength, 1024, this.maxlength); this.rtl = z(a.rtl, !1, this.rtl); - if (this.cache = b = z(a.cache, !0, this.cache)) { - this.H = null, this.S = "number" === typeof b ? b : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; + if (this.cache = c = z(a.cache, !0, this.cache)) { + this.H = null, this.S = "number" === typeof c ? c : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; } this.h = ""; this.M = null; this.A = ""; this.N = null; if (this.matcher) { - for (const d of this.matcher.keys()) { - this.h += (this.h ? "|" : "") + d; + for (const e of this.matcher.keys()) { + this.h += (this.h ? "|" : "") + e; } } if (this.stemmer) { - for (const d of this.stemmer.keys()) { - this.A += (this.A ? "|" : "") + d; + for (const e of this.stemmer.keys()) { + this.A += (this.A ? "|" : "") + e; } } return this; }; -t.addStemmer = function(a, c) { +t.addStemmer = function(a, b) { this.stemmer || (this.stemmer = new Map()); - this.stemmer.set(a, c); + this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; this.N = null; this.cache && H(this); @@ -167,42 +167,42 @@ t.addFilter = function(a) { this.cache && H(this); return this; }; -t.addMapper = function(a, c) { +t.addMapper = function(a, b) { if ("object" === typeof a) { - return this.addReplacer(a, c); + return this.addReplacer(a, b); } if (1 < a.length) { - return this.addMatcher(a, c); + return this.addMatcher(a, b); } this.mapper || (this.mapper = new Map()); - this.mapper.set(a, c); + this.mapper.set(a, b); this.cache && H(this); return this; }; -t.addMatcher = function(a, c) { +t.addMatcher = function(a, b) { if ("object" === typeof a) { - return this.addReplacer(a, c); + return this.addReplacer(a, b); } if (2 > a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, c); + return this.addMapper(a, b); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, c); + this.matcher.set(a, b); this.h += (this.h ? "|" : "") + a; this.M = null; this.cache && H(this); return this; }; -t.addReplacer = function(a, c) { +t.addReplacer = function(a, b) { if ("string" === typeof a) { - return this.addMatcher(a, c); + return this.addMatcher(a, b); } this.replacer || (this.replacer = []); - this.replacer.push(a, c); + this.replacer.push(a, b); this.cache && H(this); return this; }; -t.encode = function(a) { +t.encode = function(a, b) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.B.has(a)) { @@ -216,47 +216,47 @@ t.encode = function(a) { this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(ha, "$1 $2").replace(ia, "$1 $2").replace(fa, "$1 ")); const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let b = [], e = this.split || "" === this.split ? a.split(this.split) : a; - for (let f = 0, g, h; f < e.length; f++) { - if ((g = h = e[f]) && !(g.length < this.minlength || g.length > this.maxlength)) { + let d = [], e = A(), f = this.split || "" === this.split ? a.split(this.split) : [a]; + for (let h = 0, k, l; h < f.length; h++) { + if ((k = l = f[h]) && !(k.length < this.minlength || k.length > this.maxlength || b && e[k])) { if (c) { - b.push(g); + b && (e[k] = 1), d.push(k); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(g) : !this.filter.has(g))) { - if (this.cache && g.length <= this.L) { + if (!this.filter || ("function" === typeof this.filter ? this.filter(k) : !this.filter.has(k))) { + if (this.cache && k.length <= this.L) { if (this.H) { - var d = this.G.get(g); - if (d || "" === d) { - d && b.push(d); + var g = this.G.get(k); + if (g || "" === g) { + g && d.push(g); continue; } } else { this.H = setTimeout(H, 50, this); } } - this.stemmer && 2 < g.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), g = g.replace(this.N, k => this.stemmer.get(k))); - if (g && (this.mapper || this.dedupe && 1 < g.length)) { - d = ""; - for (let k = 0, l = "", m, n; k < g.length; k++) { - m = g.charAt(k), m === l && this.dedupe || ((n = this.mapper && this.mapper.get(m)) || "" === n ? n === l && this.dedupe || !(l = n) || (d += n) : d += l = m); + this.stemmer && 2 < k.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), k = k.replace(this.N, m => this.stemmer.get(m))); + if (k && (this.mapper || this.dedupe && 1 < k.length)) { + g = ""; + for (let m = 0, n = "", p, r; m < k.length; m++) { + p = k.charAt(m), p === n && this.dedupe || ((r = this.mapper && this.mapper.get(p)) || "" === r ? r === n && this.dedupe || !(n = r) || (g += r) : g += n = p); } - g = d; + k = g; } - this.matcher && 1 < g.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), g = g.replace(this.M, k => this.matcher.get(k))); - if (g && this.replacer) { - for (d = 0; g && d < this.replacer.length; d += 2) { - g = g.replace(this.replacer[d], this.replacer[d + 1]); + this.matcher && 1 < k.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), k = k.replace(this.M, m => this.matcher.get(m))); + if (k && this.replacer) { + for (g = 0; k && g < this.replacer.length; g += 2) { + k = k.replace(this.replacer[g], this.replacer[g + 1]); } } - this.cache && h.length <= this.L && (this.G.set(h, g), this.G.size > this.S && (this.G.clear(), this.L = this.L / 1.1 | 0)); - g && b.push(g); + this.cache && l.length <= this.L && (this.G.set(l, k), this.G.size > this.S && (this.G.clear(), this.L = this.L / 1.1 | 0)); + !k || b && e[k] || (b && (e[k] = 1), d.push(k)); } } } } - this.finalize && (b = this.finalize(b) || b); - this.cache && a.length <= this.K && (this.B.set(a, b), this.B.size > this.S && (this.B.clear(), this.K = this.K / 1.1 | 0)); - return b; + this.finalize && (d = this.finalize(d) || d); + this.cache && a.length <= this.K && (this.B.set(a, d), this.B.size > this.S && (this.B.clear(), this.K = this.K / 1.1 | 0)); + return d; }; function H(a) { a.H = null; @@ -266,32 +266,32 @@ function H(a) { ;let I, L; async function ka(a) { a = a.data; - var c = a.task; - const b = a.id; - let e = a.args; - switch(c) { + var b = a.task; + const c = a.id; + let d = a.args; + switch(b) { case "init": L = a.options || {}; - (c = a.factory) ? (Function("return " + c)()(self), I = new self.FlexSearch.Index(L), delete self.FlexSearch) : I = new N(L); - postMessage({id:b}); + (b = a.factory) ? (Function("return " + b)()(self), I = new self.FlexSearch.Index(L), delete self.FlexSearch) : I = new N(L); + postMessage({id:c}); break; default: - let d; - if ("export" === c) { + let e; + if ("export" === b) { if (!L.export || "function" !== typeof L.export) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "export".'); } - e[1] ? (e[0] = L.export, e[2] = 0, e[3] = 1) : e = null; + d[1] ? (d[0] = L.export, d[2] = 0, d[3] = 1) : d = null; } - if ("import" === c) { + if ("import" === b) { if (!L.import || "function" !== typeof L.import) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } - e[0] && (a = await L.import.call(I, e[0]), I.import(e[0], a)); + d[0] && (a = await L.import.call(I, d[0]), I.import(d[0], a)); } else { - (d = e && I[c].apply(I, e)) && d.then && (d = await d); + (e = d && I[b].apply(I, d)) && e.then && (e = await e); } - postMessage("search" === c ? {id:b, msg:d} : {id:b}); + postMessage("search" === b ? {id:c, msg:e} : {id:c}); } } ;function la(a) { @@ -307,47 +307,47 @@ function qa() { } function ma(a) { this[a + "Async"] = function() { - const c = arguments; - var b = c[c.length - 1]; - let e; - "function" === typeof b && (e = b, delete c[c.length - 1]); + const b = arguments; + var c = b[b.length - 1]; + let d; + "function" === typeof c && (d = c, delete b[b.length - 1]); na ? pa || (pa = Date.now() - oa >= this.priority * this.priority * 3) : (na = setTimeout(qa, 0), oa = Date.now()); if (pa) { const f = this; return new Promise(g => { setTimeout(function() { - g(f[a + "Async"].apply(f, c)); + g(f[a + "Async"].apply(f, b)); }, 0); }); } - const d = this[a].apply(this, c); - b = d.then ? d : new Promise(f => f(d)); - e && b.then(e); - return b; + const e = this[a].apply(this, b); + c = e.then ? e : new Promise(f => f(e)); + d && c.then(d); + return c; }; } ;let O = 0; function P(a = {}) { - function c(g) { + function b(g) { function h(k) { k = k.data || k; - const l = k.id, m = l && d.h[l]; - m && (m(k.msg), delete d.h[l]); + const l = k.id, m = l && e.h[l]; + m && (m(k.msg), delete e.h[l]); } this.worker = g; this.h = A(); if (this.worker) { - e ? this.worker.on("message", h) : this.worker.onmessage = h; + d ? this.worker.on("message", h) : this.worker.onmessage = h; if (a.config) { return new Promise(function(k) { - d.h[++O] = function() { - k(d); + e.h[++O] = function() { + k(e); 1e9 < O && (O = 0); }; - d.worker.postMessage({id:O, task:"init", factory:b, options:a}); + e.worker.postMessage({id:O, task:"init", factory:c, options:a}); }); } - this.worker.postMessage({task:"init", factory:b, options:a}); + this.worker.postMessage({task:"init", factory:c, options:a}); this.priority = a.priority || 4; return this; } @@ -355,12 +355,12 @@ function P(a = {}) { if (!this || this.constructor !== P) { return new P(a); } - let b = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; - b && (b = b.toString()); - const e = "undefined" === typeof window, d = this, f = ra(b, e, a.worker); + let c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; + c && (c = c.toString()); + const d = "undefined" === typeof window, e = this, f = ra(c, d, a.worker); return f.then ? f.then(function(g) { - return c.call(d, g); - }) : c.call(this, f); + return b.call(e, g); + }) : b.call(this, f); } Q("add"); Q("append"); @@ -373,118 +373,118 @@ Q("import"); la(P.prototype); function Q(a) { P.prototype[a] = function() { - const c = this, b = [].slice.call(arguments); - var e = b[b.length - 1]; - let d; - "function" === typeof e && (d = e, b.pop()); - e = new Promise(function(f) { - "export" === a && "function" === typeof b[0] && (b[0] = null); - c.h[++O] = f; - c.worker.postMessage({task:a, id:O, args:b}); + const b = this, c = [].slice.call(arguments); + var d = c[c.length - 1]; + let e; + "function" === typeof d && (e = d, c.pop()); + d = new Promise(function(f) { + "export" === a && "function" === typeof c[0] && (c[0] = null); + b.h[++O] = f; + b.worker.postMessage({task:a, id:O, args:c}); }); - return d ? (e.then(d), this) : e; + return e ? (d.then(e), this) : d; }; } -function ra(a, c, b) { - return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function ra(a, b, c) { + return b ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function sa(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 5000 | 0); - for (const d of a.entries()) { - e.push(d), e.length === c && (b.push(e), e = []); - } - e.length && b.push(e); - return b; -} -function ta(a, c) { - c || (c = new Map()); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c.set(e[0], e[1]); +;function sa(a, b = 0) { + let c = [], d = []; + b && (b = 250000 / b * 5000 | 0); + for (const e of a.entries()) { + d.push(e), d.length === b && (c.push(d), d = []); } + d.length && c.push(d); return c; } -function ua(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 1000 | 0); - for (const d of a.entries()) { - e.push([d[0], sa(d[1])[0]]), e.length === c && (b.push(e), e = []); +function ta(a, b) { + b || (b = new Map()); + for (let c = 0, d; c < a.length; c++) { + d = a[c], b.set(d[0], d[1]); } - e.length && b.push(e); return b; } -function va(a, c) { - c || (c = new Map()); - for (let b = 0, e, d; b < a.length; b++) { - e = a[b], d = c.get(e[0]), c.set(e[0], ta(e[1], d)); +function ua(a, b = 0) { + let c = [], d = []; + b && (b = 250000 / b * 1000 | 0); + for (const e of a.entries()) { + d.push([e[0], sa(e[1])[0]]), d.length === b && (c.push(d), d = []); } + d.length && c.push(d); return c; } +function va(a, b) { + b || (b = new Map()); + for (let c = 0, d, e; c < a.length; c++) { + d = a[c], e = b.get(d[0]), b.set(d[0], ta(d[1], e)); + } + return b; +} function wa(a) { - let c = [], b = []; - for (const e of a.keys()) { - b.push(e), 250000 === b.length && (c.push(b), b = []); + let b = [], c = []; + for (const d of a.keys()) { + c.push(d), 250000 === c.length && (b.push(c), c = []); } - b.length && c.push(b); - return c; + c.length && b.push(c); + return b; } -function xa(a, c) { - c || (c = new Set()); - for (let b = 0; b < a.length; b++) { - c.add(a[b]); +function xa(a, b) { + b || (b = new Set()); + for (let c = 0; c < a.length; c++) { + b.add(a[c]); } - return c; + return b; } -function ya(a, c, b, e, d, f, g = 0) { - const h = e && e.constructor === Array; - var k = h ? e.shift() : e; +function ya(a, b, c, d, e, f, g = 0) { + const h = d && d.constructor === Array; + var k = h ? d.shift() : d; if (!k) { - return this.export(a, c, d, f + 1); + return this.export(a, b, e, f + 1); } - if ((k = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(k))) && k.then) { + if ((k = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(k))) && k.then) { const l = this; return k.then(function() { - return ya.call(l, a, c, b, h ? e : null, d, f, g + 1); + return ya.call(l, a, b, c, h ? d : null, e, f, g + 1); }); } - return ya.call(this, a, c, b, h ? e : null, d, f, g + 1); + return ya.call(this, a, b, c, h ? d : null, e, f, g + 1); } -function za(a, c) { - let b = ""; - for (const e of a.entries()) { - a = e[0]; - const d = e[1]; +function za(a, b) { + let c = ""; + for (const d of a.entries()) { + a = d[0]; + const e = d[1]; let f = ""; - for (let g = 0, h; g < d.length; g++) { - h = d[g] || [""]; + for (let g = 0, h; g < e.length; g++) { + h = e[g] || [""]; let k = ""; for (let l = 0; l < h.length; l++) { - k += (k ? "," : "") + ("string" === c ? '"' + h[l] + '"' : h[l]); + k += (k ? "," : "") + ("string" === b ? '"' + h[l] + '"' : h[l]); } k = "[" + k + "]"; f += (f ? "," : "") + k; } f = '["' + a + '",[' + f + "]]"; - b += (b ? "," : "") + f; + c += (c ? "," : "") + f; } - return b; + return c; } -;function Aa(a, c, b, e) { - let d = []; +;function Aa(a, b, c, d) { + let e = []; for (let f = 0, g; f < a.index.length; f++) { - if (g = a.index[f], c >= g.length) { - c -= g.length; + if (g = a.index[f], b >= g.length) { + b -= g.length; } else { - c = g[e ? "splice" : "slice"](c, b); - const h = c.length; - if (h && (d = d.length ? d.concat(c) : c, b -= h, e && (a.length -= h), !b)) { + b = g[d ? "splice" : "slice"](b, c); + const h = b.length; + if (h && (e = e.length ? e.concat(b) : b, c -= h, d && (a.length -= h), !c)) { break; } - c = 0; + b = 0; } } - return d; + return e; } function R(a) { if (!this || this.constructor !== R) { @@ -492,30 +492,30 @@ function R(a) { } this.index = a ? [a] : []; this.length = a ? a.length : 0; - const c = this; - return new Proxy([], {get(b, e) { - if ("length" === e) { - return c.length; + const b = this; + return new Proxy([], {get(c, d) { + if ("length" === d) { + return b.length; } - if ("push" === e) { - return function(d) { - c.index[c.index.length - 1].push(d); - c.length++; + if ("push" === d) { + return function(e) { + b.index[b.index.length - 1].push(e); + b.length++; }; } - if ("pop" === e) { + if ("pop" === d) { return function() { - if (c.length) { - return c.length--, c.index[c.index.length - 1].pop(); + if (b.length) { + return b.length--, b.index[b.index.length - 1].pop(); } }; } - if ("indexOf" === e) { - return function(d) { + if ("indexOf" === d) { + return function(e) { let f = 0; - for (let g = 0, h, k; g < c.index.length; g++) { - h = c.index[g]; - k = h.indexOf(d); + for (let g = 0, h, k; g < b.index.length; g++) { + h = b.index[g]; + k = h.indexOf(e); if (0 <= k) { return f + k; } @@ -524,36 +524,36 @@ function R(a) { return -1; }; } - if ("includes" === e) { - return function(d) { - for (let f = 0; f < c.index.length; f++) { - if (c.index[f].includes(d)) { + if ("includes" === d) { + return function(e) { + for (let f = 0; f < b.index.length; f++) { + if (b.index[f].includes(e)) { return !0; } } return !1; }; } - if ("slice" === e) { - return function(d, f) { - return Aa(c, d || 0, f || c.length, !1); + if ("slice" === d) { + return function(e, f) { + return Aa(b, e || 0, f || b.length, !1); }; } - if ("splice" === e) { - return function(d, f) { - return Aa(c, d || 0, f || c.length, !0); + if ("splice" === d) { + return function(e, f) { + return Aa(b, e || 0, f || b.length, !0); }; } - if ("constructor" === e) { + if ("constructor" === d) { return Array; } - if ("symbol" !== typeof e) { - return (b = c.index[e / 2 ** 31 | 0]) && b[e]; + if ("symbol" !== typeof d) { + return (c = b.index[d / 2 ** 31 | 0]) && c[d]; } - }, set(b, e, d) { - b = e / 2 ** 31 | 0; - (c.index[b] || (c.index[b] = []))[e] = d; - c.length++; + }, set(c, d, e) { + c = d / 2 ** 31 | 0; + (b.index[c] || (b.index[c] = []))[d] = e; + b.length++; return !0; }}); } @@ -575,13 +575,13 @@ function S(a = 8) { 32 < a ? (this.B = Ba, this.A = BigInt(a)) : (this.B = Ca, this.A = a); } S.prototype.get = function(a) { - const c = this.index[this.B(a)]; - return c && c.get(a); + const b = this.index[this.B(a)]; + return b && b.get(a); }; -S.prototype.set = function(a, c) { - var b = this.B(a); - let e = this.index[b]; - e ? (b = e.size, e.set(a, c), (b -= e.size) && this.size++) : (this.index[b] = e = new Map([[a, c]]), this.h.push(e), this.size++); +S.prototype.set = function(a, b) { + var c = this.B(a); + let d = this.index[c]; + d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.h.push(d), this.size++); }; function T(a = 8) { if (!this || this.constructor !== T) { @@ -593,18 +593,18 @@ function T(a = 8) { 32 < a ? (this.B = Ba, this.A = BigInt(a)) : (this.B = Ca, this.A = a); } T.prototype.add = function(a) { - var c = this.B(a); - let b = this.index[c]; - b ? (c = b.size, b.add(a), (c -= b.size) && this.size++) : (this.index[c] = b = new Set([a]), this.h.push(b), this.size++); + var b = this.B(a); + let c = this.index[b]; + c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c), this.size++); }; t = S.prototype; t.has = T.prototype.has = function(a) { - const c = this.index[this.B(a)]; - return c && c.has(a); + const b = this.index[this.B(a)]; + return b && b.has(a); }; t.delete = T.prototype.delete = function(a) { - const c = this.index[this.B(a)]; - c && c.delete(a) && this.size--; + const b = this.index[this.B(a)]; + b && b.delete(a) && this.size--; }; t.clear = T.prototype.clear = function() { this.index = A(); @@ -613,91 +613,91 @@ t.clear = T.prototype.clear = function() { }; t.values = T.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].values()) { - yield c; + for (let b of this.h[a].values()) { + yield b; } } }; t.keys = T.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].keys()) { - yield c; + for (let b of this.h[a].keys()) { + yield b; } } }; t.entries = T.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].entries()) { - yield c; + for (let b of this.h[a].entries()) { + yield b; } } }; function Ca(a) { - let c = 2 ** this.A - 1; + let b = 2 ** this.A - 1; if ("number" == typeof a) { - return a & c; + return a & b; } - let b = 0, e = this.A + 1; - for (let d = 0; d < a.length; d++) { - b = (b * e ^ a.charCodeAt(d)) & c; + let c = 0, d = this.A + 1; + for (let e = 0; e < a.length; e++) { + c = (c * d ^ a.charCodeAt(e)) & b; } - return 32 === this.A ? b + 2 ** 31 : b; + return 32 === this.A ? c + 2 ** 31 : c; } function Ba(a) { - let c = BigInt(2) ** this.A - BigInt(1); - var b = typeof a; - if ("bigint" === b) { - return a & c; + let b = BigInt(2) ** this.A - BigInt(1); + var c = typeof a; + if ("bigint" === c) { + return a & b; } - if ("number" === b) { - return BigInt(a) & c; + if ("number" === c) { + return BigInt(a) & b; } - b = BigInt(0); - let e = this.A + BigInt(1); - for (let d = 0; d < a.length; d++) { - b = (b * e ^ BigInt(a.charCodeAt(d))) & c; + c = BigInt(0); + let d = this.A + BigInt(1); + for (let e = 0; e < a.length; e++) { + c = (c * d ^ BigInt(a.charCodeAt(e))) & b; } - return b; + return c; } -;U.prototype.add = function(a, c, b) { - aa(a) && (c = a, a = ca(c, this.key)); - if (c && (a || 0 === a)) { - if (!b && this.reg.has(a)) { - return this.update(a, c); +;U.prototype.add = function(a, b, c) { + aa(a) && (b = a, a = ca(b, this.key)); + if (b && (a || 0 === a)) { + if (!c && this.reg.has(a)) { + return this.update(a, b); } for (let h = 0, k; h < this.field.length; h++) { k = this.F[h]; - var e = this.index.get(this.field[h]); + var d = this.index.get(this.field[h]); if ("function" === typeof k) { - var d = k(c); - d && e.add(a, d, !1, !0); + var e = k(b); + e && d.add(a, e, !1, !0); } else { - if (d = k.I, !d || d(c)) { - k.constructor === String ? k = ["" + k] : D(k) && (k = [k]), Da(c, k, this.J, 0, e, a, k[0], b); + if (e = k.I, !e || e(b)) { + k.constructor === String ? k = ["" + k] : D(k) && (k = [k]), Da(b, k, this.J, 0, d, a, k[0], c); } } } if (this.tag) { - for (e = 0; e < this.D.length; e++) { - var f = this.D[e], g = this.R[e]; - d = this.tag.get(g); + for (d = 0; d < this.D.length; d++) { + var f = this.D[d], g = this.R[d]; + e = this.tag.get(g); let h = A(); if ("function" === typeof f) { - if (f = f(c), !f) { + if (f = f(b), !f) { continue; } } else { const k = f.I; - if (k && !k(c)) { + if (k && !k(b)) { continue; } f.constructor === String && (f = "" + f); - f = ca(c, f); + f = ca(b, f); } - if (d && f) { + if (e && f) { D(f) && (f = [f]); for (let k = 0, l, m; k < f.length; k++) { - if (l = f[k], !h[l] && (h[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), !b || !m.includes(a))) { + if (l = f[k], !h[l] && (h[l] = 1, (g = e.get(l)) ? m = g : e.set(l, m = []), !c || !m.includes(a))) { if (m.length === 2 ** 31 - 1) { g = new R(m); if (this.fastupdate) { @@ -705,91 +705,91 @@ function Ba(a) { n.includes(m) && (n[n.indexOf(m)] = g); } } - d.set(l, m = g); + e.set(l, m = g); } m.push(a); this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m])); } } } else { - d || console.warn("Tag '" + g + "' was not found"); + e || console.warn("Tag '" + g + "' was not found"); } } } - if (this.store && (!b || !this.store.has(a))) { + if (this.store && (!c || !this.store.has(a))) { let h; if (this.C) { h = A(); for (let k = 0, l; k < this.C.length; k++) { l = this.C[k]; - if ((b = l.I) && !b(c)) { + if ((c = l.I) && !c(b)) { continue; } let m; if ("function" === typeof l) { - m = l(c); + m = l(b); if (!m) { continue; } l = [l.V]; } else if (D(l) || l.constructor === String) { - h[l] = c[l]; + h[l] = b[l]; continue; } - Ea(c, h, l, 0, l[0], m); + Ea(b, h, l, 0, l[0], m); } } - this.store.set(a, h || c); + this.store.set(a, h || b); } this.worker && (this.fastupdate || this.reg.add(a)); } return this; }; -function Ea(a, c, b, e, d, f) { - a = a[d]; - if (e === b.length - 1) { - c[d] = f || a; +function Ea(a, b, c, d, e, f) { + a = a[e]; + if (d === c.length - 1) { + b[e] = f || a; } else if (a) { if (a.constructor === Array) { - for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { - Ea(a, c, b, e, d); + for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) { + Ea(a, b, c, d, e); } } else { - c = c[d] || (c[d] = A()), d = b[++e], Ea(a, c, b, e, d); + b = b[e] || (b[e] = A()), e = c[++d], Ea(a, b, c, d, e); } } } -function Da(a, c, b, e, d, f, g, h) { +function Da(a, b, c, d, e, f, g, h) { if (a = a[g]) { - if (e === c.length - 1) { + if (d === b.length - 1) { if (a.constructor === Array) { - if (b[e]) { - for (c = 0; c < a.length; c++) { - d.add(f, a[c], !0, !0); + if (c[d]) { + for (b = 0; b < a.length; b++) { + e.add(f, a[b], !0, !0); } return; } a = a.join(" "); } - d.add(f, a, h, !0); + e.add(f, a, h, !0); } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Da(a, c, b, e, d, f, g, h); + Da(a, b, c, d, e, f, g, h); } } else { - g = c[++e], Da(a, c, b, e, d, f, g, h); + g = b[++d], Da(a, b, c, d, e, f, g, h); } } } else { - d.db && d.remove(f); + e.db && e.remove(f); } } -;function Fa(a, c, b, e, d, f, g) { +;function Fa(a, b, c, d, e, f, g) { const h = a.length; let k = [], l, m; l = A(); - for (let n = 0, p, r, q, u; n < c; n++) { + for (let n = 0, p, r, q, u; n < b; n++) { for (let v = 0; v < h; v++) { if (q = a[v], n < q.length && (p = q[n])) { for (let w = 0; w < p.length; w++) { @@ -797,66 +797,66 @@ function Da(a, c, b, e, d, f, g, h) { (m = l[r]) ? l[r]++ : (m = 0, l[r] = 1); u = k[m] || (k[m] = []); if (!g) { - let x = n + (v || !d ? 0 : f || 0); + let x = n + (v || !e ? 0 : f || 0); u = u[x] || (u[x] = []); } u.push(r); - if (g && b && m === h - 1 && u.length - e === b) { - return e ? u.slice(e) : u; + if (g && c && m === h - 1 && u.length - d === c) { + return d ? u.slice(d) : u; } } } } } if (a = k.length) { - if (d) { - k = 1 < k.length ? Ga(k, b, e, g, f) : (k = k[0]).length > b || e ? k.slice(e, b + e) : k; + if (e) { + k = 1 < k.length ? Ga(k, c, d, g, f) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; } else { if (a < h) { return []; } k = k[a - 1]; - if (b || e) { + if (c || d) { if (g) { - if (k.length > b || e) { - k = k.slice(e, b + e); + if (k.length > c || d) { + k = k.slice(d, c + d); } } else { - d = []; + e = []; for (let n = 0, p; n < k.length; n++) { - if (p = k[n], p.length > e) { - e -= p.length; + if (p = k[n], p.length > d) { + d -= p.length; } else { - if (p.length > b || e) { - p = p.slice(e, b + e), b -= p.length, e && (e -= p.length); + if (p.length > c || d) { + p = p.slice(d, c + d), c -= p.length, d && (d -= p.length); } - d.push(p); - if (!b) { + e.push(p); + if (!c) { break; } } } - k = 1 < d.length ? [].concat.apply([], d) : d[0]; + k = 1 < e.length ? [].concat.apply([], e) : e[0]; } } } } return k; } -function Ga(a, c, b, e, d) { +function Ga(a, b, c, d, e) { const f = [], g = A(); let h; var k = a.length; let l; - if (e) { - for (d = k - 1; 0 <= d; d--) { - if (l = (e = a[d]) && e.length) { + if (d) { + for (e = k - 1; 0 <= e; e--) { + if (l = (d = a[e]) && d.length) { for (k = 0; k < l; k++) { - if (h = e[k], !g[h]) { - if (g[h] = 1, b) { - b--; + if (h = d[k], !g[h]) { + if (g[h] = 1, c) { + c--; } else { - if (f.push(h), f.length === c) { + if (f.push(h), f.length === b) { return f; } } @@ -868,15 +868,15 @@ function Ga(a, c, b, e, d) { for (let m = k - 1, n, p = 0; 0 <= m; m--) { n = a[m]; for (let r = 0; r < n.length; r++) { - if (l = (e = n[r]) && e.length) { + if (l = (d = n[r]) && d.length) { for (let q = 0; q < l; q++) { - if (h = e[q], !g[h]) { - if (g[h] = 1, b) { - b--; + if (h = d[q], !g[h]) { + if (g[h] = 1, c) { + c--; } else { - let u = (r + (m < k - 1 ? d || 0 : 0)) / (m + 1) | 0; + let u = (r + (m < k - 1 ? e || 0 : 0)) / (m + 1) | 0; (f[u] || (f[u] = [])).push(h); - if (++p === c) { + if (++p === b) { return f; } } @@ -888,72 +888,72 @@ function Ga(a, c, b, e, d) { } return f; } -function Ha(a, c, b) { - const e = A(), d = []; - for (let f = 0, g; f < c.length; f++) { - g = c[f]; +function Ha(a, b, c) { + const d = A(), e = []; + for (let f = 0, g; f < b.length; f++) { + g = b[f]; for (let h = 0; h < g.length; h++) { - e[g[h]] = 1; + d[g[h]] = 1; } } - if (b) { + if (c) { for (let f = 0, g; f < a.length; f++) { - g = a[f], e[g] && (d.push(g), e[g] = 0); + g = a[f], d[g] && (e.push(g), d[g] = 0); } } else { for (let f = 0, g, h; f < a.result.length; f++) { - for (g = a.result[f], c = 0; c < g.length; c++) { - h = g[c], e[h] && ((d[f] || (d[f] = [])).push(h), e[h] = 0); + for (g = a.result[f], b = 0; b < g.length; b++) { + h = g[b], d[h] && ((e[f] || (e[f] = [])).push(h), d[h] = 0); } } } - return d; + return e; } -;function Ia(a, c, b, e) { +;function Ia(a, b, c, d) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, e ? V.call(this, a) : a; + return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? V.call(this, a) : a; } - let d = []; + let e = []; for (let f = 0, g, h; f < a.length; f++) { if ((g = a[f]) && (h = g.length)) { - if (b) { - if (b >= h) { - b -= h; + if (c) { + if (c >= h) { + c -= h; continue; } - b < h && (g = c ? g.slice(b, b + c) : g.slice(b), h = g.length, b = 0); + c < h && (g = b ? g.slice(c, c + b) : g.slice(c), h = g.length, c = 0); } - h > c && (g = g.slice(0, c), h = c); - if (!d.length && h >= c) { - return e ? V.call(this, g) : g; + h > b && (g = g.slice(0, b), h = b); + if (!e.length && h >= b) { + return d ? V.call(this, g) : g; } - d.push(g); - c -= h; - if (!c) { + e.push(g); + b -= h; + if (!b) { break; } } } - d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? V.call(this, d) : d; + e = 1 < e.length ? [].concat.apply([], e) : e[0]; + return d ? V.call(this, e) : e; } -;function Ja(a, c, b) { - var e = b[0]; - if (e.then) { - return Promise.all(b).then(function(m) { - return a[c].apply(a, m); +;function Ja(a, b, c) { + var d = c[0]; + if (d.then) { + return Promise.all(c).then(function(m) { + return a[b].apply(a, m); }); } - if (e[0] && e[0].index) { - return a[c].apply(a, e); + if (d[0] && d[0].index) { + return a[b].apply(a, d); } - e = []; - let d = [], f = 0, g = 0, h, k, l; - for (let m = 0, n; m < b.length; m++) { - if (n = b[m]) { + d = []; + let e = [], f = 0, g = 0, h, k, l; + for (let m = 0, n; m < c.length; m++) { + if (n = c[m]) { let p; if (n.constructor === W) { p = n.result; @@ -975,99 +975,99 @@ function Ha(a, c, b) { } } if (p.then) { - d.push(p); + e.push(p); } else if (p.length) { - e[m] = p; - } else if (!l && ("and" === c || "xor" === c)) { - e = []; + d[m] = p; + } else if (!l && ("and" === b || "xor" === b)) { + d = []; break; } } } - return {O:e, P:d, limit:f, offset:g, enrich:h, resolve:k, suggest:l}; + return {O:d, P:e, limit:f, offset:g, enrich:h, resolve:k, suggest:l}; } ;W.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Ja(this, "or", arguments); - return Ka.call(this, a, c, b, e, d, f); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f} = Ja(this, "or", arguments); + return Ka.call(this, a, b, c, d, e, f); }; -function Ka(a, c, b, e, d, f) { - if (c.length) { +function Ka(a, b, c, d, e, f) { + if (b.length) { const g = this; - return Promise.all(c).then(function(h) { + return Promise.all(b).then(function(h) { a = []; for (let k = 0, l; k < h.length; k++) { (l = h[k]).length && (a[k] = l); } - return Ka.call(g, a, [], b, e, d, f); + return Ka.call(g, a, [], c, d, e, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ga(a, b, e, !1, this.h), e = 0)); - return f ? this.resolve(b, e, d) : this; + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ga(a, c, d, !1, this.h), d = 0)); + return f ? this.resolve(c, d, e) : this; } ;W.prototype.and = function() { - let a = this.result.length, c, b, e, d; + let a = this.result.length, b, c, d, e; if (!a) { const f = arguments[0]; - f && (a = !!f.suggest, d = f.resolve, c = f.limit, b = f.offset, e = f.enrich && d); + f && (a = !!f.suggest, e = f.resolve, b = f.limit, c = f.offset, d = f.enrich && e); } if (a) { const {O:f, P:g, limit:h, offset:k, enrich:l, resolve:m, suggest:n} = Ja(this, "and", arguments); return La.call(this, f, g, h, k, l, m, n); } - return d ? this.resolve(c, b, e) : this; + return e ? this.resolve(b, c, d) : this; }; -function La(a, c, b, e, d, f, g) { - if (c.length) { +function La(a, b, c, d, e, f, g) { + if (b.length) { const h = this; - return Promise.all(c).then(function(k) { + return Promise.all(b).then(function(k) { a = []; for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return La.call(h, a, [], b, e, d, f, g); + return La.call(h, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (c = da(a)) { - return this.result = Fa(a, c, b, e, g, this.h, f), f ? d ? V.call(this.index, this.result) : this.result : this; + if (b = da(a)) { + return this.result = Fa(a, b, c, d, g, this.h, f), f ? e ? V.call(this.index, this.result) : this.result : this; } this.result = []; } } else { g || (this.result = a); } - return f ? this.resolve(b, e, d) : this; + return f ? this.resolve(c, d, e) : this; } ;W.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "xor", arguments); - return Ma.call(this, a, c, b, e, d, f, g); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f, suggest:g} = Ja(this, "xor", arguments); + return Ma.call(this, a, b, c, d, e, f, g); }; -function Ma(a, c, b, e, d, f, g) { - if (c.length) { +function Ma(a, b, c, d, e, f, g) { + if (b.length) { const h = this; - return Promise.all(c).then(function(k) { + return Promise.all(b).then(function(k) { a = []; for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return Ma.call(h, a, [], b, e, d, f, g); + return Ma.call(h, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = Na.call(this, a, b, e, f, this.h), f ? d ? V.call(this.index, this.result) : this.result : this; + return this.result = Na.call(this, a, c, d, f, this.h), f ? e ? V.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } - return f ? this.resolve(b, e, d) : this; + return f ? this.resolve(c, d, e) : this; } -function Na(a, c, b, e, d) { +function Na(a, b, c, d, e) { const f = [], g = A(); let h = 0; for (let k = 0, l; k < a.length; k++) { @@ -1088,18 +1088,18 @@ function Na(a, c, b, e, d) { if (l = p[k]) { for (let r = 0, q; r < l.length; r++) { if (q = l[r], 1 === g[q]) { - if (b) { - b--; + if (c) { + c--; } else { - if (e) { - if (f.push(q), f.length === c) { + if (d) { + if (f.push(q), f.length === b) { return f; } } else { - const u = k + (n ? d : 0); + const u = k + (n ? e : 0); f[u] || (f[u] = []); f[u].push(q); - if (++m === c) { + if (++m === b) { return f; } } @@ -1113,44 +1113,44 @@ function Na(a, c, b, e, d) { return f; } ;W.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "not", arguments); - return Oa.call(this, a, c, b, e, d, f, g); + const {O:a, P:b, limit:c, offset:d, enrich:e, resolve:f, suggest:g} = Ja(this, "not", arguments); + return Oa.call(this, a, b, c, d, e, f, g); }; -function Oa(a, c, b, e, d, f, g) { - if (c.length) { +function Oa(a, b, c, d, e, f, g) { + if (b.length) { const h = this; - return Promise.all(c).then(function(k) { + return Promise.all(b).then(function(k) { a = []; for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return Oa.call(h, a, [], b, e, d, f, g); + return Oa.call(h, a, [], c, d, e, f, g); }); } if (a.length && this.result.length) { - this.result = Pa.call(this, a, b, e, f); + this.result = Pa.call(this, a, c, d, f); } else if (f) { - return this.resolve(b, e, d); + return this.resolve(c, d, e); } - return f ? d ? V.call(this.index, this.result) : this.result : this; + return f ? e ? V.call(this.index, this.result) : this.result : this; } -function Pa(a, c, b, e) { - const d = []; +function Pa(a, b, c, d) { + const e = []; a = new Set(a.flat().flat()); for (let f = 0, g, h = 0; f < this.result.length; f++) { if (g = this.result[f]) { for (let k = 0, l; k < g.length; k++) { if (l = g[k], !a.has(l)) { - if (b) { - b--; + if (c) { + c--; } else { - if (e) { - if (d.push(l), d.length === c) { - return d; + if (d) { + if (e.push(l), e.length === b) { + return e; } } else { - if (d[f] || (d[f] = []), d[f].push(l), ++h === c) { - return d; + if (e[f] || (e[f] = []), e[f].push(l), ++h === b) { + return e; } } } @@ -1158,7 +1158,7 @@ function Pa(a, c, b, e) { } } } - return d; + return e; } ;function W(a) { if (!this || this.constructor !== W) { @@ -1173,32 +1173,32 @@ function Pa(a, c, b, e) { } W.prototype.limit = function(a) { if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - if (e.length <= a) { - if (c[b] = e, a -= e.length, !a) { + const b = []; + for (let c = 0, d; c < this.result.length; c++) { + if (d = this.result[c]) { + if (d.length <= a) { + if (b[c] = d, a -= d.length, !a) { break; } } else { - c[b] = e.slice(0, a); + b[c] = d.slice(0, a); break; } } } - this.result = c; + this.result = b; } return this; }; W.prototype.offset = function(a) { if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - e.length <= a ? a -= e.length : (c[b] = e.slice(a), a = 0); + const b = []; + for (let c = 0, d; c < this.result.length; c++) { + if (d = this.result[c]) { + d.length <= a ? a -= d.length : (b[c] = d.slice(a), a = 0); } } - this.result = c; + this.result = b; } return this; }; @@ -1206,15 +1206,15 @@ W.prototype.boost = function(a) { this.h += a; return this; }; -W.prototype.resolve = function(a, c, b) { - const e = this.result, d = this.index; +W.prototype.resolve = function(a, b, c) { + const d = this.result, e = this.index; this.result = this.index = null; - return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), Ia.call(d, e, a || 100, c, b)) : e; + return d.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ia.call(e, d, a || 100, b, c)) : d; }; A(); -U.prototype.search = function(a, c, b, e) { - b || (!c && aa(a) ? (b = a, a = "") : aa(c) && (b = c, c = 0)); - let d = []; +U.prototype.search = function(a, b, c, d) { + c || (!b && aa(a) ? (c = a, a = "") : aa(b) && (c = b, b = 0)); + let e = []; var f = []; let g; var h; @@ -1223,15 +1223,15 @@ U.prototype.search = function(a, c, b, e) { let n = 0; var p = !0; let r; - if (b) { - b.constructor === Array && (b = {index:b}); - a = b.query || a; - g = b.pluck; - k = b.merge; - l = g || b.field || (l = b.index) && (l.index ? null : l); - m = this.tag && b.tag; - var q = b.suggest; - p = !1 !== b.resolve; + if (c) { + c.constructor === Array && (c = {index:c}); + a = c.query || a; + g = c.pluck; + k = c.merge; + l = g || c.field || (l = c.index) && (l.index ? null : l); + m = this.tag && c.tag; + var q = c.suggest; + p = !1 !== c.resolve; if (!p && !g) { if (l = l || this.field) { D(l) ? g = l : (l.constructor === Array && 1 === l.length && (l = l[0]), g = l.field || l.index); @@ -1240,12 +1240,12 @@ U.prototype.search = function(a, c, b, e) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } - this.store && b.enrich && !p && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - r = (h = this.store && b.enrich && p) && b.highlight; - c = b.limit || c; - var u = b.offset || 0; - c || (c = 100); - if (m && (!this.db || !e)) { + this.store && c.enrich && !p && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + r = (h = this.store && c.enrich && p) && c.highlight; + b = c.limit || b; + var u = c.offset || 0; + b || (b = 100); + if (m && (!this.db || !d)) { m.constructor !== Array && (m = [m]); var v = []; for (let B = 0, y; B < m.length; B++) { @@ -1289,25 +1289,25 @@ U.prototype.search = function(a, c, b, e) { console.warn("Tag '" + v[f] + ":" + v[f + 1] + "' will be skipped because there is no field '" + v[f] + "'."); continue; } - p.push(q = q.db.tag(v[f + 1], c, u, h)); + p.push(q = q.db.tag(v[f + 1], b, u, h)); } else { - q = Qa.call(this, v[f], v[f + 1], c, u, h); + q = Qa.call(this, v[f], v[f + 1], b, u, h); } - d.push({field:v[f], tag:v[f + 1], result:q}); + e.push({field:v[f], tag:v[f + 1], result:q}); } } return p.length ? Promise.all(p).then(function(B) { for (let y = 0; y < B.length; y++) { - d[y].result = B[y]; + e[y].result = B[y]; } - return d; - }) : d; + return e; + }) : e; } } l && l.constructor !== Array && (l = [l]); } l || (l = this.field); - v = !e && (this.worker || this.db) && []; + v = !d && (this.worker || this.db) && []; let F; for (let B = 0, y, C, M; B < l.length; B++) { C = l[B]; @@ -1315,30 +1315,30 @@ U.prototype.search = function(a, c, b, e) { continue; } let E; - D(C) || (E = C, C = E.field, a = E.query || a, c = E.limit || c, u = E.offset || u, q = E.suggest || q, h = this.store && (E.enrich || h)); - if (e) { - y = e[B]; + D(C) || (E = C, C = E.field, a = E.query || a, b = E.limit || b, u = E.offset || u, q = E.suggest || q, h = this.store && (E.enrich || h)); + if (d) { + y = d[B]; } else { - if (w = E || b, x = this.index.get(C), m && (this.db && (w.tag = m, F = x.db.support_tag_search, w.field = l), F || (w.enrich = !1)), v) { - v[B] = x.search(a, c, w); + if (w = E || c, x = this.index.get(C), m && (this.db && (w.tag = m, F = x.db.support_tag_search, w.field = l), F || (w.enrich = !1)), v) { + v[B] = x.search(a, b, w); w && h && (w.enrich = h); continue; } else { - y = x.search(a, c, w), w && h && (w.enrich = h); + y = x.search(a, b, w), w && h && (w.enrich = h); } } M = y && (p ? y.length : y.result.length); if (m && M) { w = []; x = 0; - if (this.db && e) { + if (this.db && d) { if (!F) { - for (let J = l.length; J < e.length; J++) { - let K = e[J]; + for (let J = l.length; J < d.length; J++) { + let K = d[J]; if (K && K.length) { x++, w.push(K); } else if (!q) { - return p ? d : new W(d); + return p ? e : new W(e); } } } @@ -1349,13 +1349,13 @@ U.prototype.search = function(a, c, b, e) { if (console.warn("Tag '" + m[J] + ":" + m[J + 1] + "' will be skipped because there is no field '" + m[J] + "'."), q) { continue; } else { - return p ? d : new W(d); + return p ? e : new W(e); } } if (ob = (K = K && K.get(m[J + 1])) && K.length) { x++, w.push(K); } else if (!q) { - return p ? d : new W(d); + return p ? e : new W(e); } } } @@ -1369,9 +1369,9 @@ U.prototype.search = function(a, c, b, e) { } } if (M) { - f[n] = C, d.push(y), n++; + f[n] = C, e.push(y), n++; } else if (1 === l.length) { - return p ? d : new W(d); + return p ? e : new W(e); } } if (v) { @@ -1382,58 +1382,58 @@ U.prototype.search = function(a, c, b, e) { if (console.warn("Tag '" + m[h] + ":" + m[h + 1] + "' was not found because there is no field '" + m[h] + "'."), q) { continue; } else { - return p ? d : new W(d); + return p ? e : new W(e); } } - v.push(f.db.tag(m[h + 1], c, u, !1)); + v.push(f.db.tag(m[h + 1], b, u, !1)); } } const B = this; return Promise.all(v).then(function(y) { - return y.length ? B.search(a, c, b, y) : y; + return y.length ? B.search(a, b, c, y) : y; }); } if (!n) { - return p ? d : new W(d); + return p ? e : new W(e); } if (g && (!h || !this.store)) { - return d[0]; + return e[0]; } v = []; for (u = 0; u < f.length; u++) { - q = d[u]; + q = e[u]; h && q.length && "undefined" === typeof q[0].doc && (this.db ? v.push(q = this.index.get(this.field[0]).db.enrich(q)) : q = V.call(this, q)); if (g) { return p ? r ? Ra(a, q, this.index, g, r) : q : new W(q); } - d[u] = {field:f[u], result:q}; + e[u] = {field:f[u], result:q}; } if (h && this.db && v.length) { const B = this; return Promise.all(v).then(function(y) { for (let C = 0; C < y.length; C++) { - d[C].result = y[C]; + e[C].result = y[C]; } - return k ? Sa(d) : r ? Ra(a, d, B.index, g, r) : d; + return k ? Sa(e) : r ? Ra(a, e, B.index, g, r) : e; }); } - return k ? Sa(d) : r ? Ra(a, d, this.index, g, r) : d; + return k ? Sa(e) : r ? Ra(a, e, this.index, g, r) : e; }; -function Ra(a, c, b, e, d) { +function Ra(a, b, c, d, e) { let f, g; - for (let k = 0, l, m, n; k < c.length; k++) { + for (let k = 0, l, m, n; k < b.length; k++) { let p; - if (e) { - p = c, n = e; + if (d) { + p = b, n = d; } else { - var h = c[k]; + var h = b[k]; n = h.field; if (!n) { continue; } p = h.result; } - m = b.get(n); + m = c.get(n); l = m.encoder; h = m.tokenize; l !== f && (f = l, g = f.encode(a)); @@ -1448,14 +1448,14 @@ function Ra(a, c, b, e, d) { for (let B = 0, y; B < g.length; B++) { if (y = g[B], "strict" === h) { if (x === y) { - q += (q ? " " : "") + d.replace("$1", w); + q += (q ? " " : "") + e.replace("$1", w); F = !0; break; } } else { const C = x.indexOf(y); if (-1 < C) { - q += (q ? " " : "") + w.substring(0, C) + d.replace("$1", w.substring(C, y.length)) + w.substring(C + y.length); + q += (q ? " " : "") + w.substring(0, C) + e.replace("$1", w.substring(C, y.length)) + w.substring(C + y.length); F = !0; break; } @@ -1466,33 +1466,33 @@ function Ra(a, c, b, e, d) { } p[r].highlight = q; } - if (e) { + if (d) { break; } } - return c; + return b; } function Sa(a) { - const c = [], b = A(); - for (let e = 0, d, f; e < a.length; e++) { - d = a[e]; - f = d.result; + const b = [], c = A(); + for (let d = 0, e, f; d < a.length; d++) { + e = a[d]; + f = e.result; for (let g = 0, h, k, l; g < f.length; g++) { - k = f[g], "object" !== typeof k && (k = {id:k}), h = k.id, (l = b[h]) ? l.push(d.field) : (k.field = b[h] = [d.field], c.push(k)); + k = f[g], "object" !== typeof k && (k = {id:k}), h = k.id, (l = c[h]) ? l.push(e.field) : (k.field = c[h] = [e.field], b.push(k)); } } - return c; + return b; } -function Qa(a, c, b, e, d) { +function Qa(a, b, c, d, e) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; } - if ((a = (f = f && f.get(c)) && f.length - e) && 0 < a) { - if (a > b || e) { - f = f.slice(e, e + b); + if ((a = (f = f && f.get(b)) && f.length - d) && 0 < a) { + if (a > c || d) { + f = f.slice(d, d + c); } - d && (f = V.call(this, f)); + e && (f = V.call(this, f)); return f; } } @@ -1500,66 +1500,66 @@ function V(a) { if (!this || !this.store) { return a; } - const c = Array(a.length); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c[b] = {id:e, doc:this.store.get(e)}; + const b = Array(a.length); + for (let c = 0, d; c < a.length; c++) { + d = a[c], b[c] = {id:d, doc:this.store.get(d)}; } - return c; + return b; } ;function U(a) { if (!this || this.constructor !== U) { return new U(a); } - const c = a.document || a.doc || a; - let b, e; + const b = a.document || a.doc || a; + let c, d; this.F = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && Ta(b, this.J) || "id"; - (e = a.keystore || 0) && (this.keystore = e); + this.key = (c = b.key || b.id) && Ta(c, this.J) || "id"; + (d = a.keystore || 0) && (this.keystore = d); this.fastupdate = !!a.fastupdate; - this.reg = !this.fastupdate || a.worker || a.db ? e ? new T(e) : new Set() : e ? new S(e) : new Map(); - this.C = (b = c.store || null) && b && !0 !== b && []; - this.store = b && (e ? new S(e) : new Map()); - this.cache = (b = a.cache || null) && new X(b); + this.reg = !this.fastupdate || a.worker || a.db ? d ? new T(d) : new Set() : d ? new S(d) : new Map(); + this.C = (c = b.store || null) && c && !0 !== c && []; + this.store = c && (d ? new S(d) : new Map()); + this.cache = (c = a.cache || null) && new X(c); a.cache = !1; this.worker = a.worker || !1; this.priority = a.priority || 4; - this.index = Ua.call(this, a, c); + this.index = Ua.call(this, a, b); this.tag = null; - if (b = c.tag) { - if ("string" === typeof b && (b = [b]), b.length) { + if (c = b.tag) { + if ("string" === typeof c && (c = [c]), c.length) { this.tag = new Map(); this.D = []; this.R = []; - for (let d = 0, f, g; d < b.length; d++) { - f = b[d]; + for (let e = 0, f, g; e < c.length; e++) { + f = c[e]; g = f.field || f; if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.D[d] = f.custom : (this.D[d] = Ta(g, this.J), f.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = f.filter)); - this.R[d] = g; + f.custom ? this.D[e] = f.custom : (this.D[e] = Ta(g, this.J), f.filter && ("string" === typeof this.D[e] && (this.D[e] = new String(this.D[e])), this.D[e].I = f.filter)); + this.R[e] = g; this.tag.set(g, new Map()); } } } if (this.worker) { this.fastupdate = !1; - const d = []; + const e = []; for (const f of this.index.values()) { - f.then && d.push(f); + f.then && e.push(f); } - if (d.length) { + if (e.length) { const f = this; - return Promise.all(d).then(function(g) { + return Promise.all(e).then(function(g) { const h = new Map(); let k = 0; for (const m of f.index.entries()) { const n = m[0]; var l = m[1]; if (l.then) { - l = d[k].encoder || {}; + l = e[k].encoder || {}; let p = h.get(l); p || (p = l.encode ? l : new G(l), h.set(l, p)); l = g[k]; @@ -1580,101 +1580,101 @@ t.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); } - let c = this.field; + let b = this.field; if (this.tag) { for (let f = 0, g; f < this.R.length; f++) { g = this.R[f]; - var b = void 0; - this.index.set(g, b = new N({}, this.reg)); - c === this.field && (c = c.slice(0)); - c.push(g); - b.tag = this.tag.get(g); + var c = void 0; + this.index.set(g, c = new N({}, this.reg)); + b === this.field && (b = b.slice(0)); + b.push(g); + c.tag = this.tag.get(g); } } - b = []; - const e = {db:a.db, type:a.type, fastupdate:a.fastupdate}; - for (let f = 0, g, h; f < c.length; f++) { - e.field = h = c[f]; + c = []; + const d = {db:a.db, type:a.type, fastupdate:a.fastupdate}; + for (let f = 0, g, h; f < b.length; f++) { + d.field = h = b[f]; g = this.index.get(h); - const k = new a.constructor(a.id, e); + const k = new a.constructor(a.id, d); k.id = a.id; - b[f] = k.mount(g); + c[f] = k.mount(g); g.document = !0; f ? g.bypass = !0 : g.store = this.store; } - const d = this; - return this.db = Promise.all(b).then(function() { - d.db = !0; + const e = this; + return this.db = Promise.all(c).then(function() { + e.db = !0; }); }; -t.commit = async function(a, c) { - const b = []; - for (const e of this.index.values()) { - b.push(e.commit(a, c)); +t.commit = async function(a, b) { + const c = []; + for (const d of this.index.values()) { + c.push(d.commit(a, b)); } - await Promise.all(b); + await Promise.all(c); this.reg.clear(); }; t.destroy = function() { const a = []; - for (const c of this.index.values()) { - a.push(c.destroy()); + for (const b of this.index.values()) { + a.push(b.destroy()); } return Promise.all(a); }; -function Ua(a, c) { - const b = new Map(); - let e = c.index || c.field || c; - D(e) && (e = [e]); - for (let d = 0, f, g; d < e.length; d++) { - f = e[d]; +function Ua(a, b) { + const c = new Map(); + let d = b.index || b.field || b; + D(d) && (d = [d]); + for (let e = 0, f, g; e < d.length; e++) { + f = d[e]; D(f) || (g = f, f = f.field); g = aa(g) ? Object.assign({}, a, g) : a; if (this.worker) { const h = new P(g); h.encoder = g.encoder; - b.set(f, h); + c.set(f, h); } - this.worker || b.set(f, new N(g, this.reg)); - g.custom ? this.F[d] = g.custom : (this.F[d] = Ta(f, this.J), g.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = g.filter)); - this.field[d] = f; + this.worker || c.set(f, new N(g, this.reg)); + g.custom ? this.F[e] = g.custom : (this.F[e] = Ta(f, this.J), g.filter && ("string" === typeof this.F[e] && (this.F[e] = new String(this.F[e])), this.F[e].I = g.filter)); + this.field[e] = f; } if (this.C) { - a = c.store; + a = b.store; D(a) && (a = [a]); - for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = Ta(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); + for (let e = 0, f, g; e < a.length; e++) { + f = a[e], g = f.field || f, f.custom ? (this.C[e] = f.custom, f.custom.V = g) : (this.C[e] = Ta(g, this.J), f.filter && ("string" === typeof this.C[e] && (this.C[e] = new String(this.C[e])), this.C[e].I = f.filter)); } } - return b; + return c; } -function Ta(a, c) { - const b = a.split(":"); - let e = 0; - for (let d = 0; d < b.length; d++) { - a = b[d], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); +function Ta(a, b) { + const c = a.split(":"); + let d = 0; + for (let e = 0; e < c.length; e++) { + a = c[e], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (b[d] = !0), a && (c[d++] = a); } - e < b.length && (b.length = e); - return 1 < e ? b : b[0]; + d < c.length && (c.length = d); + return 1 < d ? c : c[0]; } -t.append = function(a, c) { - return this.add(a, c, !0); +t.append = function(a, b) { + return this.add(a, b, !0); }; -t.update = function(a, c) { - return this.remove(a).add(a, c); +t.update = function(a, b) { + return this.remove(a).add(a, b); }; t.remove = function(a) { aa(a) && (a = ca(a, this.key)); - for (var c of this.index.values()) { - c.remove(a, !0); + for (var b of this.index.values()) { + b.remove(a, !0); } if (this.reg.has(a)) { if (this.tag && !this.fastupdate) { - for (let b of this.tag.values()) { - for (let e of b) { - c = e[0]; - const d = e[1], f = d.indexOf(a); - -1 < f && (1 < d.length ? d.splice(f, 1) : b.delete(c)); + for (let c of this.tag.values()) { + for (let d of c) { + b = d[0]; + const e = d[1], f = e.indexOf(a); + -1 < f && (1 < e.length ? e.splice(f, 1) : c.delete(b)); } } } @@ -1686,13 +1686,13 @@ t.remove = function(a) { }; t.clear = function() { const a = []; - for (const c of this.index.values()) { - const b = c.clear(); - b.then && a.push(b); + for (const b of this.index.values()) { + const c = b.clear(); + c.then && a.push(c); } if (this.tag) { - for (const c of this.tag.values()) { - c.clear(); + for (const b of this.tag.values()) { + b.clear(); } } this.store && this.store.clear(); @@ -1709,121 +1709,121 @@ t.cleanup = function() { return this; }; t.get = function(a) { - return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(c) { - return c[0] && c[0].doc || null; + return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(b) { + return b[0] && b[0].doc || null; }) : this.store.get(a) || null; }; -t.set = function(a, c) { - "object" === typeof a && (c = a, a = ca(c, this.key)); - this.store.set(a, c); +t.set = function(a, b) { + "object" === typeof a && (b = a, a = ca(b, this.key)); + this.store.set(a, b); return this; }; t.searchCache = Va; -t.export = function(a, c, b = 0, e = 0) { - if (b < this.field.length) { - const g = this.field[b]; - if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { +t.export = function(a, b, c = 0, d = 0) { + if (c < this.field.length) { + const g = this.field[c]; + if ((b = this.index.get(g).export(a, g, c, d = 1)) && b.then) { const h = this; - return c.then(function() { - return h.export(a, g, b + 1); + return b.then(function() { + return h.export(a, g, c + 1); }); } - return this.export(a, g, b + 1); + return this.export(a, g, c + 1); } - let d, f; - switch(e) { + let e, f; + switch(d) { case 0: - d = "reg"; + e = "reg"; f = wa(this.reg); - c = null; + b = null; break; case 1: - d = "tag"; + e = "tag"; f = this.tag && ua(this.tag, this.reg.size); - c = null; + b = null; break; case 2: - d = "doc"; + e = "doc"; f = this.store && sa(this.store); - c = null; + b = null; break; default: return; } - return ya.call(this, a, c, d, f, b, e); + return ya.call(this, a, b, e, f, c, d); }; -t.import = function(a, c) { - var b = a.split("."); - "json" === b[b.length - 1] && b.pop(); - const e = 2 < b.length ? b[0] : ""; - b = 2 < b.length ? b[2] : b[1]; - if (this.worker && e) { - return this.index.get(e).import(a); +t.import = function(a, b) { + var c = a.split("."); + "json" === c[c.length - 1] && c.pop(); + const d = 2 < c.length ? c[0] : ""; + c = 2 < c.length ? c[2] : c[1]; + if (this.worker && d) { + return this.index.get(d).import(a); } - if (c) { - "string" === typeof c && (c = JSON.parse(c)); - if (e) { - return this.index.get(e).import(b, c); + if (b) { + "string" === typeof b && (b = JSON.parse(b)); + if (d) { + return this.index.get(d).import(c, b); } - switch(b) { + switch(c) { case "reg": this.fastupdate = !1; - this.reg = xa(c, this.reg); - for (let d = 0, f; d < this.field.length; d++) { - f = this.index.get(this.field[d]), f.fastupdate = !1, f.reg = this.reg; + this.reg = xa(b, this.reg); + for (let e = 0, f; e < this.field.length; e++) { + f = this.index.get(this.field[e]), f.fastupdate = !1, f.reg = this.reg; } if (this.worker) { - c = []; - for (const d of this.index.values()) { - c.push(d.import(a)); + b = []; + for (const e of this.index.values()) { + b.push(e.import(a)); } - return Promise.all(c); + return Promise.all(b); } break; case "tag": - this.tag = va(c, this.tag); + this.tag = va(b, this.tag); break; case "doc": - this.store = ta(c, this.store); + this.store = ta(b, this.store); } } }; la(U.prototype); -function Va(a, c, b) { - const e = ("object" === typeof a ? "" + a.query : a).toLowerCase(); +function Va(a, b, c) { + const d = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new X()); - let d = this.cache.get(e); - if (!d) { - d = this.search(a, c, b); - if (d.then) { + let e = this.cache.get(d); + if (!e) { + e = this.search(a, b, c); + if (e.then) { const f = this; - d.then(function(g) { - f.cache.set(e, g); + e.then(function(g) { + f.cache.set(d, g); return g; }); } - this.cache.set(e, d); + this.cache.set(d, e); } - return d; + return e; } function X(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -X.prototype.set = function(a, c) { - this.cache.set(this.h = a, c); +X.prototype.set = function(a, b) { + this.cache.set(this.h = a, b); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; X.prototype.get = function(a) { - const c = this.cache.get(a); - c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c)); - return c; + const b = this.cache.get(a); + b && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, b)); + return b; }; X.prototype.remove = function(a) { - for (const c of this.cache) { - const b = c[0]; - c[1].includes(a) && this.cache.delete(b); + for (const b of this.cache) { + const c = b[0]; + b[1].includes(a) && this.cache.delete(c); } }; X.prototype.clear = function() { @@ -1836,115 +1836,117 @@ const Ya = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], const Za = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), $a = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; const ab = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; var bb = {Exact:Wa, Default:Xa, Normalize:Xa, LatinBalance:{mapper:Ya}, LatinAdvanced:{mapper:Ya, matcher:Za, replacer:$a}, LatinExtra:{mapper:Ya, replacer:$a.concat([/(?!^)[aeo]/g, ""]), matcher:Za}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (let b = 0; b < a.length; b++) { - var c = a[b]; - let e = c.charAt(0), d = ab[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = ab[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + for (let c = 0; c < a.length; c++) { + var b = a[c]; + let d = b.charAt(0), e = ab[d]; + for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = ab[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { } - a[b] = e; + a[c] = d; } }}, CJK:{split:""}, LatinExact:Wa, LatinDefault:Xa, LatinSimple:Xa}; -N.prototype.remove = function(a, c) { - const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); - if (b) { +N.prototype.remove = function(a, b) { + const c = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); + if (c) { if (this.fastupdate) { - for (let e = 0, d; e < b.length; e++) { - if (d = b[e]) { - if (2 > d.length) { - d.pop(); + for (let d = 0, e; d < c.length; d++) { + if (e = c[d]) { + if (2 > e.length) { + e.pop(); } else { - const f = d.indexOf(a); - f === b.length - 1 ? d.pop() : d.splice(f, 1); + const f = e.indexOf(a); + f === c.length - 1 ? e.pop() : e.splice(f, 1); } } } } else { cb(this.map, a), this.depth && cb(this.ctx, a); } - c || this.reg.delete(a); + b || this.reg.delete(a); } this.db && (this.commit_task.push({del:a}), this.T && db(this)); this.cache && this.cache.remove(a); return this; }; -function cb(a, c) { - let b = 0; - var e = "undefined" === typeof c; +function cb(a, b) { + let c = 0; + var d = "undefined" === typeof b; if (a.constructor === Array) { - for (let d = 0, f, g; d < a.length; d++) { - if ((f = a[d]) && f.length) { - if (e) { - b++; + for (let e = 0, f, g; e < a.length; e++) { + if ((f = a[e]) && f.length) { + if (d) { + c++; } else { - if (g = f.indexOf(c), 0 <= g) { - 1 < f.length ? (f.splice(g, 1), b++) : delete a[d]; + if (g = f.indexOf(b), 0 <= g) { + 1 < f.length ? (f.splice(g, 1), c++) : delete a[e]; break; } else { - b++; + c++; } } } } } else { - for (let d of a.entries()) { - e = d[0]; - const f = cb(d[1], c); - f ? b += f : a.delete(e); + for (let e of a.entries()) { + d = e[0]; + const f = cb(e[1], b); + f ? c += f : a.delete(d); } } - return b; + return c; } ;const eb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -N.prototype.add = function(a, c, b, e) { - if (c && (a || 0 === a)) { - if (!e && !b && this.reg.has(a)) { - return this.update(a, c); +N.prototype.add = function(a, b, c, d) { + if (b && (a || 0 === a)) { + if (!d && !c && this.reg.has(a)) { + return this.update(a, b); } - c = this.encoder.encode(c); - if (e = c.length) { - const l = A(), m = A(), n = this.depth, p = this.resolution; - for (let r = 0; r < e; r++) { - let q = c[this.rtl ? e - 1 - r : r]; - var d = q.length; - if (d && (n || !m[q])) { - var f = this.score ? this.score(c, q, r, null, 0) : fb(p, e, r), g = ""; + d = this.depth; + b = this.encoder.encode(b, !d); + const l = b.length; + if (l) { + const m = A(), n = A(), p = this.resolution; + for (let r = 0; r < l; r++) { + let q = b[this.rtl ? l - 1 - r : r]; + var e = q.length; + if (e && (d || !n[q])) { + var f = this.score ? this.score(b, q, r, null, 0) : fb(p, l, r), g = ""; switch(this.tokenize) { case "full": - if (2 < d) { - for (let u = 0, v; u < d; u++) { - for (f = d; f > u; f--) { + if (2 < e) { + for (let u = 0, v; u < e; u++) { + for (f = e; f > u; f--) { g = q.substring(u, f); - v = this.rtl ? d - 1 - u : u; - var h = this.score ? this.score(c, q, r, g, v) : fb(p, e, r, d, v); - gb(this, m, g, h, a, b); + v = this.rtl ? e - 1 - u : u; + var h = this.score ? this.score(b, q, r, g, v) : fb(p, l, r, e, v); + gb(this, n, g, h, a, c); } } break; } case "bidirectional": case "reverse": - if (1 < d) { - for (h = d - 1; 0 < h; h--) { - g = q[this.rtl ? d - 1 - h : h] + g; - var k = this.score ? this.score(c, q, r, g, h) : fb(p, e, r, d, h); - gb(this, m, g, k, a, b); + if (1 < e) { + for (h = e - 1; 0 < h; h--) { + g = q[this.rtl ? e - 1 - h : h] + g; + var k = this.score ? this.score(b, q, r, g, h) : fb(p, l, r, e, h); + gb(this, n, g, k, a, c); } g = ""; } case "forward": - if (1 < d) { - for (h = 0; h < d; h++) { - g += q[this.rtl ? d - 1 - h : h], gb(this, m, g, f, a, b); + if (1 < e) { + for (h = 0; h < e; h++) { + g += q[this.rtl ? e - 1 - h : h], gb(this, n, g, f, a, c); } break; } default: - if (gb(this, m, q, f, a, b), n && 1 < e && r < e - 1) { - for (d = A(), g = this.U, f = q, h = Math.min(n + 1, this.rtl ? r + 1 : e - r), d[f] = 1, k = 1; k < h; k++) { - if ((q = c[this.rtl ? e - 1 - r - k : r + k]) && !d[q]) { - d[q] = 1; - const u = this.score ? this.score(c, f, r, q, k - 1) : fb(g + (e / 2 > g ? 0 : 1), e, r, h - 1, k - 1), v = this.bidirectional && q > f; - gb(this, l, v ? f : q, u, a, b, v ? q : f); + if (gb(this, n, q, f, a, c), d && 1 < l && r < l - 1) { + for (e = A(), g = this.U, f = q, h = Math.min(d + 1, this.rtl ? r + 1 : l - r), e[f] = 1, k = 1; k < h; k++) { + if ((q = b[this.rtl ? l - 1 - r - k : r + k]) && !e[q]) { + e[q] = 1; + const u = this.score ? this.score(b, f, r, q, k - 1) : fb(g + (l / 2 > g ? 0 : 1), l, r, h - 1, k - 1), v = this.bidirectional && q > f; + gb(this, m, v ? f : q, u, a, c, v ? q : f); } } } @@ -1953,160 +1955,160 @@ N.prototype.add = function(a, c, b, e) { } this.fastupdate || this.reg.add(a); } else { - c = ""; + b = ""; } } - this.db && (c || this.commit_task.push({del:a}), this.T && db(this)); + this.db && (b || this.commit_task.push({del:a}), this.T && db(this)); return this; }; -function gb(a, c, b, e, d, f, g) { +function gb(a, b, c, d, e, f, g) { let h = g ? a.ctx : a.map, k; - if (!c[b] || g && !(k = c[b])[g]) { - if (g ? (c = k || (c[b] = A()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = k = []), h = h[e] || (h[e] = []), !f || !h.includes(d)) { + if (!b[c] || g && !(k = b[c])[g]) { + if (g ? (b = k || (b[c] = A()), b[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : b[c] = 1, (k = h.get(c)) ? h = k : h.set(c, h = k = []), h = h[d] || (h[d] = []), !f || !h.includes(e)) { if (h.length === 2 ** 31 - 1) { - c = new R(h); + b = new R(h); if (a.fastupdate) { for (let l of a.reg.values()) { - l.includes(h) && (l[l.indexOf(h)] = c); + l.includes(h) && (l[l.indexOf(h)] = b); } } - k[e] = h = c; + k[d] = h = b; } - h.push(d); - a.fastupdate && ((e = a.reg.get(d)) ? e.push(h) : a.reg.set(d, [h])); + h.push(e); + a.fastupdate && ((d = a.reg.get(e)) ? d.push(h) : a.reg.set(e, [h])); } } } -function fb(a, c, b, e, d) { - return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; +function fb(a, b, c, d, e) { + return c && 1 < a ? b + (d || 0) <= a ? c + (e || 0) : (a - 1) / (b + (d || 0)) * (c + (e || 0)) + 1 | 0 : 0; } -;N.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); - let e = [], d, f, g, h = 0, k, l, m, n, p; - b ? (a = b.query || a, c = b.limit || c, h = b.offset || 0, f = b.context, g = b.suggest, p = (k = !1 !== b.resolve) && b.enrich, m = b.boost, n = b.resolution, l = this.db && b.tag) : k = this.resolve; - let r = this.encoder.encode(a); - d = r.length; - c = c || (k ? 100 : 0); - if (1 === d) { - return hb.call(this, r[0], "", c, h, k, p, l); - } +;N.prototype.search = function(a, b, c) { + c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); + let d = [], e, f, g, h = 0, k, l, m, n, p; + c ? (a = c.query || a, b = c.limit || b, h = c.offset || 0, f = c.context, g = c.suggest, p = (k = !1 !== c.resolve) && c.enrich, m = c.boost, n = c.resolution, l = this.db && c.tag) : k = this.resolve; f = this.depth && !1 !== f; - if (2 === d && f && !g) { - return hb.call(this, r[1], r[0], c, h, k, p, l); + let r = this.encoder.encode(a, !f); + e = r.length; + b = b || (k ? 100 : 0); + if (1 === e) { + return hb.call(this, r[0], "", b, h, k, p, l); + } + if (2 === e && f && !g) { + return hb.call(this, r[1], r[0], b, h, k, p, l); } let q = A(), u = 0, v; f && (v = r[0], u = 1); n || 0 === n || (n = v ? this.U : this.resolution); if (this.db) { - if (this.db.search && (a = this.db.search(this, r, c, h, g, k, p, l), !1 !== a)) { + if (this.db.search && (a = this.db.search(this, r, b, h, g, k, p, l), !1 !== a)) { return a; } const w = this; return async function() { - for (let x, F; u < d; u++) { + for (let x, F; u < e; u++) { if ((F = r[u]) && !q[F]) { q[F] = 1; x = await ib(w, F, v, 0, 0, !1, !1); - if (x = jb(x, e, g, n)) { - e = x; + if (x = jb(x, d, g, n)) { + d = x; break; } - v && (g && x && e.length || (v = F)); + v && (g && x && d.length || (v = F)); } - g && v && u === d - 1 && !e.length && (n = w.resolution, v = "", u = -1, q = A()); + g && v && u === e - 1 && !d.length && (n = w.resolution, v = "", u = -1, q = A()); } - return kb(e, n, c, h, g, m, k); + return kb(d, n, b, h, g, m, k); }(); } - for (let w, x; u < d; u++) { + for (let w, x; u < e; u++) { if ((x = r[u]) && !q[x]) { q[x] = 1; w = ib(this, x, v, 0, 0, !1, !1); - if (w = jb(w, e, g, n)) { - e = w; + if (w = jb(w, d, g, n)) { + d = w; break; } - v && (g && w && e.length || (v = x)); + v && (g && w && d.length || (v = x)); } - g && v && u === d - 1 && !e.length && (n = this.resolution, v = "", u = -1, q = A()); + g && v && u === e - 1 && !d.length && (n = this.resolution, v = "", u = -1, q = A()); } - return kb(e, n, c, h, g, m, k); + return kb(d, n, b, h, g, m, k); }; -function kb(a, c, b, e, d, f, g) { +function kb(a, b, c, d, e, f, g) { let h = a.length, k = a; if (1 < h) { - k = Fa(a, c, b, e, d, f, g); + k = Fa(a, b, c, d, e, f, g); } else if (1 === h) { - return g ? Ia.call(null, a[0], b, e) : new W(a[0]); + return g ? Ia.call(null, a[0], c, d) : new W(a[0]); } return g ? k : new W(k); } -function hb(a, c, b, e, d, f, g) { - a = ib(this, a, c, b, e, d, f, g); +function hb(a, b, c, d, e, f, g) { + a = ib(this, a, b, c, d, e, f, g); return this.db ? a.then(function(h) { - return d ? h || [] : new W(h); - }) : a && a.length ? d ? Ia.call(this, a, b, e) : new W(a) : d ? [] : new W(); + return e ? h || [] : new W(h); + }) : a && a.length ? e ? Ia.call(this, a, c, d) : new W(a) : e ? [] : new W(); } -function jb(a, c, b, e) { - let d = []; +function jb(a, b, c, d) { + let e = []; if (a && a.length) { - if (a.length <= e) { - c.push(a); + if (a.length <= d) { + b.push(a); return; } - for (let f = 0, g; f < e; f++) { + for (let f = 0, g; f < d; f++) { if (g = a[f]) { - d[f] = g; + e[f] = g; } } - if (d.length) { - c.push(d); + if (e.length) { + b.push(e); return; } } - if (!b) { - return d; + if (!c) { + return e; } } -function ib(a, c, b, e, d, f, g, h) { +function ib(a, b, c, d, e, f, g, h) { let k; - b && (k = a.bidirectional && c > b) && (k = b, b = c, c = k); + c && (k = a.bidirectional && b > c) && (k = c, c = b, b = k); if (a.db) { - return a.db.get(c, b, e, d, f, g, h); + return a.db.get(b, c, d, e, f, g, h); } - a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); + a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); return a; } -;function N(a, c) { +;function N(a, b) { if (!this || this.constructor !== N) { return new N(a); } if (a) { - var b = D(a) ? a : a.preset; - b && (eb[b] || console.warn("Preset not found: " + b), a = Object.assign({}, eb[b], a)); + var c = D(a) ? a : a.preset; + c && (eb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, eb[c], a)); } else { a = {}; } - b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? bb[a.encoder] : a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new G(d) : {encode:d}; + c = a.context; + const d = !0 === c ? {depth:1} : c || {}, e = D(a.encoder) ? bb[a.encoder] : a.encode || a.encoder || {}; + this.encoder = e.encode ? e : "object" === typeof e ? new G(e) : {encode:e}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; - this.depth = "strict" === b && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.tokenize = c = (c = a.tokenize) && "default" !== c && "exact" !== c && c || "strict"; + this.depth = "strict" === c && d.depth || 0; + this.bidirectional = !1 !== d.bidirectional; this.fastupdate = !!a.fastupdate; this.score = a.score || null; - e && e.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); - (b = a.keystore || 0) && (this.keystore = b); - this.map = b ? new S(b) : new Map(); - this.ctx = b ? new S(b) : new Map(); - this.reg = c || (this.fastupdate ? b ? new S(b) : new Map() : b ? new T(b) : new Set()); - this.U = e.resolution || 3; - this.rtl = d.rtl || a.rtl || !1; - this.cache = (b = a.cache || null) && new X(b); + d && d.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); + (c = a.keystore || 0) && (this.keystore = c); + this.map = c ? new S(c) : new Map(); + this.ctx = c ? new S(c) : new Map(); + this.reg = b || (this.fastupdate ? c ? new S(c) : new Map() : c ? new T(c) : new Set()); + this.U = d.resolution || 3; + this.rtl = e.rtl || a.rtl || !1; + this.cache = (c = a.cache || null) && new X(c); this.resolve = !1 !== a.resolve; - if (b = a.db) { - this.db = this.mount(b); + if (c = a.db) { + this.db = this.mount(c); } this.T = !1 !== a.commit; this.commit_task = []; @@ -2118,9 +2120,9 @@ t.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); }; -t.commit = function(a, c) { +t.commit = function(a, b) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); - return this.db.commit(this, a, c); + return this.db.commit(this, a, b); }; t.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); @@ -2140,15 +2142,15 @@ t.clear = function() { this.db && (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [{clear:!0}]); return this; }; -t.append = function(a, c) { - return this.add(a, c, !0); +t.append = function(a, b) { + return this.add(a, b, !0); }; t.contain = function(a) { return this.db ? this.db.has(a) : this.reg.has(a); }; -t.update = function(a, c) { - const b = this, e = this.remove(a); - return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); +t.update = function(a, b) { + const c = this, d = this.remove(a); + return d && d.then ? d.then(() => c.add(a, b)) : this.add(a, b); }; t.cleanup = function() { if (!this.fastupdate) { @@ -2159,77 +2161,77 @@ t.cleanup = function() { return this; }; t.searchCache = Va; -t.export = function(a, c, b = 0, e = 0) { - let d, f; - switch(e) { +t.export = function(a, b, c = 0, d = 0) { + let e, f; + switch(d) { case 0: - d = "reg"; + e = "reg"; f = wa(this.reg); break; case 1: - d = "cfg"; + e = "cfg"; f = null; break; case 2: - d = "map"; + e = "map"; f = sa(this.map, this.reg.size); break; case 3: - d = "ctx"; + e = "ctx"; f = ua(this.ctx, this.reg.size); break; default: return; } - return ya.call(this, a, c, d, f, b, e); + return ya.call(this, a, b, e, f, c, d); }; -t.import = function(a, c) { - if (c) { - switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { +t.import = function(a, b) { + if (b) { + switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = xa(c, this.reg); + this.reg = xa(b, this.reg); break; case "map": - this.map = ta(c, this.map); + this.map = ta(b, this.map); break; case "ctx": - this.ctx = va(c, this.ctx); + this.ctx = va(b, this.ctx); } } }; t.serialize = function(a = !0) { - let c = "", b = "", e = ""; + let b = "", c = "", d = ""; if (this.reg.size) { let f; - for (var d of this.reg.keys()) { - f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); + for (var e of this.reg.keys()) { + f || (f = typeof e), b += (b ? "," : "") + ("string" === f ? '"' + e + '"' : e); } - c = "index.reg=new Set([" + c + "]);"; - b = za(this.map, f); - b = "index.map=new Map([" + b + "]);"; + b = "index.reg=new Set([" + b + "]);"; + c = za(this.map, f); + c = "index.map=new Map([" + c + "]);"; for (const g of this.ctx.entries()) { - d = g[0]; + e = g[0]; let h = za(g[1], f); h = "new Map([" + h + "])"; - h = '["' + d + '",' + h + "]"; - e += (e ? "," : "") + h; + h = '["' + e + '",' + h + "]"; + d += (d ? "," : "") + h; } - e = "index.ctx=new Map([" + e + "]);"; + d = "index.ctx=new Map([" + d + "]);"; } - return a ? "function inject(index){" + c + b + e + "}" : c + b + e; + return a ? "function inject(index){" + b + c + d + "}" : b + c + d; }; la(N.prototype); const lb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), mb = ["map", "ctx", "tag", "reg", "cfg"], Y = A(); -function nb(a, c = {}) { +function nb(a, b = {}) { if (!this || this.constructor !== nb) { - return new nb(a, c); + return new nb(a, b); } - "object" === typeof a && (c = a, a = a.name); + "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""); - this.field = c.field ? c.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; - this.type = c.type; + this.field = b.field ? b.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; + this.type = b.type; this.fastupdate = this.support_tag_search = !1; this.db = null; this.h = {}; @@ -2250,18 +2252,18 @@ t.open = function() { navigator.storage && navigator.storage.persist(); Y[a.id] || (Y[a.id] = []); Y[a.id].push(a.field); - const c = lb.open(a.id, 1); - c.onupgradeneeded = function() { - const b = a.db = this.result; - for (let e = 0, d; e < mb.length; e++) { - d = mb[e]; + const b = lb.open(a.id, 1); + b.onupgradeneeded = function() { + const c = a.db = this.result; + for (let d = 0, e; d < mb.length; d++) { + e = mb[d]; for (let f = 0, g; f < Y[a.id].length; f++) { - g = Y[a.id][f], b.objectStoreNames.contains(d + ("reg" !== d ? g ? ":" + g : "" : "")) || b.createObjectStore(d + ("reg" !== d ? g ? ":" + g : "" : "")); + g = Y[a.id][f], c.objectStoreNames.contains(e + ("reg" !== e ? g ? ":" + g : "" : "")) || c.createObjectStore(e + ("reg" !== e ? g ? ":" + g : "" : "")); } } }; - return a.db = Z(c, function(b) { - a.db = b; + return a.db = Z(b, function(c) { + a.db = c; a.db.onversionchange = function() { a.close(); }; @@ -2277,42 +2279,42 @@ t.destroy = function() { }; t.clear = function() { const a = []; - for (let b = 0, e; b < mb.length; b++) { - e = mb[b]; - for (let d = 0, f; d < Y[this.id].length; d++) { - f = Y[this.id][d], a.push(e + ("reg" !== e ? f ? ":" + f : "" : "")); + for (let c = 0, d; c < mb.length; c++) { + d = mb[c]; + for (let e = 0, f; e < Y[this.id].length; e++) { + f = Y[this.id][e], a.push(d + ("reg" !== d ? f ? ":" + f : "" : "")); } } - const c = this.db.transaction(a, "readwrite"); - for (let b = 0; b < a.length; b++) { - c.objectStore(a[b]).clear(); + const b = this.db.transaction(a, "readwrite"); + for (let c = 0; c < a.length; c++) { + b.objectStore(a[c]).clear(); } - return Z(c); + return Z(b); }; -t.get = function(a, c, b = 0, e = 0, d = !0, f = !1) { - a = this.db.transaction((c ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((c ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(c ? c + ":" + a : a); +t.get = function(a, b, c = 0, d = 0, e = !0, f = !1) { + a = this.db.transaction((b ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((b ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(b ? b + ":" + a : a); const g = this; return Z(a).then(function(h) { let k = []; if (!h || !h.length) { return k; } - if (d) { - if (!b && !e && 1 === h.length) { + if (e) { + if (!c && !d && 1 === h.length) { return h[0]; } for (let l = 0, m; l < h.length; l++) { if ((m = h[l]) && m.length) { - if (e >= m.length) { - e -= m.length; + if (d >= m.length) { + d -= m.length; continue; } - const n = b ? e + Math.min(m.length - e, b) : m.length; - for (let p = e; p < n; p++) { + const n = c ? d + Math.min(m.length - d, c) : m.length; + for (let p = d; p < n; p++) { k.push(m[p]); } - e = 0; - if (k.length === b) { + d = 0; + if (k.length === c) { break; } } @@ -2322,78 +2324,78 @@ t.get = function(a, c, b = 0, e = 0, d = !0, f = !1) { return h; }); }; -t.tag = function(a, c = 0, b = 0, e = !1) { +t.tag = function(a, b = 0, c = 0, d = !1) { a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a); - const d = this; + const e = this; return Z(a).then(function(f) { - if (!f || !f.length || b >= f.length) { + if (!f || !f.length || c >= f.length) { return []; } - if (!c && !b) { + if (!b && !c) { return f; } - f = f.slice(b, b + c); - return e ? d.enrich(f) : f; + f = f.slice(c, c + b); + return d ? e.enrich(f) : f; }); }; t.enrich = function(a) { "object" !== typeof a && (a = [a]); - const c = this.db.transaction("reg", "readonly").objectStore("reg"), b = []; - for (let e = 0; e < a.length; e++) { - b[e] = Z(c.get(a[e])); + const b = this.db.transaction("reg", "readonly").objectStore("reg"), c = []; + for (let d = 0; d < a.length; d++) { + c[d] = Z(b.get(a[d])); } - return Promise.all(b).then(function(e) { - for (let d = 0; d < e.length; d++) { - e[d] = {id:a[d], doc:e[d] ? JSON.parse(e[d]) : null}; + return Promise.all(c).then(function(d) { + for (let e = 0; e < d.length; e++) { + d[e] = {id:a[e], doc:d[e] ? JSON.parse(d[e]) : null}; } - return e; + return d; }); }; t.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); - return Z(a).then(function(c) { - return !!c; + return Z(a).then(function(b) { + return !!b; }); }; t.search = null; t.info = function() { }; -t.transaction = function(a, c, b) { +t.transaction = function(a, b, c) { a += "reg" !== a ? this.field ? ":" + this.field : "" : ""; - let e = this.h[a + ":" + c]; - if (e) { - return b.call(this, e); + let d = this.h[a + ":" + b]; + if (d) { + return c.call(this, d); } - let d = this.db.transaction(a, c); - this.h[a + ":" + c] = e = d.objectStore(a); - const f = b.call(this, e); - this.h[a + ":" + c] = null; - return Z(d).finally(function() { - d = e = null; + let e = this.db.transaction(a, b); + this.h[a + ":" + b] = d = e.objectStore(a); + const f = c.call(this, d); + this.h[a + ":" + b] = null; + return Z(e).finally(function() { + e = d = null; return f; }); }; -t.commit = async function(a, c, b) { - if (c) { +t.commit = async function(a, b, c) { + if (b) { await this.clear(), a.commit_task = []; } else { - let e = a.commit_task; + let d = a.commit_task; a.commit_task = []; - for (let d = 0, f; d < e.length; d++) { - if (f = e[d], f.clear) { + for (let e = 0, f; e < d.length; e++) { + if (f = d[e], f.clear) { await this.clear(); - c = !0; + b = !0; break; } else { - e[d] = f.del; + d[e] = f.del; } } - c || (b || (e = e.concat(ba(a.reg))), e.length && await this.remove(e)); + b || (c || (d = d.concat(ba(a.reg))), d.length && await this.remove(d)); } - a.reg.size && (await this.transaction("map", "readwrite", function(e) { - for (const d of a.map) { - const f = d[0], g = d[1]; - g.length && (c ? e.put(g, f) : e.get(f).onsuccess = function() { + a.reg.size && (await this.transaction("map", "readwrite", function(d) { + for (const e of a.map) { + const f = e[0], g = e[1]; + g.length && (b ? d.put(g, f) : d.get(f).onsuccess = function() { let h = this.result; var k; if (h && h.length) { @@ -2413,15 +2415,15 @@ t.commit = async function(a, c, b) { } else { h = g, k = 1; } - k && e.put(h, f); + k && d.put(h, f); }); } - }), await this.transaction("ctx", "readwrite", function(e) { - for (const d of a.ctx) { - const f = d[0], g = d[1]; + }), await this.transaction("ctx", "readwrite", function(d) { + for (const e of a.ctx) { + const f = e[0], g = e[1]; for (const h of g) { const k = h[0], l = h[1]; - l.length && (c ? e.put(l, f + ":" + k) : e.get(f + ":" + k).onsuccess = function() { + l.length && (b ? d.put(l, f + ":" + k) : d.get(f + ":" + k).onsuccess = function() { let m = this.result; var n; if (m && m.length) { @@ -2441,85 +2443,85 @@ t.commit = async function(a, c, b) { } else { m = l, n = 1; } - n && e.put(m, f + ":" + k); + n && d.put(m, f + ":" + k); }); } } - }), a.store ? await this.transaction("reg", "readwrite", function(e) { - for (const d of a.store) { - const f = d[0], g = d[1]; - e.put("object" === typeof g ? JSON.stringify(g) : 1, f); + }), a.store ? await this.transaction("reg", "readwrite", function(d) { + for (const e of a.store) { + const f = e[0], g = e[1]; + d.put("object" === typeof g ? JSON.stringify(g) : 1, f); } - }) : a.bypass || await this.transaction("reg", "readwrite", function(e) { - for (const d of a.reg.keys()) { - e.put(1, d); + }) : a.bypass || await this.transaction("reg", "readwrite", function(d) { + for (const e of a.reg.keys()) { + d.put(1, e); } - }), a.tag && await this.transaction("tag", "readwrite", function(e) { - for (const d of a.tag) { - const f = d[0], g = d[1]; - g.length && (e.get(f).onsuccess = function() { + }), a.tag && await this.transaction("tag", "readwrite", function(d) { + for (const e of a.tag) { + const f = e[0], g = e[1]; + g.length && (d.get(f).onsuccess = function() { let h = this.result; h = h && h.length ? h.concat(g) : g; - e.put(h, f); + d.put(h, f); }); } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function pb(a, c, b) { - const e = a.value; - let d, f = 0; - for (let g = 0, h; g < e.length; g++) { - if (h = b ? e : e[g]) { - for (let k = 0, l, m; k < c.length; k++) { - if (m = c[k], l = h.indexOf(m), 0 <= l) { - if (d = 1, 1 < h.length) { +function pb(a, b, c) { + const d = a.value; + let e, f = 0; + for (let g = 0, h; g < d.length; g++) { + if (h = c ? d : d[g]) { + for (let k = 0, l, m; k < b.length; k++) { + if (m = b[k], l = h.indexOf(m), 0 <= l) { + if (e = 1, 1 < h.length) { h.splice(l, 1); } else { - e[g] = []; + d[g] = []; break; } } } f += h.length; } - if (b) { + if (c) { break; } } - f ? d && a.update(e) : a.delete(); + f ? e && a.update(d) : a.delete(); a.continue(); } t.remove = function(a) { "object" !== typeof a && (a = [a]); - return Promise.all([this.transaction("map", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && pb(b, a); + return Promise.all([this.transaction("map", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && pb(c, a); }; - }), this.transaction("ctx", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && pb(b, a); + }), this.transaction("ctx", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && pb(c, a); }; - }), this.transaction("tag", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && pb(b, a, !0); + }), this.transaction("tag", "readwrite", function(b) { + b.openCursor().onsuccess = function() { + const c = this.result; + c && pb(c, a, !0); }; - }), this.transaction("reg", "readwrite", function(c) { - for (let b = 0; b < a.length; b++) { - c.delete(a[b]); + }), this.transaction("reg", "readwrite", function(b) { + for (let c = 0; c < a.length; c++) { + b.delete(a[c]); } })]); }; -function Z(a, c) { - return new Promise((b, e) => { +function Z(a, b) { + return new Promise((c, d) => { a.onsuccess = a.oncomplete = function() { - c && c(this.result); - c = null; - b(this.result); + b && b(this.result); + b = null; + c(this.result); }; - a.onerror = a.onblocked = e; + a.onerror = a.onblocked = d; a = null; }); } diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js index 89c2bdb..089a192 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -1,95 +1,95 @@ /**! - * FlexSearch.js v0.8.156 (Bundle/Module) + * FlexSearch.js v0.8.157 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var t;function z(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function A(){return Object.create(null)}function D(a){return"string"===typeof a} -function G(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function ba(a,b){if(D(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,da)}catch(d){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:z(c&&new Set(c),null,this.filter);this.dedupe=z(a.dedupe,!0,this.dedupe);this.matcher=z((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=z((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=z((c=a.stemmer)&&new Map(c), -null,this.stemmer);this.replacer=z(a.replacer,null,this.replacer);this.minlength=z(a.minlength,1,this.minlength);this.maxlength=z(a.maxlength,1024,this.maxlength);this.rtl=z(a.rtl,!1,this.rtl);if(this.cache=c=z(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.A+= -(this.A?"|":"")+d;return this};t.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&I(this);return this};t.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&I(this);return this}; +var t;function z(a,b,c){const d=typeof c,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(c){if("function"===e&&d===e)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===e?b:a}function A(){return Object.create(null)}function D(a){return"string"===typeof a} +function G(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function ba(a,b){if(D(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; +this.numeric=z(a.numeric,d)}else{try{this.split=z(this.split,da)}catch(e){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:z(c&&new Set(c),null,this.filter);this.dedupe=z(a.dedupe,!0,this.dedupe);this.matcher=z((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=z((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=z((c=a.stemmer)&&new Map(c), +null,this.stemmer);this.replacer=z(a.replacer,null,this.replacer);this.minlength=z(a.minlength,1,this.minlength);this.maxlength=z(a.maxlength,1024,this.maxlength);this.rtl=z(a.rtl,!1,this.rtl);if(this.cache=c=z(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const e of this.matcher.keys())this.h+=(this.h?"|":"")+e;if(this.stemmer)for(const e of this.stemmer.keys())this.A+= +(this.A?"|":"")+e;return this};t.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&I(this);return this};t.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&I(this);return this}; t.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&I(this);return this}; t.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&I(this);return this}; -t.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(I,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ia?a.normalize("NFKD").replace(ia,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength))if(b)c.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.L)if(this.H){var d=this.G.get(g);if(d||""===d){d&&c.push(d);continue}}else this.H=setTimeout(I,50,this);this.stemmer&&2this.stemmer.get(k))); -if(g&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(g&&this.replacer)for(d=0;g&&dthis.S&& -(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function I(a){a.H=null;a.B.clear();a.G.clear()};let K,ja;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":ja=a.options||{};(b=a.factory)?(Function("return "+b)()(self),K=new self.FlexSearch.Index(ja),delete self.FlexSearch):K=new M(ja);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=ja.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await ja.import.call(K,e[0]),K.import(e[0],a)):(d=e&&K[b].apply(K,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} -function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);na?pa||(pa=Date.now()-oa>=this.priority*this.priority*3):(na=setTimeout(qa,0),oa=Date.now());if(pa){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let N=0; -function P(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&d.h[l];m&&(m(k.msg),delete d.h[l])}this.worker=g;this.h=A();if(this.worker){e?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){d.h[++N]=function(){k(d);1E9this.maxlength||b&&e[k]))if(c)b&&(e[k]=1),d.push(k);else if(!this.filter||("function"===typeof this.filter?this.filter(k):!this.filter.has(k))){if(this.cache&&k.length<=this.L)if(this.H){var g=this.G.get(k);if(g||""===g){g&&d.push(g);continue}}else this.H=setTimeout(I,50,this);this.stemmer&&2this.stemmer.get(m)));if(k&&(this.mapper||this.dedupe&&1this.matcher.get(m)));if(k&&this.replacer)for(g=0;k&&gthis.S&&(this.G.clear(),this.L=this.L/1.1|0));!k||b&&e[k]||(b&&(e[k]=1),d.push(k))}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.K&&(this.B.set(a,d),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return d};function I(a){a.H=null;a.B.clear();a.G.clear()};let K,ja;async function ka(a){a=a.data;var b=a.task;const c=a.id;let d=a.args;switch(b){case "init":ja=a.options||{};(b=a.factory)?(Function("return "+b)()(self),K=new self.FlexSearch.Index(ja),delete self.FlexSearch):K=new M(ja);postMessage({id:c});break;default:let e;"export"===b&&(d[1]?(d[0]=ja.export,d[2]=0,d[3]=1):d=null);"import"===b?d[0]&&(a=await ja.import.call(K,d[0]),K.import(d[0],a)):(e=d&&K[b].apply(K,d))&&e.then&&(e=await e);postMessage("search"===b?{id:c,msg:e}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} +function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let d;"function"===typeof c&&(d=c,delete b[b.length-1]);na?pa||(pa=Date.now()-oa>=this.priority*this.priority*3):(na=setTimeout(qa,0),oa=Date.now());if(pa){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const e=this[a].apply(this,b);c=e.then?e:new Promise(f=>f(e));d&&c.then(d);return c}};let N=0; +function P(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=g;this.h=A();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++N]=function(){k(e);1E9=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const h=b.length;if(h&&(d=d.length?d.concat(b):b,c-=h,e&&(a.length-=h),!c))break;b=0}return d} -function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,h,k;g=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} +function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){let f=0;for(let g=0,h,k;gc||e?k.slice(e,c+e):k;else{if(ac||e)k=k.slice(e,c+e)}else{d= -[];for(let n=0,p;ne)e-=p.length;else{if(p.length>c||e)p=p.slice(e,c+e),c-=p.length,e&&(e-=p.length);d.push(p);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,e?V.call(this,a):a;let d=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!d.length&&h>=b)return e?V.call(this,g):g;d.push(g);b-=h;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ga(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};W.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:h,offset:k,enrich:l,resolve:m,suggest:n}=Ja(this,"and",arguments);return La.call(this,f,g,h,k,l,m,n)}return d?this.resolve(b,c,e):this}; -function La(a,b,c,e,d,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Fa(a,b,c,e,g,this.h,f),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};W.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,e,d,f,g)}; -function Ma(a,b,c,e,d,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function Na(a,b,c,e,d){const f=[],g=A();let h=0;for(let k=0,l;kc||e)a=a.slice(e,e+c);d&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;cc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e= +[];for(let n=0,p;nd)d-=p.length;else{if(p.length>c||d)p=p.slice(d,c+d),c-=p.length,d&&(d-=p.length);e.push(p);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,d?V.call(this,a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!e.length&&h>=b)return d?V.call(this,g):g;e.push(g);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=Ga(a,c,d,!1,this.h),d=0));return f?this.resolve(c,d,e):this};W.prototype.and=function(){let a=this.result.length,b,c,d,e;if(!a){const f=arguments[0];f&&(a=!!f.suggest,e=f.resolve,b=f.limit,c=f.offset,d=f.enrich&&e)}if(a){const {O:f,P:g,limit:h,offset:k,enrich:l,resolve:m,suggest:n}=Ja(this,"and",arguments);return La.call(this,f,g,h,k,l,m,n)}return e?this.resolve(b,c,d):this}; +function La(a,b,c,d,e,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Fa(a,b,c,d,g,this.h,f),f?e?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,d,e):this};W.prototype.xor=function(){const {O:a,P:b,limit:c,offset:d,enrich:e,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,d,e,f,g)}; +function Ma(a,b,c,d,e,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,d,f,this.h),f?e?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,d,e):this} +function Na(a,b,c,d,e){const f=[],g=A();let h=0;for(let k=0,l;kc||d)a=a.slice(d,d+c);e&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -X.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:!1,numeric:!1,dedupe:!1};const Xa={};const Ya=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Za=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),$a=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ab={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var bb={Exact:Wa,Default:Xa,Normalize:Xa,LatinBalance:{mapper:Ya},LatinAdvanced:{mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cd.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else cb(this.map,a),this.depth&&cb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&db(this));this.cache&&this.cache.remove(a);return this}; -function cb(a,b){let c=0;var e="undefined"===typeof b;if(a.constructor===Array)for(let d=0,f,g;du;f--){g=q.substring(u,f);v=this.rtl?d-1-u:u;var h=this.score?this.score(b,q,r,g,v):fb(p,e,r,d,v); -gb(this,m,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1), -e,r,h-1,k-1),v=this.bidirectional&&q>f;gb(this,l,v?f:q,u,a,c,v?q:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&db(this));return this}; -function gb(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=A()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){b=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[e]=h=b}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} -function fb(a,b,c,e,d){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,e,d,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=D(a)?a:a.preset;c&&(a=Object.assign({},eb[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=D(a.encoder)?bb[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new H(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.U=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new X(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}t=M.prototype; +t.export=function(a,b,c=0,d=0){if(cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +X.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:!1,numeric:!1,dedupe:!1};const Xa={};const Ya=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Za=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),$a=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ab={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var bb={Exact:Wa,Default:Xa,Normalize:Xa,LatinBalance:{mapper:Ya},LatinAdvanced:{mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;ce.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else cb(this.map,a),this.depth&&cb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&db(this));this.cache&&this.cache.remove(a);return this}; +function cb(a,b){let c=0;var d="undefined"===typeof b;if(a.constructor===Array)for(let e=0,f,g;eu;f--){g=q.substring(u,f);v=this.rtl?e-1-u:u;var h=this.score?this.score(b,q,r,g,v):fb(p, +l,r,e,v);gb(this,n,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1),l,r,h-1,k-1),v=this.bidirectional&&q>f;gb(this,m,v?f:q,u,a,c,v?q:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&db(this));return this}; +function gb(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=A()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} +function fb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=D(a)?a:a.preset;c&&(a=Object.assign({},eb[c],a))}else a={};c=a.context;const d=!0===c?{depth:1}:c||{},e=D(a.encoder)?bb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new H(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.U=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new X(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}t=M.prototype; t.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};t.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};t.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function db(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} -t.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};t.append=function(a,b){return this.add(a,b,!0)};t.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};t.update=function(a,b){const c=this,e=this.remove(a);return e&&e.then?e.then(()=>c.add(a,b)):this.add(a,b)}; -t.cleanup=function(){if(!this.fastupdate)return this;cb(this.map);this.depth&&cb(this.ctx);return this};t.searchCache=Va;t.export=function(a,b,c=0,e=0){let d,f;switch(e){case 0:d="reg";f=wa(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=sa(this.map,this.reg.size);break;case 3:d="ctx";f=ua(this.ctx,this.reg.size);break;default:return}return ya.call(this,a,b,d,f,c,e)}; +t.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};t.append=function(a,b){return this.add(a,b,!0)};t.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};t.update=function(a,b){const c=this,d=this.remove(a);return d&&d.then?d.then(()=>c.add(a,b)):this.add(a,b)}; +t.cleanup=function(){if(!this.fastupdate)return this;cb(this.map);this.depth&&cb(this.ctx);return this};t.searchCache=Va;t.export=function(a,b,c=0,d=0){let e,f;switch(d){case 0:e="reg";f=wa(this.reg);break;case 1:e="cfg";f=null;break;case 2:e="map";f=sa(this.map,this.reg.size);break;case 3:e="ctx";f=ua(this.ctx,this.reg.size);break;default:return}return ya.call(this,a,b,e,f,c,d)}; t.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length){e-=m.length;continue}const n=c?e+Math.min(m.length-e,c):m.length;for(let p=e;p=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; -t.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e=m.length){d-=m.length;continue}const n=c?d+Math.min(m.length-d,c):m.length;for(let p=d;p=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})}; +t.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let d=0;d{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};export default {Index:M,Charset:bb,Encoder:H,Document:U,Worker:P,Resolver:W,IndexedDB:ob,Language:{}}; +function Z(a,b){return new Promise((c,d)=>{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=d;a=null})};export default {Index:M,Charset:bb,Encoder:H,Document:U,Worker:P,Resolver:W,IndexedDB:ob,Language:{}}; export const Index=M;export const Charset=bb;export const Encoder=H;export const Document=U;export const Worker=P;export const Resolver=W;export const IndexedDB=ob;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.debug.js b/dist/flexsearch.compact.debug.js index cf43ce2..ee8ed7f 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.156 (Bundle/Debug) + * FlexSearch.js v0.8.157 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -7,7 +7,7 @@ */ (function(self){'use strict'; var x; -function A(a, c, b) { +function z(a, c, b) { const e = typeof b, d = typeof a; if ("undefined" !== e) { if ("undefined" !== d) { @@ -85,7 +85,7 @@ function I(a = {}) { } x = I.prototype; x.assign = function(a) { - this.normalize = A(a.normalize, !0, this.normalize); + this.normalize = z(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, e; if (b || "" === b) { if ("object" === typeof b && b.constructor !== RegExp) { @@ -108,28 +108,28 @@ x.assign = function(a) { } else { this.split = b, e = !1 === b || 2 > "a1a".split(b).length; } - this.numeric = A(a.numeric, e); + this.numeric = z(a.numeric, e); } else { try { - this.split = A(this.split, ba); + this.split = z(this.split, ba); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } - this.numeric = A(a.numeric, A(this.numeric, !0)); + this.numeric = z(a.numeric, z(this.numeric, !0)); } - this.prepare = A(a.prepare, null, this.prepare); - this.finalize = A(a.finalize, null, this.finalize); + this.prepare = z(a.prepare, null, this.prepare); + this.finalize = z(a.finalize, null, this.finalize); b = a.filter; - this.filter = "function" === typeof b ? b : A(b && new Set(b), null, this.filter); - this.dedupe = A(a.dedupe, !0, this.dedupe); - this.matcher = A((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = A((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = A((b = a.stemmer) && new Map(b), null, this.stemmer); - this.replacer = A(a.replacer, null, this.replacer); - this.minlength = A(a.minlength, 1, this.minlength); - this.maxlength = A(a.maxlength, 1024, this.maxlength); - this.rtl = A(a.rtl, !1, this.rtl); - if (this.cache = b = A(a.cache, !0, this.cache)) { + this.filter = "function" === typeof b ? b : z(b && new Set(b), null, this.filter); + this.dedupe = z(a.dedupe, !0, this.dedupe); + this.matcher = z((b = a.matcher) && new Map(b), null, this.matcher); + this.mapper = z((b = a.mapper) && new Map(b), null, this.mapper); + this.stemmer = z((b = a.stemmer) && new Map(b), null, this.stemmer); + this.replacer = z(a.replacer, null, this.replacer); + this.minlength = z(a.minlength, 1, this.minlength); + this.maxlength = z(a.maxlength, 1024, this.maxlength); + this.rtl = z(a.rtl, !1, this.rtl); + if (this.cache = b = z(a.cache, !0, this.cache)) { this.H = null, this.R = "number" === typeof b ? b : 2e5, this.F = new Map(), this.G = new Map(), this.L = this.K = 128; } this.h = ""; @@ -196,7 +196,7 @@ x.addReplacer = function(a, c) { this.cache && J(this); return this; }; -x.encode = function(a) { +x.encode = function(a, c) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.F.has(a)) { @@ -209,48 +209,48 @@ x.encode = function(a) { this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = fa ? a.normalize("NFKD").replace(fa, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(da, "$1 $2").replace(ea, "$1 $2").replace(ca, "$1 ")); - const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let b = [], e = this.split || "" === this.split ? a.split(this.split) : a; - for (let f = 0, g, k; f < e.length; f++) { - if ((g = k = e[f]) && !(g.length < this.minlength || g.length > this.maxlength)) { - if (c) { - b.push(g); + const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + let e = [], d = B(), f = this.split || "" === this.split ? a.split(this.split) : [a]; + for (let k = 0, h, l; k < f.length; k++) { + if ((h = l = f[k]) && !(h.length < this.minlength || h.length > this.maxlength || c && d[h])) { + if (b) { + c && (d[h] = 1), e.push(h); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(g) : !this.filter.has(g))) { - if (this.cache && g.length <= this.L) { + if (!this.filter || ("function" === typeof this.filter ? this.filter(h) : !this.filter.has(h))) { + if (this.cache && h.length <= this.L) { if (this.H) { - var d = this.G.get(g); - if (d || "" === d) { - d && b.push(d); + var g = this.G.get(h); + if (g || "" === g) { + g && e.push(g); continue; } } else { this.H = setTimeout(J, 50, this); } } - this.stemmer && 2 < g.length && (this.N || (this.N = new RegExp("(?!^)(" + this.C + ")$")), g = g.replace(this.N, h => this.stemmer.get(h))); - if (g && (this.mapper || this.dedupe && 1 < g.length)) { - d = ""; - for (let h = 0, l = "", n, m; h < g.length; h++) { - n = g.charAt(h), n === l && this.dedupe || ((m = this.mapper && this.mapper.get(n)) || "" === m ? m === l && this.dedupe || !(l = m) || (d += m) : d += l = n); + this.stemmer && 2 < h.length && (this.N || (this.N = new RegExp("(?!^)(" + this.C + ")$")), h = h.replace(this.N, n => this.stemmer.get(n))); + if (h && (this.mapper || this.dedupe && 1 < h.length)) { + g = ""; + for (let n = 0, m = "", r, p; n < h.length; n++) { + r = h.charAt(n), r === m && this.dedupe || ((p = this.mapper && this.mapper.get(r)) || "" === p ? p === m && this.dedupe || !(m = p) || (g += p) : g += m = r); } - g = d; + h = g; } - this.matcher && 1 < g.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), g = g.replace(this.M, h => this.matcher.get(h))); - if (g && this.replacer) { - for (d = 0; g && d < this.replacer.length; d += 2) { - g = g.replace(this.replacer[d], this.replacer[d + 1]); + this.matcher && 1 < h.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), h = h.replace(this.M, n => this.matcher.get(n))); + if (h && this.replacer) { + for (g = 0; h && g < this.replacer.length; g += 2) { + h = h.replace(this.replacer[g], this.replacer[g + 1]); } } - this.cache && k.length <= this.L && (this.G.set(k, g), this.G.size > this.R && (this.G.clear(), this.L = this.L / 1.1 | 0)); - g && b.push(g); + this.cache && l.length <= this.L && (this.G.set(l, h), this.G.size > this.R && (this.G.clear(), this.L = this.L / 1.1 | 0)); + !h || c && d[h] || (c && (d[h] = 1), e.push(h)); } } } } - this.finalize && (b = this.finalize(b) || b); - this.cache && a.length <= this.K && (this.F.set(a, b), this.F.size > this.R && (this.F.clear(), this.K = this.K / 1.1 | 0)); - return b; + this.finalize && (e = this.finalize(e) || e); + this.cache && a.length <= this.K && (this.F.set(a, e), this.F.size > this.R && (this.F.clear(), this.K = this.K / 1.1 | 0)); + return e; }; function J(a) { a.H = null; @@ -969,8 +969,8 @@ U.prototype.search = function(a, c, b, e) { if (l) { l.constructor !== Array && (l = [l]); var u = []; - for (let z = 0, v; z < l.length; z++) { - v = l[z]; + for (let A = 0, v; A < l.length; A++) { + v = l[A]; if (C(v)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } @@ -1007,9 +1007,9 @@ U.prototype.search = function(a, c, b, e) { q = Ia.call(this, u[p], u[p + 1], c, t, g), d.push({field:u[p], tag:u[p + 1], result:q}); } } - return f.length ? Promise.all(f).then(function(z) { - for (let v = 0; v < z.length; v++) { - d[v].result = z[v]; + return f.length ? Promise.all(f).then(function(A) { + for (let v = 0; v < A.length; v++) { + d[v].result = A[v]; } return d; }) : d; @@ -1019,15 +1019,15 @@ U.prototype.search = function(a, c, b, e) { } h || (h = this.field); u = !e && (this.worker || this.db) && []; - for (let z = 0, v, D, E; z < h.length; z++) { - D = h[z]; + for (let A = 0, v, D, E; A < h.length; A++) { + D = h[A]; let F; C(D) || (F = D, D = F.field, a = F.query || a, c = F.limit || c, t = F.offset || t, k = F.suggest || k, g = this.store && (F.enrich || g)); if (e) { - v = e[z]; + v = e[A]; } else { if (w = F || b, y = this.index.get(D), l && (w.enrich = !1), u) { - u[z] = y.search(a, c, w); + u[A] = y.search(a, c, w); w && g && (w.enrich = g); continue; } else { @@ -1069,9 +1069,9 @@ U.prototype.search = function(a, c, b, e) { } } if (u) { - const z = this; + const A = this; return Promise.all(u).then(function(v) { - return v.length ? z.search(a, c, b, v) : v; + return v.length ? A.search(a, c, b, v) : v; }); } if (!n) { @@ -1115,26 +1115,26 @@ function Ja(a, c, b, e, d) { w = t[u]; y = l.encode(w); y = 1 < y.length ? y.join(" ") : y[0]; - let z; + let A; if (y && w) { for (let v = 0, D; v < g.length; v++) { if (D = g[v], "strict" === k) { if (y === D) { q += (q ? " " : "") + d.replace("$1", w); - z = !0; + A = !0; break; } } else { const E = y.indexOf(D); if (-1 < E) { q += (q ? " " : "") + w.substring(0, E) + d.replace("$1", w.substring(E, D.length)) + w.substring(E + D.length); - z = !0; + A = !0; break; } } } } - z || (q += (q ? " " : "") + t[u]); + A || (q += (q ? " " : "") + t[u]); } r[p].highlight = q; } @@ -1467,14 +1467,16 @@ M.prototype.add = function(a, c, b, e) { if (!e && !b && this.reg.has(a)) { return this.update(a, c); } - c = this.encoder.encode(c); - if (e = c.length) { - const l = B(), n = B(), m = this.depth, r = this.resolution; - for (let p = 0; p < e; p++) { - let q = c[this.rtl ? e - 1 - p : p]; + e = this.depth; + c = this.encoder.encode(c, !e); + const l = c.length; + if (l) { + const n = B(), m = B(), r = this.resolution; + for (let p = 0; p < l; p++) { + let q = c[this.rtl ? l - 1 - p : p]; var d = q.length; - if (d && (m || !n[q])) { - var f = this.score ? this.score(c, q, p, null, 0) : Va(r, e, p), g = ""; + if (d && (e || !m[q])) { + var f = this.score ? this.score(c, q, p, null, 0) : Va(r, l, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { @@ -1482,8 +1484,8 @@ M.prototype.add = function(a, c, b, e) { for (f = d; f > t; f--) { g = q.substring(t, f); u = this.rtl ? d - 1 - t : t; - var k = this.score ? this.score(c, q, p, g, u) : Va(r, e, p, d, u); - Z(this, n, g, k, a, b); + var k = this.score ? this.score(c, q, p, g, u) : Va(r, l, p, d, u); + Z(this, m, g, k, a, b); } } break; @@ -1493,25 +1495,25 @@ M.prototype.add = function(a, c, b, e) { if (1 < d) { for (k = d - 1; 0 < k; k--) { g = q[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, q, p, g, k) : Va(r, e, p, d, k); - Z(this, n, g, h, a, b); + var h = this.score ? this.score(c, q, p, g, k) : Va(r, l, p, d, k); + Z(this, m, g, h, a, b); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += q[this.rtl ? d - 1 - k : k], Z(this, n, g, f, a, b); + g += q[this.rtl ? d - 1 - k : k], Z(this, m, g, f, a, b); } break; } default: - if (Z(this, n, q, f, a, b), m && 1 < e && p < e - 1) { - for (d = B(), g = this.S, f = q, k = Math.min(m + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { - if ((q = c[this.rtl ? e - 1 - p - h : p + h]) && !d[q]) { + if (Z(this, m, q, f, a, b), e && 1 < l && p < l - 1) { + for (d = B(), g = this.S, f = q, k = Math.min(e + 1, this.rtl ? p + 1 : l - p), d[f] = 1, h = 1; h < k; h++) { + if ((q = c[this.rtl ? l - 1 - p - h : p + h]) && !d[q]) { d[q] = 1; - const t = this.score ? this.score(c, f, p, q, h - 1) : Va(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; - Z(this, l, u ? f : q, t, a, b, u ? q : f); + const t = this.score ? this.score(c, f, p, q, h - 1) : Va(g + (l / 2 > g ? 0 : 1), l, p, k - 1, h - 1), u = this.bidirectional && q > f; + Z(this, n, u ? f : q, t, a, b, u ? q : f); } } } @@ -1546,13 +1548,13 @@ function Va(a, c, b, e, d) { } else { k = !0; } - a = this.encoder.encode(a); + f = this.depth && !1 !== f; + a = this.encoder.encode(a, !f); b = a.length; c = c || (k ? 100 : 0); if (1 === b) { return g = c, (c = Wa(this, a[0], "")) && c.length ? Aa.call(this, c, g, d) : []; } - f = this.depth && !1 !== f; if (2 === b && f && !g) { return g = c, (c = Wa(this, a[1], a[0])) && c.length ? Aa.call(this, c, g, d) : []; } diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index b1f4b55..d4cdc87 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -1,24 +1,24 @@ /**! - * FlexSearch.js v0.8.156 (Bundle) + * FlexSearch.js v0.8.157 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function(self){'use strict';var x;function A(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function B(){return Object.create(null)}function C(a){return"string"===typeof a} +(function(self){'use strict';var x;function z(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function B(){return Object.create(null)}function C(a){return"string"===typeof a} function G(a){return"object"===typeof a}function H(a,c){if(C(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; -this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ba)}catch(d){this.split=/\s+/}this.numeric=A(a.numeric,A(this.numeric,!0))}this.prepare=A(a.prepare,null,this.prepare);this.finalize=A(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:A(b&&new Set(b),null,this.filter);this.dedupe=A(a.dedupe,!0,this.dedupe);this.matcher=A((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=A((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=A((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=A(a.replacer,null,this.replacer);this.minlength=A(a.minlength,1,this.minlength);this.maxlength=A(a.maxlength,1024,this.maxlength);this.rtl=A(a.rtl,!1,this.rtl);if(this.cache=b=A(a.cache,!0,this.cache))this.H=null,this.R="number"===typeof b?b:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.C="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.C+= +x.assign=function(a){this.normalize=z(a.normalize,!0,this.normalize);let c=a.include,b=c||a.exclude||a.split,e;if(b||""===b){if("object"===typeof b&&b.constructor!==RegExp){let d="";e=!c;c||(d+="\\p{Z}");b.letter&&(d+="\\p{L}");b.number&&(d+="\\p{N}",e=!!c);b.symbol&&(d+="\\p{S}");b.punctuation&&(d+="\\p{P}");b.control&&(d+="\\p{C}");if(b=b.char)d+="object"===typeof b?b.join(""):b;try{this.split=new RegExp("["+(c?"^":"")+d+"]+","u")}catch(f){this.split=/\s+/}}else this.split=b,e=!1===b||2>"a1a".split(b).length; +this.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,ba)}catch(d){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:z(b&&new Set(b),null,this.filter);this.dedupe=z(a.dedupe,!0,this.dedupe);this.matcher=z((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=z((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=z((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=z(a.replacer,null,this.replacer);this.minlength=z(a.minlength,1,this.minlength);this.maxlength=z(a.maxlength,1024,this.maxlength);this.rtl=z(a.rtl,!1,this.rtl);if(this.cache=b=z(a.cache,!0,this.cache))this.H=null,this.R="number"===typeof b?b:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.C="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.C+= (this.C?"|":"")+d;return this};x.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.C+=(this.C?"|":"")+a;this.N=null;this.cache&&J(this);return this};x.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&J(this);return this}; x.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&J(this);return this}; x.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&J(this);return this}; -x.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(J,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength))if(c)b.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.L)if(this.H){var d=this.G.get(g);if(d||""===d){d&&b.push(d);continue}}else this.H=setTimeout(J,50,this);this.stemmer&&2this.stemmer.get(h))); -if(g&&(this.mapper||this.dedupe&&1this.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&dthis.R&& -(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function J(a){a.H=null;a.F.clear();a.G.clear()};let K,L;async function ia(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":L=a.options||{};(c=a.factory)?(Function("return "+c)()(self),K=new self.FlexSearch.Index(L),delete self.FlexSearch):K=new N(L);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=L.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await L.import.call(K,e[0]),K.import(e[0],a)):(d=e&&K[c].apply(K,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ja(a){O.call(a,"add");O.call(a,"append");O.call(a,"search");O.call(a,"update");O.call(a,"remove")}let ka,la,P;function ma(){ka=P=0} +x.encode=function(a,c){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(J,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength||c&&d[h]))if(b)c&&(d[h]=1),e.push(h);else if(!this.filter||("function"===typeof this.filter?this.filter(h):!this.filter.has(h))){if(this.cache&&h.length<=this.L)if(this.H){var g=this.G.get(h);if(g||""===g){g&&e.push(g);continue}}else this.H=setTimeout(J,50,this);this.stemmer&&2this.stemmer.get(n)));if(h&&(this.mapper||this.dedupe&&1this.matcher.get(n)));if(h&&this.replacer)for(g=0;h&&gthis.R&&(this.G.clear(),this.L=this.L/1.1|0));!h||c&&d[h]||(c&&(d[h]=1),e.push(h))}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.F.set(a,e),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return e};function J(a){a.H=null;a.F.clear();a.G.clear()};let K,L;async function ia(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":L=a.options||{};(c=a.factory)?(Function("return "+c)()(self),K=new self.FlexSearch.Index(L),delete self.FlexSearch):K=new N(L);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=L.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await L.import.call(K,e[0]),K.import(e[0],a)):(d=e&&K[c].apply(K,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ja(a){O.call(a,"add");O.call(a,"append");O.call(a,"search");O.call(a,"update");O.call(a,"remove")}let ka,la,P;function ma(){ka=P=0} function O(a){this[a+"Async"]=function(){const c=arguments;var b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);ka?P||(P=Date.now()-la>=this.priority*this.priority*3):(ka=setTimeout(ma,0),la=Date.now());if(P){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};let Q=0; -function R(a={}){function c(g){function k(h){h=h.data||h;const l=h.id,m=l&&d.h[l];m&&(m(h.msg),delete d.h[l])}this.worker=g;this.h=B();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++Q]=function(){h(d);1E9b||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} -function ya(a,c,b){const e=[],d=B();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?V.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};W.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; -function Da(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(c=aa(a))return this.result=xa(a,c,b,e,g),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};W.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Ba(this,"xor",arguments);return Ea.call(this,a,c,b,e,d,f,g)}; -function Ea(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Fa.call(this,a,b,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} -function Fa(a,c,b,e,d){const f=[],g=B();let k=0;for(let h=0,l;hb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} +function ya(a,c,b){const e=[],d=B();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?V.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};W.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:n,suggest:m}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,n,m)}return d?this.resolve(c,b,e):this}; +function Da(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(c=aa(a))return this.result=xa(a,c,b,e,g),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};W.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Ba(this,"xor",arguments);return Ea.call(this,a,c,b,e,d,f,g)}; +function Ea(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Fa.call(this,a,b,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} +function Fa(a,c,b,e,d){const f=[],g=B();let k=0;for(let h=0,l;hb||e)a=a.slice(e,e+b);d&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; X.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};X.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:!1,numeric:!1,dedupe:!1};const Oa={};const Pa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Qa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Ra=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Sa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Ta={Exact:Na,Default:Oa,Normalize:Oa,LatinBalance:{mapper:Pa},LatinAdvanced:{mapper:Pa,matcher:Qa,replacer:Ra},LatinExtra:{mapper:Pa,replacer:Ra.concat([/(?!^)[aeo]/g,""]),matcher:Qa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bd.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Y(this.map,a),this.depth&&Y(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Y(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Va(r,e,p,d,u); -Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),e,p, -k-1,h-1),u=this.bidirectional&&q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=B()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Va(a,c,b,e,d){return b&&1t;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Va(r, +l,p,d,u);Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g? +0:1),l,p,k-1,h-1),u=this.bidirectional&&q>f;Z(this,n,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=B()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Va(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function N(a,c){if(!this||this.constructor!==N)return new N(a);if(a){var b=C(a)?a:a.preset;b&&(a=Object.assign({},Ua[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=C(a.encoder)?Ta[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new I(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.S=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new X(b);this.priority=a.priority||4}x=N.prototype;x.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};x.append=function(a,c){return this.add(a,c,!0)};x.contain=function(a){return this.reg.has(a)}; x.update=function(a,c){const b=this,e=this.remove(a);return e&&e.then?e.then(()=>b.add(a,c)):this.add(a,c)};x.cleanup=function(){if(!this.fastupdate)return this;Y(this.map);this.depth&&Y(this.ctx);return this};x.searchCache=Ma;x.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=sa(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=oa(this.map,this.reg.size);break;case 3:d="ctx";f=qa(this.ctx,this.reg.size);break;default:return}return T.call(this,a,c,d,f,b,e)}; diff --git a/dist/flexsearch.compact.module.debug.js b/dist/flexsearch.compact.module.debug.js index bb9daca..05e4856 100644 --- a/dist/flexsearch.compact.module.debug.js +++ b/dist/flexsearch.compact.module.debug.js @@ -1,12 +1,12 @@ /**! - * FlexSearch.js v0.8.156 (Bundle/Debug) + * FlexSearch.js v0.8.157 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ var x; -function A(a, c, b) { +function z(a, c, b) { const e = typeof b, d = typeof a; if ("undefined" !== e) { if ("undefined" !== d) { @@ -84,7 +84,7 @@ function I(a = {}) { } x = I.prototype; x.assign = function(a) { - this.normalize = A(a.normalize, !0, this.normalize); + this.normalize = z(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, e; if (b || "" === b) { if ("object" === typeof b && b.constructor !== RegExp) { @@ -107,28 +107,28 @@ x.assign = function(a) { } else { this.split = b, e = !1 === b || 2 > "a1a".split(b).length; } - this.numeric = A(a.numeric, e); + this.numeric = z(a.numeric, e); } else { try { - this.split = A(this.split, ba); + this.split = z(this.split, ba); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } - this.numeric = A(a.numeric, A(this.numeric, !0)); + this.numeric = z(a.numeric, z(this.numeric, !0)); } - this.prepare = A(a.prepare, null, this.prepare); - this.finalize = A(a.finalize, null, this.finalize); + this.prepare = z(a.prepare, null, this.prepare); + this.finalize = z(a.finalize, null, this.finalize); b = a.filter; - this.filter = "function" === typeof b ? b : A(b && new Set(b), null, this.filter); - this.dedupe = A(a.dedupe, !0, this.dedupe); - this.matcher = A((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = A((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = A((b = a.stemmer) && new Map(b), null, this.stemmer); - this.replacer = A(a.replacer, null, this.replacer); - this.minlength = A(a.minlength, 1, this.minlength); - this.maxlength = A(a.maxlength, 1024, this.maxlength); - this.rtl = A(a.rtl, !1, this.rtl); - if (this.cache = b = A(a.cache, !0, this.cache)) { + this.filter = "function" === typeof b ? b : z(b && new Set(b), null, this.filter); + this.dedupe = z(a.dedupe, !0, this.dedupe); + this.matcher = z((b = a.matcher) && new Map(b), null, this.matcher); + this.mapper = z((b = a.mapper) && new Map(b), null, this.mapper); + this.stemmer = z((b = a.stemmer) && new Map(b), null, this.stemmer); + this.replacer = z(a.replacer, null, this.replacer); + this.minlength = z(a.minlength, 1, this.minlength); + this.maxlength = z(a.maxlength, 1024, this.maxlength); + this.rtl = z(a.rtl, !1, this.rtl); + if (this.cache = b = z(a.cache, !0, this.cache)) { this.H = null, this.R = "number" === typeof b ? b : 2e5, this.F = new Map(), this.G = new Map(), this.L = this.K = 128; } this.h = ""; @@ -195,7 +195,7 @@ x.addReplacer = function(a, c) { this.cache && J(this); return this; }; -x.encode = function(a) { +x.encode = function(a, c) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.F.has(a)) { @@ -208,48 +208,48 @@ x.encode = function(a) { this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = fa ? a.normalize("NFKD").replace(fa, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(da, "$1 $2").replace(ea, "$1 $2").replace(ca, "$1 ")); - const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let b = [], e = this.split || "" === this.split ? a.split(this.split) : a; - for (let f = 0, g, k; f < e.length; f++) { - if ((g = k = e[f]) && !(g.length < this.minlength || g.length > this.maxlength)) { - if (c) { - b.push(g); + const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + let e = [], d = B(), f = this.split || "" === this.split ? a.split(this.split) : [a]; + for (let k = 0, h, l; k < f.length; k++) { + if ((h = l = f[k]) && !(h.length < this.minlength || h.length > this.maxlength || c && d[h])) { + if (b) { + c && (d[h] = 1), e.push(h); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(g) : !this.filter.has(g))) { - if (this.cache && g.length <= this.L) { + if (!this.filter || ("function" === typeof this.filter ? this.filter(h) : !this.filter.has(h))) { + if (this.cache && h.length <= this.L) { if (this.H) { - var d = this.G.get(g); - if (d || "" === d) { - d && b.push(d); + var g = this.G.get(h); + if (g || "" === g) { + g && e.push(g); continue; } } else { this.H = setTimeout(J, 50, this); } } - this.stemmer && 2 < g.length && (this.N || (this.N = new RegExp("(?!^)(" + this.C + ")$")), g = g.replace(this.N, h => this.stemmer.get(h))); - if (g && (this.mapper || this.dedupe && 1 < g.length)) { - d = ""; - for (let h = 0, l = "", n, m; h < g.length; h++) { - n = g.charAt(h), n === l && this.dedupe || ((m = this.mapper && this.mapper.get(n)) || "" === m ? m === l && this.dedupe || !(l = m) || (d += m) : d += l = n); + this.stemmer && 2 < h.length && (this.N || (this.N = new RegExp("(?!^)(" + this.C + ")$")), h = h.replace(this.N, n => this.stemmer.get(n))); + if (h && (this.mapper || this.dedupe && 1 < h.length)) { + g = ""; + for (let n = 0, m = "", r, p; n < h.length; n++) { + r = h.charAt(n), r === m && this.dedupe || ((p = this.mapper && this.mapper.get(r)) || "" === p ? p === m && this.dedupe || !(m = p) || (g += p) : g += m = r); } - g = d; + h = g; } - this.matcher && 1 < g.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), g = g.replace(this.M, h => this.matcher.get(h))); - if (g && this.replacer) { - for (d = 0; g && d < this.replacer.length; d += 2) { - g = g.replace(this.replacer[d], this.replacer[d + 1]); + this.matcher && 1 < h.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), h = h.replace(this.M, n => this.matcher.get(n))); + if (h && this.replacer) { + for (g = 0; h && g < this.replacer.length; g += 2) { + h = h.replace(this.replacer[g], this.replacer[g + 1]); } } - this.cache && k.length <= this.L && (this.G.set(k, g), this.G.size > this.R && (this.G.clear(), this.L = this.L / 1.1 | 0)); - g && b.push(g); + this.cache && l.length <= this.L && (this.G.set(l, h), this.G.size > this.R && (this.G.clear(), this.L = this.L / 1.1 | 0)); + !h || c && d[h] || (c && (d[h] = 1), e.push(h)); } } } } - this.finalize && (b = this.finalize(b) || b); - this.cache && a.length <= this.K && (this.F.set(a, b), this.F.size > this.R && (this.F.clear(), this.K = this.K / 1.1 | 0)); - return b; + this.finalize && (e = this.finalize(e) || e); + this.cache && a.length <= this.K && (this.F.set(a, e), this.F.size > this.R && (this.F.clear(), this.K = this.K / 1.1 | 0)); + return e; }; function J(a) { a.H = null; @@ -968,8 +968,8 @@ U.prototype.search = function(a, c, b, e) { if (l) { l.constructor !== Array && (l = [l]); var u = []; - for (let z = 0, v; z < l.length; z++) { - v = l[z]; + for (let A = 0, v; A < l.length; A++) { + v = l[A]; if (C(v)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } @@ -1006,9 +1006,9 @@ U.prototype.search = function(a, c, b, e) { q = Ia.call(this, u[p], u[p + 1], c, t, g), d.push({field:u[p], tag:u[p + 1], result:q}); } } - return f.length ? Promise.all(f).then(function(z) { - for (let v = 0; v < z.length; v++) { - d[v].result = z[v]; + return f.length ? Promise.all(f).then(function(A) { + for (let v = 0; v < A.length; v++) { + d[v].result = A[v]; } return d; }) : d; @@ -1018,15 +1018,15 @@ U.prototype.search = function(a, c, b, e) { } h || (h = this.field); u = !e && (this.worker || this.db) && []; - for (let z = 0, v, D, E; z < h.length; z++) { - D = h[z]; + for (let A = 0, v, D, E; A < h.length; A++) { + D = h[A]; let F; C(D) || (F = D, D = F.field, a = F.query || a, c = F.limit || c, t = F.offset || t, k = F.suggest || k, g = this.store && (F.enrich || g)); if (e) { - v = e[z]; + v = e[A]; } else { if (w = F || b, y = this.index.get(D), l && (w.enrich = !1), u) { - u[z] = y.search(a, c, w); + u[A] = y.search(a, c, w); w && g && (w.enrich = g); continue; } else { @@ -1068,9 +1068,9 @@ U.prototype.search = function(a, c, b, e) { } } if (u) { - const z = this; + const A = this; return Promise.all(u).then(function(v) { - return v.length ? z.search(a, c, b, v) : v; + return v.length ? A.search(a, c, b, v) : v; }); } if (!n) { @@ -1114,26 +1114,26 @@ function Ja(a, c, b, e, d) { w = t[u]; y = l.encode(w); y = 1 < y.length ? y.join(" ") : y[0]; - let z; + let A; if (y && w) { for (let v = 0, D; v < g.length; v++) { if (D = g[v], "strict" === k) { if (y === D) { q += (q ? " " : "") + d.replace("$1", w); - z = !0; + A = !0; break; } } else { const E = y.indexOf(D); if (-1 < E) { q += (q ? " " : "") + w.substring(0, E) + d.replace("$1", w.substring(E, D.length)) + w.substring(E + D.length); - z = !0; + A = !0; break; } } } } - z || (q += (q ? " " : "") + t[u]); + A || (q += (q ? " " : "") + t[u]); } r[p].highlight = q; } @@ -1466,14 +1466,16 @@ M.prototype.add = function(a, c, b, e) { if (!e && !b && this.reg.has(a)) { return this.update(a, c); } - c = this.encoder.encode(c); - if (e = c.length) { - const l = B(), n = B(), m = this.depth, r = this.resolution; - for (let p = 0; p < e; p++) { - let q = c[this.rtl ? e - 1 - p : p]; + e = this.depth; + c = this.encoder.encode(c, !e); + const l = c.length; + if (l) { + const n = B(), m = B(), r = this.resolution; + for (let p = 0; p < l; p++) { + let q = c[this.rtl ? l - 1 - p : p]; var d = q.length; - if (d && (m || !n[q])) { - var f = this.score ? this.score(c, q, p, null, 0) : Va(r, e, p), g = ""; + if (d && (e || !m[q])) { + var f = this.score ? this.score(c, q, p, null, 0) : Va(r, l, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { @@ -1481,8 +1483,8 @@ M.prototype.add = function(a, c, b, e) { for (f = d; f > t; f--) { g = q.substring(t, f); u = this.rtl ? d - 1 - t : t; - var k = this.score ? this.score(c, q, p, g, u) : Va(r, e, p, d, u); - Z(this, n, g, k, a, b); + var k = this.score ? this.score(c, q, p, g, u) : Va(r, l, p, d, u); + Z(this, m, g, k, a, b); } } break; @@ -1492,25 +1494,25 @@ M.prototype.add = function(a, c, b, e) { if (1 < d) { for (k = d - 1; 0 < k; k--) { g = q[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, q, p, g, k) : Va(r, e, p, d, k); - Z(this, n, g, h, a, b); + var h = this.score ? this.score(c, q, p, g, k) : Va(r, l, p, d, k); + Z(this, m, g, h, a, b); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += q[this.rtl ? d - 1 - k : k], Z(this, n, g, f, a, b); + g += q[this.rtl ? d - 1 - k : k], Z(this, m, g, f, a, b); } break; } default: - if (Z(this, n, q, f, a, b), m && 1 < e && p < e - 1) { - for (d = B(), g = this.S, f = q, k = Math.min(m + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { - if ((q = c[this.rtl ? e - 1 - p - h : p + h]) && !d[q]) { + if (Z(this, m, q, f, a, b), e && 1 < l && p < l - 1) { + for (d = B(), g = this.S, f = q, k = Math.min(e + 1, this.rtl ? p + 1 : l - p), d[f] = 1, h = 1; h < k; h++) { + if ((q = c[this.rtl ? l - 1 - p - h : p + h]) && !d[q]) { d[q] = 1; - const t = this.score ? this.score(c, f, p, q, h - 1) : Va(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; - Z(this, l, u ? f : q, t, a, b, u ? q : f); + const t = this.score ? this.score(c, f, p, q, h - 1) : Va(g + (l / 2 > g ? 0 : 1), l, p, k - 1, h - 1), u = this.bidirectional && q > f; + Z(this, n, u ? f : q, t, a, b, u ? q : f); } } } @@ -1545,13 +1547,13 @@ function Va(a, c, b, e, d) { } else { k = !0; } - a = this.encoder.encode(a); + f = this.depth && !1 !== f; + a = this.encoder.encode(a, !f); b = a.length; c = c || (k ? 100 : 0); if (1 === b) { return g = c, (c = Xa(this, a[0], "")) && c.length ? Aa.call(this, c, g, d) : []; } - f = this.depth && !1 !== f; if (2 === b && f && !g) { return g = c, (c = Xa(this, a[1], a[0])) && c.length ? Aa.call(this, c, g, d) : []; } diff --git a/dist/flexsearch.compact.module.min.js b/dist/flexsearch.compact.module.min.js index 5763a6c..1a53124 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -1,24 +1,24 @@ /**! - * FlexSearch.js v0.8.156 (Bundle) + * FlexSearch.js v0.8.157 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var x;function A(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function B(){return Object.create(null)}function C(a){return"string"===typeof a} +var x;function z(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function B(){return Object.create(null)}function C(a){return"string"===typeof a} function G(a){return"object"===typeof a}function H(a,c){if(C(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; -this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ba)}catch(d){this.split=/\s+/}this.numeric=A(a.numeric,A(this.numeric,!0))}this.prepare=A(a.prepare,null,this.prepare);this.finalize=A(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:A(b&&new Set(b),null,this.filter);this.dedupe=A(a.dedupe,!0,this.dedupe);this.matcher=A((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=A((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=A((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=A(a.replacer,null,this.replacer);this.minlength=A(a.minlength,1,this.minlength);this.maxlength=A(a.maxlength,1024,this.maxlength);this.rtl=A(a.rtl,!1,this.rtl);if(this.cache=b=A(a.cache,!0,this.cache))this.H=null,this.R="number"===typeof b?b:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.C="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.C+= +x.assign=function(a){this.normalize=z(a.normalize,!0,this.normalize);let c=a.include,b=c||a.exclude||a.split,e;if(b||""===b){if("object"===typeof b&&b.constructor!==RegExp){let d="";e=!c;c||(d+="\\p{Z}");b.letter&&(d+="\\p{L}");b.number&&(d+="\\p{N}",e=!!c);b.symbol&&(d+="\\p{S}");b.punctuation&&(d+="\\p{P}");b.control&&(d+="\\p{C}");if(b=b.char)d+="object"===typeof b?b.join(""):b;try{this.split=new RegExp("["+(c?"^":"")+d+"]+","u")}catch(f){this.split=/\s+/}}else this.split=b,e=!1===b||2>"a1a".split(b).length; +this.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,ba)}catch(d){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:z(b&&new Set(b),null,this.filter);this.dedupe=z(a.dedupe,!0,this.dedupe);this.matcher=z((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=z((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=z((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=z(a.replacer,null,this.replacer);this.minlength=z(a.minlength,1,this.minlength);this.maxlength=z(a.maxlength,1024,this.maxlength);this.rtl=z(a.rtl,!1,this.rtl);if(this.cache=b=z(a.cache,!0,this.cache))this.H=null,this.R="number"===typeof b?b:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.C="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.C+= (this.C?"|":"")+d;return this};x.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.C+=(this.C?"|":"")+a;this.N=null;this.cache&&J(this);return this};x.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&J(this);return this}; x.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&J(this);return this}; x.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&J(this);return this}; -x.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(J,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength))if(c)b.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.L)if(this.H){var d=this.G.get(g);if(d||""===d){d&&b.push(d);continue}}else this.H=setTimeout(J,50,this);this.stemmer&&2this.stemmer.get(h))); -if(g&&(this.mapper||this.dedupe&&1this.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&dthis.R&& -(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function J(a){a.H=null;a.F.clear();a.G.clear()};let K,L;async function ia(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":L=a.options||{};(c=a.factory)?(Function("return "+c)()(self),K=new self.FlexSearch.Index(L),delete self.FlexSearch):K=new N(L);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=L.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await L.import.call(K,e[0]),K.import(e[0],a)):(d=e&&K[c].apply(K,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ja(a){O.call(a,"add");O.call(a,"append");O.call(a,"search");O.call(a,"update");O.call(a,"remove")}let ka,la,P;function ma(){ka=P=0} +x.encode=function(a,c){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(J,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength||c&&d[h]))if(b)c&&(d[h]=1),e.push(h);else if(!this.filter||("function"===typeof this.filter?this.filter(h):!this.filter.has(h))){if(this.cache&&h.length<=this.L)if(this.H){var g=this.G.get(h);if(g||""===g){g&&e.push(g);continue}}else this.H=setTimeout(J,50,this);this.stemmer&&2this.stemmer.get(n)));if(h&&(this.mapper||this.dedupe&&1this.matcher.get(n)));if(h&&this.replacer)for(g=0;h&&gthis.R&&(this.G.clear(),this.L=this.L/1.1|0));!h||c&&d[h]||(c&&(d[h]=1),e.push(h))}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.K&&(this.F.set(a,e),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return e};function J(a){a.H=null;a.F.clear();a.G.clear()};let K,L;async function ia(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":L=a.options||{};(c=a.factory)?(Function("return "+c)()(self),K=new self.FlexSearch.Index(L),delete self.FlexSearch):K=new N(L);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=L.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await L.import.call(K,e[0]),K.import(e[0],a)):(d=e&&K[c].apply(K,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ja(a){O.call(a,"add");O.call(a,"append");O.call(a,"search");O.call(a,"update");O.call(a,"remove")}let ka,la,P;function ma(){ka=P=0} function O(a){this[a+"Async"]=function(){const c=arguments;var b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);ka?P||(P=Date.now()-la>=this.priority*this.priority*3):(ka=setTimeout(ma,0),la=Date.now());if(P){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};let Q=0; -function R(a={}){function c(g){function k(h){h=h.data||h;const l=h.id,m=l&&d.h[l];m&&(m(h.msg),delete d.h[l])}this.worker=g;this.h=B();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++Q]=function(){h(d);1E9b||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} -function ya(a,c,b){const e=[],d=B();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?V.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};W.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; -function Da(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(c=aa(a))return this.result=xa(a,c,b,e,g),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};W.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Ba(this,"xor",arguments);return Ea.call(this,a,c,b,e,d,f,g)}; -function Ea(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Fa.call(this,a,b,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} -function Fa(a,c,b,e,d){const f=[],g=B();let k=0;for(let h=0,l;hb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} +function ya(a,c,b){const e=[],d=B();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?V.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};W.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:n,suggest:m}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,n,m)}return d?this.resolve(c,b,e):this}; +function Da(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(c=aa(a))return this.result=xa(a,c,b,e,g),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};W.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Ba(this,"xor",arguments);return Ea.call(this,a,c,b,e,d,f,g)}; +function Ea(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Fa.call(this,a,b,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} +function Fa(a,c,b,e,d){const f=[],g=B();let k=0;for(let h=0,l;hb||e)a=a.slice(e,e+b);d&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; X.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};X.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:!1,numeric:!1,dedupe:!1};const Oa={};const Pa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Qa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Ra=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Sa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Ta={Exact:Na,Default:Oa,Normalize:Oa,LatinBalance:{mapper:Pa},LatinAdvanced:{mapper:Pa,matcher:Qa,replacer:Ra},LatinExtra:{mapper:Pa,replacer:Ra.concat([/(?!^)[aeo]/g,""]),matcher:Qa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bd.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Y(this.map,a),this.depth&&Y(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Y(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Wa(r,e,p,d,u); -Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),e,p, -k-1,h-1),u=this.bidirectional&&q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=B()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Wa(a,c,b,e,d){return b&&1t;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Wa(r, +l,p,d,u);Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g? +0:1),l,p,k-1,h-1),u=this.bidirectional&&q>f;Z(this,n,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=B()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Wa(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function N(a,c){if(!this||this.constructor!==N)return new N(a);if(a){var b=C(a)?a:a.preset;b&&(a=Object.assign({},Ua[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=C(a.encoder)?Ta[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new I(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.S=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new X(b);this.priority=a.priority||4}x=N.prototype;x.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};x.append=function(a,c){return this.add(a,c,!0)};x.contain=function(a){return this.reg.has(a)}; x.update=function(a,c){const b=this,e=this.remove(a);return e&&e.then?e.then(()=>b.add(a,c)):this.add(a,c)};x.cleanup=function(){if(!this.fastupdate)return this;Y(this.map);this.depth&&Y(this.ctx);return this};x.searchCache=Ma;x.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=sa(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=oa(this.map,this.reg.size);break;case 3:d="ctx";f=qa(this.ctx,this.reg.size);break;default:return}return T.call(this,a,c,d,f,b,e)}; diff --git a/dist/flexsearch.es5.debug.js b/dist/flexsearch.es5.debug.js index 08ed8c4..2945f55 100644 --- a/dist/flexsearch.es5.debug.js +++ b/dist/flexsearch.es5.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.156 (ES5/Debug) + * FlexSearch.js v0.8.157 (ES5/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -137,12 +137,12 @@ function oa(a, b, c, d) { if (!e.done) { return a.h.C = !1, e; } - var g = e.value; - } catch (f) { - return a.h.A = null, la(a.h, f), pa(a); + var f = e.value; + } catch (g) { + return a.h.A = null, la(a.h, g), pa(a); } a.h.A = null; - d.call(a.h, g); + d.call(a.h, f); return pa(a); } function pa(a) { @@ -198,25 +198,25 @@ function sa(a) { return a.throw(d); } return new Promise(function(d, e) { - function g(f) { - f.done ? d(f.value) : Promise.resolve(f.value).then(b, c).then(g, e); + function f(g) { + g.done ? d(g.value) : Promise.resolve(g.value).then(b, c).then(f, e); } - g(a.next()); + f(a.next()); }); } function ta(a) { return sa(new qa(new ma(a))); } C("Symbol", function(a) { - function b(g) { + function b(f) { if (this instanceof b) { throw new TypeError("Symbol is not a constructor"); } - return new c(d + (g || "") + "_" + e++, g); + return new c(d + (f || "") + "_" + e++, f); } - function c(g, f) { - this.h = g; - ba(this, "description", {configurable:!0, writable:!0, value:f}); + function c(f, g) { + this.h = f; + ba(this, "description", {configurable:!0, writable:!0, value:g}); } if (a) { return a; @@ -248,52 +248,52 @@ function ua(a) { return a; } C("Promise", function(a) { - function b(f) { + function b(g) { this.A = 0; this.B = void 0; this.h = []; this.H = !1; - var h = this.C(); + var k = this.C(); try { - f(h.resolve, h.reject); - } catch (k) { - h.reject(k); + g(k.resolve, k.reject); + } catch (h) { + k.reject(h); } } function c() { this.h = null; } - function d(f) { - return f instanceof b ? f : new b(function(h) { - h(f); + function d(g) { + return g instanceof b ? g : new b(function(k) { + k(g); }); } if (a) { return a; } - c.prototype.A = function(f) { + c.prototype.A = function(g) { if (null == this.h) { this.h = []; - var h = this; + var k = this; this.B(function() { - h.D(); + k.D(); }); } - this.h.push(f); + this.h.push(g); }; var e = B.setTimeout; - c.prototype.B = function(f) { - e(f, 0); + c.prototype.B = function(g) { + e(g, 0); }; c.prototype.D = function() { for (; this.h && this.h.length;) { - var f = this.h; + var g = this.h; this.h = []; - for (var h = 0; h < f.length; ++h) { - var k = f[h]; - f[h] = null; + for (var k = 0; k < g.length; ++k) { + var h = g[k]; + g[k] = null; try { - k(); + h(); } catch (l) { this.C(l); } @@ -301,74 +301,74 @@ C("Promise", function(a) { } this.h = null; }; - c.prototype.C = function(f) { + c.prototype.C = function(g) { this.B(function() { - throw f; + throw g; }); }; b.prototype.C = function() { - function f(l) { + function g(l) { return function(m) { - k || (k = !0, l.call(h, m)); + h || (h = !0, l.call(k, m)); }; } - var h = this, k = !1; - return {resolve:f(this.fa), reject:f(this.D)}; + var k = this, h = !1; + return {resolve:g(this.fa), reject:g(this.D)}; }; - b.prototype.fa = function(f) { - if (f === this) { + b.prototype.fa = function(g) { + if (g === this) { this.D(new TypeError("A Promise cannot resolve to itself")); } else { - if (f instanceof b) { - this.ha(f); + if (g instanceof b) { + this.ha(g); } else { a: { - switch(typeof f) { + switch(typeof g) { case "object": - var h = null != f; + var k = null != g; break a; case "function": - h = !0; + k = !0; break a; default: - h = !1; + k = !1; } } - h ? this.ea(f) : this.G(f); + k ? this.ea(g) : this.G(g); } } }; - b.prototype.ea = function(f) { - var h = void 0; + b.prototype.ea = function(g) { + var k = void 0; try { - h = f.then; - } catch (k) { - this.D(k); + k = g.then; + } catch (h) { + this.D(h); return; } - "function" == typeof h ? this.ia(h, f) : this.G(f); + "function" == typeof k ? this.ia(k, g) : this.G(g); }; - b.prototype.D = function(f) { - this.M(2, f); + b.prototype.D = function(g) { + this.M(2, g); }; - b.prototype.G = function(f) { - this.M(1, f); + b.prototype.G = function(g) { + this.M(1, g); }; - b.prototype.M = function(f, h) { + b.prototype.M = function(g, k) { if (0 != this.A) { - throw Error("Cannot settle(" + f + ", " + h + "): Promise already settled in state" + this.A); + throw Error("Cannot settle(" + g + ", " + k + "): Promise already settled in state" + this.A); } - this.A = f; - this.B = h; + this.A = g; + this.B = k; 2 === this.A && this.ga(); this.N(); }; b.prototype.ga = function() { - var f = this; + var g = this; e(function() { - if (f.T()) { - var h = B.console; - "undefined" !== typeof h && h.error(f.B); + if (g.T()) { + var k = B.console; + "undefined" !== typeof k && k.error(g.B); } }, 1); }; @@ -376,43 +376,43 @@ C("Promise", function(a) { if (this.H) { return !1; } - var f = B.CustomEvent, h = B.Event, k = B.dispatchEvent; - if ("undefined" === typeof k) { + var g = B.CustomEvent, k = B.Event, h = B.dispatchEvent; + if ("undefined" === typeof h) { return !0; } - "function" === typeof f ? f = new f("unhandledrejection", {cancelable:!0}) : "function" === typeof h ? f = new h("unhandledrejection", {cancelable:!0}) : (f = B.document.createEvent("CustomEvent"), f.initCustomEvent("unhandledrejection", !1, !0, f)); - f.promise = this; - f.reason = this.B; - return k(f); + "function" === typeof g ? g = new g("unhandledrejection", {cancelable:!0}) : "function" === typeof k ? g = new k("unhandledrejection", {cancelable:!0}) : (g = B.document.createEvent("CustomEvent"), g.initCustomEvent("unhandledrejection", !1, !0, g)); + g.promise = this; + g.reason = this.B; + return h(g); }; b.prototype.N = function() { if (null != this.h) { - for (var f = 0; f < this.h.length; ++f) { - g.A(this.h[f]); + for (var g = 0; g < this.h.length; ++g) { + f.A(this.h[g]); } this.h = null; } }; - var g = new c(); - b.prototype.ha = function(f) { - var h = this.C(); - f.U(h.resolve, h.reject); - }; - b.prototype.ia = function(f, h) { + var f = new c(); + b.prototype.ha = function(g) { var k = this.C(); + g.U(k.resolve, k.reject); + }; + b.prototype.ia = function(g, k) { + var h = this.C(); try { - f.call(h, k.resolve, k.reject); + g.call(k, h.resolve, h.reject); } catch (l) { - k.reject(l); + h.reject(l); } }; - b.prototype.then = function(f, h) { - function k(p, q) { - return "function" == typeof p ? function(t) { + b.prototype.then = function(g, k) { + function h(p, q) { + return "function" == typeof p ? function(r) { try { - l(p(t)); - } catch (w) { - m(w); + l(p(r)); + } catch (v) { + m(v); } } : q; } @@ -420,56 +420,56 @@ C("Promise", function(a) { l = p; m = q; }); - this.U(k(f, l), k(h, m)); + this.U(h(g, l), h(k, m)); return n; }; - b.prototype.catch = function(f) { - return this.then(void 0, f); + b.prototype.catch = function(g) { + return this.then(void 0, g); }; - b.prototype.U = function(f, h) { - function k() { + b.prototype.U = function(g, k) { + function h() { switch(l.A) { case 1: - f(l.B); + g(l.B); break; case 2: - h(l.B); + k(l.B); break; default: throw Error("Unexpected state: " + l.A); } } var l = this; - null == this.h ? g.A(k) : this.h.push(k); + null == this.h ? f.A(h) : this.h.push(h); this.H = !0; }; b.resolve = d; - b.reject = function(f) { - return new b(function(h, k) { - k(f); + b.reject = function(g) { + return new b(function(k, h) { + h(g); }); }; - b.race = function(f) { - return new b(function(h, k) { - for (var l = y(f), m = l.next(); !m.done; m = l.next()) { - d(m.value).U(h, k); + b.race = function(g) { + return new b(function(k, h) { + for (var l = y(g), m = l.next(); !m.done; m = l.next()) { + d(m.value).U(k, h); } }); }; - b.all = function(f) { - var h = y(f), k = h.next(); - return k.done ? d([]) : new b(function(l, m) { - function n(t) { - return function(w) { - p[t] = w; + b.all = function(g) { + var k = y(g), h = k.next(); + return h.done ? d([]) : new b(function(l, m) { + function n(r) { + return function(v) { + p[r] = v; q--; 0 == q && l(p); }; } var p = [], q = 0; do { - p.push(void 0), q++, d(k.value).U(n(p.length - 1), m), k = h.next(); - } while (!k.done); + p.push(void 0), q++, d(h.value).U(n(p.length - 1), m), h = k.next(); + } while (!h.done); }); }; return b; @@ -478,8 +478,8 @@ function va(a, b) { a instanceof String && (a += ""); var c = 0, d = !1, e = {next:function() { if (!d && c < a.length) { - var g = c++; - return {value:b(g, a[g]), done:!1}; + var f = c++; + return {value:b(f, a[f]), done:!1}; } d = !0; return {done:!0, value:void 0}; @@ -507,30 +507,30 @@ function F(a, b) { return Object.prototype.hasOwnProperty.call(a, b); } C("WeakMap", function(a) { - function b(k) { - this.h = (h += Math.random() + 1).toString(); - if (k) { - k = y(k); - for (var l; !(l = k.next()).done;) { + function b(h) { + this.h = (k += Math.random() + 1).toString(); + if (h) { + h = y(h); + for (var l; !(l = h.next()).done;) { l = l.value, this.set(l[0], l[1]); } } } function c() { } - function d(k) { - var l = typeof k; - return "object" === l && null !== k || "function" === l; + function d(h) { + var l = typeof h; + return "object" === l && null !== h || "function" === l; } - function e(k) { - if (!F(k, f)) { + function e(h) { + if (!F(h, g)) { var l = new c(); - ba(k, f, {value:l}); + ba(h, g, {value:l}); } } - function g(k) { - var l = Object[k]; - l && (Object[k] = function(m) { + function f(h) { + var l = Object[h]; + l && (Object[h] = function(m) { if (m instanceof c) { return m; } @@ -543,88 +543,88 @@ C("WeakMap", function(a) { return !1; } try { - var k = Object.seal({}), l = Object.seal({}), m = new a([[k, 2], [l, 3]]); - if (2 != m.get(k) || 3 != m.get(l)) { + var h = Object.seal({}), l = Object.seal({}), m = new a([[h, 2], [l, 3]]); + if (2 != m.get(h) || 3 != m.get(l)) { return !1; } - m.delete(k); + m.delete(h); m.set(l, 4); - return !m.has(k) && 4 == m.get(l); + return !m.has(h) && 4 == m.get(l); } catch (n) { return !1; } }()) { return a; } - var f = "$jscomp_hidden_" + Math.random(); - g("freeze"); - g("preventExtensions"); - g("seal"); - var h = 0; - b.prototype.set = function(k, l) { - if (!d(k)) { + var g = "$jscomp_hidden_" + Math.random(); + f("freeze"); + f("preventExtensions"); + f("seal"); + var k = 0; + b.prototype.set = function(h, l) { + if (!d(h)) { throw Error("Invalid WeakMap key"); } - e(k); - if (!F(k, f)) { - throw Error("WeakMap key fail: " + k); + e(h); + if (!F(h, g)) { + throw Error("WeakMap key fail: " + h); } - k[f][this.h] = l; + h[g][this.h] = l; return this; }; - b.prototype.get = function(k) { - return d(k) && F(k, f) ? k[f][this.h] : void 0; + b.prototype.get = function(h) { + return d(h) && F(h, g) ? h[g][this.h] : void 0; }; - b.prototype.has = function(k) { - return d(k) && F(k, f) && F(k[f], this.h); + b.prototype.has = function(h) { + return d(h) && F(h, g) && F(h[g], this.h); }; - b.prototype.delete = function(k) { - return d(k) && F(k, f) && F(k[f], this.h) ? delete k[f][this.h] : !1; + b.prototype.delete = function(h) { + return d(h) && F(h, g) && F(h[g], this.h) ? delete h[g][this.h] : !1; }; return b; }); C("Map", function(a) { function b() { - var h = {}; - return h.J = h.next = h.head = h; + var k = {}; + return k.J = k.next = k.head = k; } - function c(h, k) { - var l = h[1]; + function c(k, h) { + var l = k[1]; return ua(function() { if (l) { - for (; l.head != h[1];) { + for (; l.head != k[1];) { l = l.J; } for (; l.next != l.head;) { - return l = l.next, {done:!1, value:k(l)}; + return l = l.next, {done:!1, value:h(l)}; } l = null; } return {done:!0, value:void 0}; }); } - function d(h, k) { - var l = k && typeof k; - "object" == l || "function" == l ? g.has(k) ? l = g.get(k) : (l = "" + ++f, g.set(k, l)) : l = "p_" + k; - var m = h[0][l]; - if (m && F(h[0], l)) { - for (h = 0; h < m.length; h++) { - var n = m[h]; - if (k !== k && n.key !== n.key || k === n.key) { - return {id:l, list:m, index:h, F:n}; + function d(k, h) { + var l = h && typeof h; + "object" == l || "function" == l ? f.has(h) ? l = f.get(h) : (l = "" + ++g, f.set(h, l)) : l = "p_" + h; + var m = k[0][l]; + if (m && F(k[0], l)) { + for (k = 0; k < m.length; k++) { + var n = m[k]; + if (h !== h && n.key !== n.key || h === n.key) { + return {id:l, list:m, index:k, F:n}; } } } return {id:l, list:m, index:-1, F:void 0}; } - function e(h) { + function e(k) { this[0] = {}; this[1] = b(); this.size = 0; - if (h) { - h = y(h); - for (var k; !(k = h.next()).done;) { - k = k.value, this.set(k[0], k[1]); + if (k) { + k = y(k); + for (var h; !(h = k.next()).done;) { + h = h.value, this.set(h[0], h[1]); } } } @@ -633,12 +633,12 @@ C("Map", function(a) { return !1; } try { - var h = Object.seal({x:4}), k = new a(y([[h, "s"]])); - if ("s" != k.get(h) || 1 != k.size || k.get({x:4}) || k.set({x:4}, "t") != k || 2 != k.size) { + var k = Object.seal({x:4}), h = new a(y([[k, "s"]])); + if ("s" != h.get(k) || 1 != h.size || h.get({x:4}) || h.set({x:4}, "t") != h || 2 != h.size) { return !1; } - var l = k.entries(), m = l.next(); - if (m.done || m.value[0] != h || "s" != m.value[1]) { + var l = h.entries(), m = l.next(); + if (m.done || m.value[0] != k || "s" != m.value[1]) { return !1; } m = l.next(); @@ -649,51 +649,51 @@ C("Map", function(a) { }()) { return a; } - var g = new WeakMap(); - e.prototype.set = function(h, k) { - h = 0 === h ? 0 : h; - var l = d(this, h); + var f = new WeakMap(); + e.prototype.set = function(k, h) { + k = 0 === k ? 0 : k; + var l = d(this, k); l.list || (l.list = this[0][l.id] = []); - l.F ? l.F.value = k : (l.F = {next:this[1], J:this[1].J, head:this[1], key:h, value:k}, l.list.push(l.F), this[1].J.next = l.F, this[1].J = l.F, this.size++); + l.F ? l.F.value = h : (l.F = {next:this[1], J:this[1].J, head:this[1], key:k, value:h}, l.list.push(l.F), this[1].J.next = l.F, this[1].J = l.F, this.size++); return this; }; - e.prototype.delete = function(h) { - h = d(this, h); - return h.F && h.list ? (h.list.splice(h.index, 1), h.list.length || delete this[0][h.id], h.F.J.next = h.F.next, h.F.next.J = h.F.J, h.F.head = null, this.size--, !0) : !1; + e.prototype.delete = function(k) { + k = d(this, k); + return k.F && k.list ? (k.list.splice(k.index, 1), k.list.length || delete this[0][k.id], k.F.J.next = k.F.next, k.F.next.J = k.F.J, k.F.head = null, this.size--, !0) : !1; }; e.prototype.clear = function() { this[0] = {}; this[1] = this[1].J = b(); this.size = 0; }; - e.prototype.has = function(h) { - return !!d(this, h).F; + e.prototype.has = function(k) { + return !!d(this, k).F; }; - e.prototype.get = function(h) { - return (h = d(this, h).F) && h.value; + e.prototype.get = function(k) { + return (k = d(this, k).F) && k.value; }; e.prototype.entries = function() { - return c(this, function(h) { - return [h.key, h.value]; + return c(this, function(k) { + return [k.key, k.value]; }); }; e.prototype.keys = function() { - return c(this, function(h) { - return h.key; + return c(this, function(k) { + return k.key; }); }; e.prototype.values = function() { - return c(this, function(h) { - return h.value; + return c(this, function(k) { + return k.value; }); }; - e.prototype.forEach = function(h, k) { + e.prototype.forEach = function(k, h) { for (var l = this.entries(), m; !(m = l.next()).done;) { - m = m.value, h.call(k, m[1], m[0], this); + m = m.value, k.call(h, m[1], m[0], this); } }; e.prototype[Symbol.iterator] = e.prototype.entries; - var f = 0; + var g = 0; return e; }); C("Set", function(a) { @@ -716,13 +716,13 @@ C("Set", function(a) { if (!d.has(c) || 1 != d.size || d.add(c) != d || 1 != d.size || d.add({x:4}) != d || 2 != d.size) { return !1; } - var e = d.entries(), g = e.next(); - if (g.done || g.value[0] != c || g.value[1] != c) { + var e = d.entries(), f = e.next(); + if (f.done || f.value[0] != c || f.value[1] != c) { return !1; } - g = e.next(); - return g.done || g.value[0] == c || 4 != g.value[0].x || g.value[1] != g.value[0] ? !1 : e.next().done; - } catch (f) { + f = e.next(); + return f.done || f.value[0] == c || 4 != f.value[0].x || f.value[1] != f.value[0] ? !1 : e.next().done; + } catch (g) { return !1; } }()) { @@ -756,8 +756,8 @@ C("Set", function(a) { b.prototype[Symbol.iterator] = b.prototype.values; b.prototype.forEach = function(c, d) { var e = this; - this.h.forEach(function(g) { - return c.call(d, g, g, e); + this.h.forEach(function(f) { + return c.call(d, f, f, e); }); }; return b; @@ -781,8 +781,8 @@ C("Array.prototype.includes", function(a) { var e = d.length; c = c || 0; for (0 > c && (c = Math.max(c + e, 0)); c < e; c++) { - var g = d[c]; - if (g === b || Object.is(g, b)) { + var f = d[c]; + if (f === b || Object.is(f, b)) { return !0; } } @@ -843,8 +843,8 @@ function G(a, b, c) { if ("undefined" !== e) { if (c) { if ("function" === e && d === e) { - return function(g) { - return a(c(g)); + return function(f) { + return a(c(f)); }; } b = a.constructor; @@ -915,15 +915,15 @@ function Ga(a) { if (!this || this.constructor !== Ga) { var b = Function.prototype.bind, c = b.apply, d = [null], e = d.concat; if (arguments instanceof Array) { - var g = arguments; + var f = arguments; } else { - g = y(arguments); - for (var f, h = []; !(f = g.next()).done;) { - h.push(f.value); + f = y(arguments); + for (var g, k = []; !(g = f.next()).done;) { + k.push(g.value); } - g = h; + f = k; } - return new (c.call(b, Ga, e.call(d, g)))(); + return new (c.call(b, Ga, e.call(d, f)))(); } if (arguments.length) { for (b = 0; b < arguments.length; b++) { @@ -952,7 +952,7 @@ u.assign = function(a) { } try { this.split = new RegExp("[" + (b ? "^" : "") + d + "]+", "u"); - } catch (g) { + } catch (f) { console.error("Your split configuration:", c, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } } else { @@ -962,7 +962,7 @@ u.assign = function(a) { } else { try { this.split = G(this.split, Ba); - } catch (g) { + } catch (f) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } this.numeric = G(a.numeric, G(this.numeric, !0)); @@ -1046,8 +1046,8 @@ u.addReplacer = function(a, b) { this.cache && K(this); return this; }; -u.encode = function(a) { - var b = this; +u.encode = function(a, b) { + var c = this; if (this.cache && a.length <= this.G) { if (this.D) { if (this.B.has(a)) { @@ -1060,50 +1060,50 @@ u.encode = function(a) { this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = Fa ? a.normalize("NFKD").replace(Fa, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(Da, "$1 $2").replace(Ea, "$1 $2").replace(Ca, "$1 ")); - for (var c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer), d = [], e = this.split || "" === this.split ? a.split(this.split) : a, g = 0, f = void 0, h = void 0; g < e.length; g++) { - if ((f = h = e[g]) && !(f.length < this.minlength || f.length > this.maxlength)) { - if (c) { - d.push(f); + for (var d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer), e = [], f = I(), g = this.split || "" === this.split ? a.split(this.split) : [a], k = 0, h = void 0, l = void 0; k < g.length; k++) { + if ((h = l = g[k]) && !(h.length < this.minlength || h.length > this.maxlength || b && f[h])) { + if (d) { + b && (f[h] = 1), e.push(h); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(f) : !this.filter.has(f))) { - if (this.cache && f.length <= this.H) { + if (!this.filter || ("function" === typeof this.filter ? this.filter(h) : !this.filter.has(h))) { + if (this.cache && h.length <= this.H) { if (this.D) { - var k = this.C.get(f); - if (k || "" === k) { - k && d.push(k); + var m = this.C.get(h); + if (m || "" === m) { + m && e.push(m); continue; } } else { this.D = setTimeout(K, 50, this); } } - this.stemmer && 2 < f.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), f = f.replace(this.N, function(q) { - return b.stemmer.get(q); + this.stemmer && 2 < h.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), h = h.replace(this.N, function(v) { + return c.stemmer.get(v); })); - if (f && (this.mapper || this.dedupe && 1 < f.length)) { - k = ""; - for (var l = 0, m = "", n = void 0, p = void 0; l < f.length; l++) { - n = f.charAt(l), n === m && this.dedupe || ((p = this.mapper && this.mapper.get(n)) || "" === p ? p === m && this.dedupe || !(m = p) || (k += p) : k += m = n); + if (h && (this.mapper || this.dedupe && 1 < h.length)) { + m = ""; + for (var n = 0, p = "", q = void 0, r = void 0; n < h.length; n++) { + q = h.charAt(n), q === p && this.dedupe || ((r = this.mapper && this.mapper.get(q)) || "" === r ? r === p && this.dedupe || !(p = r) || (m += r) : m += p = q); } - f = k; + h = m; } - this.matcher && 1 < f.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), f = f.replace(this.M, function(q) { - return b.matcher.get(q); + this.matcher && 1 < h.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), h = h.replace(this.M, function(v) { + return c.matcher.get(v); })); - if (f && this.replacer) { - for (k = 0; f && k < this.replacer.length; k += 2) { - f = f.replace(this.replacer[k], this.replacer[k + 1]); + if (h && this.replacer) { + for (m = 0; h && m < this.replacer.length; m += 2) { + h = h.replace(this.replacer[m], this.replacer[m + 1]); } } - this.cache && h.length <= this.H && (this.C.set(h, f), this.C.size > this.T && (this.C.clear(), this.H = this.H / 1.1 | 0)); - f && d.push(f); + this.cache && l.length <= this.H && (this.C.set(l, h), this.C.size > this.T && (this.C.clear(), this.H = this.H / 1.1 | 0)); + !h || b && f[h] || (b && (f[h] = 1), e.push(h)); } } } } - this.finalize && (d = this.finalize(d) || d); - this.cache && a.length <= this.G && (this.B.set(a, d), this.B.size > this.T && (this.B.clear(), this.G = this.G / 1.1 | 0)); - return d; + this.finalize && (e = this.finalize(e) || e); + this.cache && a.length <= this.G && (this.B.set(a, e), this.B.size > this.T && (this.B.clear(), this.G = this.G / 1.1 | 0)); + return e; }; function K(a) { a.D = null; @@ -1112,9 +1112,9 @@ function K(a) { } ;var Ha, M; function Ia(a) { - var b, c, d, e, g, f; - return ta(function(h) { - switch(h.h) { + var b, c, d, e, f, g; + return ta(function(k) { + switch(k.h) { case 1: a = a.data; b = a.task; @@ -1127,9 +1127,9 @@ function Ia(a) { postMessage({id:c}); break; default: - h.h = 2; + k.h = 2; return; - }h.h = 0; + }k.h = 0; break; case 2: if ("export" === b) { @@ -1143,25 +1143,25 @@ function Ia(a) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } if (!d[0]) { - h.h = 5; + k.h = 5; break; } - return D(h, M.import.call(Ha, d[0]), 9); + return D(k, M.import.call(Ha, d[0]), 9); } - g = d && Ha[b].apply(Ha, d); - if (!g || !g.then) { - h.h = 5; + f = d && Ha[b].apply(Ha, d); + if (!f || !f.then) { + k.h = 5; break; } - return D(h, g, 7); + return D(k, f, 7); case 7: - g = h.D; - h.h = 5; + f = k.D; + k.h = 5; break; case 9: - f = h.D, Ha.import(d[0], f); + g = k.D, Ha.import(d[0], g); case 5: - postMessage("search" === b ? {id:c, msg:g} : {id:c}), h.h = 0; + postMessage("search" === b ? {id:c, msg:f} : {id:c}), k.h = 0; } }); } @@ -1186,15 +1186,15 @@ function Ka(a) { La ? Oa || (Oa = Date.now() - Na >= this.priority * this.priority * 3) : (La = setTimeout(Pa, 0), Na = Date.now()); if (Oa) { var e = this; - return new Promise(function(f) { + return new Promise(function(g) { setTimeout(function() { - f(e[a + "Async"].apply(e, b)); + g(e[a + "Async"].apply(e, b)); }, 0); }); } - var g = this[a].apply(this, b); - c = g.then ? g : new Promise(function(f) { - return f(g); + var f = this[a].apply(this, b); + c = f.then ? f : new Promise(function(g) { + return g(f); }); d && c.then(d); return c; @@ -1202,20 +1202,20 @@ function Ka(a) { } ;var Qa = 0; function Ra(a) { - function b(f) { - function h(k) { - k = k.data || k; - var l = k.id, m = l && e.h[l]; - m && (m(k.msg), delete e.h[l]); + function b(g) { + function k(h) { + h = h.data || h; + var l = h.id, m = l && e.h[l]; + m && (m(h.msg), delete e.h[l]); } - this.worker = f; + this.worker = g; this.h = I(); if (this.worker) { - d ? this.worker.on("message", h) : this.worker.onmessage = h; + d ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { - return new Promise(function(k) { + return new Promise(function(h) { e.h[++Qa] = function() { - k(e); + h(e); 1e9 < Qa && (Qa = 0); }; e.worker.postMessage({id:Qa, task:"init", factory:c, options:a}); @@ -1232,10 +1232,10 @@ function Ra(a) { } var c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; c && (c = c.toString()); - var d = "undefined" === typeof window, e = this, g = Sa(c, d, a.worker); - return g.then ? g.then(function(f) { - return b.call(e, f); - }) : b.call(this, g); + var d = "undefined" === typeof window, e = this, f = Sa(c, d, a.worker); + return f.then ? f.then(function(g) { + return b.call(e, g); + }) : b.call(this, f); } P("add"); P("append"); @@ -1253,9 +1253,9 @@ function P(a) { var e = d; c.pop(); } - d = new Promise(function(g) { + d = new Promise(function(f) { "export" === a && "function" === typeof c[0] && (c[0] = null); - b.h[++Qa] = g; + b.h[++Qa] = f; b.worker.postMessage({task:a, id:Qa, args:c}); }); return e ? (d.then(e), this) : d; @@ -1317,19 +1317,19 @@ function Ya(a, b) { } return b; } -function Za(a, b, c, d, e, g, f) { - f = void 0 === f ? 0 : f; - var h = d && d.constructor === Array, k = h ? d.shift() : d; - if (!k) { - return this.export(a, b, e, g + 1); +function Za(a, b, c, d, e, f, g) { + g = void 0 === g ? 0 : g; + var k = d && d.constructor === Array, h = k ? d.shift() : d; + if (!h) { + return this.export(a, b, e, f + 1); } - if ((k = a((b ? b + "." : "") + (f + 1) + "." + c, JSON.stringify(k))) && k.then) { + if ((h = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(h))) && h.then) { var l = this; - return k.then(function() { - return Za.call(l, a, b, c, h ? d : null, e, g, f + 1); + return h.then(function() { + return Za.call(l, a, b, c, k ? d : null, e, f, g + 1); }); } - return Za.call(this, a, b, c, h ? d : null, e, g, f + 1); + return Za.call(this, a, b, c, k ? d : null, e, f, g + 1); } function $a(a, b) { var c = ""; @@ -1338,27 +1338,27 @@ function $a(a, b) { var e = d.value; d = e[0]; e = e[1]; - for (var g = "", f = 0, h; f < e.length; f++) { - h = e[f] || [""]; - for (var k = "", l = 0; l < h.length; l++) { - k += (k ? "," : "") + ("string" === b ? '"' + h[l] + '"' : h[l]); + for (var f = "", g = 0, k; g < e.length; g++) { + k = e[g] || [""]; + for (var h = "", l = 0; l < k.length; l++) { + h += (h ? "," : "") + ("string" === b ? '"' + k[l] + '"' : k[l]); } - k = "[" + k + "]"; - g += (g ? "," : "") + k; + h = "[" + h + "]"; + f += (f ? "," : "") + h; } - g = '["' + d + '",[' + g + "]]"; - c += (c ? "," : "") + g; + f = '["' + d + '",[' + f + "]]"; + c += (c ? "," : "") + f; } return c; } ;function ab(a, b, c, d) { - for (var e = [], g = 0, f; g < a.index.length; g++) { - if (f = a.index[g], b >= f.length) { - b -= f.length; + for (var e = [], f = 0, g; f < a.index.length; f++) { + if (g = a.index[f], b >= g.length) { + b -= g.length; } else { - b = f[d ? "splice" : "slice"](b, c); - if (f = b.length) { - if (e = e.length ? e.concat(b) : b, c -= f, d && (a.length -= f), !c) { + b = g[d ? "splice" : "slice"](b, c); + if (g = b.length) { + if (e = e.length ? e.concat(b) : b, c -= g, d && (a.length -= g), !c) { break; } } @@ -1393,21 +1393,21 @@ function S(a) { } if ("indexOf" === d) { return function(e) { - for (var g = 0, f = 0, h, k; f < b.index.length; f++) { - h = b.index[f]; - k = h.indexOf(e); - if (0 <= k) { - return g + k; + for (var f = 0, g = 0, k, h; g < b.index.length; g++) { + k = b.index[g]; + h = k.indexOf(e); + if (0 <= h) { + return f + h; } - g += h.length; + f += k.length; } return -1; }; } if ("includes" === d) { return function(e) { - for (var g = 0; g < b.index.length; g++) { - if (b.index[g].includes(e)) { + for (var f = 0; f < b.index.length; f++) { + if (b.index[f].includes(e)) { return !0; } } @@ -1415,13 +1415,13 @@ function S(a) { }; } if ("slice" === d) { - return function(e, g) { - return ab(b, e || 0, g || b.length, !1); + return function(e, f) { + return ab(b, e || 0, f || b.length, !1); }; } if ("splice" === d) { - return function(e, g) { - return ab(b, e || 0, g || b.length, !0); + return function(e, f) { + return ab(b, e || 0, f || b.length, !0); }; } if ("constructor" === d) { @@ -1492,14 +1492,14 @@ u.clear = U.prototype.clear = function() { this.size = 0; }; u.values = U.prototype.values = function db() { - var b, c = this, d, e, g; - return ra(db, function(f) { - switch(f.h) { + var b, c = this, d, e, f; + return ra(db, function(g) { + switch(g.h) { case 1: b = 0; case 2: if (!(b < c.h.length)) { - f.h = 0; + g.h = 0; break; } d = y(c.h[b].values()); @@ -1507,25 +1507,25 @@ u.values = U.prototype.values = function db() { case 5: if (e.done) { b++; - f.h = 2; + g.h = 2; break; } - g = e.value; - return D(f, g, 6); + f = e.value; + return D(g, f, 6); case 6: - e = d.next(), f.h = 5; + e = d.next(), g.h = 5; } }); }; u.keys = U.prototype.keys = function eb() { - var b, c = this, d, e, g; - return ra(eb, function(f) { - switch(f.h) { + var b, c = this, d, e, f; + return ra(eb, function(g) { + switch(g.h) { case 1: b = 0; case 2: if (!(b < c.h.length)) { - f.h = 0; + g.h = 0; break; } d = y(c.h[b].keys()); @@ -1533,25 +1533,25 @@ u.keys = U.prototype.keys = function eb() { case 5: if (e.done) { b++; - f.h = 2; + g.h = 2; break; } - g = e.value; - return D(f, g, 6); + f = e.value; + return D(g, f, 6); case 6: - e = d.next(), f.h = 5; + e = d.next(), g.h = 5; } }); }; u.entries = U.prototype.entries = function fb() { - var b, c = this, d, e, g; - return ra(fb, function(f) { - switch(f.h) { + var b, c = this, d, e, f; + return ra(fb, function(g) { + switch(g.h) { case 1: b = 0; case 2: if (!(b < c.h.length)) { - f.h = 0; + g.h = 0; break; } d = y(c.h[b].entries()); @@ -1559,13 +1559,13 @@ u.entries = U.prototype.entries = function fb() { case 5: if (e.done) { b++; - f.h = 2; + g.h = 2; break; } - g = e.value; - return D(f, g, 6); + f = e.value; + return D(g, f, 6); case 6: - e = d.next(), f.h = 5; + e = d.next(), g.h = 5; } }); }; @@ -1590,58 +1590,58 @@ function bb() { } for (var d = 0, e; d < this.field.length; d++) { e = this.L[d]; - var g = this.index.get(this.field[d]); + var f = this.index.get(this.field[d]); if ("function" === typeof e) { - (e = e(b)) && g.add(a, e, !1, !0); + (e = e(b)) && f.add(a, e, !1, !0); } else { - var f = e.R; - if (!f || f(b)) { - e.constructor === String ? e = ["" + e] : J(e) && (e = [e]), gb(b, e, this.S, 0, g, a, e[0], c); + var g = e.R; + if (!g || g(b)) { + e.constructor === String ? e = ["" + e] : J(e) && (e = [e]), gb(b, e, this.S, 0, f, a, e[0], c); } } } if (this.tag) { for (d = 0; d < this.K.length; d++) { - f = this.K[d]; - var h = this.aa[d]; - g = this.tag.get(h); + g = this.K[d]; + var k = this.aa[d]; + f = this.tag.get(k); e = I(); - if ("function" === typeof f) { - if (f = f(b), !f) { + if ("function" === typeof g) { + if (g = g(b), !g) { continue; } } else { - var k = f.R; - if (k && !k(b)) { + var h = g.R; + if (h && !h(b)) { continue; } - f.constructor === String && (f = "" + f); - f = za(b, f); + g.constructor === String && (g = "" + g); + g = za(b, g); } - if (g && f) { - for (J(f) && (f = [f]), h = 0, k = void 0; h < f.length; h++) { - var l = f[h]; + if (f && g) { + for (J(g) && (g = [g]), k = 0, h = void 0; k < g.length; k++) { + var l = g[k]; if (!e[l]) { e[l] = 1; var m; - (m = g.get(l)) ? k = m : g.set(l, k = []); - if (!c || !k.includes(a)) { - if (k.length === Math.pow(2, 31) - 1) { - m = new S(k); + (m = f.get(l)) ? h = m : f.set(l, h = []); + if (!c || !h.includes(a)) { + if (h.length === Math.pow(2, 31) - 1) { + m = new S(h); if (this.fastupdate) { for (var n = y(this.reg.values()), p = n.next(); !p.done; p = n.next()) { - p = p.value, p.includes(k) && (p[p.indexOf(k)] = m); + p = p.value, p.includes(h) && (p[p.indexOf(h)] = m); } } - g.set(l, k = m); + f.set(l, h = m); } - k.push(a); - this.fastupdate && ((l = this.reg.get(a)) ? l.push(k) : this.reg.set(a, [k])); + h.push(a); + this.fastupdate && ((l = this.reg.get(a)) ? l.push(h) : this.reg.set(a, [h])); } } } } else { - g || console.warn("Tag '" + h + "' was not found"); + f || console.warn("Tag '" + k + "' was not found"); } } } @@ -1649,11 +1649,11 @@ function bb() { if (this.I) { var q = I(); for (c = 0; c < this.I.length; c++) { - if (d = this.I[c], g = d.R, !g || g(b)) { - g = void 0; + if (d = this.I[c], f = d.R, !f || f(b)) { + f = void 0; if ("function" === typeof d) { - g = d(b); - if (!g) { + f = d(b); + if (!f) { continue; } d = [d.ja]; @@ -1661,7 +1661,7 @@ function bb() { q[d] = b[d]; continue; } - hb(b, q, d, 0, d[0], g); + hb(b, q, d, 0, d[0], f); } } } @@ -1671,10 +1671,10 @@ function bb() { } return this; }; -function hb(a, b, c, d, e, g) { +function hb(a, b, c, d, e, f) { a = a[e]; if (d === c.length - 1) { - b[e] = g || a; + b[e] = f || a; } else if (a) { if (a.constructor === Array) { for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) { @@ -1685,103 +1685,103 @@ function hb(a, b, c, d, e, g) { } } } -function gb(a, b, c, d, e, g, f, h) { - if (a = a[f]) { +function gb(a, b, c, d, e, f, g, k) { + if (a = a[g]) { if (d === b.length - 1) { if (a.constructor === Array) { if (c[d]) { for (b = 0; b < a.length; b++) { - e.add(g, a[b], !0, !0); + e.add(f, a[b], !0, !0); } return; } a = a.join(" "); } - e.add(g, a, h, !0); + e.add(f, a, k, !0); } else { if (a.constructor === Array) { - for (f = 0; f < a.length; f++) { - gb(a, b, c, d, e, g, f, h); + for (g = 0; g < a.length; g++) { + gb(a, b, c, d, e, f, g, k); } } else { - f = b[++d], gb(a, b, c, d, e, g, f, h); + g = b[++d], gb(a, b, c, d, e, f, g, k); } } } else { - e.db && e.remove(g); + e.db && e.remove(f); } } -;function ib(a, b, c, d, e, g, f) { - var h = a.length, k = []; +;function ib(a, b, c, d, e, f, g) { + var k = a.length, h = []; var l = I(); for (var m = 0, n = void 0, p, q; m < b; m++) { - for (var t = 0; t < h; t++) { - var w = a[t]; - if (m < w.length && (n = w[m])) { - for (var r = 0; r < n.length; r++) { - p = n[r]; - (w = l[p]) ? l[p]++ : (w = 0, l[p] = 1); - q = k[w] || (k[w] = []); - if (!f) { - var z = m + (t || !e ? 0 : g || 0); + for (var r = 0; r < k; r++) { + var v = a[r]; + if (m < v.length && (n = v[m])) { + for (var t = 0; t < n.length; t++) { + p = n[t]; + (v = l[p]) ? l[p]++ : (v = 0, l[p] = 1); + q = h[v] || (h[v] = []); + if (!g) { + var z = m + (r || !e ? 0 : f || 0); q = q[z] || (q[z] = []); } q.push(p); - if (f && c && w === h - 1 && q.length - d === c) { + if (g && c && v === k - 1 && q.length - d === c) { return d ? q.slice(d) : q; } } } } } - if (a = k.length) { + if (a = h.length) { if (e) { - k = 1 < k.length ? jb(k, c, d, f, g) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; + h = 1 < h.length ? jb(h, c, d, g, f) : (h = h[0]).length > c || d ? h.slice(d, c + d) : h; } else { - if (a < h) { + if (a < k) { return []; } - k = k[a - 1]; + h = h[a - 1]; if (c || d) { - if (f) { - if (k.length > c || d) { - k = k.slice(d, c + d); + if (g) { + if (h.length > c || d) { + h = h.slice(d, c + d); } } else { e = []; - for (g = 0; g < k.length; g++) { - if (f = k[g], f.length > d) { - d -= f.length; + for (f = 0; f < h.length; f++) { + if (g = h[f], g.length > d) { + d -= g.length; } else { - if (f.length > c || d) { - f = f.slice(d, c + d), c -= f.length, d && (d -= f.length); + if (g.length > c || d) { + g = g.slice(d, c + d), c -= g.length, d && (d -= g.length); } - e.push(f); + e.push(g); if (!c) { break; } } } - k = 1 < e.length ? [].concat.apply([], e) : e[0]; + h = 1 < e.length ? [].concat.apply([], e) : e[0]; } } } } - return k; + return h; } function jb(a, b, c, d, e) { - var g = [], f = I(), h = a.length, k; + var f = [], g = I(), k = a.length, h; if (d) { - for (e = h - 1; 0 <= e; e--) { - if (k = (d = a[e]) && d.length) { - for (h = 0; h < k; h++) { - var l = d[h]; - if (!f[l]) { - if (f[l] = 1, c) { + for (e = k - 1; 0 <= e; e--) { + if (h = (d = a[e]) && d.length) { + for (k = 0; k < h; k++) { + var l = d[k]; + if (!g[l]) { + if (g[l] = 1, c) { c--; } else { - if (g.push(l), g.length === b) { - return g; + if (f.push(l), f.length === b) { + return f; } } } @@ -1789,19 +1789,19 @@ function jb(a, b, c, d, e) { } } } else { - for (var m = h - 1, n, p = 0; 0 <= m; m--) { + for (var m = k - 1, n, p = 0; 0 <= m; m--) { n = a[m]; for (var q = 0; q < n.length; q++) { - if (k = (d = n[q]) && d.length) { - for (var t = 0; t < k; t++) { - if (l = d[t], !f[l]) { - if (f[l] = 1, c) { + if (h = (d = n[q]) && d.length) { + for (var r = 0; r < h; r++) { + if (l = d[r], !g[l]) { + if (g[l] = 1, c) { c--; } else { - var w = (q + (m < h - 1 ? e || 0 : 0)) / (m + 1) | 0; - (g[w] || (g[w] = [])).push(l); + var v = (q + (m < k - 1 ? e || 0 : 0)) / (m + 1) | 0; + (f[v] || (f[v] = [])).push(l); if (++p === b) { - return g; + return f; } } } @@ -1810,13 +1810,13 @@ function jb(a, b, c, d, e) { } } } - return g; + return f; } function kb(a, b, c) { - for (var d = I(), e = [], g = 0, f; g < b.length; g++) { - f = b[g]; - for (var h = 0; h < f.length; h++) { - d[f[h]] = 1; + for (var d = I(), e = [], f = 0, g; f < b.length; f++) { + g = b[f]; + for (var k = 0; k < g.length; k++) { + d[g[k]] = 1; } } if (c) { @@ -1825,8 +1825,8 @@ function kb(a, b, c) { } } else { for (b = 0; b < a.result.length; b++) { - for (c = a.result[b], f = 0; f < c.length; f++) { - g = c[f], d[g] && ((e[b] || (e[b] = [])).push(g), d[g] = 0); + for (c = a.result[b], g = 0; g < c.length; g++) { + f = c[g], d[f] && ((e[b] || (e[b] = [])).push(f), d[f] = 0); } } } @@ -1839,21 +1839,21 @@ function kb(a, b, c) { if (1 === a.length) { return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? W.call(this, a) : a; } - for (var e = [], g = 0, f = void 0, h = void 0; g < a.length; g++) { - if ((f = a[g]) && (h = f.length)) { + for (var e = [], f = 0, g = void 0, k = void 0; f < a.length; f++) { + if ((g = a[f]) && (k = g.length)) { if (c) { - if (c >= h) { - c -= h; + if (c >= k) { + c -= k; continue; } - c < h && (f = b ? f.slice(c, c + b) : f.slice(c), h = f.length, c = 0); + c < k && (g = b ? g.slice(c, c + b) : g.slice(c), k = g.length, c = 0); } - h > b && (f = f.slice(0, b), h = b); - if (!e.length && h >= b) { - return d ? W.call(this, f) : f; + k > b && (g = g.slice(0, b), k = b); + if (!e.length && k >= b) { + return d ? W.call(this, g) : g; } - e.push(f); - b -= h; + e.push(g); + b -= k; if (!b) { break; } @@ -1873,7 +1873,7 @@ function kb(a, b, c) { return a[b].apply(a, d); } d = []; - for (var e = [], g = 0, f = 0, h, k, l, m = 0, n = void 0; m < c.length; m++) { + for (var e = [], f = 0, g = 0, k, h, l, m = 0, n = void 0; m < c.length; m++) { if (n = c[m]) { var p = void 0; if (n.constructor === X) { @@ -1881,8 +1881,8 @@ function kb(a, b, c) { } else if (n.constructor === Array) { p = n; } else { - if (g = n.limit || 0, f = n.offset || 0, l = n.suggest, k = n.resolve, h = n.enrich && k, n.index) { - n.resolve = !1, n.enrich = !1, p = n.index.search(n).result, n.resolve = k, n.enrich = h; + if (f = n.limit || 0, g = n.offset || 0, l = n.suggest, h = n.resolve, k = n.enrich && h, n.index) { + n.resolve = !1, n.enrich = !1, p = n.index.search(n).result, n.resolve = h, n.enrich = k; } else if (n.and) { p = a.and(n.and); } else if (n.or) { @@ -1905,25 +1905,25 @@ function kb(a, b, c) { } } } - return {W:d, $:e, limit:g, offset:f, enrich:h, resolve:k, suggest:l}; + return {W:d, $:e, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; } ;X.prototype.or = function() { var a = mb(this, "or", arguments); return nb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve); }; -function nb(a, b, c, d, e, g) { +function nb(a, b, c, d, e, f) { if (b.length) { - var f = this; - return Promise.all(b).then(function(h) { + var g = this; + return Promise.all(b).then(function(k) { a = []; - for (var k = 0, l = void 0; k < h.length; k++) { - (l = h[k]).length && (a[k] = l); + for (var h = 0, l = void 0; h < k.length; h++) { + (l = k[h]).length && (a[h] = l); } - return nb.call(f, a, [], c, d, e, g); + return nb.call(g, a, [], c, d, e, f); }); } a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = jb(a, c, d, !1, this.h), d = 0)); - return g ? this.resolve(c, d, e) : this; + return f ? this.resolve(c, d, e) : this; } ;X.prototype.and = function() { var a = this.result.length; @@ -1934,20 +1934,20 @@ function nb(a, b, c, d, e, g) { var c = b.resolve; var d = b.limit; var e = b.offset; - var g = b.enrich && c; + var f = b.enrich && c; } } - return a ? (a = mb(this, "and", arguments), ob.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest)) : c ? this.resolve(d, e, g) : this; + return a ? (a = mb(this, "and", arguments), ob.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest)) : c ? this.resolve(d, e, f) : this; }; -function ob(a, b, c, d, e, g, f) { +function ob(a, b, c, d, e, f, g) { if (b.length) { - var h = this; - return Promise.all(b).then(function(k) { + var k = this; + return Promise.all(b).then(function(h) { a = []; - for (var l = 0, m = void 0; l < k.length; l++) { - (m = k[l]).length && (a[l] = m); + for (var l = 0, m = void 0; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); } - return ob.call(h, a, [], c, d, e, g, f); + return ob.call(k, a, [], c, d, e, f, g); }); } if (a.length) { @@ -1955,73 +1955,73 @@ function ob(a, b, c, d, e, g, f) { this.result = a[0]; } else { if (b = Aa(a)) { - return this.result = ib(a, b, c, d, f, this.h, g), g ? e ? W.call(this.index, this.result) : this.result : this; + return this.result = ib(a, b, c, d, g, this.h, f), f ? e ? W.call(this.index, this.result) : this.result : this; } this.result = []; } } else { - f || (this.result = a); + g || (this.result = a); } - return g ? this.resolve(c, d, e) : this; + return f ? this.resolve(c, d, e) : this; } ;X.prototype.xor = function() { var a = mb(this, "xor", arguments); return pb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); }; -function pb(a, b, c, d, e, g, f) { +function pb(a, b, c, d, e, f, g) { if (b.length) { - var h = this; - return Promise.all(b).then(function(k) { + var k = this; + return Promise.all(b).then(function(h) { a = []; - for (var l = 0, m = void 0; l < k.length; l++) { - (m = k[l]).length && (a[l] = m); + for (var l = 0, m = void 0; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); } - return pb.call(h, a, [], c, d, e, g, f); + return pb.call(k, a, [], c, d, e, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = qb.call(this, a, c, d, g, this.h), g ? e ? W.call(this.index, this.result) : this.result : this; + return this.result = qb.call(this, a, c, d, f, this.h), f ? e ? W.call(this.index, this.result) : this.result : this; } } else { - f || (this.result = a); + g || (this.result = a); } - return g ? this.resolve(c, d, e) : this; + return f ? this.resolve(c, d, e) : this; } function qb(a, b, c, d, e) { - for (var g = [], f = I(), h = 0, k = 0, l; k < a.length; k++) { - if (l = a[k]) { - h < l.length && (h = l.length); + for (var f = [], g = I(), k = 0, h = 0, l; h < a.length; h++) { + if (l = a[h]) { + k < l.length && (k = l.length); for (var m = 0, n; m < l.length; m++) { if (n = l[m]) { for (var p = 0, q; p < n.length; p++) { - q = n[p], f[q] = f[q] ? 2 : 1; + q = n[p], g[q] = g[q] ? 2 : 1; } } } } } - for (l = k = 0; k < h; k++) { + for (l = h = 0; h < k; h++) { for (m = 0; m < a.length; m++) { if (n = a[m]) { - if (n = n[k]) { + if (n = n[h]) { for (p = 0; p < n.length; p++) { - if (q = n[p], 1 === f[q]) { + if (q = n[p], 1 === g[q]) { if (c) { c--; } else { if (d) { - if (g.push(q), g.length === b) { - return g; + if (f.push(q), f.length === b) { + return f; } } else { - var t = k + (m ? e : 0); - g[t] || (g[t] = []); - g[t].push(q); + var r = h + (m ? e : 0); + f[r] || (f[r] = []); + f[r].push(q); if (++l === b) { - return g; + return f; } } } @@ -2031,37 +2031,37 @@ function qb(a, b, c, d, e) { } } } - return g; + return f; } ;X.prototype.not = function() { var a = mb(this, "not", arguments); return rb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); }; -function rb(a, b, c, d, e, g, f) { +function rb(a, b, c, d, e, f, g) { if (b.length) { - var h = this; - return Promise.all(b).then(function(k) { + var k = this; + return Promise.all(b).then(function(h) { a = []; - for (var l = 0, m = void 0; l < k.length; l++) { - (m = k[l]).length && (a[l] = m); + for (var l = 0, m = void 0; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); } - return rb.call(h, a, [], c, d, e, g, f); + return rb.call(k, a, [], c, d, e, f, g); }); } if (a.length && this.result.length) { - this.result = sb.call(this, a, c, d, g); - } else if (g) { + this.result = sb.call(this, a, c, d, f); + } else if (f) { return this.resolve(c, d, e); } - return g ? e ? W.call(this.index, this.result) : this.result : this; + return f ? e ? W.call(this.index, this.result) : this.result : this; } function sb(a, b, c, d) { var e = []; a = new Set(a.flat().flat()); - for (var g = 0, f, h = 0; g < this.result.length; g++) { - if (f = this.result[g]) { - for (var k = 0, l; k < f.length; k++) { - if (l = f[k], !a.has(l)) { + for (var f = 0, g, k = 0; f < this.result.length; f++) { + if (g = this.result[f]) { + for (var h = 0, l; h < g.length; h++) { + if (l = g[h], !a.has(l)) { if (c) { c--; } else { @@ -2070,7 +2070,7 @@ function sb(a, b, c, d) { return e; } } else { - if (e[g] || (e[g] = []), e[g].push(l), ++h === b) { + if (e[f] || (e[f] = []), e[f].push(l), ++k === b) { return e; } } @@ -2133,7 +2133,7 @@ X.prototype.resolve = function(a, b, c) { I(); V.prototype.search = function(a, b, c, d) { c || (!b && xa(a) ? (c = a, a = "") : xa(b) && (c = b, b = 0)); - var e = [], g = [], f, h = 0, k = !0; + var e = [], f = [], g, k = 0, h = !0; if (c) { c.constructor === Array && (c = {index:c}); a = c.query || a; @@ -2142,8 +2142,8 @@ V.prototype.search = function(a, b, c, d) { var n = l || c.field || (n = c.index) && (n.index ? null : n); var p = this.tag && c.tag; var q = c.suggest; - k = !1 !== c.resolve; - if (!k && !l) { + h = !1 !== c.resolve; + if (!h && !l) { if (n = n || this.field) { J(n) ? l = n : (n.constructor === Array && 1 === n.length && (n = n[0]), l = n.field || n.index); } @@ -2151,64 +2151,64 @@ V.prototype.search = function(a, b, c, d) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } - this.store && c.enrich && !k && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - var t = (f = this.store && c.enrich && k) && c.highlight; + this.store && c.enrich && !h && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); + var r = (g = this.store && c.enrich && h) && c.highlight; b = c.limit || b; - var w = c.offset || 0; + var v = c.offset || 0; b || (b = 100); if (p && (!this.db || !d)) { p.constructor !== Array && (p = [p]); - for (var r = [], z = 0, A = void 0; z < p.length; z++) { + for (var t = [], z = 0, A = void 0; z < p.length; z++) { A = p[z]; if (J(A)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } if (A.field && A.tag) { - var v = A.tag; - if (v.constructor === Array) { - for (var x = 0; x < v.length; x++) { - r.push(A.field, v[x]); + var w = A.tag; + if (w.constructor === Array) { + for (var x = 0; x < w.length; x++) { + t.push(A.field, w[x]); } } else { - r.push(A.field, v); + t.push(A.field, w); } } else { - v = Object.keys(A); + w = Object.keys(A); x = 0; - for (var E = void 0, N = void 0; x < v.length; x++) { - if (E = v[x], N = A[E], N.constructor === Array) { + for (var E = void 0, N = void 0; x < w.length; x++) { + if (E = w[x], N = A[E], N.constructor === Array) { for (var H = 0; H < N.length; H++) { - r.push(E, N[H]); + t.push(E, N[H]); } } else { - r.push(E, N); + t.push(E, N); } } } } - if (!r.length) { + if (!t.length) { throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); } - p = r; + p = t; if (!a) { - k = []; - if (r.length) { - for (g = 0; g < r.length; g += 2) { + h = []; + if (t.length) { + for (f = 0; f < t.length; f += 2) { q = void 0; if (this.db) { - q = this.index.get(r[g]); + q = this.index.get(t[f]); if (!q) { - console.warn("Tag '" + r[g] + ":" + r[g + 1] + "' will be skipped because there is no field '" + r[g] + "'."); + console.warn("Tag '" + t[f] + ":" + t[f + 1] + "' will be skipped because there is no field '" + t[f] + "'."); continue; } - k.push(q = q.db.tag(r[g + 1], b, w, f)); + h.push(q = q.db.tag(t[f + 1], b, v, g)); } else { - q = tb.call(this, r[g], r[g + 1], b, w, f); + q = tb.call(this, t[f], t[f + 1], b, v, g); } - e.push({field:r[g], tag:r[g + 1], result:q}); + e.push({field:t[f], tag:t[f + 1], result:q}); } } - return k.length ? Promise.all(k).then(function(Q) { + return h.length ? Promise.all(h).then(function(Q) { for (var R = 0; R < Q.length; R++) { e[R].result = Q[R]; } @@ -2219,34 +2219,34 @@ V.prototype.search = function(a, b, c, d) { n && n.constructor !== Array && (n = [n]); } n || (n = this.field); - r = !d && (this.worker || this.db) && []; + t = !d && (this.worker || this.db) && []; z = 0; - for (x = A = v = void 0; z < n.length; z++) { + for (x = A = w = void 0; z < n.length; z++) { if (A = n[z], !this.db || !this.tag || this.L[z]) { - v = void 0; - J(A) || (v = A, A = v.field, a = v.query || a, b = v.limit || b, w = v.offset || w, q = v.suggest || q, f = this.store && (v.enrich || f)); + w = void 0; + J(A) || (w = A, A = w.field, a = w.query || a, b = w.limit || b, v = w.offset || v, q = w.suggest || q, g = this.store && (w.enrich || g)); if (d) { - v = d[z]; + w = d[z]; } else { - x = v || c; - v = this.index.get(A); + x = w || c; + w = this.index.get(A); if (p) { if (this.db) { x.tag = p; - var Ma = v.db.support_tag_search; + var Ma = w.db.support_tag_search; x.field = n; } Ma || (x.enrich = !1); } - if (r) { - r[z] = v.search(a, b, x); - x && f && (x.enrich = f); + if (t) { + t[z] = w.search(a, b, x); + x && g && (x.enrich = g); continue; } else { - v = v.search(a, b, x), x && f && (x.enrich = f); + w = w.search(a, b, x), x && g && (x.enrich = g); } } - x = v && (k ? v.length : v.result.length); + x = w && (h ? w.length : w.result.length); if (p && x) { E = []; N = 0; @@ -2257,7 +2257,7 @@ V.prototype.search = function(a, b, c, d) { if (L && L.length) { N++, E.push(L); } else if (!q) { - return k ? e : new X(e); + return h ? e : new X(e); } } } @@ -2269,119 +2269,119 @@ V.prototype.search = function(a, b, c, d) { if (console.warn("Tag '" + p[H] + ":" + p[H + 1] + "' will be skipped because there is no field '" + p[H] + "'."), q) { continue; } else { - return k ? e : new X(e); + return h ? e : new X(e); } } if (Wb = (L = L && L.get(p[H + 1])) && L.length) { N++, E.push(L); } else if (!q) { - return k ? e : new X(e); + return h ? e : new X(e); } } } if (N) { - v = kb(v, E, k); - x = v.length; + w = kb(w, E, h); + x = w.length; if (!x && !q) { - return k ? v : new X(v); + return h ? w : new X(w); } N--; } } if (x) { - g[h] = A, e.push(v), h++; + f[k] = A, e.push(w), k++; } else if (1 === n.length) { - return k ? e : new X(e); + return h ? e : new X(e); } } } - if (r) { + if (t) { if (this.db && p && p.length && !Ma) { - for (f = 0; f < p.length; f += 2) { - g = this.index.get(p[f]); - if (!g) { - if (console.warn("Tag '" + p[f] + ":" + p[f + 1] + "' was not found because there is no field '" + p[f] + "'."), q) { + for (g = 0; g < p.length; g += 2) { + f = this.index.get(p[g]); + if (!f) { + if (console.warn("Tag '" + p[g] + ":" + p[g + 1] + "' was not found because there is no field '" + p[g] + "'."), q) { continue; } else { - return k ? e : new X(e); + return h ? e : new X(e); } } - r.push(g.db.tag(p[f + 1], b, w, !1)); + t.push(f.db.tag(p[g + 1], b, v, !1)); } } var Xb = this; - return Promise.all(r).then(function(Q) { + return Promise.all(t).then(function(Q) { return Q.length ? Xb.search(a, b, c, Q) : Q; }); } - if (!h) { - return k ? e : new X(e); + if (!k) { + return h ? e : new X(e); } - if (l && (!f || !this.store)) { + if (l && (!g || !this.store)) { return e[0]; } - r = []; - for (w = 0; w < g.length; w++) { - q = e[w]; - f && q.length && "undefined" === typeof q[0].doc && (this.db ? r.push(q = this.index.get(this.field[0]).db.enrich(q)) : q = W.call(this, q)); + t = []; + for (v = 0; v < f.length; v++) { + q = e[v]; + g && q.length && "undefined" === typeof q[0].doc && (this.db ? t.push(q = this.index.get(this.field[0]).db.enrich(q)) : q = W.call(this, q)); if (l) { - return k ? t ? ub(a, q, this.index, l, t) : q : new X(q); + return h ? r ? ub(a, q, this.index, l, r) : q : new X(q); } - e[w] = {field:g[w], result:q}; + e[v] = {field:f[v], result:q}; } - if (f && this.db && r.length) { + if (g && this.db && t.length) { var Yb = this; - return Promise.all(r).then(function(Q) { + return Promise.all(t).then(function(Q) { for (var R = 0; R < Q.length; R++) { e[R].result = Q[R]; } - return m ? vb(e) : t ? ub(a, e, Yb.index, l, t) : e; + return m ? vb(e) : r ? ub(a, e, Yb.index, l, r) : e; }); } - return m ? vb(e) : t ? ub(a, e, this.index, l, t) : e; + return m ? vb(e) : r ? ub(a, e, this.index, l, r) : e; }; function ub(a, b, c, d, e) { - for (var g, f, h, k = 0, l, m; k < b.length; k++) { + for (var f, g, k, h = 0, l, m; h < b.length; h++) { if (d) { var n = b; m = d; } else { - l = b[k]; + l = b[h]; m = l.field; if (!m) { continue; } n = l.result; } - h = c.get(m); - l = h.encoder; - h = h.tokenize; - l !== g && (g = l, f = g.encode(a)); + k = c.get(m); + l = k.encoder; + k = k.tokenize; + l !== f && (f = l, g = f.encode(a)); for (var p = 0; p < n.length; p++) { - for (var q = "", t = za(n[p].doc, m).split(/\s+/), w = 0, r, z; w < t.length; w++) { - r = t[w]; - z = l.encode(r); + for (var q = "", r = za(n[p].doc, m).split(/\s+/), v = 0, t, z; v < r.length; v++) { + t = r[v]; + z = l.encode(t); z = 1 < z.length ? z.join(" ") : z[0]; var A = void 0; - if (z && r) { - for (var v = 0, x; v < f.length; v++) { - if (x = f[v], "strict" === h) { + if (z && t) { + for (var w = 0, x; w < g.length; w++) { + if (x = g[w], "strict" === k) { if (z === x) { - q += (q ? " " : "") + e.replace("$1", r); + q += (q ? " " : "") + e.replace("$1", t); A = !0; break; } } else { var E = z.indexOf(x); if (-1 < E) { - q += (q ? " " : "") + r.substring(0, E) + e.replace("$1", r.substring(E, x.length)) + r.substring(E + x.length); + q += (q ? " " : "") + t.substring(0, E) + e.replace("$1", t.substring(E, x.length)) + t.substring(E + x.length); A = !0; break; } } } } - A || (q += (q ? " " : "") + t[w]); + A || (q += (q ? " " : "") + r[v]); } n[p].highlight = q; } @@ -2392,26 +2392,26 @@ function ub(a, b, c, d, e) { return b; } function vb(a) { - for (var b = [], c = I(), d = 0, e, g; d < a.length; d++) { + for (var b = [], c = I(), d = 0, e, f; d < a.length; d++) { e = a[d]; - g = e.result; - for (var f = 0, h, k, l; f < g.length; f++) { - k = g[f], "object" !== typeof k && (k = {id:k}), h = k.id, (l = c[h]) ? l.push(e.field) : (k.field = c[h] = [e.field], b.push(k)); + f = e.result; + for (var g = 0, k, h, l; g < f.length; g++) { + h = f[g], "object" !== typeof h && (h = {id:h}), k = h.id, (l = c[k]) ? l.push(e.field) : (h.field = c[k] = [e.field], b.push(h)); } } return b; } function tb(a, b, c, d, e) { - var g = this.tag.get(a); - if (!g) { + var f = this.tag.get(a); + if (!f) { return console.warn("Tag '" + a + "' was not found"), []; } - if ((a = (g = g && g.get(b)) && g.length - d) && 0 < a) { + if ((a = (f = f && f.get(b)) && f.length - d) && 0 < a) { if (a > c || d) { - g = g.slice(d, d + c); + f = f.slice(d, d + c); } - e && (g = W.call(this, g)); - return g; + e && (f = W.call(this, f)); + return f; } } function W(a) { @@ -2463,21 +2463,21 @@ function W(a) { } if (this.worker) { this.fastupdate = !1; - var g = []; + var f = []; a = y(this.index.values()); for (c = a.next(); !c.done; c = a.next()) { - c = c.value, c.then && g.push(c); + c = c.value, c.then && f.push(c); } - if (g.length) { - var f = this; - return Promise.all(g).then(function(h) { - for (var k = new Map(), l = 0, m = y(f.index.entries()), n = m.next(); !n.done; n = m.next()) { + if (f.length) { + var g = this; + return Promise.all(f).then(function(k) { + for (var h = new Map(), l = 0, m = y(g.index.entries()), n = m.next(); !n.done; n = m.next()) { var p = n.value; n = p[0]; var q = p[1]; - q.then && (q = g[l].encoder || {}, p = k.get(q), p || (p = q.encode ? q : new Ga(q), k.set(q, p)), q = h[l], q.encoder = p, f.index.set(n, q), l++); + q.then && (q = f[l].encoder || {}, p = h.get(q), p || (p = q.encode ? q : new Ga(q), h.set(q, p)), q = k[l], q.encoder = p, g.index.set(n, q), l++); } - return f; + return g; }); } } else { @@ -2503,34 +2503,34 @@ u.mount = function(a) { c = []; d = {db:a.db, type:a.type, fastupdate:a.fastupdate}; e = 0; - var g = void 0; - for (g = void 0; e < b.length; e++) { - d.field = g = b[e]; - g = this.index.get(g); - var f = new a.constructor(a.id, d); - f.id = a.id; - c[e] = f.mount(g); - g.document = !0; - e ? g.bypass = !0 : g.store = this.store; + var f = void 0; + for (f = void 0; e < b.length; e++) { + d.field = f = b[e]; + f = this.index.get(f); + var g = new a.constructor(a.id, d); + g.id = a.id; + c[e] = g.mount(f); + f.document = !0; + e ? f.bypass = !0 : f.store = this.store; } - var h = this; + var k = this; return this.db = Promise.all(c).then(function() { - h.db = !0; + k.db = !0; }); }; u.commit = function(a, b) { - var c = this, d, e, g, f; - return ta(function(h) { - if (1 == h.h) { + var c = this, d, e, f, g; + return ta(function(k) { + if (1 == k.h) { d = []; e = y(c.index.values()); - for (g = e.next(); !g.done; g = e.next()) { - f = g.value, d.push(f.commit(a, b)); + for (f = e.next(); !f.done; f = e.next()) { + g = f.value, d.push(g.commit(a, b)); } - return D(h, Promise.all(d), 2); + return D(k, Promise.all(d), 2); } c.reg.clear(); - h.h = 0; + k.h = 0; }); }; u.destroy = function() { @@ -2542,18 +2542,18 @@ u.destroy = function() { function xb(a, b) { var c = new Map(), d = b.index || b.field || b; J(d) && (d = [d]); - for (var e = 0, g, f = void 0; e < d.length; e++) { - g = d[e]; - J(g) || (f = g, g = g.field); - f = xa(f) ? Object.assign({}, a, f) : a; + for (var e = 0, f, g = void 0; e < d.length; e++) { + f = d[e]; + J(f) || (g = f, f = f.field); + g = xa(g) ? Object.assign({}, a, g) : a; if (this.worker) { - var h = new Ra(f); - h.encoder = f.encoder; - c.set(g, h); + var k = new Ra(g); + k.encoder = g.encoder; + c.set(f, k); } - this.worker || c.set(g, new O(f, this.reg)); - f.custom ? this.L[e] = f.custom : (this.L[e] = wb(g, this.S), f.filter && ("string" === typeof this.L[e] && (this.L[e] = new String(this.L[e])), this.L[e].R = f.filter)); - this.field[e] = g; + this.worker || c.set(f, new O(g, this.reg)); + g.custom ? this.L[e] = g.custom : (this.L[e] = wb(f, this.S), g.filter && ("string" === typeof this.L[e] && (this.L[e] = new String(this.L[e])), this.L[e].R = g.filter)); + this.field[e] = f; } if (this.I) { for (a = b.store, J(a) && (a = [a]), b = 0; b < a.length; b++) { @@ -2585,11 +2585,11 @@ u.remove = function(a) { for (b = y(this.tag.values()), c = b.next(); !c.done; c = b.next()) { c = c.value; for (var d = y(c), e = d.next(); !e.done; e = d.next()) { - var g = e.value; - e = g[0]; - g = g[1]; - var f = g.indexOf(a); - -1 < f && (1 < g.length ? g.splice(f, 1) : c.delete(e)); + var f = e.value; + e = f[0]; + f = f[1]; + var g = f.indexOf(a); + -1 < g && (1 < f.length ? f.splice(g, 1) : c.delete(e)); } } } @@ -2638,33 +2638,33 @@ u.export = function(a, b, c, d) { if (c < this.field.length) { var e = this.field[c]; if ((b = this.index.get(e).export(a, e, c, d = 1)) && b.then) { - var g = this; + var f = this; return b.then(function() { - return g.export(a, e, c + 1); + return f.export(a, e, c + 1); }); } return this.export(a, e, c + 1); } switch(d) { case 0: - var f = "reg"; - var h = Xa(this.reg); + var g = "reg"; + var k = Xa(this.reg); b = null; break; case 1: - f = "tag"; - h = this.tag && Va(this.tag, this.reg.size); + g = "tag"; + k = this.tag && Va(this.tag, this.reg.size); b = null; break; case 2: - f = "doc"; - h = this.store && Ta(this.store); + g = "doc"; + k = this.store && Ta(this.store); b = null; break; default: return; } - return Za.call(this, a, b, f, h, c, d); + return Za.call(this, a, b, g, k, c, d); }; u.import = function(a, b) { var c = a.split("."); @@ -2711,10 +2711,10 @@ function yb(a, b, c) { if (!e) { e = this.search(a, b, c); if (e.then) { - var g = this; - e.then(function(f) { - g.cache.set(d, f); - return f; + var f = this; + e.then(function(g) { + f.cache.set(d, g); + return g; }); } this.cache.set(d, e); @@ -2753,7 +2753,7 @@ var Cb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t" var Eb = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; var Fb = {Exact:zb, Default:Ab, Normalize:Ab, LatinBalance:{mapper:Bb}, LatinAdvanced:{mapper:Bb, matcher:Cb, replacer:Db}, LatinExtra:{mapper:Bb, replacer:Db.concat([/(?!^)[aeo]/g, ""]), matcher:Cb}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { for (var b = 0; b < a.length; b++) { - for (var c = a[b], d = c.charAt(0), e = Eb[d], g = 1, f; g < c.length && (f = c.charAt(g), "h" === f || "w" === f || !(f = Eb[f]) || f === e || (d += f, e = f, 4 !== d.length)); g++) { + for (var c = a[b], d = c.charAt(0), e = Eb[d], f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Eb[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { } a[b] = d; } @@ -2767,8 +2767,8 @@ O.prototype.remove = function(a, b) { if (2 > e.length) { e.pop(); } else { - var g = e.indexOf(a); - g === c.length - 1 ? e.pop() : e.splice(g, 1); + var f = e.indexOf(a); + f === c.length - 1 ? e.pop() : e.splice(f, 1); } } } @@ -2784,13 +2784,13 @@ O.prototype.remove = function(a, b) { function Gb(a, b) { var c = 0, d = "undefined" === typeof b; if (a.constructor === Array) { - for (var e = 0, g = void 0, f; e < a.length; e++) { - if ((g = a[e]) && g.length) { + for (var e = 0, f = void 0, g; e < a.length; e++) { + if ((f = a[e]) && f.length) { if (d) { c++; } else { - if (f = g.indexOf(b), 0 <= f) { - 1 < g.length ? (g.splice(f, 1), c++) : delete a[e]; + if (g = f.indexOf(b), 0 <= g) { + 1 < f.length ? (f.splice(g, 1), c++) : delete a[e]; break; } else { c++; @@ -2800,7 +2800,7 @@ function Gb(a, b) { } } else { for (d = y(a.entries()), e = d.next(); !e.done; e = d.next()) { - g = e.value, e = g[0], (g = Gb(g[1], b)) ? c += g : a.delete(e); + f = e.value, e = f[0], (f = Gb(f[1], b)) ? c += f : a.delete(e); } } return c; @@ -2811,19 +2811,21 @@ O.prototype.add = function(a, b, c, d) { if (!d && !c && this.reg.has(a)) { return this.update(a, b); } - b = this.encoder.encode(b); - if (d = b.length) { - for (var e = I(), g = I(), f = this.depth, h = this.resolution, k = 0; k < d; k++) { - var l = b[this.rtl ? d - 1 - k : k], m = l.length; - if (m && (f || !g[l])) { - var n = this.score ? this.score(b, l, k, null, 0) : Jb(h, d, k), p = ""; + d = this.depth; + b = this.encoder.encode(b, !d); + var e = b.length; + if (e) { + for (var f = I(), g = I(), k = this.resolution, h = 0; h < e; h++) { + var l = b[this.rtl ? e - 1 - h : h], m = l.length; + if (m && (d || !g[l])) { + var n = this.score ? this.score(b, l, h, null, 0) : Jb(k, e, h), p = ""; switch(this.tokenize) { case "full": if (2 < m) { n = 0; for (var q; n < m; n++) { - for (var t = m; t > n; t--) { - p = l.substring(n, t), q = this.rtl ? m - 1 - n : n, q = this.score ? this.score(b, l, k, p, q) : Jb(h, d, k, m, q), Kb(this, g, p, q, a, c); + for (var r = m; r > n; r--) { + p = l.substring(n, r), q = this.rtl ? m - 1 - n : n, q = this.score ? this.score(b, l, h, p, q) : Jb(k, e, h, m, q), Kb(this, g, p, q, a, c); } } break; @@ -2831,25 +2833,25 @@ O.prototype.add = function(a, b, c, d) { case "bidirectional": case "reverse": if (1 < m) { - for (t = m - 1; 0 < t; t--) { - p = l[this.rtl ? m - 1 - t : t] + p, q = this.score ? this.score(b, l, k, p, t) : Jb(h, d, k, m, t), Kb(this, g, p, q, a, c); + for (r = m - 1; 0 < r; r--) { + p = l[this.rtl ? m - 1 - r : r] + p, q = this.score ? this.score(b, l, h, p, r) : Jb(k, e, h, m, r), Kb(this, g, p, q, a, c); } p = ""; } case "forward": if (1 < m) { - for (t = 0; t < m; t++) { - p += l[this.rtl ? m - 1 - t : t], Kb(this, g, p, n, a, c); + for (r = 0; r < m; r++) { + p += l[this.rtl ? m - 1 - r : r], Kb(this, g, p, n, a, c); } break; } default: - if (Kb(this, g, l, n, a, c), f && 1 < d && k < d - 1) { - for (m = I(), p = this.da, n = l, t = Math.min(f + 1, this.rtl ? k + 1 : d - k), q = m[n] = 1; q < t; q++) { - if ((l = b[this.rtl ? d - 1 - k - q : k + q]) && !m[l]) { + if (Kb(this, g, l, n, a, c), d && 1 < e && h < e - 1) { + for (m = I(), p = this.da, n = l, r = Math.min(d + 1, this.rtl ? h + 1 : e - h), q = m[n] = 1; q < r; q++) { + if ((l = b[this.rtl ? e - 1 - h - q : h + q]) && !m[l]) { m[l] = 1; - var w = this.score ? this.score(b, n, k, l, q - 1) : Jb(p + (d / 2 > p ? 0 : 1), d, k, t - 1, q - 1), r = this.bidirectional && l > n; - Kb(this, e, r ? n : l, w, a, c, r ? l : n); + var v = this.score ? this.score(b, n, h, l, q - 1) : Jb(p + (e / 2 > p ? 0 : 1), e, h, r - 1, q - 1), t = this.bidirectional && l > n; + Kb(this, f, t ? n : l, v, a, c, t ? l : n); } } } @@ -2864,21 +2866,21 @@ O.prototype.add = function(a, b, c, d) { this.db && (b || this.commit_task.push({del:a}), this.ca && Hb(this)); return this; }; -function Kb(a, b, c, d, e, g, f) { - var h = f ? a.ctx : a.map, k; - if (!b[c] || f && !(k = b[c])[f]) { - if (f ? (b = k || (b[c] = I()), b[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : b[c] = 1, (k = h.get(c)) ? h = k : h.set(c, h = k = []), h = h[d] || (h[d] = []), !g || !h.includes(e)) { - if (h.length === Math.pow(2, 31) - 1) { - b = new S(h); +function Kb(a, b, c, d, e, f, g) { + var k = g ? a.ctx : a.map, h; + if (!b[c] || g && !(h = b[c])[g]) { + if (g ? (b = h || (b[c] = I()), b[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : b[c] = 1, (h = k.get(c)) ? k = h : k.set(c, k = h = []), k = k[d] || (k[d] = []), !f || !k.includes(e)) { + if (k.length === Math.pow(2, 31) - 1) { + b = new S(k); if (a.fastupdate) { - for (c = y(a.reg.values()), g = c.next(); !g.done; g = c.next()) { - g = g.value, g.includes(h) && (g[g.indexOf(h)] = b); + for (c = y(a.reg.values()), f = c.next(); !f.done; f = c.next()) { + f = f.value, f.includes(k) && (f[f.indexOf(k)] = b); } } - k[d] = h = b; + h[d] = k = b; } - h.push(e); - a.fastupdate && ((d = a.reg.get(e)) ? d.push(h) : a.reg.set(e, [h])); + k.push(e); + a.fastupdate && ((d = a.reg.get(e)) ? d.push(k) : a.reg.set(e, [k])); } } } @@ -2887,105 +2889,105 @@ function Jb(a, b, c, d, e) { } ;O.prototype.search = function(a, b, c) { c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); - var d = [], e = 0, g; + var d = [], e = 0, f; if (c) { a = c.query || a; b = c.limit || b; e = c.offset || 0; - var f = c.context; - var h = c.suggest; - var k = (g = !1 !== c.resolve) && c.enrich; + var g = c.context; + var k = c.suggest; + var h = (f = !1 !== c.resolve) && c.enrich; var l = c.boost; var m = c.resolution; var n = this.db && c.tag; } else { - g = this.resolve; + f = this.resolve; } - var p = this.encoder.encode(a); + g = this.depth && !1 !== g; + var p = this.encoder.encode(a, !g); var q = p.length; - b = b || (g ? 100 : 0); + b = b || (f ? 100 : 0); if (1 === q) { - return Lb.call(this, p[0], "", b, e, g, k, n); + return Lb.call(this, p[0], "", b, e, f, h, n); } - f = this.depth && !1 !== f; - if (2 === q && f && !h) { - return Lb.call(this, p[1], p[0], b, e, g, k, n); + if (2 === q && g && !k) { + return Lb.call(this, p[1], p[0], b, e, f, h, n); } - var t = I(), w = 0; - if (f) { - var r = p[0]; - w = 1; + var r = I(), v = 0; + if (g) { + var t = p[0]; + v = 1; } - m || 0 === m || (m = r ? this.da : this.resolution); + m || 0 === m || (m = t ? this.da : this.resolution); if (this.db) { - if (this.db.search && (a = this.db.search(this, p, b, e, h, g, k, n), !1 !== a)) { + if (this.db.search && (a = this.db.search(this, p, b, e, k, f, h, n), !1 !== a)) { return a; } var z = this; return function() { - var A, v; + var A, w; return ta(function(x) { switch(x.h) { case 1: - v = A = void 0; + w = A = void 0; case 2: - if (!(w < q)) { + if (!(v < q)) { x.h = 4; break; } - v = p[w]; - if (!v || t[v]) { + w = p[v]; + if (!w || r[w]) { x.h = 5; break; } - t[v] = 1; - return D(x, Mb(z, v, r, 0, 0, !1, !1), 6); + r[w] = 1; + return D(x, Mb(z, w, t, 0, 0, !1, !1), 6); case 6: A = x.D; - if (A = Nb(A, d, h, m)) { + if (A = Nb(A, d, k, m)) { d = A; x.h = 4; break; } - r && (h && A && d.length || (r = v)); + t && (k && A && d.length || (t = w)); case 5: - h && r && w === q - 1 && !d.length && (m = z.resolution, r = "", w = -1, t = I()); - w++; + k && t && v === q - 1 && !d.length && (m = z.resolution, t = "", v = -1, r = I()); + v++; x.h = 2; break; case 4: - return x.return(Ob(d, m, b, e, h, l, g)); + return x.return(Ob(d, m, b, e, k, l, f)); } }); }(); } - for (c = a = void 0; w < q; w++) { - if ((c = p[w]) && !t[c]) { - t[c] = 1; - a = Mb(this, c, r, 0, 0, !1, !1); - if (a = Nb(a, d, h, m)) { + for (c = a = void 0; v < q; v++) { + if ((c = p[v]) && !r[c]) { + r[c] = 1; + a = Mb(this, c, t, 0, 0, !1, !1); + if (a = Nb(a, d, k, m)) { d = a; break; } - r && (h && a && d.length || (r = c)); + t && (k && a && d.length || (t = c)); } - h && r && w === q - 1 && !d.length && (m = this.resolution, r = "", w = -1, t = I()); + k && t && v === q - 1 && !d.length && (m = this.resolution, t = "", v = -1, r = I()); } - return Ob(d, m, b, e, h, l, g); + return Ob(d, m, b, e, k, l, f); }; -function Ob(a, b, c, d, e, g, f) { - var h = a.length, k = a; - if (1 < h) { - k = ib(a, b, c, d, e, g, f); - } else if (1 === h) { - return f ? lb.call(null, a[0], c, d) : new X(a[0]); +function Ob(a, b, c, d, e, f, g) { + var k = a.length, h = a; + if (1 < k) { + h = ib(a, b, c, d, e, f, g); + } else if (1 === k) { + return g ? lb.call(null, a[0], c, d) : new X(a[0]); } - return f ? k : new X(k); + return g ? h : new X(h); } -function Lb(a, b, c, d, e, g, f) { - a = Mb(this, a, b, c, d, e, g, f); - return this.db ? a.then(function(h) { - return e ? h || [] : new X(h); +function Lb(a, b, c, d, e, f, g) { + a = Mb(this, a, b, c, d, e, f, g); + return this.db ? a.then(function(k) { + return e ? k || [] : new X(k); }) : a && a.length ? e ? lb.call(this, a, c, d) : new X(a) : e ? [] : new X(); } function Nb(a, b, c, d) { @@ -2995,9 +2997,9 @@ function Nb(a, b, c, d) { b.push(a); return; } - for (var g = 0, f; g < d; g++) { - if (f = a[g]) { - e[g] = f; + for (var f = 0, g; f < d; f++) { + if (g = a[f]) { + e[f] = g; } } if (e.length) { @@ -3009,11 +3011,11 @@ function Nb(a, b, c, d) { return e; } } -function Mb(a, b, c, d, e, g, f, h) { - var k; - c && (k = a.bidirectional && b > c) && (k = c, c = b, b = k); +function Mb(a, b, c, d, e, f, g, k) { + var h; + c && (h = a.bidirectional && b > c) && (h = c, c = b, b = h); if (a.db) { - return a.db.get(b, c, d, e, g, f, h); + return a.db.get(b, c, d, e, f, g, k); } a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); return a; @@ -3108,24 +3110,24 @@ u.export = function(a, b, c, d) { switch(d) { case 0: var e = "reg"; - var g = Xa(this.reg); + var f = Xa(this.reg); break; case 1: e = "cfg"; - g = null; + f = null; break; case 2: e = "map"; - g = Ta(this.map, this.reg.size); + f = Ta(this.map, this.reg.size); break; case 3: e = "ctx"; - g = Va(this.ctx, this.reg.size); + f = Va(this.ctx, this.reg.size); break; default: return; } - return Za.call(this, a, b, e, g, c, d); + return Za.call(this, a, b, e, f, c, d); }; u.import = function(a, b) { if (b) { @@ -3148,20 +3150,20 @@ u.serialize = function(a) { if (this.reg.size) { var e; c = y(this.reg.keys()); - for (var g = c.next(); !g.done; g = c.next()) { - g = g.value, e || (e = typeof g), b += (b ? "," : "") + ("string" === e ? '"' + g + '"' : g); + for (var f = c.next(); !f.done; f = c.next()) { + f = f.value, e || (e = typeof f), b += (b ? "," : "") + ("string" === e ? '"' + f + '"' : f); } b = "index.reg=new Set([" + b + "]);"; c = $a(this.map, e); c = "index.map=new Map([" + c + "]);"; - g = y(this.ctx.entries()); - for (var f = g.next(); !f.done; f = g.next()) { - var h = f.value; - f = h[0]; - h = $a(h[1], e); - h = "new Map([" + h + "])"; - h = '["' + f + '",' + h + "]"; - d += (d ? "," : "") + h; + f = y(this.ctx.entries()); + for (var g = f.next(); !g.done; g = f.next()) { + var k = g.value; + g = k[0]; + k = $a(k[1], e); + k = "new Map([" + k + "])"; + k = '["' + g + '",' + k + "]"; + d += (d ? "," : "") + k; } d = "index.ctx=new Map([" + d + "]);"; } @@ -3203,8 +3205,8 @@ u.open = function() { b.onupgradeneeded = function() { for (var c = a.db = this.result, d = 0, e; d < Qb.length; d++) { e = Qb[d]; - for (var g = 0, f; g < Rb[a.id].length; g++) { - f = Rb[a.id][g], c.objectStoreNames.contains(e + ("reg" !== e ? f ? ":" + f : "" : "")) || c.createObjectStore(e + ("reg" !== e ? f ? ":" + f : "" : "")); + for (var f = 0, g; f < Rb[a.id].length; f++) { + g = Rb[a.id][f], c.objectStoreNames.contains(e + ("reg" !== e ? g ? ":" + g : "" : "")) || c.createObjectStore(e + ("reg" !== e ? g ? ":" + g : "" : "")); } } }; @@ -3236,40 +3238,40 @@ u.clear = function() { } return Z(b); }; -u.get = function(a, b, c, d, e, g) { +u.get = function(a, b, c, d, e, f) { c = void 0 === c ? 0 : c; d = void 0 === d ? 0 : d; e = void 0 === e ? !0 : e; - g = void 0 === g ? !1 : g; + f = void 0 === f ? !1 : f; a = this.db.transaction((b ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((b ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(b ? b + ":" + a : a); - var f = this; - return Z(a).then(function(h) { - var k = []; - if (!h || !h.length) { - return k; + var g = this; + return Z(a).then(function(k) { + var h = []; + if (!k || !k.length) { + return h; } if (e) { - if (!c && !d && 1 === h.length) { - return h[0]; + if (!c && !d && 1 === k.length) { + return k[0]; } - for (var l = 0, m = void 0; l < h.length; l++) { - if ((m = h[l]) && m.length) { + for (var l = 0, m = void 0; l < k.length; l++) { + if ((m = k[l]) && m.length) { if (d >= m.length) { d -= m.length; } else { for (var n = c ? d + Math.min(m.length - d, c) : m.length, p = d; p < n; p++) { - k.push(m[p]); + h.push(m[p]); } d = 0; - if (k.length === c) { + if (h.length === c) { break; } } } } - return g ? f.enrich(k) : k; + return f ? g.enrich(h) : h; } - return h; + return k; }); }; u.tag = function(a, b, c, d) { @@ -3278,15 +3280,15 @@ u.tag = function(a, b, c, d) { d = void 0 === d ? !1 : d; a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a); var e = this; - return Z(a).then(function(g) { - if (!g || !g.length || c >= g.length) { + return Z(a).then(function(f) { + if (!f || !f.length || c >= f.length) { return []; } if (!b && !c) { - return g; + return f; } - g = g.slice(c, c + b); - return d ? e.enrich(g) : g; + f = f.slice(c, c + b); + return d ? e.enrich(f) : f; }); }; u.enrich = function(a) { @@ -3295,8 +3297,8 @@ u.enrich = function(a) { c[d] = Z(b.get(a[d])); } return Promise.all(c).then(function(e) { - for (var g = 0; g < e.length; g++) { - e[g] = {id:a[g], doc:e[g] ? JSON.parse(e[g]) : null}; + for (var f = 0; f < e.length; f++) { + e[f] = {id:a[f], doc:e[f] ? JSON.parse(e[f]) : null}; } return e; }); @@ -3318,116 +3320,116 @@ u.transaction = function(a, b, c) { } var e = this.db.transaction(a, b); this.h[a + ":" + b] = d = e.objectStore(a); - var g = c.call(this, d); + var f = c.call(this, d); this.h[a + ":" + b] = null; return Z(e).finally(function() { e = d = null; - return g; + return f; }); }; u.commit = function(a, b, c) { - var d = this, e, g, f; - return ta(function(h) { - switch(h.h) { + var d = this, e, f, g; + return ta(function(k) { + switch(k.h) { case 1: if (b) { - return D(h, d.clear(), 12); + return D(k, d.clear(), 12); } e = a.commit_task; a.commit_task = []; - g = 0; - f = void 0; + f = 0; + g = void 0; case 4: - if (!(g < e.length)) { - h.h = 6; + if (!(f < e.length)) { + k.h = 6; break; } - f = e[g]; - if (!f.clear) { - e[g] = f.del; - h.h = 5; + g = e[f]; + if (!g.clear) { + e[f] = g.del; + k.h = 5; break; } - return D(h, d.clear(), 8); + return D(k, d.clear(), 8); case 8: b = !0; - h.h = 6; + k.h = 6; break; case 5: - g++; - h.h = 4; + f++; + k.h = 4; break; case 6: if (b) { - h.h = 3; + k.h = 3; break; } c || (e = e.concat(ya(a.reg))); if (!e.length) { - h.h = 10; + k.h = 10; break; } - return D(h, d.remove(e), 11); + return D(k, d.remove(e), 11); case 11: case 10: - h.h = 3; + k.h = 3; break; case 12: a.commit_task = []; case 3: - return a.reg.size ? D(h, d.transaction("map", "readwrite", function(k) { + return a.reg.size ? D(k, d.transaction("map", "readwrite", function(h) { for (var l = y(a.map), m = l.next(), n = {}; !m.done; n = {O:void 0, Y:void 0}, m = l.next()) { - m = m.value, n.Y = m[0], n.O = m[1], n.O.length && (b ? k.put(n.O, n.Y) : k.get(n.Y).onsuccess = function(p) { + m = m.value, n.Y = m[0], n.O = m[1], n.O.length && (b ? h.put(n.O, n.Y) : h.get(n.Y).onsuccess = function(p) { return function() { - var q = this.result, t; + var q = this.result, r; if (q && q.length) { - for (var w = Math.max(q.length, p.O.length), r = 0, z; r < w; r++) { - if ((z = p.O[r]) && z.length) { - if ((t = q[r]) && t.length) { + for (var v = Math.max(q.length, p.O.length), t = 0, z; t < v; t++) { + if ((z = p.O[t]) && z.length) { + if ((r = q[t]) && r.length) { for (var A = 0; A < z.length; A++) { - t.push(z[A]); + r.push(z[A]); } } else { - q[r] = z; + q[t] = z; } - t = 1; + r = 1; } } } else { - q = p.O, t = 1; + q = p.O, r = 1; } - t && k.put(q, p.Y); + r && h.put(q, p.Y); }; }(n)); } - }), 13) : h.return(); + }), 13) : k.return(); case 13: - return D(h, d.transaction("ctx", "readwrite", function(k) { + return D(k, d.transaction("ctx", "readwrite", function(h) { for (var l = y(a.ctx), m = l.next(), n = {}; !m.done; n = {V:void 0}, m = l.next()) { m = m.value; n.V = m[0]; m = y(m[1]); for (var p = m.next(), q = {}; !p.done; q = {P:void 0, Z:void 0}, p = m.next()) { - p = p.value, q.Z = p[0], q.P = p[1], q.P.length && (b ? k.put(q.P, n.V + ":" + q.Z) : k.get(n.V + ":" + q.Z).onsuccess = function(t, w) { + p = p.value, q.Z = p[0], q.P = p[1], q.P.length && (b ? h.put(q.P, n.V + ":" + q.Z) : h.get(n.V + ":" + q.Z).onsuccess = function(r, v) { return function() { - var r = this.result, z; - if (r && r.length) { - for (var A = Math.max(r.length, t.P.length), v = 0, x; v < A; v++) { - if ((x = t.P[v]) && x.length) { - if ((z = r[v]) && z.length) { + var t = this.result, z; + if (t && t.length) { + for (var A = Math.max(t.length, r.P.length), w = 0, x; w < A; w++) { + if ((x = r.P[w]) && x.length) { + if ((z = t[w]) && z.length) { for (var E = 0; E < x.length; E++) { z.push(x[E]); } } else { - r[v] = x; + t[w] = x; } z = 1; } } } else { - r = t.P, z = 1; + t = r.P, z = 1; } - z && k.put(r, w.V + ":" + t.Z); + z && h.put(t, v.V + ":" + r.Z); }; }(q, n)); } @@ -3435,65 +3437,65 @@ u.commit = function(a, b, c) { }), 14); case 14: if (a.store) { - return D(h, d.transaction("reg", "readwrite", function(k) { + return D(k, d.transaction("reg", "readwrite", function(h) { for (var l = y(a.store), m = l.next(); !m.done; m = l.next()) { var n = m.value; m = n[0]; n = n[1]; - k.put("object" === typeof n ? JSON.stringify(n) : 1, m); + h.put("object" === typeof n ? JSON.stringify(n) : 1, m); } }), 16); } if (a.bypass) { - h.h = 16; + k.h = 16; break; } - return D(h, d.transaction("reg", "readwrite", function(k) { + return D(k, d.transaction("reg", "readwrite", function(h) { for (var l = y(a.reg.keys()), m = l.next(); !m.done; m = l.next()) { - k.put(1, m.value); + h.put(1, m.value); } }), 16); case 16: if (!a.tag) { - h.h = 20; + k.h = 20; break; } - return D(h, d.transaction("tag", "readwrite", function(k) { + return D(k, d.transaction("tag", "readwrite", function(h) { for (var l = y(a.tag), m = l.next(), n = {}; !m.done; n = {X:void 0, ba:void 0}, m = l.next()) { - m = m.value, n.ba = m[0], n.X = m[1], n.X.length && (k.get(n.ba).onsuccess = function(p) { + m = m.value, n.ba = m[0], n.X = m[1], n.X.length && (h.get(n.ba).onsuccess = function(p) { return function() { var q = this.result; q = q && q.length ? q.concat(p.X) : p.X; - k.put(q, p.ba); + h.put(q, p.ba); }; }(n)); } }), 20); case 20: - a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear(), h.h = 0; + a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear(), k.h = 0; } }); }; function Tb(a, b, c) { - for (var d = a.value, e, g = 0, f = 0, h; f < d.length; f++) { - if (h = c ? d : d[f]) { - for (var k = 0, l; k < b.length; k++) { - if (l = b[k], l = h.indexOf(l), 0 <= l) { - if (e = 1, 1 < h.length) { - h.splice(l, 1); + for (var d = a.value, e, f = 0, g = 0, k; g < d.length; g++) { + if (k = c ? d : d[g]) { + for (var h = 0, l; h < b.length; h++) { + if (l = b[h], l = k.indexOf(l), 0 <= l) { + if (e = 1, 1 < k.length) { + k.splice(l, 1); } else { - d[f] = []; + d[g] = []; break; } } } - g += h.length; + f += k.length; } if (c) { break; } } - g ? e && a.update(d) : a.delete(); + f ? e && a.update(d) : a.delete(); a.continue(); } u.remove = function(a) { diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js index 0509d57..7dd35f7 100644 --- a/dist/flexsearch.es5.min.js +++ b/dist/flexsearch.es5.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.156 (ES5) + * FlexSearch.js v0.8.157 (ES5) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -14,22 +14,22 @@ function qa(a){this.next=function(b){ka(a.h);a.h.A?b=oa(a,a.h.A.next,b,a.h.G):(a function sa(a){function b(d){return a.next(d)}function c(d){return a.throw(d)}return new Promise(function(d,e){function g(f){f.done?d(f.value):Promise.resolve(f.value).then(b,c).then(g,e)}g(a.next())})}function ta(a){return sa(new qa(new ma(a)))} C("Symbol",function(a){function b(g){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(g||"")+"_"+e++,g)}function c(g,f){this.h=g;ba(this,"description",{configurable:!0,writable:!0,value:f})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",e=0;return b}); C("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c"a1a".split(c).length; this.numeric=G(a.numeric,e)}else{try{this.split=G(this.split,Ba)}catch(g){this.split=/\s+/}this.numeric=G(a.numeric,G(this.numeric,!0))}this.prepare=G(a.prepare,null,this.prepare);this.finalize=G(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:G(c&&new Set(c),null,this.filter);this.dedupe=G(a.dedupe,!0,this.dedupe);this.matcher=G((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=G((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=G((c=a.stemmer)&&new Map(c), null,this.stemmer);this.replacer=G(a.replacer,null,this.replacer);this.minlength=G(a.minlength,1,this.minlength);this.maxlength=G(a.maxlength,1024,this.maxlength);this.rtl=G(a.rtl,!1,this.rtl);if(this.cache=c=G(a.cache,!0,this.cache))this.D=null,this.T="number"===typeof c?c:2E5,this.B=new Map,this.C=new Map,this.H=this.G=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(a=y(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.h+=(this.h?"|":"")+b.value;if(this.stemmer)for(a=y(this.stemmer.keys()), b=a.next();!b.done;b=a.next())this.A+=(this.A?"|":"")+b.value;return this};u.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&K(this);return this};u.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&K(this);return this}; u.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&K(this);return this}; u.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&K(this);return this}; -u.encode=function(a){var b=this;if(this.cache&&a.length<=this.G)if(this.D){if(this.B.has(a))return this.B.get(a)}else this.D=setTimeout(K,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=Fa?a.normalize("NFKD").replace(Fa,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength))if(c)d.push(f);else if(!this.filter||("function"===typeof this.filter?this.filter(f):!this.filter.has(f))){if(this.cache&&f.length<=this.H)if(this.D){var k=this.C.get(f);if(k||""===k){k&&d.push(k);continue}}else this.D=setTimeout(K,50,this);this.stemmer&&2this.T&&(this.C.clear(),this.H=this.H/1.1|0));f&&d.push(f)}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.G&&(this.B.set(a,d),this.B.size>this.T&&(this.B.clear(),this.G=this.G/1.1|0));return d};function K(a){a.D=null;a.B.clear();a.C.clear()};var Ha,Ia; -function Ja(a){var b,c,d,e,g,f;return ta(function(h){switch(h.h){case 1:a=a.data;b=a.task;c=a.id;d=a.args;switch(b){case "init":Ia=a.options||{};(e=a.factory)?(Function("return "+e)()(self),Ha=new self.FlexSearch.Index(Ia),delete self.FlexSearch):Ha=new M(Ia);postMessage({id:c});break;default:h.h=2;return}h.h=0;break;case 2:"export"===b&&(d[1]?(d[0]=Ia.export,d[2]=0,d[3]=1):d=null);if("import"===b){if(!d[0]){h.h=5;break}return D(h,Ia.import.call(Ha,d[0]),9)}g=d&&Ha[b].apply(Ha,d);if(!g||!g.then){h.h= -5;break}return D(h,g,7);case 7:g=h.D;h.h=5;break;case 9:f=h.D,Ha.import(d[0],f);case 5:postMessage("search"===b?{id:c,msg:g}:{id:c}),h.h=0}})};function Ka(a){La.call(a,"add");La.call(a,"append");La.call(a,"search");La.call(a,"update");La.call(a,"remove")}var Na,Oa,Pa;function Qa(){Na=Pa=0} +u.encode=function(a,b){var c=this;if(this.cache&&a.length<=this.G)if(this.D){if(this.B.has(a))return this.B.get(a)}else this.D=setTimeout(K,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=Fa?a.normalize("NFKD").replace(Fa,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength||b&&g[h]))if(d)b&&(g[h]=1),e.push(h);else if(!this.filter||("function"===typeof this.filter?this.filter(h):!this.filter.has(h))){if(this.cache&&h.length<=this.H)if(this.D){var m=this.C.get(h);if(m||""===m){m&&e.push(m);continue}}else this.D=setTimeout(K,50,this);this.stemmer&&2this.T&&(this.C.clear(),this.H=this.H/1.1|0));!h||b&&g[h]||(b&&(g[h]=1),e.push(h))}this.finalize&&(e=this.finalize(e)||e);this.cache&&a.length<=this.G&&(this.B.set(a,e),this.B.size>this.T&&(this.B.clear(),this.G=this.G/1.1|0));return e};function K(a){a.D=null;a.B.clear();a.C.clear()};var Ha,Ia; +function Ja(a){var b,c,d,e,g,f;return ta(function(k){switch(k.h){case 1:a=a.data;b=a.task;c=a.id;d=a.args;switch(b){case "init":Ia=a.options||{};(e=a.factory)?(Function("return "+e)()(self),Ha=new self.FlexSearch.Index(Ia),delete self.FlexSearch):Ha=new M(Ia);postMessage({id:c});break;default:k.h=2;return}k.h=0;break;case 2:"export"===b&&(d[1]?(d[0]=Ia.export,d[2]=0,d[3]=1):d=null);if("import"===b){if(!d[0]){k.h=5;break}return D(k,Ia.import.call(Ha,d[0]),9)}g=d&&Ha[b].apply(Ha,d);if(!g||!g.then){k.h= +5;break}return D(k,g,7);case 7:g=k.D;k.h=5;break;case 9:f=k.D,Ha.import(d[0],f);case 5:postMessage("search"===b?{id:c,msg:g}:{id:c}),k.h=0}})};function Ka(a){La.call(a,"add");La.call(a,"append");La.call(a,"search");La.call(a,"update");La.call(a,"remove")}var Na,Oa,Pa;function Qa(){Na=Pa=0} function La(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if("function"===typeof c){var d=c;delete b[b.length-1]}Na?Pa||(Pa=Date.now()-Oa>=this.priority*this.priority*3):(Na=setTimeout(Qa,0),Oa=Date.now());if(Pa){var e=this;return new Promise(function(f){setTimeout(function(){f(e[a+"Async"].apply(e,b))},0)})}var g=this[a].apply(this,b);c=g.then?g:new Promise(function(f){return f(g)});d&&c.then(d);return c}};var Ra=0; -function Sa(a){function b(f){function h(k){k=k.data||k;var l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=f;this.h=I();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++Ra]=function(){k(e);1E9=f.length)b-=f.length;else{b=f[d?"splice":"slice"](b,c);if(f=b.length)if(e=e.length?e.concat(b):b,c-=f,d&&(a.length-=f),!c)break;b=0}return e} -function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var g=0,f=0,h,k;f=f.length)b-=f.length;else{b=f[d?"splice":"slice"](b,c);if(f=b.length)if(e=e.length?e.concat(b):b,c-=f,d&&(a.length-=f),!c)break;b=0}return e} +function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var g=0,f=0,k,h;fc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+ -d)}else{e=[];for(g=0;gd)d-=f.length;else{if(f.length>c||d)f=f.slice(d,c+d),c-=f.length,d&&(d-=f.length);e.push(f);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,d?V.call(this,a):a;for(var e=[],g=0,f=void 0,h=void 0;g=h){c-=h;continue}cb&&(f=f.slice(0,b),h=b);if(!e.length&&h>=b)return d?V.call(this,f):f;e.push(f);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=kb(a,c,d,!1,this.h),d=0));return g?this.resolve(c,d,e):this};W.prototype.and=function(){var a=this.result.length;if(!a){var b=arguments[0];if(b){a=!!b.suggest;var c=b.resolve;var d=b.limit;var e=b.offset;var g=b.enrich&&c}}return a?(a=nb(this,"and",arguments),pb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)):c?this.resolve(d,e,g):this}; -function pb(a,b,c,d,e,g,f){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else{if(b=Aa(a))return this.result=jb(a,b,c,d,f,this.h,g),g?e?V.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?this.resolve(c,d,e):this};W.prototype.xor=function(){var a=nb(this,"xor",arguments);return qb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)}; -function qb(a,b,c,d,e,g,f){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else return this.result=rb.call(this,a,c,d,g,this.h),g?e?V.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(c,d,e):this} -function rb(a,b,c,d,e){for(var g=[],f=I(),h=0,k=0,l;kc||d?h.slice(d,c+d):h;else{if(ac||d)h=h.slice(d,c+ +d)}else{e=[];for(g=0;gd)d-=f.length;else{if(f.length>c||d)f=f.slice(d,c+d),c-=f.length,d&&(d-=f.length);e.push(f);if(!c)break}h=1b?b?a.slice(c,c+b):a.slice(c):a,d?V.call(this,a):a;for(var e=[],g=0,f=void 0,k=void 0;g=k){c-=k;continue}cb&&(f=f.slice(0,b),k=b);if(!e.length&&k>=b)return d?V.call(this,f):f;e.push(f);b-=k;if(!b)break}e=1a.length?this.result=a[0]:(this.result=kb(a,c,d,!1,this.h),d=0));return g?this.resolve(c,d,e):this};W.prototype.and=function(){var a=this.result.length;if(!a){var b=arguments[0];if(b){a=!!b.suggest;var c=b.resolve;var d=b.limit;var e=b.offset;var g=b.enrich&&c}}return a?(a=nb(this,"and",arguments),pb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)):c?this.resolve(d,e,g):this}; +function pb(a,b,c,d,e,g,f){if(b.length){var k=this;return Promise.all(b).then(function(h){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else{if(b=Aa(a))return this.result=jb(a,b,c,d,f,this.h,g),g?e?V.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?this.resolve(c,d,e):this};W.prototype.xor=function(){var a=nb(this,"xor",arguments);return qb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)}; +function qb(a,b,c,d,e,g,f){if(b.length){var k=this;return Promise.all(b).then(function(h){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else return this.result=rb.call(this,a,c,d,g,this.h),g?e?V.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(c,d,e):this} +function rb(a,b,c,d,e){for(var g=[],f=I(),k=0,h=0,l;hc||d)a=a.slice(d,d+c);e&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;for(var b=Array(a.length),c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; X.prototype.get=function(a){var b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(var b=y(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};X.prototype.clear=function(){this.cache.clear();this.h=""};var Ab={normalize:!1,numeric:!1,dedupe:!1};var Bb={};var Cb=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);var Db=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Eb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];var Fb={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Gb={Exact:Ab,Default:Bb,Normalize:Bb,LatinBalance:{mapper:Cb},LatinAdvanced:{mapper:Cb,matcher:Db,replacer:Eb},LatinExtra:{mapper:Cb,replacer:Eb.concat([/(?!^)[aeo]/g,""]),matcher:Db},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;be.length)e.pop();else{var g=e.indexOf(a);g===c.length-1?e.pop():e.splice(g,1)}}else Hb(this.map,a),this.depth&&Hb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Ib(this));this.cache&&this.cache.remove(a);return this}; -function Hb(a,b){var c=0,d="undefined"===typeof b;if(a.constructor===Array)for(var e=0,g=void 0,f;en;r--)q=l.substring(n,r),p=this.rtl?m-1-n:n,p=this.score?this.score(b,l,k,q,p):Kb(h,d,k,m,p),Lb(this,g,q, -p,a,c);break}case "bidirectional":case "reverse":if(1q?0:1),d,k,r-1,p-1),t=this.bidirectional&& -l>n;Lb(this,e,t?n:l,w,a,c,t?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.ca&&Ib(this));return this}; -function Lb(a,b,c,d,e,g,f){var h=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])if(f?(b=k||(b[c]=I()),b[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!g||!h.includes(e)){if(h.length===Math.pow(2,31)-1){b=new R(h);if(a.fastupdate)for(c=y(a.reg.values()),g=c.next();!g.done;g=c.next())g=g.value,g.includes(h)&&(g[g.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} -function Kb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,g,f,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=J(a)?a:a.preset;c&&(a=Object.assign({},Jb[c],a))}else a={};c=a.context;var d=!0===c?{depth:1}:c||{},e=J(a.encoder)?Gb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new Ga(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; +function Hb(a,b){var c=0,d="undefined"===typeof b;if(a.constructor===Array)for(var e=0,g=void 0,f;en;r--)q=l.substring(n,r),p=this.rtl?m-1-n:n,p=this.score?this.score(b,l,h,q,p):Kb(k,e,h,m,p),Lb(this, +f,q,p,a,c);break}case "bidirectional":case "reverse":if(1q?0:1),e,h,r-1,p-1),t=this.bidirectional&& +l>n;Lb(this,g,t?n:l,v,a,c,t?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.ca&&Ib(this));return this}; +function Lb(a,b,c,d,e,g,f){var k=f?a.ctx:a.map,h;if(!b[c]||f&&!(h=b[c])[f])if(f?(b=h||(b[c]=I()),b[f]=1,(h=k.get(f))?k=h:k.set(f,k=new Map)):b[c]=1,(h=k.get(c))?k=h:k.set(c,k=h=[]),k=k[d]||(k[d]=[]),!g||!k.includes(e)){if(k.length===Math.pow(2,31)-1){b=new R(k);if(a.fastupdate)for(c=y(a.reg.values()),g=c.next();!g.done;g=c.next())g=g.value,g.includes(k)&&(g[g.indexOf(k)]=b);h[d]=k=b}k.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(k):a.reg.set(e,[k]))}} +function Kb(a,b,c,d,e){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,d,e,g,f,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=J(a)?a:a.preset;c&&(a=Object.assign({},Jb[c],a))}else a={};c=a.context;var d=!0===c?{depth:1}:c||{},e=J(a.encoder)?Gb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new Ga(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.da=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new X(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.ca=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}u=M.prototype; u.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};u.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};u.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function Ib(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};u.append=function(a,b){return this.add(a,b,!0)};u.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};u.update=function(a,b){var c=this,d=this.remove(a);return d&&d.then?d.then(function(){return c.add(a,b)}):this.add(a,b)}; u.cleanup=function(){if(!this.fastupdate)return this;Hb(this.map);this.depth&&Hb(this.ctx);return this};u.searchCache=zb;u.export=function(a,b,c,d){c=void 0===c?0:c;d=void 0===d?0:d;switch(d){case 0:var e="reg";var g=Ya(this.reg);break;case 1:e="cfg";g=null;break;case 2:e="map";g=Ua(this.map,this.reg.size);break;case 3:e="ctx";g=Wa(this.ctx,this.reg.size);break;default:return}return $a.call(this,a,b,e,g,c,d)}; u.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length, -q=d;q=g.length)return[];if(!b&&!c)return g;g=g.slice(c,c+b);return d?e.enrich(g):g})}; +u.get=function(a,b,c,d,e,g){c=void 0===c?0:c;d=void 0===d?0:d;e=void 0===e?!0:e;g=void 0===g?!1:g;a=this.db.transaction((b?"ctx":"map")+(this.field?":"+this.field:""),"readonly").objectStore((b?"ctx":"map")+(this.field?":"+this.field:"")).get(b?b+":"+a:a);var f=this;return Z(a).then(function(k){var h=[];if(!k||!k.length)return h;if(e){if(!c&&!d&&1===k.length)return k[0];for(var l=0,m=void 0;l=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length, +q=d;q=g.length)return[];if(!b&&!c)return g;g=g.slice(c,c+b);return d?e.enrich(g):g})}; u.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;d a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, d); + return this.addMapper(a, c); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, d); + this.matcher.set(a, c); this.g += (this.g ? "|" : "") + a; this.s = null; this.cache && G(this); return this; }; -r.addReplacer = function(a, d) { +r.addReplacer = function(a, c) { if ("string" === typeof a) { - return this.addMatcher(a, d); + return this.addMatcher(a, c); } this.replacer || (this.replacer = []); - this.replacer.push(a, d); + this.replacer.push(a, c); this.cache && G(this); return this; }; -r.encode = function(a) { +r.encode = function(a, c) { if (this.cache && a.length <= this.m) { if (this.l) { if (this.i.has(a)) { @@ -185,79 +185,79 @@ r.encode = function(a) { } this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = E ? a.normalize("NFKD").replace(E, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(B, "$1 $2").replace(C, "$1 $2").replace(A, "$1 ")); - const d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let b = [], f = this.split || "" === this.split ? a.split(this.split) : a; - for (let g = 0, e, h; g < f.length; g++) { - if ((e = h = f[g]) && !(e.length < this.minlength || e.length > this.maxlength)) { - if (d) { - b.push(e); + this.numeric && 3 < a.length && (a = a.replace(C, "$1 $2").replace(D, "$1 $2").replace(B, "$1 ")); + const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + let f = [], d = w(), g = this.split || "" === this.split ? a.split(this.split) : [a]; + for (let k = 0, h, l; k < g.length; k++) { + if ((h = l = g[k]) && !(h.length < this.minlength || h.length > this.maxlength || c && d[h])) { + if (b) { + c && (d[h] = 1), f.push(h); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(e) : !this.filter.has(e))) { - if (this.cache && e.length <= this.o) { + if (!this.filter || ("function" === typeof this.filter ? this.filter(h) : !this.filter.has(h))) { + if (this.cache && h.length <= this.o) { if (this.l) { - var c = this.j.get(e); - if (c || "" === c) { - c && b.push(c); + var e = this.j.get(h); + if (e || "" === e) { + e && f.push(e); continue; } } else { this.l = setTimeout(G, 50, this); } } - this.stemmer && 2 < e.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), e = e.replace(this.u, k => this.stemmer.get(k))); - if (e && (this.mapper || this.dedupe && 1 < e.length)) { - c = ""; - for (let k = 0, n = "", m, v; k < e.length; k++) { - m = e.charAt(k), m === n && this.dedupe || ((v = this.mapper && this.mapper.get(m)) || "" === v ? v === n && this.dedupe || !(n = v) || (c += v) : c += n = m); + this.stemmer && 2 < h.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), h = h.replace(this.u, n => this.stemmer.get(n))); + if (h && (this.mapper || this.dedupe && 1 < h.length)) { + e = ""; + for (let n = 0, v = "", x, p; n < h.length; n++) { + x = h.charAt(n), x === v && this.dedupe || ((p = this.mapper && this.mapper.get(x)) || "" === p ? p === v && this.dedupe || !(v = p) || (e += p) : e += v = x); } - e = c; + h = e; } - this.matcher && 1 < e.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), e = e.replace(this.s, k => this.matcher.get(k))); - if (e && this.replacer) { - for (c = 0; e && c < this.replacer.length; c += 2) { - e = e.replace(this.replacer[c], this.replacer[c + 1]); + this.matcher && 1 < h.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), h = h.replace(this.s, n => this.matcher.get(n))); + if (h && this.replacer) { + for (e = 0; h && e < this.replacer.length; e += 2) { + h = h.replace(this.replacer[e], this.replacer[e + 1]); } } - this.cache && h.length <= this.o && (this.j.set(h, e), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); - e && b.push(e); + this.cache && l.length <= this.o && (this.j.set(l, h), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); + !h || c && d[h] || (c && (d[h] = 1), f.push(h)); } } } } - this.finalize && (b = this.finalize(b) || b); - this.cache && a.length <= this.m && (this.i.set(a, b), this.i.size > this.A && (this.i.clear(), this.m = this.m / 1.1 | 0)); - return b; + this.finalize && (f = this.finalize(f) || f); + this.cache && a.length <= this.m && (this.i.set(a, f), this.i.size > this.A && (this.i.clear(), this.m = this.m / 1.1 | 0)); + return f; }; function G(a) { a.l = null; a.i.clear(); a.j.clear(); } -;function H(a, d, b) { +;function H(a, c, b) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = b || a.length > d ? d ? a.slice(b, b + d) : a.slice(b) : a; + return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a; } let f = []; - for (let c = 0, g, e; c < a.length; c++) { - if ((g = a[c]) && (e = g.length)) { + for (let d = 0, g, e; d < a.length; d++) { + if ((g = a[d]) && (e = g.length)) { if (b) { if (b >= e) { b -= e; continue; } - b < e && (g = d ? g.slice(b, b + d) : g.slice(b), e = g.length, b = 0); + b < e && (g = c ? g.slice(b, b + c) : g.slice(b), e = g.length, b = 0); } - e > d && (g = g.slice(0, d), e = d); - if (!f.length && e >= d) { + e > c && (g = g.slice(0, c), e = c); + if (!f.length && e >= c) { return g; } f.push(g); - d -= e; - if (!d) { + c -= e; + if (!c) { break; } } @@ -265,38 +265,38 @@ function G(a) { return f = 1 < f.length ? [].concat.apply([], f) : f[0]; } ;w(); -I.prototype.remove = function(a, d) { +I.prototype.remove = function(a, c) { const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); if (b) { if (this.fastupdate) { - for (let f = 0, c; f < b.length; f++) { - if (c = b[f]) { - if (2 > c.length) { - c.pop(); + for (let f = 0, d; f < b.length; f++) { + if (d = b[f]) { + if (2 > d.length) { + d.pop(); } else { - const g = c.indexOf(a); - g === b.length - 1 ? c.pop() : c.splice(g, 1); + const g = d.indexOf(a); + g === b.length - 1 ? d.pop() : d.splice(g, 1); } } } } else { J(this.map, a), this.depth && J(this.ctx, a); } - d || this.reg.delete(a); + c || this.reg.delete(a); } return this; }; -function J(a, d) { +function J(a, c) { let b = 0; - var f = "undefined" === typeof d; + var f = "undefined" === typeof c; if (a.constructor === Array) { - for (let c = 0, g, e; c < a.length; c++) { - if ((g = a[c]) && g.length) { + for (let d = 0, g, e; d < a.length; d++) { + if ((g = a[d]) && g.length) { if (f) { b++; } else { - if (e = g.indexOf(d), 0 <= e) { - 1 < g.length ? (g.splice(e, 1), b++) : delete a[c]; + if (e = g.indexOf(c), 0 <= e) { + 1 < g.length ? (g.splice(e, 1), b++) : delete a[d]; break; } else { b++; @@ -305,65 +305,67 @@ function J(a, d) { } } } else { - for (let c of a.entries()) { - f = c[0]; - const g = J(c[1], d); + for (let d of a.entries()) { + f = d[0]; + const g = J(d[1], c); g ? b += g : a.delete(f); } } return b; } ;const K = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -I.prototype.add = function(a, d, b, f) { - if (d && (a || 0 === a)) { +I.prototype.add = function(a, c, b, f) { + if (c && (a || 0 === a)) { if (!f && !b && this.reg.has(a)) { - return this.update(a, d); + return this.update(a, c); } - d = this.encoder.encode(d); - if (f = d.length) { - const n = w(), m = w(), v = this.depth, D = this.resolution; - for (let p = 0; p < f; p++) { - let l = d[this.rtl ? f - 1 - p : p]; - var c = l.length; - if (c && (v || !m[l])) { - var g = this.score ? this.score(d, l, p, null, 0) : L(D, f, p), e = ""; + f = this.depth; + c = this.encoder.encode(c, !f); + const l = c.length; + if (l) { + const n = w(), v = w(), x = this.resolution; + for (let p = 0; p < l; p++) { + let m = c[this.rtl ? l - 1 - p : p]; + var d = m.length; + if (d && (f || !v[m])) { + var g = this.score ? this.score(c, m, p, null, 0) : L(x, l, p), e = ""; switch(this.tokenize) { case "full": - if (2 < c) { - for (let q = 0, t; q < c; q++) { - for (g = c; g > q; g--) { - e = l.substring(q, g); - t = this.rtl ? c - 1 - q : q; - var h = this.score ? this.score(d, l, p, e, t) : L(D, f, p, c, t); - M(this, m, e, h, a, b); + if (2 < d) { + for (let q = 0, t; q < d; q++) { + for (g = d; g > q; g--) { + e = m.substring(q, g); + t = this.rtl ? d - 1 - q : q; + var k = this.score ? this.score(c, m, p, e, t) : L(x, l, p, d, t); + M(this, v, e, k, a, b); } } break; } case "bidirectional": case "reverse": - if (1 < c) { - for (h = c - 1; 0 < h; h--) { - e = l[this.rtl ? c - 1 - h : h] + e; - var k = this.score ? this.score(d, l, p, e, h) : L(D, f, p, c, h); - M(this, m, e, k, a, b); + if (1 < d) { + for (k = d - 1; 0 < k; k--) { + e = m[this.rtl ? d - 1 - k : k] + e; + var h = this.score ? this.score(c, m, p, e, k) : L(x, l, p, d, k); + M(this, v, e, h, a, b); } e = ""; } case "forward": - if (1 < c) { - for (h = 0; h < c; h++) { - e += l[this.rtl ? c - 1 - h : h], M(this, m, e, g, a, b); + if (1 < d) { + for (k = 0; k < d; k++) { + e += m[this.rtl ? d - 1 - k : k], M(this, v, e, g, a, b); } break; } default: - if (M(this, m, l, g, a, b), v && 1 < f && p < f - 1) { - for (c = w(), e = this.v, g = l, h = Math.min(v + 1, this.rtl ? p + 1 : f - p), c[g] = 1, k = 1; k < h; k++) { - if ((l = d[this.rtl ? f - 1 - p - k : p + k]) && !c[l]) { - c[l] = 1; - const q = this.score ? this.score(d, g, p, l, k - 1) : L(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; - M(this, n, t ? g : l, q, a, b, t ? l : g); + if (M(this, v, m, g, a, b), f && 1 < l && p < l - 1) { + for (d = w(), e = this.v, g = m, k = Math.min(f + 1, this.rtl ? p + 1 : l - p), d[g] = 1, h = 1; h < k; h++) { + if ((m = c[this.rtl ? l - 1 - p - h : p + h]) && !d[m]) { + d[m] = 1; + const q = this.score ? this.score(c, g, p, m, h - 1) : L(e + (l / 2 > e ? 0 : 1), l, p, k - 1, h - 1), t = this.bidirectional && m > g; + M(this, n, t ? g : m, q, a, b, t ? m : g); } } } @@ -375,97 +377,97 @@ I.prototype.add = function(a, d, b, f) { } return this; }; -function M(a, d, b, f, c, g, e) { - let h = e ? a.ctx : a.map, k; - if (!d[b] || e && !(k = d[b])[e]) { - e ? (d = k || (d[b] = w()), d[e] = 1, (k = h.get(e)) ? h = k : h.set(e, h = new Map())) : d[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[f] || (h[f] = []), g && h.includes(c) || (h.push(c), a.fastupdate && ((d = a.reg.get(c)) ? d.push(h) : a.reg.set(c, [h]))); +function M(a, c, b, f, d, g, e) { + let k = e ? a.ctx : a.map, h; + if (!c[b] || e && !(h = c[b])[e]) { + e ? (c = h || (c[b] = w()), c[e] = 1, (h = k.get(e)) ? k = h : k.set(e, k = new Map())) : c[b] = 1, (h = k.get(b)) ? k = h : k.set(b, k = []), k = k[f] || (k[f] = []), g && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k]))); } } -function L(a, d, b, f, c) { - return b && 1 < a ? d + (f || 0) <= a ? b + (c || 0) : (a - 1) / (d + (f || 0)) * (b + (c || 0)) + 1 | 0 : 0; +function L(a, c, b, f, d) { + return b && 1 < a ? c + (f || 0) <= a ? b + (d || 0) : (a - 1) / (c + (f || 0)) * (b + (d || 0)) + 1 | 0 : 0; } -;I.prototype.search = function(a, d, b) { - b || (d || "object" !== typeof a ? "object" === typeof d && (b = d, d = 0) : (b = a, a = "")); - var f = [], c = 0; +;I.prototype.search = function(a, c, b) { + b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); + var f = [], d = 0; if (b) { a = b.query || a; - d = b.limit || d; - c = b.offset || 0; + c = b.limit || c; + d = b.offset || 0; var g = b.context; var e = b.suggest; - var h = !0; - var k = b.resolution; + var k = !0; + var h = b.resolution; } else { - h = !0; - } - a = this.encoder.encode(a); - b = a.length; - d = d || (h ? 100 : 0); - if (1 === b) { - return e = c, (c = N(this, a[0], "")) && c.length ? H.call(this, c, d, e) : []; + k = !0; } g = this.depth && !1 !== g; + a = this.encoder.encode(a, !g); + b = a.length; + c = c || (k ? 100 : 0); + if (1 === b) { + return e = d, (d = N(this, a[0], "")) && d.length ? H.call(this, d, c, e) : []; + } if (2 === b && g && !e) { - return e = c, (c = N(this, a[1], a[0])) && c.length ? H.call(this, c, d, e) : []; + return e = d, (d = N(this, a[1], a[0])) && d.length ? H.call(this, d, c, e) : []; } - h = w(); - var n = 0; + k = w(); + var l = 0; if (g) { - var m = a[0]; - n = 1; + var n = a[0]; + l = 1; } - k || 0 === k || (k = m ? this.v : this.resolution); - for (let l, q; n < b; n++) { - if ((q = a[n]) && !h[q]) { - h[q] = 1; - l = N(this, q, m); + h || 0 === h || (h = n ? this.v : this.resolution); + for (let m, q; l < b; l++) { + if ((q = a[l]) && !k[q]) { + k[q] = 1; + m = N(this, q, n); a: { - g = l; - var v = f, D = e, p = k; + g = m; + var v = f, x = e, p = h; let t = []; if (g && g.length) { if (g.length <= p) { v.push(g); - l = void 0; + m = void 0; break a; } - for (let x = 0, y; x < p; x++) { - if (y = g[x]) { - t[x] = y; + for (let y = 0, z; y < p; y++) { + if (z = g[y]) { + t[y] = z; } } if (t.length) { v.push(t); - l = void 0; + m = void 0; break a; } } - l = D ? void 0 : t; + m = x ? void 0 : t; } - if (l) { - f = l; + if (m) { + f = m; break; } - m && (e && l && f.length || (m = q)); + n && (e && m && f.length || (n = q)); } - e && m && n === b - 1 && !f.length && (k = this.resolution, m = "", n = -1, h = w()); + e && n && l === b - 1 && !f.length && (h = this.resolution, n = "", l = -1, k = w()); } a: { a = f; f = a.length; - m = a; + n = a; if (1 < f) { b: { f = e; - m = a.length; + n = a.length; e = []; b = w(); - for (let l = 0, q, t, x, y; l < k; l++) { - for (n = 0; n < m; n++) { - if (x = a[n], l < x.length && (q = x[l])) { + for (let m = 0, q, t, y, z; m < h; m++) { + for (l = 0; l < n; l++) { + if (y = a[l], m < y.length && (q = y[m])) { for (g = 0; g < q.length; g++) { - if (t = q[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), y = e[h] || (e[h] = []), y.push(t), d && h === m - 1 && y.length - c === d) { - m = c ? y.slice(c) : y; + if (t = q[g], (k = b[t]) ? b[t]++ : (k = 0, b[t] = 1), z = e[k] || (e[k] = []), z.push(t), c && k === n - 1 && z.length - d === c) { + n = d ? z.slice(d) : z; break b; } } @@ -476,14 +478,14 @@ function L(a, d, b, f, c) { if (f) { if (1 < e.length) { c: { - for (a = [], k = w(), f = e.length, h = f - 1; 0 <= h; h--) { - if (b = (f = e[h]) && f.length) { - for (n = 0; n < b; n++) { - if (m = f[n], !k[m]) { - if (k[m] = 1, c) { - c--; + for (a = [], h = w(), f = e.length, k = f - 1; 0 <= k; k--) { + if (b = (f = e[k]) && f.length) { + for (l = 0; l < b; l++) { + if (n = f[l], !h[n]) { + if (h[n] = 1, d) { + d--; } else { - if (a.push(m), a.length === d) { + if (a.push(n), a.length === c) { break c; } } @@ -493,39 +495,39 @@ function L(a, d, b, f, c) { } } } else { - a = (e = e[0]).length > d || c ? e.slice(c, d + c) : e; + a = (e = e[0]).length > c || d ? e.slice(d, c + d) : e; } e = a; } else { - if (a < m) { - m = []; + if (a < n) { + n = []; break b; } e = e[a - 1]; - if (d || c) { - if (e.length > d || c) { - e = e.slice(c, d + c); + if (c || d) { + if (e.length > c || d) { + e = e.slice(d, c + d); } } } } - m = e; + n = e; } } else if (1 === f) { - d = H.call(null, a[0], d, c); + c = H.call(null, a[0], c, d); break a; } - d = m; + c = n; } - return d; + return c; }; -function N(a, d, b) { +function N(a, c, b) { let f; - b && (f = a.bidirectional && d > b) && (f = b, b = d, d = f); - a = b ? (a = a.ctx.get(b)) && a.get(d) : a.map.get(d); + b && (f = a.bidirectional && c > b) && (f = b, b = c, c = f); + a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } -;function I(a, d) { +;function I(a, c) { if (!this || this.constructor !== I) { return new I(a); } @@ -536,8 +538,8 @@ function N(a, d, b) { a = {}; } b = a.context; - const f = !0 === b ? {depth:1} : b || {}, c = a.encode || a.encoder || {}; - this.encoder = c.encode ? c : "object" === typeof c ? new F(c) : {encode:c}; + const f = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || {}; + this.encoder = d.encode ? d : "object" === typeof d ? new F(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; this.depth = "strict" === b && f.depth || 0; @@ -547,9 +549,9 @@ function N(a, d, b) { f && f.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); this.map = new Map(); this.ctx = new Map(); - this.reg = d || (this.fastupdate ? new Map() : new Set()); + this.reg = c || (this.fastupdate ? new Map() : new Set()); this.v = f.resolution || 3; - this.rtl = c.rtl || a.rtl || !1; + this.rtl = d.rtl || a.rtl || !1; } r = I.prototype; r.clear = function() { @@ -558,15 +560,15 @@ r.clear = function() { this.reg.clear(); return this; }; -r.append = function(a, d) { - return this.add(a, d, !0); +r.append = function(a, c) { + return this.add(a, c, !0); }; r.contain = function(a) { return this.reg.has(a); }; -r.update = function(a, d) { +r.update = function(a, c) { const b = this, f = this.remove(a); - return f && f.then ? f.then(() => b.add(a, d)) : this.add(a, d); + return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); }; r.cleanup = function() { if (!this.fastupdate) { diff --git a/dist/flexsearch.light.min.js b/dist/flexsearch.light.min.js index a5b4503..33ed4b9 100644 --- a/dist/flexsearch.light.min.js +++ b/dist/flexsearch.light.min.js @@ -1,26 +1,26 @@ /**! - * FlexSearch.js v0.8.156 (Light) + * FlexSearch.js v0.8.157 (Light) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function(self){'use strict';var r;function u(a,d,b){const f=typeof b,c=typeof a;if("undefined"!==f){if("undefined"!==c){if(b){if("function"===c&&f===c)return function(h){return a(b(h))};d=a.constructor;if(d===b.constructor){if(d===Array)return b.concat(a);if(d===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(d===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===c?d:a}function w(){return Object.create(null)};const z=/[^\p{L}\p{N}]+/u,A=/(\d{3})/g,B=/(\D)(\d{3})/g,C=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; -this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,z)}catch(c){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!0,this.dedupe);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,1024,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const c of this.matcher.keys())this.g+=(this.g?"|":"")+c;if(this.stemmer)for(const c of this.stemmer.keys())this.h+= -(this.h?"|":"")+c;return this};r.addStemmer=function(a,d){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,d);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; -r.addMapper=function(a,d){if("object"===typeof a)return this.addReplacer(a,d);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,d);this.matcher||(this.matcher=new Map);this.matcher.set(a,d);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this}; -r.addReplacer=function(a,d){if("string"===typeof a)return this.addMatcher(a,d);this.replacer||(this.replacer=[]);this.replacer.push(a,d);this.cache&&G(this);return this}; -r.encode=function(a){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength))if(d)b.push(e);else if(!this.filter||("function"===typeof this.filter?this.filter(e):!this.filter.has(e))){if(this.cache&&e.length<=this.o)if(this.l){var c=this.j.get(e);if(c||""===c){c&&b.push(c);continue}}else this.l=setTimeout(G,50,this);this.stemmer&&2this.stemmer.get(k))); -if(e&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(e&&this.replacer)for(c=0;e&&cthis.A&& -(this.j.clear(),this.o=this.o/1.1|0));e&&b.push(e)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.m&&(this.i.set(a,b),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return b};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,d,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>d?d?a.slice(b,b+d):a.slice(b):a;let f=[];for(let c=0,g,e;c=e){b-=e;continue}bd&&(g=g.slice(0,d),e=d);if(!f.length&&e>=d)return g;f.push(g);d-=e;if(!d)break}return f=1c.length)c.pop();else{const g=c.indexOf(a);g===b.length-1?c.pop():c.splice(g,1)}}else J(this.map,a),this.depth&&J(this.ctx,a);d||this.reg.delete(a)}return this}; -function J(a,d){let b=0;var f="undefined"===typeof d;if(a.constructor===Array)for(let c=0,g,e;cq;g--){e=l.substring(q,g);t=this.rtl?c-1-q:q;var h=this.score?this.score(d,l,p,e,t):L(D,f,p,c,t);M(this, -m,e,h,a,b)}break}case "bidirectional":case "reverse":if(1e?0:1),f,p,h-1,k-1), -t=this.bidirectional&&l>g;M(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,d,b,f,c,g,e){let h=e?a.ctx:a.map,k;if(!d[b]||e&&!(k=d[b])[e])e?(d=k||(d[b]=w()),d[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):d[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(c)||(h.push(c),a.fastupdate&&((d=a.reg.get(c))?d.push(h):a.reg.set(c,[h])))}function L(a,d,b,f,c){return b&&1d||c?e.slice(c,d+c):e;e=a}else{if(ad||c)e=e.slice(c,d+c)}m=e}else if(1===f){d=H.call(null,a[0], -d,c);break a}d=m}return d};function N(a,d,b){let f;b&&(f=a.bidirectional&&d>b)&&(f=b,b=d,d=f);a=b?(a=a.ctx.get(b))&&a.get(d):a.map.get(d);return a};function I(a,d){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},c=a.encode||a.encoder||{};this.encoder=c.encode?c:"object"===typeof c?new F(c):{encode:c};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= -a.score||null;this.map=new Map;this.ctx=new Map;this.reg=d||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=c.rtl||a.rtl||!1}r=I.prototype;r.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};r.append=function(a,d){return this.add(a,d,!0)};r.contain=function(a){return this.reg.has(a)};r.update=function(a,d){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,d)):this.add(a,d)}; +(function(self){'use strict';var r;function u(a,c,b){const f=typeof b,d=typeof a;if("undefined"!==f){if("undefined"!==d){if(b){if("function"===d&&f===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(c===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===d?c:a}function w(){return Object.create(null)};const A=/[^\p{L}\p{N}]+/u,B=/(\d{3})/g,C=/(\D)(\d{3})/g,D=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; +this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,A)}catch(d){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!0,this.dedupe);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,1024,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const d of this.matcher.keys())this.g+=(this.g?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.h+= +(this.h?"|":"")+d;return this};r.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; +r.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this}; +r.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; +r.encode=function(a,c){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength||c&&d[h]))if(b)c&&(d[h]=1),f.push(h);else if(!this.filter||("function"===typeof this.filter?this.filter(h):!this.filter.has(h))){if(this.cache&&h.length<=this.o)if(this.l){var e=this.j.get(h);if(e||""===e){e&&f.push(e);continue}}else this.l=setTimeout(G,50,this);this.stemmer&&2this.stemmer.get(n)));if(h&&(this.mapper||this.dedupe&&1this.matcher.get(n)));if(h&&this.replacer)for(e=0;h&&ethis.A&&(this.j.clear(),this.o=this.o/1.1|0));!h||c&&d[h]||(c&&(d[h]=1),f.push(h))}this.finalize&&(f=this.finalize(f)||f);this.cache&&a.length<=this.m&&(this.i.set(a,f),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return f};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,c,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let f=[];for(let d=0,g,e;d=e){b-=e;continue}bc&&(g=g.slice(0,c),e=c);if(!f.length&&e>=c)return g;f.push(g);c-=e;if(!c)break}return f=1d.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else J(this.map,a),this.depth&&J(this.ctx,a);c||this.reg.delete(a)}return this}; +function J(a,c){let b=0;var f="undefined"===typeof c;if(a.constructor===Array)for(let d=0,g,e;dq;g--){e=m.substring(q,g);t=this.rtl?d-1-q:q;var k=this.score?this.score(c,m,p,e,t):L(x, +l,p,d,t);M(this,v,e,k,a,b)}break}case "bidirectional":case "reverse":if(1e?0: +1),l,p,k-1,h-1),t=this.bidirectional&&m>g;M(this,n,t?g:m,q,a,b,t?m:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,c,b,f,d,g,e){let k=e?a.ctx:a.map,h;if(!c[b]||e&&!(h=c[b])[e])e?(c=h||(c[b]=w()),c[e]=1,(h=k.get(e))?k=h:k.set(e,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[f]||(k[f]=[]),g&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function L(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}n=e}else if(1===f){c=H.call(null,a[0], +c,d);break a}c=n}return c};function N(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function I(a,c){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},d=a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new F(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= +a.score||null;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=d.rtl||a.rtl||!1}r=I.prototype;r.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};r.append=function(a,c){return this.add(a,c,!0)};r.contain=function(a){return this.reg.has(a)};r.update=function(a,c){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,c)):this.add(a,c)}; r.cleanup=function(){if(!this.fastupdate)return this;J(this.map);this.depth&&J(this.ctx);return this};w();const O={Index:I,Charset:null,Encoder:F,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}},P="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let Q;(Q=P.define)&&Q.amd?Q([],function(){return O}):"object"===typeof P.exports?P.exports=O:P.FlexSearch=O;}(this||self)); diff --git a/dist/flexsearch.light.module.debug.js b/dist/flexsearch.light.module.debug.js index ec7f596..7d99b93 100644 --- a/dist/flexsearch.light.module.debug.js +++ b/dist/flexsearch.light.module.debug.js @@ -1,34 +1,34 @@ /**! - * FlexSearch.js v0.8.156 (Bundle/Debug) + * FlexSearch.js v0.8.157 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ var r; -function u(a, d, b) { - const f = typeof b, c = typeof a; +function u(a, c, b) { + const f = typeof b, d = typeof a; if ("undefined" !== f) { - if ("undefined" !== c) { + if ("undefined" !== d) { if (b) { - if ("function" === c && f === c) { - return function(h) { - return a(b(h)); + if ("function" === d && f === d) { + return function(k) { + return a(b(k)); }; } - d = a.constructor; - if (d === b.constructor) { - if (d === Array) { + c = a.constructor; + if (c === b.constructor) { + if (c === Array) { return b.concat(a); } - if (d === Map) { + if (c === Map) { var g = new Map(b); for (var e of a) { g.set(e[0], e[1]); } return g; } - if (d === Set) { + if (c === Set) { e = new Set(b); for (g of a.values()) { e.add(g); @@ -41,12 +41,12 @@ function u(a, d, b) { } return b; } - return "undefined" === c ? d : a; + return "undefined" === d ? c : a; } function w() { return Object.create(null); } -;const z = /[^\p{L}\p{N}]+/u, A = /(\d{3})/g, B = /(\D)(\d{3})/g, C = /(\d{3})(\D)/g, E = /[\u0300-\u036f]/g; +;const A = /[^\p{L}\p{N}]+/u, B = /(\d{3})/g, C = /(\D)(\d{3})/g, D = /(\d{3})(\D)/g, E = /[\u0300-\u036f]/g; function F(a = {}) { if (!this || this.constructor !== F) { return new F(...arguments); @@ -62,22 +62,22 @@ function F(a = {}) { r = F.prototype; r.assign = function(a) { this.normalize = u(a.normalize, !0, this.normalize); - let d = a.include, b = d || a.exclude || a.split, f; + let c = a.include, b = c || a.exclude || a.split, f; if (b || "" === b) { if ("object" === typeof b && b.constructor !== RegExp) { - let c = ""; - f = !d; - d || (c += "\\p{Z}"); - b.letter && (c += "\\p{L}"); - b.number && (c += "\\p{N}", f = !!d); - b.symbol && (c += "\\p{S}"); - b.punctuation && (c += "\\p{P}"); - b.control && (c += "\\p{C}"); + let d = ""; + f = !c; + c || (d += "\\p{Z}"); + b.letter && (d += "\\p{L}"); + b.number && (d += "\\p{N}", f = !!c); + b.symbol && (d += "\\p{S}"); + b.punctuation && (d += "\\p{P}"); + b.control && (d += "\\p{C}"); if (b = b.char) { - c += "object" === typeof b ? b.join("") : b; + d += "object" === typeof b ? b.join("") : b; } try { - this.split = new RegExp("[" + (d ? "^" : "") + c + "]+", "u"); + this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); } catch (g) { console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } @@ -87,8 +87,8 @@ r.assign = function(a) { this.numeric = u(a.numeric, f); } else { try { - this.split = u(this.split, z); - } catch (c) { + this.split = u(this.split, A); + } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } this.numeric = u(a.numeric, u(this.numeric, !0)); @@ -113,20 +113,20 @@ r.assign = function(a) { this.h = ""; this.u = null; if (this.matcher) { - for (const c of this.matcher.keys()) { - this.g += (this.g ? "|" : "") + c; + for (const d of this.matcher.keys()) { + this.g += (this.g ? "|" : "") + d; } } if (this.stemmer) { - for (const c of this.stemmer.keys()) { - this.h += (this.h ? "|" : "") + c; + for (const d of this.stemmer.keys()) { + this.h += (this.h ? "|" : "") + d; } } return this; }; -r.addStemmer = function(a, d) { +r.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); - this.stemmer.set(a, d); + this.stemmer.set(a, c); this.h += (this.h ? "|" : "") + a; this.u = null; this.cache && G(this); @@ -137,42 +137,42 @@ r.addFilter = function(a) { this.cache && G(this); return this; }; -r.addMapper = function(a, d) { +r.addMapper = function(a, c) { if ("object" === typeof a) { - return this.addReplacer(a, d); + return this.addReplacer(a, c); } if (1 < a.length) { - return this.addMatcher(a, d); + return this.addMatcher(a, c); } this.mapper || (this.mapper = new Map()); - this.mapper.set(a, d); + this.mapper.set(a, c); this.cache && G(this); return this; }; -r.addMatcher = function(a, d) { +r.addMatcher = function(a, c) { if ("object" === typeof a) { - return this.addReplacer(a, d); + return this.addReplacer(a, c); } if (2 > a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, d); + return this.addMapper(a, c); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, d); + this.matcher.set(a, c); this.g += (this.g ? "|" : "") + a; this.s = null; this.cache && G(this); return this; }; -r.addReplacer = function(a, d) { +r.addReplacer = function(a, c) { if ("string" === typeof a) { - return this.addMatcher(a, d); + return this.addMatcher(a, c); } this.replacer || (this.replacer = []); - this.replacer.push(a, d); + this.replacer.push(a, c); this.cache && G(this); return this; }; -r.encode = function(a) { +r.encode = function(a, c) { if (this.cache && a.length <= this.m) { if (this.l) { if (this.i.has(a)) { @@ -184,79 +184,79 @@ r.encode = function(a) { } this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = E ? a.normalize("NFKD").replace(E, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(B, "$1 $2").replace(C, "$1 $2").replace(A, "$1 ")); - const d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let b = [], f = this.split || "" === this.split ? a.split(this.split) : a; - for (let g = 0, e, h; g < f.length; g++) { - if ((e = h = f[g]) && !(e.length < this.minlength || e.length > this.maxlength)) { - if (d) { - b.push(e); + this.numeric && 3 < a.length && (a = a.replace(C, "$1 $2").replace(D, "$1 $2").replace(B, "$1 ")); + const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + let f = [], d = w(), g = this.split || "" === this.split ? a.split(this.split) : [a]; + for (let k = 0, h, l; k < g.length; k++) { + if ((h = l = g[k]) && !(h.length < this.minlength || h.length > this.maxlength || c && d[h])) { + if (b) { + c && (d[h] = 1), f.push(h); } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(e) : !this.filter.has(e))) { - if (this.cache && e.length <= this.o) { + if (!this.filter || ("function" === typeof this.filter ? this.filter(h) : !this.filter.has(h))) { + if (this.cache && h.length <= this.o) { if (this.l) { - var c = this.j.get(e); - if (c || "" === c) { - c && b.push(c); + var e = this.j.get(h); + if (e || "" === e) { + e && f.push(e); continue; } } else { this.l = setTimeout(G, 50, this); } } - this.stemmer && 2 < e.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), e = e.replace(this.u, k => this.stemmer.get(k))); - if (e && (this.mapper || this.dedupe && 1 < e.length)) { - c = ""; - for (let k = 0, n = "", m, v; k < e.length; k++) { - m = e.charAt(k), m === n && this.dedupe || ((v = this.mapper && this.mapper.get(m)) || "" === v ? v === n && this.dedupe || !(n = v) || (c += v) : c += n = m); + this.stemmer && 2 < h.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), h = h.replace(this.u, n => this.stemmer.get(n))); + if (h && (this.mapper || this.dedupe && 1 < h.length)) { + e = ""; + for (let n = 0, v = "", x, p; n < h.length; n++) { + x = h.charAt(n), x === v && this.dedupe || ((p = this.mapper && this.mapper.get(x)) || "" === p ? p === v && this.dedupe || !(v = p) || (e += p) : e += v = x); } - e = c; + h = e; } - this.matcher && 1 < e.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), e = e.replace(this.s, k => this.matcher.get(k))); - if (e && this.replacer) { - for (c = 0; e && c < this.replacer.length; c += 2) { - e = e.replace(this.replacer[c], this.replacer[c + 1]); + this.matcher && 1 < h.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), h = h.replace(this.s, n => this.matcher.get(n))); + if (h && this.replacer) { + for (e = 0; h && e < this.replacer.length; e += 2) { + h = h.replace(this.replacer[e], this.replacer[e + 1]); } } - this.cache && h.length <= this.o && (this.j.set(h, e), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); - e && b.push(e); + this.cache && l.length <= this.o && (this.j.set(l, h), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); + !h || c && d[h] || (c && (d[h] = 1), f.push(h)); } } } } - this.finalize && (b = this.finalize(b) || b); - this.cache && a.length <= this.m && (this.i.set(a, b), this.i.size > this.A && (this.i.clear(), this.m = this.m / 1.1 | 0)); - return b; + this.finalize && (f = this.finalize(f) || f); + this.cache && a.length <= this.m && (this.i.set(a, f), this.i.size > this.A && (this.i.clear(), this.m = this.m / 1.1 | 0)); + return f; }; function G(a) { a.l = null; a.i.clear(); a.j.clear(); } -;function H(a, d, b) { +;function H(a, c, b) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = b || a.length > d ? d ? a.slice(b, b + d) : a.slice(b) : a; + return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a; } let f = []; - for (let c = 0, g, e; c < a.length; c++) { - if ((g = a[c]) && (e = g.length)) { + for (let d = 0, g, e; d < a.length; d++) { + if ((g = a[d]) && (e = g.length)) { if (b) { if (b >= e) { b -= e; continue; } - b < e && (g = d ? g.slice(b, b + d) : g.slice(b), e = g.length, b = 0); + b < e && (g = c ? g.slice(b, b + c) : g.slice(b), e = g.length, b = 0); } - e > d && (g = g.slice(0, d), e = d); - if (!f.length && e >= d) { + e > c && (g = g.slice(0, c), e = c); + if (!f.length && e >= c) { return g; } f.push(g); - d -= e; - if (!d) { + c -= e; + if (!c) { break; } } @@ -264,38 +264,38 @@ function G(a) { return f = 1 < f.length ? [].concat.apply([], f) : f[0]; } ;w(); -I.prototype.remove = function(a, d) { +I.prototype.remove = function(a, c) { const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); if (b) { if (this.fastupdate) { - for (let f = 0, c; f < b.length; f++) { - if (c = b[f]) { - if (2 > c.length) { - c.pop(); + for (let f = 0, d; f < b.length; f++) { + if (d = b[f]) { + if (2 > d.length) { + d.pop(); } else { - const g = c.indexOf(a); - g === b.length - 1 ? c.pop() : c.splice(g, 1); + const g = d.indexOf(a); + g === b.length - 1 ? d.pop() : d.splice(g, 1); } } } } else { J(this.map, a), this.depth && J(this.ctx, a); } - d || this.reg.delete(a); + c || this.reg.delete(a); } return this; }; -function J(a, d) { +function J(a, c) { let b = 0; - var f = "undefined" === typeof d; + var f = "undefined" === typeof c; if (a.constructor === Array) { - for (let c = 0, g, e; c < a.length; c++) { - if ((g = a[c]) && g.length) { + for (let d = 0, g, e; d < a.length; d++) { + if ((g = a[d]) && g.length) { if (f) { b++; } else { - if (e = g.indexOf(d), 0 <= e) { - 1 < g.length ? (g.splice(e, 1), b++) : delete a[c]; + if (e = g.indexOf(c), 0 <= e) { + 1 < g.length ? (g.splice(e, 1), b++) : delete a[d]; break; } else { b++; @@ -304,65 +304,67 @@ function J(a, d) { } } } else { - for (let c of a.entries()) { - f = c[0]; - const g = J(c[1], d); + for (let d of a.entries()) { + f = d[0]; + const g = J(d[1], c); g ? b += g : a.delete(f); } } return b; } ;const K = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -I.prototype.add = function(a, d, b, f) { - if (d && (a || 0 === a)) { +I.prototype.add = function(a, c, b, f) { + if (c && (a || 0 === a)) { if (!f && !b && this.reg.has(a)) { - return this.update(a, d); + return this.update(a, c); } - d = this.encoder.encode(d); - if (f = d.length) { - const n = w(), m = w(), v = this.depth, D = this.resolution; - for (let p = 0; p < f; p++) { - let l = d[this.rtl ? f - 1 - p : p]; - var c = l.length; - if (c && (v || !m[l])) { - var g = this.score ? this.score(d, l, p, null, 0) : L(D, f, p), e = ""; + f = this.depth; + c = this.encoder.encode(c, !f); + const l = c.length; + if (l) { + const n = w(), v = w(), x = this.resolution; + for (let p = 0; p < l; p++) { + let m = c[this.rtl ? l - 1 - p : p]; + var d = m.length; + if (d && (f || !v[m])) { + var g = this.score ? this.score(c, m, p, null, 0) : L(x, l, p), e = ""; switch(this.tokenize) { case "full": - if (2 < c) { - for (let q = 0, t; q < c; q++) { - for (g = c; g > q; g--) { - e = l.substring(q, g); - t = this.rtl ? c - 1 - q : q; - var h = this.score ? this.score(d, l, p, e, t) : L(D, f, p, c, t); - M(this, m, e, h, a, b); + if (2 < d) { + for (let q = 0, t; q < d; q++) { + for (g = d; g > q; g--) { + e = m.substring(q, g); + t = this.rtl ? d - 1 - q : q; + var k = this.score ? this.score(c, m, p, e, t) : L(x, l, p, d, t); + M(this, v, e, k, a, b); } } break; } case "bidirectional": case "reverse": - if (1 < c) { - for (h = c - 1; 0 < h; h--) { - e = l[this.rtl ? c - 1 - h : h] + e; - var k = this.score ? this.score(d, l, p, e, h) : L(D, f, p, c, h); - M(this, m, e, k, a, b); + if (1 < d) { + for (k = d - 1; 0 < k; k--) { + e = m[this.rtl ? d - 1 - k : k] + e; + var h = this.score ? this.score(c, m, p, e, k) : L(x, l, p, d, k); + M(this, v, e, h, a, b); } e = ""; } case "forward": - if (1 < c) { - for (h = 0; h < c; h++) { - e += l[this.rtl ? c - 1 - h : h], M(this, m, e, g, a, b); + if (1 < d) { + for (k = 0; k < d; k++) { + e += m[this.rtl ? d - 1 - k : k], M(this, v, e, g, a, b); } break; } default: - if (M(this, m, l, g, a, b), v && 1 < f && p < f - 1) { - for (c = w(), e = this.v, g = l, h = Math.min(v + 1, this.rtl ? p + 1 : f - p), c[g] = 1, k = 1; k < h; k++) { - if ((l = d[this.rtl ? f - 1 - p - k : p + k]) && !c[l]) { - c[l] = 1; - const q = this.score ? this.score(d, g, p, l, k - 1) : L(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; - M(this, n, t ? g : l, q, a, b, t ? l : g); + if (M(this, v, m, g, a, b), f && 1 < l && p < l - 1) { + for (d = w(), e = this.v, g = m, k = Math.min(f + 1, this.rtl ? p + 1 : l - p), d[g] = 1, h = 1; h < k; h++) { + if ((m = c[this.rtl ? l - 1 - p - h : p + h]) && !d[m]) { + d[m] = 1; + const q = this.score ? this.score(c, g, p, m, h - 1) : L(e + (l / 2 > e ? 0 : 1), l, p, k - 1, h - 1), t = this.bidirectional && m > g; + M(this, n, t ? g : m, q, a, b, t ? m : g); } } } @@ -374,97 +376,97 @@ I.prototype.add = function(a, d, b, f) { } return this; }; -function M(a, d, b, f, c, g, e) { - let h = e ? a.ctx : a.map, k; - if (!d[b] || e && !(k = d[b])[e]) { - e ? (d = k || (d[b] = w()), d[e] = 1, (k = h.get(e)) ? h = k : h.set(e, h = new Map())) : d[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[f] || (h[f] = []), g && h.includes(c) || (h.push(c), a.fastupdate && ((d = a.reg.get(c)) ? d.push(h) : a.reg.set(c, [h]))); +function M(a, c, b, f, d, g, e) { + let k = e ? a.ctx : a.map, h; + if (!c[b] || e && !(h = c[b])[e]) { + e ? (c = h || (c[b] = w()), c[e] = 1, (h = k.get(e)) ? k = h : k.set(e, k = new Map())) : c[b] = 1, (h = k.get(b)) ? k = h : k.set(b, k = []), k = k[f] || (k[f] = []), g && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k]))); } } -function L(a, d, b, f, c) { - return b && 1 < a ? d + (f || 0) <= a ? b + (c || 0) : (a - 1) / (d + (f || 0)) * (b + (c || 0)) + 1 | 0 : 0; +function L(a, c, b, f, d) { + return b && 1 < a ? c + (f || 0) <= a ? b + (d || 0) : (a - 1) / (c + (f || 0)) * (b + (d || 0)) + 1 | 0 : 0; } -;I.prototype.search = function(a, d, b) { - b || (d || "object" !== typeof a ? "object" === typeof d && (b = d, d = 0) : (b = a, a = "")); - var f = [], c = 0; +;I.prototype.search = function(a, c, b) { + b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); + var f = [], d = 0; if (b) { a = b.query || a; - d = b.limit || d; - c = b.offset || 0; + c = b.limit || c; + d = b.offset || 0; var g = b.context; var e = b.suggest; - var h = !0; - var k = b.resolution; + var k = !0; + var h = b.resolution; } else { - h = !0; - } - a = this.encoder.encode(a); - b = a.length; - d = d || (h ? 100 : 0); - if (1 === b) { - return e = c, (c = N(this, a[0], "")) && c.length ? H.call(this, c, d, e) : []; + k = !0; } g = this.depth && !1 !== g; + a = this.encoder.encode(a, !g); + b = a.length; + c = c || (k ? 100 : 0); + if (1 === b) { + return e = d, (d = N(this, a[0], "")) && d.length ? H.call(this, d, c, e) : []; + } if (2 === b && g && !e) { - return e = c, (c = N(this, a[1], a[0])) && c.length ? H.call(this, c, d, e) : []; + return e = d, (d = N(this, a[1], a[0])) && d.length ? H.call(this, d, c, e) : []; } - h = w(); - var n = 0; + k = w(); + var l = 0; if (g) { - var m = a[0]; - n = 1; + var n = a[0]; + l = 1; } - k || 0 === k || (k = m ? this.v : this.resolution); - for (let l, q; n < b; n++) { - if ((q = a[n]) && !h[q]) { - h[q] = 1; - l = N(this, q, m); + h || 0 === h || (h = n ? this.v : this.resolution); + for (let m, q; l < b; l++) { + if ((q = a[l]) && !k[q]) { + k[q] = 1; + m = N(this, q, n); a: { - g = l; - var v = f, D = e, p = k; + g = m; + var v = f, x = e, p = h; let t = []; if (g && g.length) { if (g.length <= p) { v.push(g); - l = void 0; + m = void 0; break a; } - for (let x = 0, y; x < p; x++) { - if (y = g[x]) { - t[x] = y; + for (let y = 0, z; y < p; y++) { + if (z = g[y]) { + t[y] = z; } } if (t.length) { v.push(t); - l = void 0; + m = void 0; break a; } } - l = D ? void 0 : t; + m = x ? void 0 : t; } - if (l) { - f = l; + if (m) { + f = m; break; } - m && (e && l && f.length || (m = q)); + n && (e && m && f.length || (n = q)); } - e && m && n === b - 1 && !f.length && (k = this.resolution, m = "", n = -1, h = w()); + e && n && l === b - 1 && !f.length && (h = this.resolution, n = "", l = -1, k = w()); } a: { a = f; f = a.length; - m = a; + n = a; if (1 < f) { b: { f = e; - m = a.length; + n = a.length; e = []; b = w(); - for (let l = 0, q, t, x, y; l < k; l++) { - for (n = 0; n < m; n++) { - if (x = a[n], l < x.length && (q = x[l])) { + for (let m = 0, q, t, y, z; m < h; m++) { + for (l = 0; l < n; l++) { + if (y = a[l], m < y.length && (q = y[m])) { for (g = 0; g < q.length; g++) { - if (t = q[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), y = e[h] || (e[h] = []), y.push(t), d && h === m - 1 && y.length - c === d) { - m = c ? y.slice(c) : y; + if (t = q[g], (k = b[t]) ? b[t]++ : (k = 0, b[t] = 1), z = e[k] || (e[k] = []), z.push(t), c && k === n - 1 && z.length - d === c) { + n = d ? z.slice(d) : z; break b; } } @@ -475,14 +477,14 @@ function L(a, d, b, f, c) { if (f) { if (1 < e.length) { c: { - for (a = [], k = w(), f = e.length, h = f - 1; 0 <= h; h--) { - if (b = (f = e[h]) && f.length) { - for (n = 0; n < b; n++) { - if (m = f[n], !k[m]) { - if (k[m] = 1, c) { - c--; + for (a = [], h = w(), f = e.length, k = f - 1; 0 <= k; k--) { + if (b = (f = e[k]) && f.length) { + for (l = 0; l < b; l++) { + if (n = f[l], !h[n]) { + if (h[n] = 1, d) { + d--; } else { - if (a.push(m), a.length === d) { + if (a.push(n), a.length === c) { break c; } } @@ -492,39 +494,39 @@ function L(a, d, b, f, c) { } } } else { - a = (e = e[0]).length > d || c ? e.slice(c, d + c) : e; + a = (e = e[0]).length > c || d ? e.slice(d, c + d) : e; } e = a; } else { - if (a < m) { - m = []; + if (a < n) { + n = []; break b; } e = e[a - 1]; - if (d || c) { - if (e.length > d || c) { - e = e.slice(c, d + c); + if (c || d) { + if (e.length > c || d) { + e = e.slice(d, c + d); } } } } - m = e; + n = e; } } else if (1 === f) { - d = H.call(null, a[0], d, c); + c = H.call(null, a[0], c, d); break a; } - d = m; + c = n; } - return d; + return c; }; -function N(a, d, b) { +function N(a, c, b) { let f; - b && (f = a.bidirectional && d > b) && (f = b, b = d, d = f); - a = b ? (a = a.ctx.get(b)) && a.get(d) : a.map.get(d); + b && (f = a.bidirectional && c > b) && (f = b, b = c, c = f); + a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } -;function I(a, d) { +;function I(a, c) { if (!this || this.constructor !== I) { return new I(a); } @@ -535,8 +537,8 @@ function N(a, d, b) { a = {}; } b = a.context; - const f = !0 === b ? {depth:1} : b || {}, c = a.encode || a.encoder || {}; - this.encoder = c.encode ? c : "object" === typeof c ? new F(c) : {encode:c}; + const f = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || {}; + this.encoder = d.encode ? d : "object" === typeof d ? new F(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; this.depth = "strict" === b && f.depth || 0; @@ -546,9 +548,9 @@ function N(a, d, b) { f && f.depth && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); this.map = new Map(); this.ctx = new Map(); - this.reg = d || (this.fastupdate ? new Map() : new Set()); + this.reg = c || (this.fastupdate ? new Map() : new Set()); this.v = f.resolution || 3; - this.rtl = c.rtl || a.rtl || !1; + this.rtl = d.rtl || a.rtl || !1; } r = I.prototype; r.clear = function() { @@ -557,15 +559,15 @@ r.clear = function() { this.reg.clear(); return this; }; -r.append = function(a, d) { - return this.add(a, d, !0); +r.append = function(a, c) { + return this.add(a, c, !0); }; r.contain = function(a) { return this.reg.has(a); }; -r.update = function(a, d) { +r.update = function(a, c) { const b = this, f = this.remove(a); - return f && f.then ? f.then(() => b.add(a, d)) : this.add(a, d); + return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); }; r.cleanup = function() { if (!this.fastupdate) { diff --git a/dist/flexsearch.light.module.min.js b/dist/flexsearch.light.module.min.js index 1c2f3ec..032b5ff 100644 --- a/dist/flexsearch.light.module.min.js +++ b/dist/flexsearch.light.module.min.js @@ -1,27 +1,27 @@ /**! - * FlexSearch.js v0.8.156 (Bundle) + * FlexSearch.js v0.8.157 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var r;function u(a,d,b){const f=typeof b,c=typeof a;if("undefined"!==f){if("undefined"!==c){if(b){if("function"===c&&f===c)return function(h){return a(b(h))};d=a.constructor;if(d===b.constructor){if(d===Array)return b.concat(a);if(d===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(d===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===c?d:a}function w(){return Object.create(null)};const z=/[^\p{L}\p{N}]+/u,A=/(\d{3})/g,B=/(\D)(\d{3})/g,C=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; -this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,z)}catch(c){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!0,this.dedupe);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,1024,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const c of this.matcher.keys())this.g+=(this.g?"|":"")+c;if(this.stemmer)for(const c of this.stemmer.keys())this.h+= -(this.h?"|":"")+c;return this};r.addStemmer=function(a,d){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,d);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; -r.addMapper=function(a,d){if("object"===typeof a)return this.addReplacer(a,d);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,d);this.matcher||(this.matcher=new Map);this.matcher.set(a,d);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this}; -r.addReplacer=function(a,d){if("string"===typeof a)return this.addMatcher(a,d);this.replacer||(this.replacer=[]);this.replacer.push(a,d);this.cache&&G(this);return this}; -r.encode=function(a){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength))if(d)b.push(e);else if(!this.filter||("function"===typeof this.filter?this.filter(e):!this.filter.has(e))){if(this.cache&&e.length<=this.o)if(this.l){var c=this.j.get(e);if(c||""===c){c&&b.push(c);continue}}else this.l=setTimeout(G,50,this);this.stemmer&&2this.stemmer.get(k))); -if(e&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(e&&this.replacer)for(c=0;e&&cthis.A&& -(this.j.clear(),this.o=this.o/1.1|0));e&&b.push(e)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.m&&(this.i.set(a,b),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return b};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,d,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>d?d?a.slice(b,b+d):a.slice(b):a;let f=[];for(let c=0,g,e;c=e){b-=e;continue}bd&&(g=g.slice(0,d),e=d);if(!f.length&&e>=d)return g;f.push(g);d-=e;if(!d)break}return f=1c.length)c.pop();else{const g=c.indexOf(a);g===b.length-1?c.pop():c.splice(g,1)}}else J(this.map,a),this.depth&&J(this.ctx,a);d||this.reg.delete(a)}return this}; -function J(a,d){let b=0;var f="undefined"===typeof d;if(a.constructor===Array)for(let c=0,g,e;cq;g--){e=l.substring(q,g);t=this.rtl?c-1-q:q;var h=this.score?this.score(d,l,p,e,t):L(D,f,p,c,t);M(this, -m,e,h,a,b)}break}case "bidirectional":case "reverse":if(1e?0:1),f,p,h-1,k-1), -t=this.bidirectional&&l>g;M(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,d,b,f,c,g,e){let h=e?a.ctx:a.map,k;if(!d[b]||e&&!(k=d[b])[e])e?(d=k||(d[b]=w()),d[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):d[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(c)||(h.push(c),a.fastupdate&&((d=a.reg.get(c))?d.push(h):a.reg.set(c,[h])))}function L(a,d,b,f,c){return b&&1d||c?e.slice(c,d+c):e;e=a}else{if(ad||c)e=e.slice(c,d+c)}m=e}else if(1===f){d=H.call(null,a[0], -d,c);break a}d=m}return d};function N(a,d,b){let f;b&&(f=a.bidirectional&&d>b)&&(f=b,b=d,d=f);a=b?(a=a.ctx.get(b))&&a.get(d):a.map.get(d);return a};function I(a,d){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},c=a.encode||a.encoder||{};this.encoder=c.encode?c:"object"===typeof c?new F(c):{encode:c};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= -a.score||null;this.map=new Map;this.ctx=new Map;this.reg=d||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=c.rtl||a.rtl||!1}r=I.prototype;r.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};r.append=function(a,d){return this.add(a,d,!0)};r.contain=function(a){return this.reg.has(a)};r.update=function(a,d){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,d)):this.add(a,d)}; +var r;function u(a,c,b){const f=typeof b,d=typeof a;if("undefined"!==f){if("undefined"!==d){if(b){if("function"===d&&f===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(c===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===d?c:a}function w(){return Object.create(null)};const A=/[^\p{L}\p{N}]+/u,B=/(\d{3})/g,C=/(\D)(\d{3})/g,D=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; +this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,A)}catch(d){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!0,this.dedupe);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,1024,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const d of this.matcher.keys())this.g+=(this.g?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.h+= +(this.h?"|":"")+d;return this};r.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; +r.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this}; +r.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; +r.encode=function(a,c){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength||c&&d[h]))if(b)c&&(d[h]=1),f.push(h);else if(!this.filter||("function"===typeof this.filter?this.filter(h):!this.filter.has(h))){if(this.cache&&h.length<=this.o)if(this.l){var e=this.j.get(h);if(e||""===e){e&&f.push(e);continue}}else this.l=setTimeout(G,50,this);this.stemmer&&2this.stemmer.get(n)));if(h&&(this.mapper||this.dedupe&&1this.matcher.get(n)));if(h&&this.replacer)for(e=0;h&&ethis.A&&(this.j.clear(),this.o=this.o/1.1|0));!h||c&&d[h]||(c&&(d[h]=1),f.push(h))}this.finalize&&(f=this.finalize(f)||f);this.cache&&a.length<=this.m&&(this.i.set(a,f),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return f};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,c,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let f=[];for(let d=0,g,e;d=e){b-=e;continue}bc&&(g=g.slice(0,c),e=c);if(!f.length&&e>=c)return g;f.push(g);c-=e;if(!c)break}return f=1d.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else J(this.map,a),this.depth&&J(this.ctx,a);c||this.reg.delete(a)}return this}; +function J(a,c){let b=0;var f="undefined"===typeof c;if(a.constructor===Array)for(let d=0,g,e;dq;g--){e=m.substring(q,g);t=this.rtl?d-1-q:q;var k=this.score?this.score(c,m,p,e,t):L(x, +l,p,d,t);M(this,v,e,k,a,b)}break}case "bidirectional":case "reverse":if(1e?0: +1),l,p,k-1,h-1),t=this.bidirectional&&m>g;M(this,n,t?g:m,q,a,b,t?m:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,c,b,f,d,g,e){let k=e?a.ctx:a.map,h;if(!c[b]||e&&!(h=c[b])[e])e?(c=h||(c[b]=w()),c[e]=1,(h=k.get(e))?k=h:k.set(e,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[f]||(k[f]=[]),g&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function L(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}n=e}else if(1===f){c=H.call(null,a[0], +c,d);break a}c=n}return c};function N(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function I(a,c){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},d=a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new F(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= +a.score||null;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=d.rtl||a.rtl||!1}r=I.prototype;r.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};r.append=function(a,c){return this.add(a,c,!0)};r.contain=function(a){return this.reg.has(a)};r.update=function(a,c){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,c)):this.add(a,c)}; r.cleanup=function(){if(!this.fastupdate)return this;J(this.map);this.depth&&J(this.ctx);return this};w();export default {Index:I,Charset:null,Encoder:F,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}}; export const Index=I;export const Charset=null;export const Encoder=F;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file diff --git a/dist/module-debug/db/redis/index.js b/dist/module-debug/db/redis/index.js index 7987505..76be90f 100644 --- a/dist/module-debug/db/redis/index.js +++ b/dist/module-debug/db/redis/index.js @@ -36,9 +36,12 @@ export default function RedisDB(name, config = {}) { this.id = (name ? sanitize(name) : "flexsearch") + "|"; this.field = config.field ? "-" + sanitize(config.field) : ""; this.type = config.type || ""; - this.fastupdate = /* tag? */ /* stringify */ /* stringify */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/; + this.fastupdate = /* tag? */ /* stringify */ /* stringify */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ + /*await rows.hasNext()*/; this.db = config.db || DB || null; this.support_tag_search = !0; + this.resolution = 9; + this.resolution_ctx = 9; //this.trx = false; Object.assign(defaults, config); this.db && delete defaults.db; @@ -54,6 +57,8 @@ RedisDB.prototype.mount = function (flexsearch) { return flexsearch.mount(this); } flexsearch.db = this; + this.resolution = flexsearch.resolution; + this.resolution_ctx = flexsearch.resolution_ctx; // todo support //this.fastupdate = flexsearch.fastupdate; return this.open(); @@ -87,7 +92,7 @@ RedisDB.prototype.clear = function () { return this.db.unlink([this.id + "map" + this.field, this.id + "ctx" + this.field, this.id + "tag" + this.field, this.id + "cfg" + this.field, this.id + "doc", this.id + "reg"]); }; -function create_result(range, type, resolve, enrich) { +function create_result(range, type, resolve, enrich, resolution) { if (resolve) { if ("number" === type) { for (let i = 0, tmp, id; i < range.length; i++) { @@ -102,7 +107,7 @@ function create_result(range, type, resolve, enrich) { for (let i = 0, tmp, id, score; i < range.length; i++) { tmp = range[i]; id = "number" === type ? parseInt(tmp.id || tmp, 10) : tmp.id || tmp; - score = tmp.score; + score = resolution - tmp.score; result[score] || (result[score] = []); result[score].push(id); } @@ -133,7 +138,7 @@ RedisDB.prototype.get = function (key, ctx, limit = 0, offset = 0, resolve = !0, return result.then(async function (range) { if (!range.length) return range; if (enrich) range = await self.enrich(range); - return create_result(range, type, resolve, enrich); + return create_result(range, type, resolve, enrich, ctx ? self.resolution_ctx : self.resolution); }); }; @@ -167,11 +172,14 @@ RedisDB.prototype.has = function (id) { }; RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, suggest = !1, resolve = !0, enrich = !1, tags) { + + const ctx = 1 < query.length && flexsearch.depth; let result, - params = []; + params = [], + weights = []; - if (1 < query.length && flexsearch.depth) { + if (ctx) { const key = this.id + "ctx" + this.field + ":"; let keyword = query[0], @@ -182,6 +190,7 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, term = query[i]; swap = flexsearch.bidirectional && term > keyword; params.push(key + (swap ? term : keyword) + ":" + (swap ? keyword : term)); + weights.push(1); keyword = term; } } else { @@ -189,6 +198,7 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, const key = this.id + "map" + this.field + ":"; for (let i = 0; i < query.length; i++) { params.push(key + query[i]); + weights.push(1); } } @@ -199,7 +209,15 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, if (suggest) { - const multi = this.db.multi().zUnionStore(key, query, { AGGREGATE: "SUM" }); + const multi = this.db.multi(); + // The zStore implementation lacks of ordering by match count (occurrences). + // Unfortunately, I couldn't find an elegant way to overcome this issue completely. + // For this reason it needs additionally a zInterStore to boost at least matches + // when all terms were found + multi.zInterStore(key, query, { AGGREGATE: "SUM" }); + query.push(key); + weights.push(query.length); + multi.zUnionStore(key, query, { WEIGHTS: weights, AGGREGATE: "SUM" }); // Strict Tag Intersection: it does not put tags into union, instead it calculates the // intersection against the term match union. This was the default behavior // of Tag-Search. But putting everything into union will also provide suggestions derived @@ -211,7 +229,7 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, for (let i = 0; i < tags.length; i += 2) { query.push(this.id + "tag-" + sanitize(tags[i]) + ":" + tags[i + 1]); } - multi.zInterStore(key, query, { AGGREGATE: "SUM" }); + multi.zInterStore(key, query, { AGGREGATE: "MAX" }); // .unlink(key) // key = key2; } @@ -221,19 +239,19 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, if (tags) for (let i = 0; i < tags.length; i += 2) { query.push(this.id + "tag-" + sanitize(tags[i]) + ":" + tags[i + 1]); } - result = this.db.multi().zInterStore(key, query, { AGGREGATE: "MIN" })[resolve ? "zRange" : "zRangeWithScores"](key, "" + offset, "" + (offset + limit - 1), { REV: !0 }).unlink(key).exec(); + result = this.db.multi().zInterStore(key, query, { AGGREGATE: "MAX" })[resolve ? "zRange" : "zRangeWithScores"](key, "" + offset, "" + (offset + limit - 1), { REV: !0 }).unlink(key).exec(); } const self = this; return result.then(async function (range) { range = suggest && tags // take the 3rd result from batch return - ? range[2] + ? range[3] // take the 2nd result from batch return - : range[1]; + : range[suggest ? 2 : 1]; if (!range.length) return range; if (enrich) range = await self.enrich(range); - return create_result(range, type, resolve, enrich); + return create_result(range, type, resolve, enrich, ctx ? self.resolution_ctx : self.resolution); }); }; @@ -241,7 +259,7 @@ RedisDB.prototype.info = function () { // todo }; -RedisDB.prototype.transaction = async function (task, callback) { +RedisDB.prototype.transaction = function (task, callback) { if (TRX) { return task.call(this, TRX); @@ -252,8 +270,9 @@ RedisDB.prototype.transaction = async function (task, callback) { promise2 = TRX.exec(); TRX = null; - callback && promise.then(callback); - await Promise.all([promise1, promise2]); + return Promise.all([promise1, promise2]).then(function () { + callback && callback(); + }); }; RedisDB.prototype.commit = async function (flexsearch, _replace, _append) { @@ -302,7 +321,7 @@ RedisDB.prototype.commit = async function (flexsearch, _replace, _append) { let result = []; for (let j = 0; j < ids.length; j++) { result.push({ - score: i, + score: this.resolution - i, value: "" + ids[j] }); } @@ -354,7 +373,10 @@ RedisDB.prototype.commit = async function (flexsearch, _replace, _append) { if ((ids = arr[i]) && ids.length) { let result = []; for (let j = 0; j < ids.length; j++) { - result.push({ score: i, value: "" + ids[j] }); + result.push({ + score: this.resolution_ctx - i, + value: "" + ids[j] + }); } if ("number" == typeof ids[0]) { this.type = "number"; @@ -362,7 +384,7 @@ RedisDB.prototype.commit = async function (flexsearch, _replace, _append) { const ref = this.id + "ctx" + this.field + ":" + ctx_key + ":" + key; trx.zAdd(ref, result); // if(this.fastupdate) for(let j = 0; j < ids.length; j++){ - // trx.sAdd("ref" + this.field + ":" + ids[j], ref); + // } if (this.fastupdate) for (let j = 0, id; j < ids.length; j++) { // Map performs bad when pushing numeric-like values as key diff --git a/dist/module-debug/encoder.js b/dist/module-debug/encoder.js index 281b9c6..89b0665 100644 --- a/dist/module-debug/encoder.js +++ b/dist/module-debug/encoder.js @@ -1,5 +1,5 @@ -import { merge_option } from "./common.js"; +import { create_object, merge_option } from "./common.js"; import normalize_polyfill from "./charset/polyfill.js"; import { EncoderOptions } from "./type.js"; @@ -198,7 +198,6 @@ Encoder.prototype.assign = function (options) { this.rtl = merge_option(options.rtl, !1, this.rtl); // auto-balanced cache - //if(SUPPORT_CACHE){ this.cache = tmp = merge_option(options.cache, !0, this.cache); if (tmp) { this.timer = null; @@ -208,7 +207,6 @@ Encoder.prototype.assign = function (options) { this.cache_enc_length = 128; this.cache_term_length = 128; } - //} // regex temporary state this.matcher_str = ""; @@ -254,7 +252,7 @@ Encoder.prototype.addStemmer = function (match, replace) { this.stemmer.set(match, replace); this.stemmer_str += (this.stemmer_str ? "|" : "") + match; this.stemmer_test = null; - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -266,7 +264,7 @@ Encoder.prototype.addFilter = function (term) { this.filter || (this.filter = new Set()); this.filter.add(term); } - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -288,7 +286,7 @@ Encoder.prototype.addMapper = function (char_match, char_replace) { } this.mapper || (this.mapper = new Map()); this.mapper.set(char_match, char_replace); - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -313,7 +311,7 @@ Encoder.prototype.addMatcher = function (match, replace) { this.matcher.set(match, replace); this.matcher_str += (this.matcher_str ? "|" : "") + match; this.matcher_test = null; - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -329,20 +327,18 @@ Encoder.prototype.addReplacer = function (regex, replace) { } this.replacer || (this.replacer = []); this.replacer.push(regex, replace); - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; /** * @param {!string} str + * @param {boolean=} dedupe_terms Note: term deduplication will break the context chain * @return {!Array} */ -Encoder.prototype.encode = function (str) { +Encoder.prototype.encode = function (str, dedupe_terms) { - //if(!str) return str; - // todo remove dupe terms - - if ( /*SUPPORT_CACHE &&*/this.cache && str.length <= this.cache_enc_length) { + if (this.cache && str.length <= this.cache_enc_length) { if (this.timer) { if (this.cache_enc.has(str)) { return this.cache_enc.get(str); @@ -379,6 +375,7 @@ Encoder.prototype.encode = function (str) { // ); // str = str.replace(this.matcher_test, match => this.matcher.get(match)); // } + // if(this.stemmer){ // this.stemmer_test || ( // this.stemmer_test = new RegExp("(?!\\b)(" + this.stemmer_str + ")(\\b|_)", "g") @@ -388,18 +385,26 @@ Encoder.prototype.encode = function (str) { const skip = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let final = [], - words = this.split || "" === this.split ? str.split( /** @type {string|RegExp} */this.split) : str; - //[str]; + dupes = create_object(), + words = this.split || "" === this.split ? str.split( /** @type {string|RegExp} */this.split) : [str]; + // str; for (let i = 0, word, base; i < words.length; i++) { // filter empty entries if (!(word = base = words[i])) { continue; } + if (word.length < this.minlength || word.length > this.maxlength) { continue; } + + if (dedupe_terms && dupes[word]) { + continue; + } + if (skip) { + dedupe_terms && (dupes[word] = 1); final.push(word); continue; } @@ -409,7 +414,7 @@ Encoder.prototype.encode = function (str) { continue; } - if ( /*SUPPORT_CACHE &&*/this.cache && word.length <= this.cache_term_length) { + if (this.cache && word.length <= this.cache_term_length) { if (this.timer) { const tmp = this.cache_term.get(word); if (tmp || "" === tmp) { @@ -491,7 +496,7 @@ Encoder.prototype.encode = function (str) { //word = word.replace(/(.)\1+/g, "$1"); //word = word.replace(/(?<=(.))\1+/g, ""); - if ( /*SUPPORT_CACHE &&*/this.cache && base.length <= this.cache_term_length) { + if (this.cache && base.length <= this.cache_term_length) { this.cache_term.set(base, word); if (this.cache_term.size > this.cache_size) { this.cache_term.clear(); @@ -499,14 +504,17 @@ Encoder.prototype.encode = function (str) { } } - word && final.push(word); + if (word && (!dedupe_terms || !dupes[word])) { + dedupe_terms && (dupes[word] = 1); + final.push(word); + } } if (this.finalize) { final = this.finalize(final) || final; } - if ( /*SUPPORT_CACHE &&*/this.cache && str.length <= this.cache_enc_length) { + if (this.cache && str.length <= this.cache_enc_length) { this.cache_enc.set(str, final); if (this.cache_enc.size > this.cache_size) { this.cache_enc.clear(); @@ -518,7 +526,6 @@ Encoder.prototype.encode = function (str) { }; export function fallback_encoder(str) { - return str.normalize("NFKD").replace(normalize, "").toLowerCase().trim().split(/\s+/); } diff --git a/dist/module-debug/index/add.js b/dist/module-debug/index/add.js index 60435fe..03a7634 100644 --- a/dist/module-debug/index/add.js +++ b/dist/module-debug/index/add.js @@ -29,9 +29,10 @@ Index.prototype.add = function (id, content, _append, _skip_update) { } } + const depth = this.depth; // do not force a string as input // https://github.com/nextapps-de/flexsearch/issues/432 - content = this.encoder.encode(content); + content = this.encoder.encode(content, !depth); const word_length = content.length; if (word_length) { @@ -40,7 +41,6 @@ Index.prototype.add = function (id, content, _append, _skip_update) { const dupes_ctx = create_object(), dupes = create_object(), - depth = this.depth, resolution = this.resolution; diff --git a/dist/module-debug/index/search.js b/dist/module-debug/index/search.js index 695f0d4..4cf55bd 100644 --- a/dist/module-debug/index/search.js +++ b/dist/module-debug/index/search.js @@ -67,12 +67,11 @@ Index.prototype.search = function (query, limit, options) { resolve = this.resolve; // || global_resolve; } - // todo: term deduplication during encoding when context is disabled - + context = this.depth && !1 !== context; // do not force a string as input // https://github.com/nextapps-de/flexsearch/issues/432 /** @type {Array} */ - let query_terms = this.encoder.encode(query); + let query_terms = this.encoder.encode(query, !context); length = query_terms.length; limit = /** @type {!number} */limit || (resolve ? 100 : 0); @@ -83,11 +82,6 @@ Index.prototype.search = function (query, limit, options) { limit, offset, resolve, enrich, tag); } - // TODO: dedupe terms within encoder? - // TODO: deduplication will break the context chain - - context = this.depth && !1 !== context; - // fast path single context if (2 === length && context && !suggest) { return single_term_query.call(this, query_terms[1], // term diff --git a/dist/module-debug/serialize.js b/dist/module-debug/serialize.js index 2fb84aa..e92750c 100644 --- a/dist/module-debug/serialize.js +++ b/dist/module-debug/serialize.js @@ -232,8 +232,7 @@ export function importIndex(key, data) { case "reg": // fast update isn't supported by export/import - this.fastupdate = /* suggest */ - /* append: */ /* enrich */ /* resolve: */!1; + this.fastupdate = /* suggest */ /* append: */ /* enrich */ /* resolve: */!1; this.reg = json_to_reg( /** @type {Array} */data, this.reg); break; diff --git a/dist/module-min/db/redis/index.js b/dist/module-min/db/redis/index.js index 7d584d0..b196c69 100644 --- a/dist/module-min/db/redis/index.js +++ b/dist/module-min/db/redis/index.js @@ -1 +1 @@ -import{createClient}from"redis";const defaults={host:"localhost",port:"6379",user:null,pass:null},VERSION=1,fields=["map","ctx","reg","tag","doc","cfg"];import StorageInterface from"../interface.js";import{toArray}from"../../common.js";function sanitize(a){return a.toLowerCase().replace(/[^a-z0-9_\-]/g,"")}let DB,TRX;export default function RedisDB(a,b={}){return this&&this.constructor===RedisDB?void("object"==typeof a&&(b=a,a=a.name),!a&&console.info("Default storage space was used, because a name was not passed."),this.id=(a?sanitize(a):"flexsearch")+"|",this.field=b.field?"-"+sanitize(b.field):"",this.type=b.type||"",this.fastupdate=!0,this.db=b.db||DB||null,this.support_tag_search=!0,Object.assign(defaults,b),this.db&&delete defaults.db):new RedisDB(a,b)}RedisDB.prototype.mount=function(a){return a.index?a.mount(this):(a.db=this,this.open())},RedisDB.prototype.open=async function(){if(this.db)return this.db;if(DB)return this.db=DB;let a=defaults.url;return a||(a=defaults.user?`redis://${defaults.user}:${defaults.pass}@${defaults.host}:${defaults.port}`:`redis://${defaults.host}:${defaults.port}`),this.db=DB=await createClient(a).on("error",a=>console.error(a)).connect()},RedisDB.prototype.close=async function(){return DB&&(await this.db.disconnect()),this.db=DB=null,this},RedisDB.prototype.destroy=function(){return this.clear()},RedisDB.prototype.clear=function(){return this.db.unlink([this.id+"map"+this.field,this.id+"ctx"+this.field,this.id+"tag"+this.field,this.id+"cfg"+this.field,this.id+"doc",this.id+"reg"])};function create_result(a,b,c,d){if(c){if("number"===b)for(let c,e,f=0;f=a.length)return[];if(!b&&!c)return a;const f=a.slice(c,c+b);return d?e.enrich(f):f})},RedisDB.prototype.enrich=function(a){return"object"!=typeof a&&(a=[a]),this.db.hmGet(this.id+"doc",a).then(function(b){for(let c=0;ce,j.push(c+(f?d:e)+":"+(f?e:d)),e=d}else{const a=this.id+"map"+this.field+":";for(let c=0;cconsole.error(a)).connect()},RedisDB.prototype.close=async function(){return DB&&(await this.db.disconnect()),this.db=DB=null,this},RedisDB.prototype.destroy=function(){return this.clear()},RedisDB.prototype.clear=function(){return this.db.unlink([this.id+"map"+this.field,this.id+"ctx"+this.field,this.id+"tag"+this.field,this.id+"cfg"+this.field,this.id+"doc",this.id+"reg"])};function create_result(a,b,c,d,e){if(c){if("number"===b)for(let c,e,f=0;f=a.length)return[];if(!b&&!c)return a;const f=a.slice(c,c+b);return d?e.enrich(f):f})},RedisDB.prototype.enrich=function(a){return"object"!=typeof a&&(a=[a]),this.db.hmGet(this.id+"doc",a).then(function(b){for(let c=0;ce,k.push(c+(f?d:e)+":"+(f?e:d)),l.push(1),e=d}else{const a=this.id+"map"+this.field+":";for(let c=0;c"a1a".split(d).length;this.numeric=merge_option(a.numeric,b)}else{try{this.split=merge_option(this.split,whitespace)}catch(a){!1,this.split=/\s+/}this.numeric=merge_option(a.numeric,merge_option(this.numeric,!0))}if(this.prepare=merge_option(a.prepare,null,this.prepare),this.finalize=merge_option(a.finalize,null,this.finalize),d=a.filter,this.filter="function"==typeof d?d:merge_option(d&&new Set(d),null,this.filter),this.dedupe=merge_option(a.dedupe,!0,this.dedupe),this.matcher=merge_option((d=a.matcher)&&new Map(d),null,this.matcher),this.mapper=merge_option((d=a.mapper)&&new Map(d),null,this.mapper),this.stemmer=merge_option((d=a.stemmer)&&new Map(d),null,this.stemmer),this.replacer=merge_option(a.replacer,null,this.replacer),this.minlength=merge_option(a.minlength,1,this.minlength),this.maxlength=merge_option(a.maxlength,1024,this.maxlength),this.rtl=merge_option(a.rtl,!1,this.rtl),this.cache=d=merge_option(a.cache,!0,this.cache),d&&(this.timer=null,this.cache_size="number"==typeof d?d:2e5,this.cache_enc=new Map,this.cache_term=new Map,this.cache_enc_length=128,this.cache_term_length=128),this.matcher_str="",this.matcher_test=null,this.stemmer_str="",this.stemmer_test=null,this.matcher)for(const a of this.matcher.keys())this.matcher_str+=(this.matcher_str?"|":"")+a;if(this.stemmer)for(const a of this.stemmer.keys())this.stemmer_str+=(this.stemmer_str?"|":"")+a;return this},Encoder.prototype.addStemmer=function(a,b){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(a,b),this.stemmer_str+=(this.stemmer_str?"|":"")+a,this.stemmer_test=null,this.cache&&clear(this),this},Encoder.prototype.addFilter=function(a){return"function"==typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a)),this.cache&&clear(this),this},Encoder.prototype.addMapper=function(a,b){return"object"==typeof a?this.addReplacer(a,b):1a.length&&(this.dedupe||this.mapper)?this.addMapper(a,b):(this.matcher||(this.matcher=new Map),this.matcher.set(a,b),this.matcher_str+=(this.matcher_str?"|":"")+a,this.matcher_test=null,this.cache&&clear(this),this)},Encoder.prototype.addReplacer=function(a,b){return"string"==typeof a?this.addMatcher(a,b):(this.replacer||(this.replacer=[]),this.replacer.push(a,b),this.cache&&clear(this),this)},Encoder.prototype.encode=function(a){if(this.cache&&a.length<=this.cache_enc_length)if(!this.timer)this.timer=setTimeout(clear,50,this);else if(this.cache_enc.has(a))return this.cache_enc.get(a);this.normalize&&("function"==typeof this.normalize?a=this.normalize(a):normalize?a=a.normalize("NFKD").replace(normalize,"").toLowerCase():a=a.toLowerCase()),this.prepare&&(a=this.prepare(a)),this.numeric&&3this.maxlength)){if(b){c.push(e);continue}if(!(this.filter&&("function"==typeof this.filter?!this.filter(e):this.filter.has(e)))){if(this.cache&&e.length<=this.cache_term_length)if(this.timer){const a=this.cache_term.get(e);if(a||""===a){a&&c.push(a);continue}}else this.timer=setTimeout(clear,50,this);if(this.stemmer&&2this.stemmer.get(a))),e&&(this.mapper||this.dedupe&&1this.matcher.get(a))),e&&this.replacer)for(let a=0;e&&athis.cache_size&&(this.cache_term.clear(),this.cache_term_length=0|this.cache_term_length/1.1)),e&&c.push(e)}}return this.finalize&&(c=this.finalize(c)||c),this.cache&&a.length<=this.cache_enc_length&&(this.cache_enc.set(a,c),this.cache_enc.size>this.cache_size&&(this.cache_enc.clear(),this.cache_enc_length=0|this.cache_enc_length/1.1)),c};export function fallback_encoder(a){return a.normalize("NFKD").replace(normalize,"").toLowerCase().trim().split(/\s+/)}function clear(a){a.timer=null,a.cache_enc.clear(),a.cache_term.clear()} \ No newline at end of file +import{create_object,merge_option}from"./common.js";import normalize_polyfill from"./charset/polyfill.js";import{EncoderOptions}from"./type.js";const whitespace=/[^\p{L}\p{N}]+/u,numeric_split_length=/(\d{3})/g,numeric_split_prev_char=/(\D)(\d{3})/g,numeric_split_next_char=/(\d{3})(\D)/g,normalize=/[\u0300-\u036f]/g;export default function Encoder(a={}){if(!this||this.constructor!==Encoder)return new Encoder(...arguments);if(arguments.length)for(let a=0;a"a1a".split(d).length;this.numeric=merge_option(a.numeric,b)}else{try{this.split=merge_option(this.split,whitespace)}catch(a){!1,this.split=/\s+/}this.numeric=merge_option(a.numeric,merge_option(this.numeric,!0))}if(this.prepare=merge_option(a.prepare,null,this.prepare),this.finalize=merge_option(a.finalize,null,this.finalize),d=a.filter,this.filter="function"==typeof d?d:merge_option(d&&new Set(d),null,this.filter),this.dedupe=merge_option(a.dedupe,!0,this.dedupe),this.matcher=merge_option((d=a.matcher)&&new Map(d),null,this.matcher),this.mapper=merge_option((d=a.mapper)&&new Map(d),null,this.mapper),this.stemmer=merge_option((d=a.stemmer)&&new Map(d),null,this.stemmer),this.replacer=merge_option(a.replacer,null,this.replacer),this.minlength=merge_option(a.minlength,1,this.minlength),this.maxlength=merge_option(a.maxlength,1024,this.maxlength),this.rtl=merge_option(a.rtl,!1,this.rtl),this.cache=d=merge_option(a.cache,!0,this.cache),d&&(this.timer=null,this.cache_size="number"==typeof d?d:2e5,this.cache_enc=new Map,this.cache_term=new Map,this.cache_enc_length=128,this.cache_term_length=128),this.matcher_str="",this.matcher_test=null,this.stemmer_str="",this.stemmer_test=null,this.matcher)for(const a of this.matcher.keys())this.matcher_str+=(this.matcher_str?"|":"")+a;if(this.stemmer)for(const a of this.stemmer.keys())this.stemmer_str+=(this.stemmer_str?"|":"")+a;return this},Encoder.prototype.addStemmer=function(a,b){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(a,b),this.stemmer_str+=(this.stemmer_str?"|":"")+a,this.stemmer_test=null,this.cache&&clear(this),this},Encoder.prototype.addFilter=function(a){return"function"==typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a)),this.cache&&clear(this),this},Encoder.prototype.addMapper=function(a,b){return"object"==typeof a?this.addReplacer(a,b):1a.length&&(this.dedupe||this.mapper)?this.addMapper(a,b):(this.matcher||(this.matcher=new Map),this.matcher.set(a,b),this.matcher_str+=(this.matcher_str?"|":"")+a,this.matcher_test=null,this.cache&&clear(this),this)},Encoder.prototype.addReplacer=function(a,b){return"string"==typeof a?this.addMatcher(a,b):(this.replacer||(this.replacer=[]),this.replacer.push(a,b),this.cache&&clear(this),this)},Encoder.prototype.encode=function(a,b){if(this.cache&&a.length<=this.cache_enc_length)if(!this.timer)this.timer=setTimeout(clear,50,this);else if(this.cache_enc.has(a))return this.cache_enc.get(a);this.normalize&&("function"==typeof this.normalize?a=this.normalize(a):normalize?a=a.normalize("NFKD").replace(normalize,"").toLowerCase():a=a.toLowerCase()),this.prepare&&(a=this.prepare(a)),this.numeric&&3this.maxlength)&&!(b&&e[g])){if(c){b&&(e[g]=1),d.push(g);continue}if(!(this.filter&&("function"==typeof this.filter?!this.filter(g):this.filter.has(g)))){if(this.cache&&g.length<=this.cache_term_length)if(this.timer){const a=this.cache_term.get(g);if(a||""===a){a&&d.push(a);continue}}else this.timer=setTimeout(clear,50,this);if(this.stemmer&&2this.stemmer.get(a))),g&&(this.mapper||this.dedupe&&1this.matcher.get(a))),g&&this.replacer)for(let a=0;g&&athis.cache_size&&(this.cache_term.clear(),this.cache_term_length=0|this.cache_term_length/1.1)),!g||b&&e[g]||(b&&(e[g]=1),d.push(g))}}return this.finalize&&(d=this.finalize(d)||d),this.cache&&a.length<=this.cache_enc_length&&(this.cache_enc.set(a,d),this.cache_enc.size>this.cache_size&&(this.cache_enc.clear(),this.cache_enc_length=0|this.cache_enc_length/1.1)),d};export function fallback_encoder(a){return a.normalize("NFKD").replace(normalize,"").toLowerCase().trim().split(/\s+/)}function clear(a){a.timer=null,a.cache_enc.clear(),a.cache_term.clear()} \ No newline at end of file diff --git a/dist/module-min/index/add.js b/dist/module-min/index/add.js index 8180c36..8acb4ea 100644 --- a/dist/module-min/index/add.js +++ b/dist/module-min/index/add.js @@ -1 +1 @@ -import{create_object}from"../common.js";import Index,{autoCommit}from"../index.js";import default_compress from"../compress.js";import{KeystoreArray}from"../keystore.js";Index.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.reg.has(a))return this.update(a,b);b=this.encoder.encode(b);const e=b.length;if(e){const d=create_object(),f=create_object(),g=this.depth,h=this.resolution;for(let j=0;jg;l--){m=i.substring(g,l),d=this.rtl?k-1-g:g;const n=this.score?this.score(b,i,j,m,d):get_score(h,e,j,k,d);this.push_index(f,m,n,a,c)}break}case"bidirectional":case"reverse":if(1h?0:1),e,j,l-1,g-1),n=this.bidirectional&&i>k;this.push_index(d,n?k:i,m,a,c,n?i:k)}}}}}this.fastupdate||this.reg.add(a)}else b=""}return this.db&&(b||this.commit_task.push({del:a}),this.commit_auto&&autoCommit(this)),this},Index.prototype.push_index=function(a,b,c,d,e,f){let g,h=f?this.ctx:this.map;if((!a[b]||f&&!(g=a[b])[f])&&(f?(a=g||(a[b]=create_object()),a[f]=1,this.compress&&(f=default_compress(f)),g=h.get(f),g?h=g:h.set(f,h=new Map)):a[b]=1,this.compress&&(b=default_compress(b)),g=h.get(b),g?h=g:h.set(b,h=g=[]),h=h[c]||(h[c]=[]),!e||!h.includes(d))){if(2147483647===h.length){const a=new KeystoreArray(h);if(this.fastupdate)for(let b of this.reg.values())b.includes(h)&&(b[b.indexOf(h)]=a);g[c]=h=a}if(h.push(d),this.fastupdate){const a=this.reg.get(d);a?a.push(h):this.reg.set(d,[h])}}};function get_score(a,b,c,d,e){return c&&1e;l--){m=i.substring(e,l),d=this.rtl?k-1-e:e;const n=this.score?this.score(b,i,j,m,d):get_score(h,f,j,k,d);this.push_index(g,m,n,a,c)}break}case"bidirectional":case"reverse":if(1h?0:1),f,j,l-1,e-1),n=this.bidirectional&&i>k;this.push_index(d,n?k:i,m,a,c,n?i:k)}}}}}this.fastupdate||this.reg.add(a)}else b=""}return this.db&&(b||this.commit_task.push({del:a}),this.commit_auto&&autoCommit(this)),this},Index.prototype.push_index=function(a,b,c,d,e,f){let g,h=f?this.ctx:this.map;if((!a[b]||f&&!(g=a[b])[f])&&(f?(a=g||(a[b]=create_object()),a[f]=1,this.compress&&(f=default_compress(f)),g=h.get(f),g?h=g:h.set(f,h=new Map)):a[b]=1,this.compress&&(b=default_compress(b)),g=h.get(b),g?h=g:h.set(b,h=g=[]),h=h[c]||(h[c]=[]),!e||!h.includes(d))){if(2147483647===h.length){const a=new KeystoreArray(h);if(this.fastupdate)for(let b of this.reg.values())b.includes(h)&&(b[b.indexOf(h)]=a);g[c]=h=a}if(h.push(d),this.fastupdate){const a=this.reg.get(d);a?a.push(h):this.reg.set(d,[h])}}};function get_score(a,b,c,d,e){return c&&1b,i&&(i=b,b=a,a=i)),this.compress&&(a=default_compress(a),b&&(b=default_compress(b))),this.db)?this.db.get(a,b,c,d,e,f,g):(b?(h=this.ctx.get(b),h=h&&h.get(a)):h=this.map.get(a),h)}; \ No newline at end of file +import{SearchOptions,SearchResults,EnrichedSearchResults,IntermediateSearchResults}from"../type.js";import{create_object,is_object,sort_by_length_down}from"../common.js";import Index from"../index.js";import default_compress from"../compress.js";import Resolver from"../resolver.js";import{intersect}from"../intersect.js";import resolve_default from"../resolve/default.js";Index.prototype.search=function(a,b,c){c||(b||"object"!=typeof a?"object"==typeof b&&(c=b,b=0):(c=a,a=""));let d,e,f,g,h,i,j,k,l=[],m=0;c?(a=c.query||a,b=c.limit||b,m=c.offset||0,e=c.context,f=c.suggest,g=!1!==c.resolve,k=g&&c.enrich,i=c.boost,j=c.resolution,h=this.db&&c.tag):g=this.resolve,e=this.depth&&!1!==e;let n=this.encoder.encode(a,!e);if(d=n.length,b=b||(g?100:0),1===d)return single_term_query.call(this,n[0],"",b,m,g,k,h);if(2===d&&e&&!f)return single_term_query.call(this,n[1],n[0],b,m,g,k,h);let o,p=create_object(),q=0;if(e&&(o=n[0],q=1),j||0===j||(j=o?this.resolution_ctx:this.resolution),this.db){if(this.db.search){const a=this.db.search(this,n,b,m,f,g,k,h);if(!1!==a)return a}const a=this;return async function(){for(let b,c;qb,i&&(i=b,b=a,a=i)),this.compress&&(a=default_compress(a),b&&(b=default_compress(b))),this.db)?this.db.get(a,b,c,d,e,f,g):(b?(h=this.ctx.get(b),h=h&&h.get(a)):h=this.map.get(a),h)}; \ No newline at end of file diff --git a/dist/module/db/redis/index.js b/dist/module/db/redis/index.js index 7987505..76be90f 100644 --- a/dist/module/db/redis/index.js +++ b/dist/module/db/redis/index.js @@ -36,9 +36,12 @@ export default function RedisDB(name, config = {}) { this.id = (name ? sanitize(name) : "flexsearch") + "|"; this.field = config.field ? "-" + sanitize(config.field) : ""; this.type = config.type || ""; - this.fastupdate = /* tag? */ /* stringify */ /* stringify */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/; + this.fastupdate = /* tag? */ /* stringify */ /* stringify */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ + /*await rows.hasNext()*/; this.db = config.db || DB || null; this.support_tag_search = !0; + this.resolution = 9; + this.resolution_ctx = 9; //this.trx = false; Object.assign(defaults, config); this.db && delete defaults.db; @@ -54,6 +57,8 @@ RedisDB.prototype.mount = function (flexsearch) { return flexsearch.mount(this); } flexsearch.db = this; + this.resolution = flexsearch.resolution; + this.resolution_ctx = flexsearch.resolution_ctx; // todo support //this.fastupdate = flexsearch.fastupdate; return this.open(); @@ -87,7 +92,7 @@ RedisDB.prototype.clear = function () { return this.db.unlink([this.id + "map" + this.field, this.id + "ctx" + this.field, this.id + "tag" + this.field, this.id + "cfg" + this.field, this.id + "doc", this.id + "reg"]); }; -function create_result(range, type, resolve, enrich) { +function create_result(range, type, resolve, enrich, resolution) { if (resolve) { if ("number" === type) { for (let i = 0, tmp, id; i < range.length; i++) { @@ -102,7 +107,7 @@ function create_result(range, type, resolve, enrich) { for (let i = 0, tmp, id, score; i < range.length; i++) { tmp = range[i]; id = "number" === type ? parseInt(tmp.id || tmp, 10) : tmp.id || tmp; - score = tmp.score; + score = resolution - tmp.score; result[score] || (result[score] = []); result[score].push(id); } @@ -133,7 +138,7 @@ RedisDB.prototype.get = function (key, ctx, limit = 0, offset = 0, resolve = !0, return result.then(async function (range) { if (!range.length) return range; if (enrich) range = await self.enrich(range); - return create_result(range, type, resolve, enrich); + return create_result(range, type, resolve, enrich, ctx ? self.resolution_ctx : self.resolution); }); }; @@ -167,11 +172,14 @@ RedisDB.prototype.has = function (id) { }; RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, suggest = !1, resolve = !0, enrich = !1, tags) { + + const ctx = 1 < query.length && flexsearch.depth; let result, - params = []; + params = [], + weights = []; - if (1 < query.length && flexsearch.depth) { + if (ctx) { const key = this.id + "ctx" + this.field + ":"; let keyword = query[0], @@ -182,6 +190,7 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, term = query[i]; swap = flexsearch.bidirectional && term > keyword; params.push(key + (swap ? term : keyword) + ":" + (swap ? keyword : term)); + weights.push(1); keyword = term; } } else { @@ -189,6 +198,7 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, const key = this.id + "map" + this.field + ":"; for (let i = 0; i < query.length; i++) { params.push(key + query[i]); + weights.push(1); } } @@ -199,7 +209,15 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, if (suggest) { - const multi = this.db.multi().zUnionStore(key, query, { AGGREGATE: "SUM" }); + const multi = this.db.multi(); + // The zStore implementation lacks of ordering by match count (occurrences). + // Unfortunately, I couldn't find an elegant way to overcome this issue completely. + // For this reason it needs additionally a zInterStore to boost at least matches + // when all terms were found + multi.zInterStore(key, query, { AGGREGATE: "SUM" }); + query.push(key); + weights.push(query.length); + multi.zUnionStore(key, query, { WEIGHTS: weights, AGGREGATE: "SUM" }); // Strict Tag Intersection: it does not put tags into union, instead it calculates the // intersection against the term match union. This was the default behavior // of Tag-Search. But putting everything into union will also provide suggestions derived @@ -211,7 +229,7 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, for (let i = 0; i < tags.length; i += 2) { query.push(this.id + "tag-" + sanitize(tags[i]) + ":" + tags[i + 1]); } - multi.zInterStore(key, query, { AGGREGATE: "SUM" }); + multi.zInterStore(key, query, { AGGREGATE: "MAX" }); // .unlink(key) // key = key2; } @@ -221,19 +239,19 @@ RedisDB.prototype.search = function (flexsearch, query, limit = 100, offset = 0, if (tags) for (let i = 0; i < tags.length; i += 2) { query.push(this.id + "tag-" + sanitize(tags[i]) + ":" + tags[i + 1]); } - result = this.db.multi().zInterStore(key, query, { AGGREGATE: "MIN" })[resolve ? "zRange" : "zRangeWithScores"](key, "" + offset, "" + (offset + limit - 1), { REV: !0 }).unlink(key).exec(); + result = this.db.multi().zInterStore(key, query, { AGGREGATE: "MAX" })[resolve ? "zRange" : "zRangeWithScores"](key, "" + offset, "" + (offset + limit - 1), { REV: !0 }).unlink(key).exec(); } const self = this; return result.then(async function (range) { range = suggest && tags // take the 3rd result from batch return - ? range[2] + ? range[3] // take the 2nd result from batch return - : range[1]; + : range[suggest ? 2 : 1]; if (!range.length) return range; if (enrich) range = await self.enrich(range); - return create_result(range, type, resolve, enrich); + return create_result(range, type, resolve, enrich, ctx ? self.resolution_ctx : self.resolution); }); }; @@ -241,7 +259,7 @@ RedisDB.prototype.info = function () { // todo }; -RedisDB.prototype.transaction = async function (task, callback) { +RedisDB.prototype.transaction = function (task, callback) { if (TRX) { return task.call(this, TRX); @@ -252,8 +270,9 @@ RedisDB.prototype.transaction = async function (task, callback) { promise2 = TRX.exec(); TRX = null; - callback && promise.then(callback); - await Promise.all([promise1, promise2]); + return Promise.all([promise1, promise2]).then(function () { + callback && callback(); + }); }; RedisDB.prototype.commit = async function (flexsearch, _replace, _append) { @@ -302,7 +321,7 @@ RedisDB.prototype.commit = async function (flexsearch, _replace, _append) { let result = []; for (let j = 0; j < ids.length; j++) { result.push({ - score: i, + score: this.resolution - i, value: "" + ids[j] }); } @@ -354,7 +373,10 @@ RedisDB.prototype.commit = async function (flexsearch, _replace, _append) { if ((ids = arr[i]) && ids.length) { let result = []; for (let j = 0; j < ids.length; j++) { - result.push({ score: i, value: "" + ids[j] }); + result.push({ + score: this.resolution_ctx - i, + value: "" + ids[j] + }); } if ("number" == typeof ids[0]) { this.type = "number"; @@ -362,7 +384,7 @@ RedisDB.prototype.commit = async function (flexsearch, _replace, _append) { const ref = this.id + "ctx" + this.field + ":" + ctx_key + ":" + key; trx.zAdd(ref, result); // if(this.fastupdate) for(let j = 0; j < ids.length; j++){ - // trx.sAdd("ref" + this.field + ":" + ids[j], ref); + // } if (this.fastupdate) for (let j = 0, id; j < ids.length; j++) { // Map performs bad when pushing numeric-like values as key diff --git a/dist/module/encoder.js b/dist/module/encoder.js index 6c31daf..abce21f 100644 --- a/dist/module/encoder.js +++ b/dist/module/encoder.js @@ -1,5 +1,5 @@ -import { merge_option } from "./common.js"; +import { create_object, merge_option } from "./common.js"; import normalize_polyfill from "./charset/polyfill.js"; import { EncoderOptions } from "./type.js"; @@ -196,7 +196,6 @@ Encoder.prototype.assign = function (options) { this.rtl = merge_option(options.rtl, !1, this.rtl); // auto-balanced cache - //if(SUPPORT_CACHE){ this.cache = tmp = merge_option(options.cache, !0, this.cache); if (tmp) { this.timer = null; @@ -206,7 +205,6 @@ Encoder.prototype.assign = function (options) { this.cache_enc_length = 128; this.cache_term_length = 128; } - //} // regex temporary state this.matcher_str = ""; @@ -252,7 +250,7 @@ Encoder.prototype.addStemmer = function (match, replace) { this.stemmer.set(match, replace); this.stemmer_str += (this.stemmer_str ? "|" : "") + match; this.stemmer_test = null; - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -264,7 +262,7 @@ Encoder.prototype.addFilter = function (term) { this.filter || (this.filter = new Set()); this.filter.add(term); } - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -286,7 +284,7 @@ Encoder.prototype.addMapper = function (char_match, char_replace) { } this.mapper || (this.mapper = new Map()); this.mapper.set(char_match, char_replace); - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -311,7 +309,7 @@ Encoder.prototype.addMatcher = function (match, replace) { this.matcher.set(match, replace); this.matcher_str += (this.matcher_str ? "|" : "") + match; this.matcher_test = null; - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -327,20 +325,18 @@ Encoder.prototype.addReplacer = function (regex, replace) { } this.replacer || (this.replacer = []); this.replacer.push(regex, replace); - /*SUPPORT_CACHE &&*/this.cache && clear(this); + this.cache && clear(this); return this; }; /** * @param {!string} str + * @param {boolean=} dedupe_terms Note: term deduplication will break the context chain * @return {!Array} */ -Encoder.prototype.encode = function (str) { +Encoder.prototype.encode = function (str, dedupe_terms) { - //if(!str) return str; - // todo remove dupe terms - - if ( /*SUPPORT_CACHE &&*/this.cache && str.length <= this.cache_enc_length) { + if (this.cache && str.length <= this.cache_enc_length) { if (this.timer) { if (this.cache_enc.has(str)) { return this.cache_enc.get(str); @@ -377,6 +373,7 @@ Encoder.prototype.encode = function (str) { // ); // str = str.replace(this.matcher_test, match => this.matcher.get(match)); // } + // if(this.stemmer){ // this.stemmer_test || ( // this.stemmer_test = new RegExp("(?!\\b)(" + this.stemmer_str + ")(\\b|_)", "g") @@ -386,18 +383,26 @@ Encoder.prototype.encode = function (str) { const skip = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let final = [], - words = this.split || "" === this.split ? str.split( /** @type {string|RegExp} */this.split) : str; - //[str]; + dupes = create_object(), + words = this.split || "" === this.split ? str.split( /** @type {string|RegExp} */this.split) : [str]; + // str; for (let i = 0, word, base; i < words.length; i++) { // filter empty entries if (!(word = base = words[i])) { continue; } + if (word.length < this.minlength || word.length > this.maxlength) { continue; } + + if (dedupe_terms && dupes[word]) { + continue; + } + if (skip) { + dedupe_terms && (dupes[word] = 1); final.push(word); continue; } @@ -407,7 +412,7 @@ Encoder.prototype.encode = function (str) { continue; } - if ( /*SUPPORT_CACHE &&*/this.cache && word.length <= this.cache_term_length) { + if (this.cache && word.length <= this.cache_term_length) { if (this.timer) { const tmp = this.cache_term.get(word); if (tmp || "" === tmp) { @@ -489,7 +494,7 @@ Encoder.prototype.encode = function (str) { //word = word.replace(/(.)\1+/g, "$1"); //word = word.replace(/(?<=(.))\1+/g, ""); - if ( /*SUPPORT_CACHE &&*/this.cache && base.length <= this.cache_term_length) { + if (this.cache && base.length <= this.cache_term_length) { this.cache_term.set(base, word); if (this.cache_term.size > this.cache_size) { this.cache_term.clear(); @@ -497,14 +502,17 @@ Encoder.prototype.encode = function (str) { } } - word && final.push(word); + if (word && (!dedupe_terms || !dupes[word])) { + dedupe_terms && (dupes[word] = 1); + final.push(word); + } } if (this.finalize) { final = this.finalize(final) || final; } - if ( /*SUPPORT_CACHE &&*/this.cache && str.length <= this.cache_enc_length) { + if (this.cache && str.length <= this.cache_enc_length) { this.cache_enc.set(str, final); if (this.cache_enc.size > this.cache_size) { this.cache_enc.clear(); @@ -516,7 +524,6 @@ Encoder.prototype.encode = function (str) { }; export function fallback_encoder(str) { - return str.normalize("NFKD").replace(normalize, "").toLowerCase().trim().split(/\s+/); } diff --git a/dist/module/index/add.js b/dist/module/index/add.js index 60435fe..03a7634 100644 --- a/dist/module/index/add.js +++ b/dist/module/index/add.js @@ -29,9 +29,10 @@ Index.prototype.add = function (id, content, _append, _skip_update) { } } + const depth = this.depth; // do not force a string as input // https://github.com/nextapps-de/flexsearch/issues/432 - content = this.encoder.encode(content); + content = this.encoder.encode(content, !depth); const word_length = content.length; if (word_length) { @@ -40,7 +41,6 @@ Index.prototype.add = function (id, content, _append, _skip_update) { const dupes_ctx = create_object(), dupes = create_object(), - depth = this.depth, resolution = this.resolution; diff --git a/dist/module/index/search.js b/dist/module/index/search.js index 695f0d4..4cf55bd 100644 --- a/dist/module/index/search.js +++ b/dist/module/index/search.js @@ -67,12 +67,11 @@ Index.prototype.search = function (query, limit, options) { resolve = this.resolve; // || global_resolve; } - // todo: term deduplication during encoding when context is disabled - + context = this.depth && !1 !== context; // do not force a string as input // https://github.com/nextapps-de/flexsearch/issues/432 /** @type {Array} */ - let query_terms = this.encoder.encode(query); + let query_terms = this.encoder.encode(query, !context); length = query_terms.length; limit = /** @type {!number} */limit || (resolve ? 100 : 0); @@ -83,11 +82,6 @@ Index.prototype.search = function (query, limit, options) { limit, offset, resolve, enrich, tag); } - // TODO: dedupe terms within encoder? - // TODO: deduplication will break the context chain - - context = this.depth && !1 !== context; - // fast path single context if (2 === length && context && !suggest) { return single_term_query.call(this, query_terms[1], // term diff --git a/dist/module/serialize.js b/dist/module/serialize.js index 2fb84aa..e92750c 100644 --- a/dist/module/serialize.js +++ b/dist/module/serialize.js @@ -232,8 +232,7 @@ export function importIndex(key, data) { case "reg": // fast update isn't supported by export/import - this.fastupdate = /* suggest */ - /* append: */ /* enrich */ /* resolve: */!1; + this.fastupdate = /* suggest */ /* append: */ /* enrich */ /* resolve: */!1; this.reg = json_to_reg( /** @type {Array} */data, this.reg); break; diff --git a/doc/context-index.svg b/doc/context-index.svg index f6506f9..99b8f84 100644 --- a/doc/context-index.svg +++ b/doc/context-index.svg @@ -2,24 +2,17 @@ - - - - - - + + + - - + - - - Term 4 + Term 4 @@ -53,12 +46,12 @@ 2. Context Score - - - 1. Partial Score + 1. Partial Score - Term 2 + Term 2 - Term 3 + Term 3 - Term 5 + Term 5 - Term 6 + Term 6 - Term 1 + Term 1 - Term 7 + Term 7 - ... + ... - ... + ... diff --git a/package-lock.json b/package-lock.json index 913339a..8a8df5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "flexsearch", - "version": "0.8.156", + "version": "0.8.157", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "flexsearch", - "version": "0.8.156", + "version": "0.8.157", "funding": [ { "type": "github", diff --git a/package.json b/package.json index 98c2043..3f212c0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "public": true, "preferGlobal": false, "name": "flexsearch", - "version": "0.8.156", + "version": "0.8.157", "description": "Next-Generation full-text search library for Browser and Node.js", "homepage": "https://github.com/nextapps-de/flexsearch/", "author": "Thomas Wilkerling", diff --git a/src/encoder.js b/src/encoder.js index 00ddb68..f7823a3 100644 --- a/src/encoder.js +++ b/src/encoder.js @@ -5,7 +5,7 @@ import { SUPPORT_CHARSET } from "./config.js"; // <-- COMPILER BLOCK -import { merge_option } from "./common.js"; +import { create_object, merge_option } from "./common.js"; import normalize_polyfill from "./charset/polyfill.js"; import { EncoderOptions } from "./type.js"; @@ -221,17 +221,15 @@ Encoder.prototype.assign = function(options){ this.rtl = merge_option(options.rtl, false, this.rtl); // auto-balanced cache - //if(SUPPORT_CACHE){ - this.cache = tmp = merge_option(options.cache, true, this.cache); - if(tmp){ - this.timer = null; - this.cache_size = typeof tmp === "number" ? tmp : 2e5; - this.cache_enc = new Map(); - this.cache_term = new Map(); - this.cache_enc_length = 128; - this.cache_term_length = 128; - } - //} + this.cache = tmp = merge_option(options.cache, true, this.cache); + if(tmp){ + this.timer = null; + this.cache_size = typeof tmp === "number" ? tmp : 2e5; + this.cache_enc = new Map(); + this.cache_term = new Map(); + this.cache_enc_length = 128; + this.cache_term_length = 128; + } // regex temporary state this.matcher_str = ""; @@ -277,7 +275,7 @@ Encoder.prototype.addStemmer = function(match, replace){ this.stemmer.set(match, replace); this.stemmer_str += (this.stemmer_str ? "|" : "") + match; this.stemmer_test = null; - /*SUPPORT_CACHE &&*/ this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -290,7 +288,7 @@ Encoder.prototype.addFilter = function(term){ this.filter || (this.filter = new Set()); this.filter.add(term); } - /*SUPPORT_CACHE &&*/ this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -312,7 +310,7 @@ Encoder.prototype.addMapper = function(char_match, char_replace){ } this.mapper || (this.mapper = new Map()); this.mapper.set(char_match, char_replace); - /*SUPPORT_CACHE &&*/ this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -337,7 +335,7 @@ Encoder.prototype.addMatcher = function(match, replace){ this.matcher.set(match , replace); this.matcher_str += (this.matcher_str ? "|" : "") + match; this.matcher_test = null; - /*SUPPORT_CACHE &&*/ this.cache && clear(this); + this.cache && clear(this); return this; }; @@ -353,20 +351,18 @@ Encoder.prototype.addReplacer = function(regex, replace){ } this.replacer || (this.replacer = []); this.replacer.push(regex, replace); - /*SUPPORT_CACHE &&*/ this.cache && clear(this); + this.cache && clear(this); return this; }; /** * @param {!string} str + * @param {boolean=} dedupe_terms Note: term deduplication will break the context chain * @return {!Array} */ -Encoder.prototype.encode = function(str){ +Encoder.prototype.encode = function(str, dedupe_terms){ - //if(!str) return str; - // todo remove dupe terms - - if(/*SUPPORT_CACHE &&*/ this.cache && str.length <= this.cache_enc_length){ + if(this.cache && str.length <= this.cache_enc_length){ if(this.timer){ if(this.cache_enc.has(str)){ return this.cache_enc.get(str); @@ -408,6 +404,7 @@ Encoder.prototype.encode = function(str){ // ); // str = str.replace(this.matcher_test, match => this.matcher.get(match)); // } + // if(this.stemmer){ // this.stemmer_test || ( // this.stemmer_test = new RegExp("(?!\\b)(" + this.stemmer_str + ")(\\b|_)", "g") @@ -417,21 +414,28 @@ Encoder.prototype.encode = function(str){ const skip = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let final = []; - let changed; + let dupes = create_object(); let words = this.split || this.split === "" ? str.split(/** @type {string|RegExp} */ (this.split)) - : str; //[str]; + : [str]; // str; for(let i = 0, word, base; i < words.length; i++){ // filter empty entries if(!(word = base = words[i])){ continue; } + if(word.length < this.minlength || word.length > this.maxlength){ continue; } + + if(dedupe_terms && dupes[word]){ + continue; + } + if(skip) { + dedupe_terms && (dupes[word] = 1); final.push(word); continue; } @@ -445,7 +449,7 @@ Encoder.prototype.encode = function(str){ continue; } - if(/*SUPPORT_CACHE &&*/ this.cache && word.length <= this.cache_term_length){ + if(this.cache && word.length <= this.cache_term_length){ if(this.timer){ const tmp = this.cache_term.get(word); if(tmp || tmp === ""){ @@ -535,7 +539,7 @@ Encoder.prototype.encode = function(str){ //word = word.replace(/(.)\1+/g, "$1"); //word = word.replace(/(?<=(.))\1+/g, ""); - if(/*SUPPORT_CACHE &&*/ this.cache && base.length <= this.cache_term_length){ + if(this.cache && base.length <= this.cache_term_length){ this.cache_term.set(base, word); if(this.cache_term.size > this.cache_size){ this.cache_term.clear(); @@ -543,14 +547,17 @@ Encoder.prototype.encode = function(str){ } } - word && final.push(word); + if(word && (!dedupe_terms || !dupes[word])){ + dedupe_terms && (dupes[word] = 1); + final.push(word); + } } if(this.finalize){ final = this.finalize(final) || final; } - if(/*SUPPORT_CACHE &&*/ this.cache && str.length <= this.cache_enc_length){ + if(this.cache && str.length <= this.cache_enc_length){ this.cache_enc.set(str, final); if(this.cache_enc.size > this.cache_size){ this.cache_enc.clear(); @@ -562,8 +569,11 @@ Encoder.prototype.encode = function(str){ }; export function fallback_encoder(str){ - - return str.normalize("NFKD").replace(normalize, "").toLowerCase().trim().split(/\s+/); + return str.normalize("NFKD") + .replace(normalize, "") + .toLowerCase() + .trim() + .split(/\s+/); } // Encoder.prototype.compress = function(str) { diff --git a/src/index/add.js b/src/index/add.js index 0899f7f..f095390 100644 --- a/src/index/add.js +++ b/src/index/add.js @@ -35,9 +35,10 @@ Index.prototype.add = function(id, content, _append, _skip_update){ } } + const depth = this.depth; // do not force a string as input // https://github.com/nextapps-de/flexsearch/issues/432 - content = this.encoder.encode(content); + content = this.encoder.encode(content, !depth); const word_length = content.length; if(word_length){ @@ -46,7 +47,6 @@ Index.prototype.add = function(id, content, _append, _skip_update){ const dupes_ctx = create_object(); const dupes = create_object(); - const depth = this.depth; const resolution = this.resolution; for(let i = 0; i < word_length; i++){ diff --git a/src/index/search.js b/src/index/search.js index 509b915..622cfc1 100644 --- a/src/index/search.js +++ b/src/index/search.js @@ -77,12 +77,11 @@ Index.prototype.search = function(query, limit, options){ resolve = !SUPPORT_RESOLVER || this.resolve; // || global_resolve; } - // todo: term deduplication during encoding when context is disabled - + context = this.depth && context !== false; // do not force a string as input // https://github.com/nextapps-de/flexsearch/issues/432 /** @type {Array} */ - let query_terms = this.encoder.encode(query); + let query_terms = this.encoder.encode(query, !context); length = query_terms.length; limit = /** @type {!number} */ (limit || (resolve ? 100 : 0)); @@ -99,11 +98,6 @@ Index.prototype.search = function(query, limit, options){ ); } - // TODO: dedupe terms within encoder? - // TODO: deduplication will break the context chain - - context = this.depth && context !== false; - // fast path single context if(length === 2 && context && !suggest){ return single_term_query.call(this, diff --git a/test/basic.js b/test/basic.js index fb94839..3567c5e 100644 --- a/test/basic.js +++ b/test/basic.js @@ -221,6 +221,9 @@ describe("Search Scoring", function(){ expect(result.length).to.equal(7); expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + result = index.search("cute"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + result = index.search("cute dogs cats"); expect(result.length).to.equal(1); expect(result).to.eql([1]); @@ -228,6 +231,9 @@ describe("Search Scoring", function(){ result = index.search("cute dogs cats", { suggest: true }); expect(result).to.eql([1, 6, 5, 4, 3, 2, 0]); + result = index.search("undefined cute undefined dogs undefined cats undefined", { suggest: true }); + expect(result).to.eql([1, 6, 5, 4, 3, 2, 0]); + result = index.search("cute cat"); expect(result.length).to.equal(0); }); @@ -256,6 +262,9 @@ describe("Tokenizer", function(){ result = index.search("cute cat"); expect(result.length).to.equal(7); expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = index.search("cute"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); }); it("Should have been \"reverse\" tokenized properly", function(){ @@ -279,6 +288,9 @@ describe("Tokenizer", function(){ result = index.search("ute ats"); expect(result.length).to.equal(7); expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = index.search("cute"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); }); it("Should have been \"full\" tokenized properly", function(){ @@ -302,6 +314,9 @@ describe("Tokenizer", function(){ result = index.search("ut at"); expect(result.length).to.equal(7); expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = index.search("cute"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); }); }); @@ -328,6 +343,9 @@ describe("Search: Suggestion", function(){ result = index.search("nothing or cute cat or cute dog", { suggest: true }); expect(result.length).to.equal(7); expect(result).to.eql([1, 6, 5, 4, 3, 2, 0]); + + result = index.search("cute"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); }); }); diff --git a/test/persistent.js b/test/persistent.js index 09ce98a..8a045c2 100644 --- a/test/persistent.js +++ b/test/persistent.js @@ -98,12 +98,23 @@ export default function(DB, DBClass){ result = await index.search("cute cats"); expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + result = await index.search("cute"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + result = await index.search("cute dogs cats"); expect(result).to.eql([1]); - // todo Redis Union did not sort by term count matches yet - if(DBClass !== "Redis"){ - result = await index.search("cute dogs cats", { suggest: true }); + result = await index.search("cute dogs cats", { suggest: true }); + expect(result).to.eql([1, 6, 5, 4, 3, 2, 0]); + + // Redis lacks of its own union feature, because it didn't provide + // a way to order results by count of union matches + if(DBClass === "Redis"){ + result = await index.search("undefined cute undefined dogs undefined cats undefined", { suggest: true }); + expect(result).to.eql([6, 5, 1, 4, 3, 2, 0]); + } + else{ + result = await index.search("undefined cute undefined dogs undefined cats undefined", { suggest: true }); expect(result).to.eql([1, 6, 5, 4, 3, 2, 0]); } @@ -141,7 +152,7 @@ export default function(DB, DBClass){ // mount database to the index //await db.mount(index); //expect(index.db).to.equal(db); - //await index.clear(); + await index.clear(); // some test data const data = [ @@ -176,9 +187,17 @@ export default function(DB, DBClass){ result = await index.search("cute dogs cats"); expect(result).to.eql([1]); - // todo Redis Union did not sort by term count matches yet - if(DBClass !== "Redis"){ - result = await index.search("cute dogs cats", { suggest: true }); + result = await index.search("cute"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + // Redis lacks of its own union feature, because it didn't provide + // a way to order results by count of union matches + if(DBClass === "Redis"){ + result = await index.search("undefined cute undefined dogs undefined cats undefined", { suggest: true }); + expect(result).to.eql([6, 5, 1, 4, 3, 2, 0]); + } + else{ + result = await index.search("undefined cute undefined dogs undefined cats undefined", { suggest: true }); expect(result).to.eql([1, 6, 5, 4, 3, 2, 0]); } @@ -416,29 +435,15 @@ export default function(DB, DBClass){ highlight: "$1" }); - // todo Redis has slightly different sorting by aggregation - if(result[0].result[0].id === 1){ - expect(result[0].result).to.eql([{ - id: 1, - doc: data[0], - highlight: 'Carmencita' - },{ - id: 2, - doc: data[1], - highlight: 'Le clown et ses chiens' - }]); - } - else{ - expect(result[0].result).to.eql([{ - id: 2, - doc: data[1], - highlight: 'Le clown et ses chiens' - },{ - id: 1, - doc: data[0], - highlight: 'Carmencita' - }]); - } + expect(result[0].result).to.eql([{ + id: 1, + doc: data[0], + highlight: 'Carmencita' + },{ + id: 2, + doc: data[1], + highlight: 'Le clown et ses chiens' + }]); // perform a query on cache result = await index.searchCache({ @@ -451,29 +456,15 @@ export default function(DB, DBClass){ highlight: "$1" }); - // todo Redis has slightly different sorting by aggregation - if(result[0].result[0].id === 1){ - expect(result[0].result).to.eql([{ - id: 1, - doc: data[0], - highlight: 'Carmencita' - }, { - id: 2, - doc: data[1], - highlight: 'Le clown et ses chiens' - }]); - } - else{ - expect(result[0].result).to.eql([{ - id: 2, - doc: data[1], - highlight: 'Le clown et ses chiens' - },{ - id: 1, - doc: data[0], - highlight: 'Carmencita' - }]); - } + expect(result[0].result).to.eql([{ + id: 1, + doc: data[0], + highlight: 'Carmencita' + }, { + id: 2, + doc: data[1], + highlight: 'Le clown et ses chiens' + }]); // perform a query using pluck result = await index.search({ @@ -487,28 +478,14 @@ export default function(DB, DBClass){ highlight: "$1" }); - // todo Redis has slightly different sorting by aggregation - if(result[0].id === 1){ - expect(result).to.eql([{ - id: 1, - doc: data[0], - highlight: 'Carmencita' - },{ - id: 2, - doc: data[1], - highlight: 'Le clown et ses chiens' - }]); - } - else{ - expect(result).to.eql([{ - id: 2, - doc: data[1], - highlight: 'Le clown et ses chiens' - },{ - id: 1, - doc: data[0], - highlight: 'Carmencita' - }]); - } + expect(result).to.eql([{ + id: 1, + doc: data[0], + highlight: 'Carmencita' + },{ + id: 2, + doc: data[1], + highlight: 'Le clown et ses chiens' + }]); }); } diff --git a/test/worker.js b/test/worker.js index 9b36732..713565f 100644 --- a/test/worker.js +++ b/test/worker.js @@ -48,6 +48,9 @@ if(!build_light && !build_compact) describe("Worker", function(){ result = await index.search("cute cat"); expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + result = await index.search("cute"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + result = await index.search("cudi tok-kat"); expect(result).to.eql([1]); });