diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js index 1253878..e81f71b 100644 --- a/dist/flexsearch.bundle.debug.js +++ b/dist/flexsearch.bundle.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.105 (Bundle/Debug) + * FlexSearch.js v0.8.107 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -60,7 +60,7 @@ function aa(a) { } return b; } -function J(a, b) { +function ba(a, b) { if (E(b)) { a = a[b]; } else { @@ -70,14 +70,14 @@ function J(a, b) { } return a; } -function ba(a) { +function ca(a) { let b = 0; for (let c = 0, e; c < a.length; c++) { (e = a[c]) && b < e.length && (b = e.length); } return b; } -;var ca = [["\u00aa", "a"], ["\u00b2", "2"], ["\u00b3", "3"], ["\u00b9", "1"], ["\u00ba", "o"], ["\u00bc", "1\u20444"], ["\u00bd", "1\u20442"], ["\u00be", "3\u20444"], ["\u00e0", "a"], ["\u00e1", "a"], ["\u00e2", "a"], ["\u00e3", "a"], ["\u00e4", "a"], ["\u00e5", "a"], ["\u00e7", "c"], ["\u00e8", "e"], ["\u00e9", "e"], ["\u00ea", "e"], ["\u00eb", "e"], ["\u00ec", "i"], ["\u00ed", "i"], ["\u00ee", "i"], ["\u00ef", "i"], ["\u00f1", "n"], ["\u00f2", "o"], ["\u00f3", "o"], ["\u00f4", "o"], ["\u00f5", +;var da = [["\u00aa", "a"], ["\u00b2", "2"], ["\u00b3", "3"], ["\u00b9", "1"], ["\u00ba", "o"], ["\u00bc", "1\u20444"], ["\u00bd", "1\u20442"], ["\u00be", "3\u20444"], ["\u00e0", "a"], ["\u00e1", "a"], ["\u00e2", "a"], ["\u00e3", "a"], ["\u00e4", "a"], ["\u00e5", "a"], ["\u00e7", "c"], ["\u00e8", "e"], ["\u00e9", "e"], ["\u00ea", "e"], ["\u00eb", "e"], ["\u00ec", "i"], ["\u00ed", "i"], ["\u00ee", "i"], ["\u00ef", "i"], ["\u00f1", "n"], ["\u00f2", "o"], ["\u00f3", "o"], ["\u00f4", "o"], ["\u00f5", "o"], ["\u00f6", "o"], ["\u00f9", "u"], ["\u00fa", "u"], ["\u00fb", "u"], ["\u00fc", "u"], ["\u00fd", "y"], ["\u00ff", "y"], ["\u0101", "a"], ["\u0103", "a"], ["\u0105", "a"], ["\u0107", "c"], ["\u0109", "c"], ["\u010b", "c"], ["\u010d", "c"], ["\u010f", "d"], ["\u0113", "e"], ["\u0115", "e"], ["\u0117", "e"], ["\u0119", "e"], ["\u011b", "e"], ["\u011d", "g"], ["\u011f", "g"], ["\u0121", "g"], ["\u0123", "g"], ["\u0125", "h"], ["\u0129", "i"], ["\u012b", "i"], ["\u012d", "i"], ["\u012f", "i"], ["\u0133", "ij"], ["\u0135", "j"], ["\u0137", "k"], ["\u013a", "l"], ["\u013c", "l"], ["\u013e", "l"], ["\u0140", "l"], ["\u0144", "n"], ["\u0146", "n"], ["\u0148", "n"], ["\u0149", "n"], ["\u014d", "o"], ["\u014f", "o"], ["\u0151", "o"], ["\u0155", "r"], ["\u0157", "r"], ["\u0159", "r"], ["\u015b", "s"], ["\u015d", "s"], ["\u015f", "s"], ["\u0161", "s"], ["\u0163", "t"], ["\u0165", "t"], ["\u0169", "u"], ["\u016b", "u"], ["\u016d", "u"], ["\u016f", "u"], ["\u0171", "u"], ["\u0173", "u"], ["\u0175", "w"], ["\u0177", "y"], ["\u017a", "z"], ["\u017c", "z"], ["\u017e", "z"], ["\u017f", "s"], ["\u01a1", "o"], ["\u01b0", "u"], ["\u01c6", "dz"], ["\u01c9", "lj"], ["\u01cc", "nj"], ["\u01ce", "a"], ["\u01d0", "i"], ["\u01d2", "o"], ["\u01d4", "u"], ["\u01d6", "u"], ["\u01d8", "u"], ["\u01da", "u"], ["\u01dc", "u"], ["\u01df", "a"], ["\u01e1", "a"], ["\u01e3", "ae"], ["\u00e6", "ae"], ["\u01fd", "ae"], ["\u01e7", "g"], ["\u01e9", "k"], ["\u01eb", "o"], ["\u01ed", "o"], ["\u01ef", "\u0292"], ["\u01f0", "j"], ["\u01f3", @@ -85,16 +85,16 @@ function ba(a) { ["\u02b2", "j"], ["\u02b3", "r"], ["\u02b4", "\u0279"], ["\u02b5", "\u027b"], ["\u02b6", "\u0281"], ["\u02b7", "w"], ["\u02b8", "y"], ["\u02e0", "\u0263"], ["\u02e1", "l"], ["\u02e2", "s"], ["\u02e3", "x"], ["\u02e4", "\u0295"], ["\u0390", "\u03b9"], ["\u03ac", "\u03b1"], ["\u03ad", "\u03b5"], ["\u03ae", "\u03b7"], ["\u03af", "\u03b9"], ["\u03b0", "\u03c5"], ["\u03ca", "\u03b9"], ["\u03cb", "\u03c5"], ["\u03cc", "\u03bf"], ["\u03cd", "\u03c5"], ["\u03ce", "\u03c9"], ["\u03d0", "\u03b2"], ["\u03d1", "\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db", "\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]]; -const da = /[^\p{L}\p{N}]+/u, ea = /(\d{3})/g, fa = /(\D)(\d{3})/g, ha = /(\d{3})(\D)/g, ia = "".normalize && /[\u0300-\u036f]/g; -function L(a) { - if (!this || this.constructor !== L) { - return new L(...arguments); +const ea = /[^\p{L}\p{N}]+/u, fa = /(\d{3})/g, ha = /(\D)(\d{3})/g, ia = /(\d{3})(\D)/g, ja = "".normalize && /[\u0300-\u036f]/g; +function J(a) { + if (!this || this.constructor !== J) { + return new J(...arguments); } for (let b = 0; b < arguments.length; b++) { this.assign(arguments[b]); } } -t = L.prototype; +t = J.prototype; t.assign = function(a) { this.normalize = A(a.normalize, !0, this.normalize); let b = a.include, c = b || a.exclude || a.split, e; @@ -122,7 +122,7 @@ t.assign = function(a) { this.numeric = A(a.numeric, e); } else { try { - this.split = A(this.split, da); + this.split = A(this.split, ea); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } @@ -130,7 +130,7 @@ t.assign = function(a) { } this.prepare = A(a.prepare, null, this.prepare); this.finalize = A(a.finalize, null, this.finalize); - ia || (this.mapper = new Map(ca)); + ja || (this.mapper = new Map(da)); this.rtl = A(a.rtl, !1, this.rtl); this.dedupe = A(a.dedupe, !1, this.dedupe); this.filter = A((c = a.filter) && new Set(c), null, this.filter); @@ -164,13 +164,13 @@ t.addStemmer = function(a, b) { this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; this.N = null; - this.cache && M(this); + this.cache && L(this); return this; }; t.addFilter = function(a) { this.filter || (this.filter = new Set()); this.filter.add(a); - this.cache && M(this); + this.cache && L(this); return this; }; t.addMapper = function(a, b) { @@ -182,7 +182,7 @@ t.addMapper = function(a, b) { } this.mapper || (this.mapper = new Map()); this.mapper.set(a, b); - this.cache && M(this); + this.cache && L(this); return this; }; t.addMatcher = function(a, b) { @@ -196,7 +196,7 @@ t.addMatcher = function(a, b) { this.matcher.set(a, b); this.h += (this.h ? "|" : "") + a; this.M = null; - this.cache && M(this); + this.cache && L(this); return this; }; t.addReplacer = function(a, b) { @@ -205,7 +205,7 @@ t.addReplacer = function(a, b) { } this.replacer || (this.replacer = []); this.replacer.push(a, b); - this.cache && M(this); + this.cache && L(this); return this; }; t.encode = function(a) { @@ -215,12 +215,12 @@ t.encode = function(a) { return this.B.get(a); } } else { - this.H = setTimeout(M, 50, this); + this.H = setTimeout(L, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ia ? a.normalize("NFKD").replace(ia, "").toLowerCase() : a.toLowerCase()); + this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ja ? a.normalize("NFKD").replace(ja, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(fa, "$1 $2").replace(ha, "$1 $2").replace(ea, "$1 ")); + this.numeric && 3 < a.length && (a = a.replace(ha, "$1 $2").replace(ia, "$1 $2").replace(fa, "$1 ")); const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let c = [], e = this.split || "" === this.split ? a.split(this.split) : a; for (let f = 0, g, k; f < e.length; f++) { @@ -237,7 +237,7 @@ t.encode = function(a) { continue; } } else { - this.H = setTimeout(M, 50, this); + this.H = setTimeout(L, 50, this); } } this.stemmer && 2 < g.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), g = g.replace(this.N, h => this.stemmer.get(h)), g.length < this.minlength || this.filter && this.filter.has(g)) && (g = ""); @@ -264,12 +264,12 @@ t.encode = function(a) { 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 M(a) { +function L(a) { a.H = null; a.B.clear(); a.G.clear(); } -;async function ja(a) { +;async function ka(a) { a = a.data; var b = self._index; const c = a.args; @@ -277,15 +277,15 @@ function M(a) { switch(e) { case "init": e = a.options || {}; - (b = a.factory) ? (Function("return " + b)()(self), self._index = new self.FlexSearch.Index(e), delete self.FlexSearch) : self._index = new N(e); + (b = a.factory) ? (Function("return " + b)()(self), self._index = new self.FlexSearch.Index(e), delete self.FlexSearch) : self._index = new M(e); postMessage({id:a.id}); break; default: a = a.id, b = b[e].apply(b, c), postMessage("search" === e ? {id:a, msg:b} : {id:a}); } } -;let ka = 0; -function O(a = {}) { +;let la = 0; +function N(a = {}) { function b(g) { function k(h) { h = h.data || h; @@ -298,67 +298,86 @@ function O(a = {}) { e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { return new Promise(function(h) { - d.h[++ka] = function() { + d.h[++la] = function() { h(d); }; - d.worker.postMessage({id:ka, task:"init", factory:c, options:a}); + d.worker.postMessage({id:la, task:"init", factory:c, options:a}); }); } this.worker.postMessage({task:"init", factory:c, options:a}); return this; } } - if (!this || this.constructor !== O) { - return new O(a); + if (!this || this.constructor !== N) { + return new N(a); } let c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; c && (c = c.toString()); - const e = "undefined" === typeof window, d = this, f = la(c, e, a.worker); + const e = "undefined" === typeof window, d = this, f = ma(c, e, a.worker); return f.then ? f.then(function(g) { return b.call(d, g); }) : b.call(this, f); } -P("add"); -P("append"); -P("search"); -P("update"); -P("remove"); -function P(a) { - O.prototype[a] = O.prototype[a + "Async"] = async function() { +O("add"); +O("append"); +O("search"); +O("update"); +O("remove"); +function O(a) { + N.prototype[a] = N.prototype[a + "Async"] = async function() { const b = this, c = [].slice.call(arguments); var e = c[c.length - 1]; let d; "function" === typeof e && (d = e, c.splice(c.length - 1, 1)); e = new Promise(function(f) { - b.h[++ka] = f; - b.worker.postMessage({task:a, id:ka, args:c}); + b.h[++la] = f; + b.worker.postMessage({task:a, id:la, args:c}); }); return d ? (e.then(d), this) : e; }; } -function la(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=" + ja.toString()], {type:"text/javascript"}))) : new window.Worker(E(c) ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function ma(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(E(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 ma(a) { - Q.call(a, "add"); - Q.call(a, "append"); - Q.call(a, "search"); - Q.call(a, "update"); - Q.call(a, "remove"); +;function na(a) { + P.call(a, "add"); + P.call(a, "append"); + P.call(a, "search"); + P.call(a, "update"); + P.call(a, "remove"); } -function Q(a) { +let Q, oa; +const pa = {}, R = {}; +function qa(a) { + Q = 0; + pa[a] = R[a]; +} +function P(a) { this[a + "Async"] = function() { - var b = arguments; - const c = b[b.length - 1]; + const b = arguments; + var c = b[b.length - 1]; let e; "function" === typeof c && (e = c, delete b[b.length - 1]); - b = this[a].apply(this, b); - e && (b.then ? b.then(e) : e(b)); - return b; + Q || (Q = setTimeout(qa, 0, a), oa = Date.now()); + R[a] || (R[a] = pa[a] = 1000); + if (!--pa[a]) { + pa[a] = R[a] = R[a] * this.priority * this.priority * 3 / (Date.now() - oa) | 0 || 1; + Q = clearTimeout(Q); + 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; }; } -;function na(a, b = 0) { +;function ra(a, b = 0) { let c = [], e = []; b && (b = 250000 / b * 5000 | 0); for (const d of a.entries()) { @@ -367,30 +386,30 @@ function Q(a) { e.length && c.push(e); return c; } -function oa(a, b) { +function sa(a, b) { b || (b = new Map()); for (let c = 0, e; c < a.length; c++) { e = a[c], b.set(e[0], e[1]); } return b; } -function pa(a, b = 0) { +function ta(a, b = 0) { let c = [], e = []; b && (b = 250000 / b * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], na(d[1])[0]]), e.length === b && (c.push(e), e = []); + e.push([d[0], ra(d[1])[0]]), e.length === b && (c.push(e), e = []); } e.length && c.push(e); return c; } -function qa(a, b) { +function ua(a, b) { b || (b = new Map()); for (let c = 0, e, d; c < a.length; c++) { - e = a[c], d = b.get(e[0]), b.set(e[0], oa(e[1], d)); + e = a[c], d = b.get(e[0]), b.set(e[0], sa(e[1], d)); } return b; } -function ra(a) { +function va(a) { let b = [], c = []; for (const e of a.keys()) { c.push(e), 250000 === c.length && (b.push(c), c = []); @@ -398,14 +417,14 @@ function ra(a) { c.length && b.push(c); return b; } -function sa(a, b) { +function wa(a, b) { b || (b = new Set()); for (let c = 0; c < a.length; c++) { b.add(a[c]); } return b; } -function ta(a, b, c, e, d, f, g = 0) { +function xa(a, b, c, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { @@ -414,12 +433,12 @@ function ta(a, b, c, e, d, f, g = 0) { if ((h = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(h))) && h.then) { const l = this; return h.then(function() { - return ta.call(l, a, b, c, k ? e : null, d, f, g + 1); + return xa.call(l, a, b, c, k ? e : null, d, f, g + 1); }); } - return ta.call(this, a, b, c, k ? e : null, d, f, g + 1); + return xa.call(this, a, b, c, k ? e : null, d, f, g + 1); } -;function ua(a, b, c, e) { +;function ya(a, b, c, e) { let d = []; for (let f = 0, g; f < a.index.length; f++) { if (g = a.index[f], b >= g.length) { @@ -435,9 +454,9 @@ function ta(a, b, c, e, d, f, g = 0) { } return d; } -function R(a) { +function S(a) { if (!this) { - return new R(a); + return new S(a); } this.index = a ? [a] : []; this.length = a ? a.length : 0; @@ -485,12 +504,12 @@ function R(a) { } if ("slice" === e) { return function(d, f) { - return ua(b, d || 0, f || b.length, !1); + return ya(b, d || 0, f || b.length, !1); }; } if ("splice" === e) { return function(d, f) { - return ua(b, d || 0, f || b.length, !0); + return ya(b, d || 0, f || b.length, !0); }; } if ("constructor" === e) { @@ -506,81 +525,81 @@ function R(a) { return !0; }}); } -R.prototype.clear = function() { +S.prototype.clear = function() { this.index.length = 0; }; -R.prototype.destroy = function() { +S.prototype.destroy = function() { this.proxy = this.index = null; }; -R.prototype.push = function() { -}; -function S(a = 8) { - if (!this) { - return new S(a); - } - this.index = B(); - this.B = []; - this.size = 0; - 32 < a ? (this.h = va, this.A = BigInt(a)) : (this.h = wa, this.A = a); -} -S.prototype.get = function(a) { - const b = this.index[this.h(a)]; - return b && b.get(a); -}; -S.prototype.set = function(a, b) { - var c = this.h(a); - let e = this.index[c]; - e ? (c = e.size, e.set(a, b), (c -= e.size) && this.size++) : (this.index[c] = e = new Map([[a, b]]), this.B.push(e)); +S.prototype.push = function() { }; function T(a = 8) { if (!this) { return new T(a); } this.index = B(); - this.h = []; - 32 < a ? (this.B = va, this.A = BigInt(a)) : (this.B = wa, this.A = a); + this.B = []; + this.size = 0; + 32 < a ? (this.h = za, this.A = BigInt(a)) : (this.h = Aa, this.A = a); } -T.prototype.add = function(a) { +T.prototype.get = function(a) { + const b = this.index[this.h(a)]; + return b && b.get(a); +}; +T.prototype.set = function(a, b) { + var c = this.h(a); + let e = this.index[c]; + e ? (c = e.size, e.set(a, b), (c -= e.size) && this.size++) : (this.index[c] = e = new Map([[a, b]]), this.B.push(e)); +}; +function U(a = 8) { + if (!this) { + return new U(a); + } + this.index = B(); + this.h = []; + 32 < a ? (this.B = za, this.A = BigInt(a)) : (this.B = Aa, this.A = a); +} +U.prototype.add = function(a) { 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)); }; -t = S.prototype; -t.has = T.prototype.has = function(a) { +t = T.prototype; +t.has = U.prototype.has = function(a) { const b = this.index[this.B(a)]; return b && b.has(a); }; -t.delete = T.prototype.delete = function(a) { +t.delete = U.prototype.delete = function(a) { const b = this.index[this.B(a)]; b && b.delete(a) && this.size--; }; -t.clear = T.prototype.clear = function() { +t.clear = U.prototype.clear = function() { this.index = B(); this.h = []; this.size = 0; }; -t.values = T.prototype.values = function*() { +t.values = U.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].values()) { yield b; } } }; -t.keys = T.prototype.keys = function*() { +t.keys = U.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].keys()) { yield b; } } }; -t.entries = T.prototype.entries = function*() { +t.entries = U.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].entries()) { yield b; } } }; -function wa(a) { +function Aa(a) { let b = 2 ** this.A - 1; if ("number" == typeof a) { return a & b; @@ -591,7 +610,7 @@ function wa(a) { } return 32 === this.A ? c + 2 ** 31 : c; } -function va(a) { +function za(a) { let b = BigInt(2) ** this.A - BigInt(1); var c = typeof a; if ("bigint" === c) { @@ -607,8 +626,8 @@ function va(a) { } return c; } -;U.prototype.add = function(a, b, c) { - I(a) && (b = a, a = J(b, this.key)); +;V.prototype.add = function(a, b, c) { + I(a) && (b = a, a = ba(b, this.key)); if (b && (a || 0 === a)) { if (!c && this.reg.has(a)) { return this.update(a, b); @@ -621,7 +640,7 @@ function va(a) { d && e.add(a, d, !1, !0); } else { if (d = h.I, !d || d(b)) { - h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), xa(b, h, this.J, 0, e, a, h[0], c); + h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Ba(b, h, this.J, 0, e, a, h[0], c); } } } @@ -640,14 +659,14 @@ function va(a) { continue; } f.constructor === String && (f = "" + f); - f = J(b, f); + f = ba(b, f); } if (d && f) { E(f) && (f = [f]); for (let h = 0, l, m; h < f.length; h++) { if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), !c || !m.includes(a))) { if (m.length === 2 ** 31 - 1) { - g = new R(m); + g = new S(m); if (this.fastupdate) { for (let n of this.reg.values()) { n.includes(m) && (n[n.indexOf(m)] = g); @@ -684,7 +703,7 @@ function va(a) { k[l] = b[l]; continue; } - ya(b, k, l, 0, l[0], m); + Ca(b, k, l, 0, l[0], m); } } this.store.set(a, k || b); @@ -692,21 +711,21 @@ function va(a) { } return this; }; -function ya(a, b, c, e, d, f) { +function Ca(a, b, c, e, d, f) { a = a[d]; if (e === c.length - 1) { b[d] = f || a; } else if (a) { if (a.constructor === Array) { for (b = b[d] = Array(a.length), d = 0; d < a.length; d++) { - ya(a, b, c, e, d); + Ca(a, b, c, e, d); } } else { - b = b[d] || (b[d] = B()), d = c[++e], ya(a, b, c, e, d); + b = b[d] || (b[d] = B()), d = c[++e], Ca(a, b, c, e, d); } } } -function xa(a, b, c, e, d, f, g, k) { +function Ba(a, b, c, e, d, f, g, k) { if (a = a[g]) { if (e === b.length - 1) { if (a.constructor === Array) { @@ -722,17 +741,17 @@ function xa(a, b, c, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - xa(a, b, c, e, d, f, g, k); + Ba(a, b, c, e, d, f, g, k); } } else { - g = b[++e], xa(a, b, c, e, d, f, g, k); + g = b[++e], Ba(a, b, c, e, d, f, g, k); } } } else { d.db && d.remove(f); } } -;function za(a, b, c, e, d, f, g) { +;function Da(a, b, c, e, d, f, g) { const k = a.length; let h = [], l; var m; @@ -748,7 +767,7 @@ function xa(a, b, c, e, d, f, g, k) { } if (a = h.length) { if (d) { - h = 1 < h.length ? Aa(h, c, e, g, f) : (h = h[0]).length > c || e ? h.slice(e, c + e) : h; + h = 1 < h.length ? Ea(h, c, e, g, f) : (h = h[0]).length > c || e ? h.slice(e, c + e) : h; } else { if (a < k) { return []; @@ -781,7 +800,7 @@ function xa(a, b, c, e, d, f, g, k) { } return h; } -function Aa(a, b, c, e, d) { +function Ea(a, b, c, e, d) { const f = [], g = B(); let k; var h = a.length; @@ -826,7 +845,7 @@ function Aa(a, b, c, e, d) { } return f; } -function Ba(a, b, c) { +function Fa(a, b, c) { const e = B(), d = []; for (let f = 0, g; f < b.length; f++) { g = b[f]; @@ -847,12 +866,12 @@ function Ba(a, b, c) { } return d; } -;function Ca(a, b, c, e) { +;function Ga(a, b, c, e) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : 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, e ? W.call(this, a) : a; } let d = []; for (let f = 0, g, k; f < a.length; f++) { @@ -866,7 +885,7 @@ function Ba(a, b, c) { } k > b && (g = g.slice(0, b), k = b); if (!d.length && k >= b) { - return e ? V.call(this, g) : g; + return e ? W.call(this, g) : g; } d.push(g); b -= k; @@ -876,9 +895,9 @@ function Ba(a, b, c) { } } d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? V.call(this, d) : d; + return e ? W.call(this, d) : d; } -;function Da(a, b, c) { +;function Ha(a, b, c) { var e = c[0]; if (e.then) { return Promise.all(c).then(function(m) { @@ -893,7 +912,7 @@ function Ba(a, b, c) { for (let m = 0, n; m < c.length; m++) { if (n = c[m]) { let p; - if (n.constructor === W) { + if (n.constructor === X) { p = n.result; } else if (n.constructor === Array) { p = n; @@ -924,11 +943,11 @@ function Ba(a, b, c) { } return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; } -;W.prototype.or = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f} = Da(this, "or", arguments); - return Ea.call(this, a, b, c, e, d, f); +;X.prototype.or = function() { + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f} = Ha(this, "or", arguments); + return Ia.call(this, a, b, c, e, d, f); }; -function Ea(a, b, c, e, d, f) { +function Ia(a, b, c, e, d, f) { if (b.length) { const g = this; return Promise.all(b).then(function(k) { @@ -936,25 +955,25 @@ function Ea(a, b, c, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return Ea.call(g, a, [], c, e, d, f); + return Ia.call(g, a, [], c, e, d, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Aa(a, c, e, !1, this.h), e = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ea(a, c, e, !1, this.h), e = 0)); return f ? this.resolve(c, e, d) : this; } -;W.prototype.and = function() { +;X.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:k, offset:h, enrich:l, resolve:m, suggest:n} = Da(this, "and", arguments); - return Fa.call(this, f, g, k, h, l, m, n); + const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:n} = Ha(this, "and", arguments); + return Ja.call(this, f, g, k, h, l, m, n); } return d ? this.resolve(b, c, e) : this; }; -function Fa(a, b, c, e, d, f, g) { +function Ja(a, b, c, e, d, f, g) { if (b.length) { const k = this; return Promise.all(b).then(function(h) { @@ -962,15 +981,15 @@ function Fa(a, b, c, e, d, f, g) { for (let l = 0, m; l < h.length; l++) { (m = h[l]).length && (a[l] = m); } - return Fa.call(k, a, [], c, e, d, f, g); + return Ja.call(k, a, [], c, e, d, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (b = ba(a)) { - return this.result = za(a, b, c, e, g, this.h, f), f ? d ? V.call(this.index, this.result) : this.result : this; + if (b = ca(a)) { + return this.result = Da(a, b, c, e, g, this.h, f), f ? d ? W.call(this.index, this.result) : this.result : this; } this.result = []; } @@ -979,11 +998,11 @@ function Fa(a, b, c, e, d, f, g) { } 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} = Da(this, "xor", arguments); - return Ga.call(this, a, b, c, e, d, f, g); +;X.prototype.xor = function() { + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ha(this, "xor", arguments); + return Ka.call(this, a, b, c, e, d, f, g); }; -function Ga(a, b, c, e, d, f, g) { +function Ka(a, b, c, e, d, f, g) { if (b.length) { const k = this; return Promise.all(b).then(function(h) { @@ -991,21 +1010,21 @@ function Ga(a, b, c, e, d, f, g) { for (let l = 0, m; l < h.length; l++) { (m = h[l]).length && (a[l] = m); } - return Ga.call(k, a, [], c, e, d, f, g); + return Ka.call(k, a, [], c, e, d, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = Ha.call(this, a, c, e, f, this.h), f ? d ? V.call(this.index, this.result) : this.result : this; + return this.result = La.call(this, a, c, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(c, e, d) : this; } -function Ha(a, b, c, e, d) { +function La(a, b, c, e, d) { const f = [], g = B(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -1050,11 +1069,11 @@ function Ha(a, b, c, e, d) { } return f; } -;W.prototype.not = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Da(this, "not", arguments); - return Ia.call(this, a, b, c, e, d, f, g); +;X.prototype.not = function() { + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ha(this, "not", arguments); + return Ma.call(this, a, b, c, e, d, f, g); }; -function Ia(a, b, c, e, d, f, g) { +function Ma(a, b, c, e, d, f, g) { if (b.length) { const k = this; return Promise.all(b).then(function(h) { @@ -1062,17 +1081,17 @@ function Ia(a, b, c, e, d, f, g) { for (let l = 0, m; l < h.length; l++) { (m = h[l]).length && (a[l] = m); } - return Ia.call(k, a, [], c, e, d, f, g); + return Ma.call(k, a, [], c, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Ja.call(this, a, c, e, f); + this.result = Na.call(this, a, c, e, f); } else if (f) { return this.resolve(c, e, d); } - return f ? d ? V.call(this.index, this.result) : this.result : this; + return f ? d ? W.call(this.index, this.result) : this.result : this; } -function Ja(a, b, c, e) { +function Na(a, b, c, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, k = 0; f < this.result.length; f++) { @@ -1098,9 +1117,9 @@ function Ja(a, b, c, e) { } return d; } -;function W(a) { - if (!this || this.constructor !== W) { - return new W(a); +;function X(a) { + if (!this || this.constructor !== X) { + return new X(a); } if (a && a.index) { return a.resolve = !1, this.index = a.index, this.h = a.boost || 0, this.result = a.index.search(a).result, this; @@ -1109,44 +1128,48 @@ function Ja(a, b, c, e) { this.result = a || []; this.h = 0; } -W.prototype.limit = function(a) { +X.prototype.limit = function(a) { if (this.result.length) { const b = []; - let c = 0; - for (let e = 0, d; e < this.result.length; e++) { - if (d = this.result[e], d.length + c < a) { - b[e] = d, c += d.length; - } else { - b[e] = d.slice(0, a - c); - this.result = b; - break; + for (let c = 0, e; c < this.result.length; c++) { + if (e = this.result[c]) { + if (e.length <= a) { + if (b[c] = e, a -= e.length, !a) { + break; + } + } else { + b[c] = e.slice(0, a); + break; + } } } - } - return this; -}; -W.prototype.offset = function(a) { - if (this.result.length) { - const b = []; - let c = 0; - for (let e = 0, d; e < this.result.length; e++) { - d = this.result[e], d.length + c < a ? c += d.length : (b[e] = d.slice(a - c), c = a); - } this.result = b; } return this; }; -W.prototype.boost = function(a) { +X.prototype.offset = function(a) { + if (this.result.length) { + const b = []; + for (let c = 0, e; c < this.result.length; c++) { + if (e = this.result[c]) { + e.length <= a ? a -= e.length : (b[c] = e.slice(a), a = 0); + } + } + this.result = b; + } + return this; +}; +X.prototype.boost = function(a) { this.h += a; return this; }; -W.prototype.resolve = function(a, b, c) { +X.prototype.resolve = function(a, b, c) { const e = this.result, d = this.index; this.result = this.index = null; - return e.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ca.call(d, e, a || 100, b, c)) : e; + return e.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ga.call(d, e, a || 100, b, c)) : e; }; B(); -U.prototype.search = function(a, b, c, e) { +V.prototype.search = function(a, b, c, e) { c || (!b && I(a) ? (c = a, a = "") : I(b) && (c = b, b = 0)); let d = [], f = [], g; let k; @@ -1222,7 +1245,7 @@ U.prototype.search = function(a, b, c, e) { } q.push(r = r.db.tag(v[p + 1], b, l, u)); } else { - r = Ka.call(this, v[p], v[p + 1], b, l, u); + r = Oa.call(this, v[p], v[p + 1], b, l, u); } d.push({field:v[p], tag:v[p + 1], result:r}); } @@ -1269,32 +1292,32 @@ U.prototype.search = function(a, b, c, e) { if (K && K.length) { y++, x.push(K); } else if (!q) { - return r ? d : new W(d); + return r ? d : new X(d); } } } } else { - for (let G = 0, K, kb; G < p.length; G += 2) { + for (let G = 0, K, pb; G < p.length; G += 2) { K = this.tag.get(p[G]); if (!K) { if (console.warn("Tag '" + p[G] + ":" + p[G + 1] + "' will be skipped because there is no field '" + p[G] + "'."), q) { continue; } else { - return r ? d : new W(d); + return r ? d : new X(d); } } - if (kb = (K = K && K.get(p[G + 1])) && K.length) { + if (pb = (K = K && K.get(p[G + 1])) && K.length) { y++, x.push(K); } else if (!q) { - return r ? d : new W(d); + return r ? d : new X(d); } } } if (y) { - w = Ba(w, x, r); + w = Fa(w, x, r); H = w.length; if (!H && !q) { - return r ? w : new W(w); + return r ? w : new X(w); } y--; } @@ -1302,7 +1325,7 @@ U.prototype.search = function(a, b, c, e) { if (H) { f[m] = D, d.push(w), m++; } else if (1 === h.length) { - return r ? d : new W(d); + return r ? d : new X(d); } } if (v) { @@ -1313,7 +1336,7 @@ U.prototype.search = function(a, b, c, e) { if (console.warn("Tag '" + p[u] + ":" + p[u + 1] + "' was not found because there is no field '" + p[u] + "'."), q) { continue; } else { - return r ? d : new W(d); + return r ? d : new X(d); } } v.push(e.db.tag(p[u + 1], b, l, !1)); @@ -1325,7 +1348,7 @@ U.prototype.search = function(a, b, c, e) { }); } if (!m) { - return r ? d : new W(d); + return r ? d : new X(d); } if (g && (!u || !this.store)) { return d[0]; @@ -1333,9 +1356,9 @@ U.prototype.search = function(a, b, c, e) { v = []; for (let z = 0, w; z < f.length; z++) { w = d[z]; - u && w.length && !w[0].doc && (this.db ? v.push(w = this.index.get(this.field[0]).db.enrich(w)) : w = V.call(this, w)); + u && w.length && !w[0].doc && (this.db ? v.push(w = this.index.get(this.field[0]).db.enrich(w)) : w = W.call(this, w)); if (g) { - return r ? w : new W(w); + return r ? w : new X(w); } d[z] = {field:f[z], result:w}; } @@ -1345,12 +1368,12 @@ U.prototype.search = function(a, b, c, e) { for (let D = 0; D < w.length; D++) { d[D].result = w[D]; } - return k ? La(d, b) : n ? Ma(d, a, z.index, z.field, z.D, n) : d; + return k ? Pa(d, b) : n ? Qa(d, a, z.index, z.field, z.D, n) : d; }); } - return k ? La(d, b) : n ? Ma(d, a, this.index, this.field, this.D, n) : d; + return k ? Pa(d, b) : n ? Qa(d, a, this.index, this.field, this.D, n) : d; }; -function Ma(a, b, c, e, d, f) { +function Qa(a, b, c, e, d, f) { let g, k, h; for (let m = 0, n, p, q, r, u; m < a.length; m++) { n = a[m].result; @@ -1362,7 +1385,7 @@ function Ma(a, b, c, e, d, f) { q !== g && (g = q, k = g.encode(b)); for (let v = 0; v < n.length; v++) { let x = ""; - var l = J(n[v].doc, u); + var l = ba(n[v].doc, u); let y = g.encode(l); l = l.split(g.split); for (let F = 0, z, w; F < y.length; F++) { @@ -1392,7 +1415,7 @@ function Ma(a, b, c, e, d, f) { } return a; } -function La(a, b) { +function Pa(a, b) { const c = [], e = B(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1411,7 +1434,7 @@ function La(a, b) { } return c; } -function Ka(a, b, c, e, d) { +function Oa(a, b, c, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1420,11 +1443,11 @@ function Ka(a, b, c, e, d) { if (a > c || e) { f = f.slice(e, e + c); } - d && (f = V.call(this, f)); + d && (f = W.call(this, f)); return f; } } -function V(a) { +function W(a) { if (!this || !this.store) { return a; } @@ -1434,24 +1457,24 @@ function V(a) { } return b; } -;function U(a) { - if (!this || this.constructor !== U) { - return new U(a); +;function V(a) { + if (!this || this.constructor !== V) { + return new V(a); } const b = a.document || a.doc || a; let c, e; this.D = []; this.field = []; this.J = []; - this.key = (c = b.key || b.id) && Na(c, this.J) || "id"; + this.key = (c = b.key || b.id) && Ra(c, this.J) || "id"; (e = a.keystore || 0) && (this.keystore = e); - this.reg = (this.fastupdate = !!a.fastupdate) ? e ? new S(e) : new Map() : e ? new T(e) : new Set(); + this.reg = (this.fastupdate = !!a.fastupdate) ? e ? new T(e) : new Map() : e ? new U(e) : new Set(); this.C = (c = b.store || null) && c && !0 !== c && []; - this.store = c && (e ? new S(e) : new Map()); - this.cache = (c = a.cache || null) && new X(c); + this.store = c && (e ? new T(e) : new Map()); + this.cache = (c = a.cache || null) && new Y(c); a.cache = !1; this.worker = a.worker; - this.index = Oa.call(this, a, b); + this.index = Sa.call(this, a, b); this.tag = null; if (c = b.tag) { if ("string" === typeof c && (c = [c]), c.length) { @@ -1464,7 +1487,7 @@ function V(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.F[d] = f.custom : (this.F[d] = Na(g, this.J), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = f.filter)); + f.custom ? this.F[d] = f.custom : (this.F[d] = Ra(g, this.J), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = f.filter)); this.R[d] = g; this.tag.set(g, new Map()); } @@ -1490,14 +1513,14 @@ function V(a) { a.db && this.mount(a.db); } } -t = U.prototype; +t = V.prototype; t.mount = function(a) { let b = this.field; if (this.tag) { for (let d = 0, f; d < this.R.length; d++) { f = this.R[d]; var c = void 0; - this.index.set(f, c = new N({}, this.reg)); + this.index.set(f, c = new M({}, this.reg)); b === this.field && (b = b.slice(0)); b.push(f); c.tag = this.tag.get(f); @@ -1532,7 +1555,7 @@ t.destroy = function() { } return Promise.all(a); }; -function Oa(a, b) { +function Sa(a, b) { const c = new Map(); let e = b.index || b.field || b; E(e) && (e = [e]); @@ -1541,23 +1564,23 @@ function Oa(a, b) { E(f) || (g = f, f = f.field); g = I(g) ? Object.assign({}, a, g) : a; if (this.worker) { - const k = new O(g); + const k = new N(g); c.set(f, k); } - this.worker || c.set(f, new N(g, this.reg)); - g.custom ? this.D[d] = g.custom : (this.D[d] = Na(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); + this.worker || c.set(f, new M(g, this.reg)); + g.custom ? this.D[d] = g.custom : (this.D[d] = Ra(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); this.field[d] = f; } if (this.C) { a = b.store; E(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] = Na(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = Ra(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); } } return c; } -function Na(a, b) { +function Ra(a, b) { const c = a.split(":"); let e = 0; for (let d = 0; d < c.length; d++) { @@ -1573,7 +1596,7 @@ t.update = function(a, b) { return this.remove(a).add(a, b); }; t.remove = function(a) { - I(a) && (a = J(a, this.key)); + I(a) && (a = ba(a, this.key)); for (var b of this.index.values()) { b.remove(a, !0); } @@ -1623,7 +1646,7 @@ t.set = function(a, b) { this.store.set(a, b); return this; }; -t.searchCache = Pa; +t.searchCache = Ta; t.export = function(a, b, c = 0, e = 0) { if (c < this.field.length) { const g = this.field[c]; @@ -1639,28 +1662,27 @@ t.export = function(a, b, c = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = ra(this.reg); + f = va(this.reg); b = null; break; case 1: d = "tag"; - f = pa(this.tag, this.reg.size); + f = ta(this.tag, this.reg.size); b = null; break; case 2: d = "doc"; - f = na(this.store); + f = ra(this.store); b = null; break; case 3: d = "cfg"; - f = {}; - b = null; + b = f = null; break; default: return; } - return ta.call(this, a, b, d, f, c, e); + return xa.call(this, a, b, d, f, c, e); }; t.import = function(a, b) { if (b) { @@ -1675,23 +1697,23 @@ t.import = function(a, b) { switch(a) { case "reg": this.fastupdate = !1; - this.reg = sa(b, this.reg); + this.reg = wa(b, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; case "tag": - this.tag = qa(b, this.tag); + this.tag = ua(b, this.tag); break; case "doc": - this.store = oa(b, this.store); + this.store = sa(b, this.store); } } }; -ma(U.prototype); -function Pa(a, b, c) { +na(V.prototype); +function Ta(a, b, c) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new X()); + this.cache || (this.cache = new Y()); let e = this.cache.get(a); if (!e) { e = this.search(a, b, c); @@ -1706,56 +1728,56 @@ function Pa(a, b, c) { } return e; } -function X(a) { +function Y(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -X.prototype.set = function(a, b) { +Y.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) { +Y.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) { +Y.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() { +Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Qa = {normalize:function(a) { +const Ua = {normalize:function(a) { return a.toLowerCase(); -}, numeric:!1, dedupe:!1}; -const Ra = 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 Sa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Ta = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -const Ua = {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}; -const Va = /[\x00-\x7F]+/g; -const Wa = /[\x00-\x7F]+/g; -const Xa = /[\x00-\x7F]+/g; -var Ya = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Qa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ra}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ra, matcher:Sa, replacer:Ta}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ra, replacer:Ta.concat([/(?!^)[aeo]/g, ""]), matcher:Sa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +}}; +const Va = 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 Wa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Xa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const Ya = {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}; +const Za = /[\x00-\x7F]+/g; +const $a = /[\x00-\x7F]+/g; +const ab = /[\x00-\x7F]+/g; +var bb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ua, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Va}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Va, matcher:Wa, replacer:Xa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Va, replacer:Xa.concat([/(?!^)[aeo]/g, ""]), matcher:Wa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let c = 0; c < a.length; c++) { var b = a[c]; - let e = b.charAt(0), d = Ua[e]; - for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = Ua[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = b.charAt(0), d = Ya[e]; + for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = Ya[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[c] = e; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Va, " "); + return ("" + a).replace(Za, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Wa, ""); + return ("" + a).replace($a, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Xa, " "); + return ("" + a).replace(ab, " "); }}}; -const Za = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; -N.prototype.add = function(a, b, c, e) { +const cb = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +M.prototype.add = function(a, b, c, e) { if (b && (a || 0 === a)) { if (!e && !c && this.reg.has(a)) { return this.update(a, b); @@ -1767,15 +1789,15 @@ N.prototype.add = function(a, b, c, e) { let r = b[this.rtl ? e - 1 - q : q]; var d = r.length; if (d && (n || !m[r])) { - var f = this.score ? this.score(b, r, q, null, 0) : $a(p, e, q), g = ""; + var f = this.score ? this.score(b, r, q, null, 0) : db(p, e, q), g = ""; switch(this.tokenize) { case "full": if (2 < d) { for (f = 0; f < d; f++) { for (var k = d; k > f; k--) { g = r.substring(f, k); - var h = this.score ? this.score(b, r, q, g, f) : $a(p, e, q, d, f); - Y(this, m, g, h, a, c); + var h = this.score ? this.score(b, r, q, g, f) : db(p, e, q, d, f); + eb(this, m, g, h, a, c); } } break; @@ -1783,24 +1805,24 @@ N.prototype.add = function(a, b, c, e) { case "reverse": if (1 < d) { for (k = d - 1; 0 < k; k--) { - g = r[k] + g, h = this.score ? this.score(b, r, q, g, k) : $a(p, e, q, d, k), Y(this, m, g, h, a, c); + g = r[k] + g, h = this.score ? this.score(b, r, q, g, k) : db(p, e, q, d, k), eb(this, m, g, h, a, c); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += r[k], Y(this, m, g, f, a, c); + g += r[k], eb(this, m, g, f, a, c); } break; } default: - if (Y(this, m, r, f, a, c), n && 1 < e && q < e - 1) { + if (eb(this, m, r, f, a, c), n && 1 < e && q < e - 1) { for (d = B(), g = this.U, f = r, k = Math.min(n + 1, e - q), d[f] = 1, h = 1; h < k; h++) { if ((r = b[this.rtl ? e - 1 - q - h : q + h]) && !d[r]) { d[r] = 1; - const u = this.score ? this.score(b, f, q, r, h) : $a(g + (e / 2 > g ? 0 : 1), e, q, k - 1, h - 1), v = this.bidirectional && r > f; - Y(this, l, v ? f : r, u, a, c, v ? r : f); + const u = this.score ? this.score(b, f, q, r, h) : db(g + (e / 2 > g ? 0 : 1), e, q, k - 1, h - 1), v = this.bidirectional && r > f; + eb(this, l, v ? f : r, u, a, c, v ? r : f); } } } @@ -1812,15 +1834,15 @@ N.prototype.add = function(a, b, c, e) { b = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.T && ab(this)); + this.db && (b || this.commit_task.push({del:a}), this.T && fb(this)); return this; }; -function Y(a, b, c, e, d, f, g) { +function eb(a, b, c, e, d, f, g) { let k = g ? a.ctx : a.map, h; if (!b[c] || g && !(h = b[c])[g]) { if (g ? (b = h || (b[c] = B()), 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[e] || (k[e] = []), !f || !k.includes(d)) { if (k.length === 2 ** 31 - 1) { - b = new R(k); + b = new S(k); if (a.fastupdate) { for (let l of a.reg.values()) { l.includes(k) && (l[l.indexOf(k)] = b); @@ -1833,10 +1855,10 @@ function Y(a, b, c, e, d, f, g) { } } } -function $a(a, b, c, e, d) { +function db(a, b, c, e, d) { return c && 1 < a ? b + (e || 0) <= a ? c + (d || 0) : (a - 1) / (b + (e || 0)) * (c + (d || 0)) + 1 | 0 : 0; } -;N.prototype.search = function(a, b, c) { +;M.prototype.search = function(a, b, c) { c || (!b && I(a) ? (c = a, a = "") : I(b) && (c = b, b = 0)); let e = [], d, f, g, k = 0, h, l, m, n, p; c ? (a = c.query || a, b = c.limit || b, k = c.offset || 0, f = c.context, g = c.suggest, p = (h = !1 !== c.resolve) && c.enrich, m = c.boost, n = c.resolution, l = this.db && c.tag) : h = this.resolve; @@ -1844,11 +1866,11 @@ function $a(a, b, c, e, d) { d = q.length; b = b || (h ? 100 : 0); if (1 === d) { - return bb.call(this, q[0], "", b, k, h, p, l); + return gb.call(this, q[0], "", b, k, h, p, l); } f = this.depth && !1 !== f; if (2 === d && f && !g) { - return bb.call(this, q[0], q[1], b, k, h, p, l); + return gb.call(this, q[0], q[1], b, k, h, p, l); } let r = B(), u = 0, v; 1 < d && f && (v = q[0], u = 1); @@ -1862,8 +1884,8 @@ function $a(a, b, c, e, d) { for (let y, F; u < d; u++) { if ((F = q[u]) && !r[F]) { r[F] = 1; - y = await cb(x, F, v, 0, 0, !1, !1); - if (y = db(y, e, g, n)) { + y = await hb(x, F, v, 0, 0, !1, !1); + if (y = ib(y, e, g, n)) { e = y; break; } @@ -1871,14 +1893,14 @@ function $a(a, b, c, e, d) { } g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); } - return eb(e, n, b, k, g, m, h); + return jb(e, n, b, k, g, m, h); }(); } for (let x, y; u < d; u++) { if ((y = q[u]) && !r[y]) { r[y] = 1; - x = cb(this, y, v, 0, 0, !1, !1); - if (x = db(x, e, g, n)) { + x = hb(this, y, v, 0, 0, !1, !1); + if (x = ib(x, e, g, n)) { e = x; break; } @@ -1886,24 +1908,24 @@ function $a(a, b, c, e, d) { } g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); } - return eb(e, n, b, k, g, m, h); + return jb(e, n, b, k, g, m, h); }; -function eb(a, b, c, e, d, f, g) { +function jb(a, b, c, e, d, f, g) { let k = a.length, h = a; if (1 < k) { - h = za(a, b, c, e, d, f, g); + h = Da(a, b, c, e, d, f, g); } else if (1 === k) { - return g ? Ca.call(null, a[0], c, e) : new W(a[0]); + return g ? Ga.call(null, a[0], c, e) : new X(a[0]); } - return g ? h : new W(h); + return g ? h : new X(h); } -function bb(a, b, c, e, d, f, g) { - a = cb(this, a, b, c, e, d, f, g); +function gb(a, b, c, e, d, f, g) { + a = hb(this, a, b, c, e, d, f, g); return this.db ? a.then(function(k) { - return d ? k || [] : new W(k); - }) : a && a.length ? d ? Ca.call(this, a, c, e) : new W(a) : d ? [] : new W(); + return d ? k || [] : new X(k); + }) : a && a.length ? d ? Ga.call(this, a, c, e) : new X(a) : d ? [] : new X(); } -function db(a, b, c, e) { +function ib(a, b, c, e) { let d = []; if (a && a.length) { if (a.length <= e) { @@ -1924,7 +1946,7 @@ function db(a, b, c, e) { return d; } } -function cb(a, b, c, e, d, f, g, k) { +function hb(a, b, c, e, d, f, g, k) { let h; c && (h = a.bidirectional && b > c) && (h = c, c = b, b = h); if (a.db) { @@ -1933,7 +1955,7 @@ function cb(a, b, c, e, d, f, g, k) { a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); return a; } -;N.prototype.remove = function(a, b) { +;M.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) { @@ -1948,15 +1970,15 @@ function cb(a, b, c, e, d, f, g, k) { } } } else { - fb(this.map, a), this.depth && fb(this.ctx, a); + kb(this.map, a), this.depth && kb(this.ctx, a); } b || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.T && ab(this)); + this.db && (this.commit_task.push({del:a}), this.T && fb(this)); this.cache && this.cache.remove(a); return this; }; -function fb(a, b) { +function kb(a, b) { let c = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1971,25 +1993,25 @@ function fb(a, b) { } } else { for (let e of a.entries()) { - const d = e[0], f = fb(e[1], b); + const d = e[0], f = kb(e[1], b); f ? c += f : a.delete(d); } } return c; } -;function N(a, b) { - if (!this || this.constructor !== N) { - return new N(a); +;function M(a, b) { + if (!this || this.constructor !== M) { + return new M(a); } if (a) { var c = E(a) ? a : a.preset; - c && (Za[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Za[c], a)); + c && (cb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, cb[c], a)); } else { a = {}; } c = a.context; - const e = !0 === c ? {depth:1} : c || {}, d = E(a.encoder) ? Ya[a.encoder] : a.encode || a.encoder || Qa; - this.encoder = d.encode ? d : "object" === typeof d ? new L(d) : {encode:d}; + const e = !0 === c ? {depth:1} : c || {}, d = E(a.encoder) ? bb[a.encoder] : a.encode || a.encoder || Ua; + this.encoder = d.encode ? d : "object" === typeof d ? new J(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = c = a.tokenize || "strict"; this.depth = "strict" === c && e.depth || 0; @@ -1997,12 +2019,12 @@ function fb(a, b) { 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.map = c ? new T(c) : new Map(); + this.ctx = c ? new T(c) : new Map(); + this.reg = b || (this.fastupdate ? c ? new T(c) : new Map() : c ? new U(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.cache = (c = a.cache || null) && new Y(c); this.resolve = !1 !== a.resolve; if (c = a.db) { this.db = this.mount(c); @@ -2010,8 +2032,9 @@ function fb(a, b) { this.T = !1 !== a.commit; this.commit_task = []; this.commit_timer = null; + this.priority = a.priority || 4; } -t = N.prototype; +t = M.prototype; t.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); @@ -2024,7 +2047,7 @@ t.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function ab(a) { +function fb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); @@ -2048,7 +2071,7 @@ 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); }; -function gb(a) { +function lb(a) { let b = 0; if (a.constructor === Array) { for (let c = 0, e; c < a.length; c++) { @@ -2056,7 +2079,7 @@ function gb(a) { } } else { for (const c of a) { - const e = c[0], d = gb(c[1]); + const e = c[0], d = lb(c[1]); d ? b += d : a.delete(e); } } @@ -2066,47 +2089,47 @@ t.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - gb(this.map); - this.depth && gb(this.ctx); + lb(this.map); + this.depth && lb(this.ctx); return this; }; -t.searchCache = Pa; +t.searchCache = Ta; t.export = function(a, b, c = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = ra(this.reg); + f = va(this.reg); break; case 1: d = "cfg"; - f = {}; + f = null; break; case 2: d = "map"; - f = na(this.map, this.reg.size); + f = ra(this.map, this.reg.size); break; case 3: d = "ctx"; - f = pa(this.ctx, this.reg.size); + f = ta(this.ctx, this.reg.size); break; default: return; } - return ta.call(this, a, b, d, f, c, e); + return xa.call(this, a, b, d, f, c, e); }; 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(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = sa(b, this.reg); + this.reg = wa(b, this.reg); break; case "map": - this.map = oa(b, this.map); + this.map = sa(b, this.map); break; case "ctx": - this.ctx = qa(b, this.ctx); + this.ctx = ua(b, this.ctx); } } }; @@ -2160,11 +2183,11 @@ t.serialize = function(a = !0) { d = "index.ctx=new Map([" + d + "]);"; return a ? "function inject(index){" + b + e + d + "}" : b + e + d; }; -ma(N.prototype); -const hb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), ib = ["map", "ctx", "tag", "reg", "cfg"]; -function jb(a, b = {}) { +na(M.prototype); +const mb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), nb = ["map", "ctx", "tag", "reg", "cfg"]; +function ob(a, b = {}) { if (!this) { - return new jb(a, b); + return new ob(a, b); } "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -2175,7 +2198,7 @@ function jb(a, b = {}) { this.db = null; this.h = {}; } -t = jb.prototype; +t = ob.prototype; t.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -2187,10 +2210,10 @@ t.open = function() { let a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { - const e = hb.open(a.id + (a.field ? ":" + a.field : ""), 1); + const e = mb.open(a.id + (a.field ? ":" + a.field : ""), 1); e.onupgradeneeded = function() { const d = a.db = this.result; - ib.forEach(f => { + nb.forEach(f => { d.objectStoreNames.contains(f) || d.createObjectStore(f); }); }; @@ -2216,13 +2239,13 @@ t.close = function() { this.db = null; }; t.destroy = function() { - const a = hb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); + const a = mb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); return Z(a); }; t.clear = function() { - const a = this.db.transaction(ib, "readwrite"); - for (let b = 0; b < ib.length; b++) { - a.objectStore(ib[b]).clear(); + const a = this.db.transaction(nb, "readwrite"); + for (let b = 0; b < nb.length; b++) { + a.objectStore(nb[b]).clear(); } return Z(a); }; @@ -2406,7 +2429,7 @@ t.commit = async function(a, b, c) { } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function lb(a, b, c) { +function qb(a, b, c) { const e = a.value; let d, f, g = 0; for (let k = 0, h; k < e.length; k++) { @@ -2435,17 +2458,17 @@ t.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && lb(c, a); + c && qb(c, a); }; }), this.transaction("ctx", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && lb(c, a); + c && qb(c, a); }; }), this.transaction("tag", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && lb(c, a, !0); + c && qb(c, a, !0); }; }), this.transaction("reg", "readwrite", function(b) { for (let c = 0; c < a.length; c++) { @@ -2465,9 +2488,9 @@ function Z(a) { a = null; }); } -;const mb = {Index:N, Charset:Ya, Encoder:L, Document:U, Worker:O, Resolver:W, IndexedDB:jb, Language:{}}, nb = self; -let ob; -(ob = nb.define) && ob.amd ? ob([], function() { - return mb; -}) : "object" === typeof nb.exports ? nb.exports = mb : nb.FlexSearch = mb; +;const rb = {Index:M, Charset:bb, Encoder:J, Document:V, Worker:N, Resolver:X, IndexedDB:ob, Language:{}}, sb = self; +let tb; +(tb = sb.define) && tb.amd ? tb([], function() { + return rb; +}) : "object" === typeof sb.exports ? sb.exports = rb : sb.FlexSearch = rb; }(this||self)); diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index b08008d..c6939f8 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -1,91 +1,92 @@ /**! - * FlexSearch.js v0.8.105 (Bundle) + * FlexSearch.js v0.8.107 (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 A(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(k){return a(c(k))};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 B(){return Object.create(null)}function E(a){return"string"===typeof a} -function I(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function J(a,b){if(E(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,da)}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);ia||(this.mapper=new Map(ca));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((c=a.filter)&&new Set(c),null,this.filter);this.matcher=A((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=A((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= +this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ea)}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);ja||(this.mapper=new Map(da));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((c=a.filter)&&new Set(c),null,this.filter);this.matcher=A((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=A((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= A((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=A(a.replacer,null,this.replacer);this.minlength=A(a.minlength,1,this.minlength);this.maxlength=A(a.maxlength,0,this.maxlength);if(this.cache=c=A(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&&M(this);return this};t.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&M(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&&M(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&&M(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(M,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.stemmer.get(h)),g.lengtha.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&&L(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&&L(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(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ja?a.normalize("NFKD").replace(ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),g.lengththis.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&d -this.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 M(a){a.H=null;a.B.clear();a.G.clear()};async function ja(a){a=a.data;var b=self._index;const c=a.args;var e=a.task;switch(e){case "init":e=a.options||{};(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new N(e);postMessage({id:a.id});break;default:a=a.id,b=b[e].apply(b,c),postMessage("search"===e?{id:a,msg:b}:{id:a})}};let ka=0; -function O(a={}){function b(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[++ka]=function(){h(d)};d.worker.postMessage({id:ka,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==O)return new O(a);let c="undefined"!==typeof self?self._factory:"undefined"!== -typeof window?window._factory:null;c&&(c=c.toString());const e="undefined"===typeof window,d=this,f=la(c,e,a.worker);return f.then?f.then(function(g){return b.call(d,g)}):b.call(this,f)}P("add");P("append");P("search");P("update");P("remove"); -function P(a){O.prototype[a]=O.prototype[a+"Async"]=async function(){const b=this,c=[].slice.call(arguments);var e=c[c.length-1];let d;"function"===typeof e&&(d=e,c.splice(c.length-1,1));e=new Promise(function(f){b.h[++ka]=f;b.worker.postMessage({task:a,id:ka,args:c})});return d?(e.then(d),this):e}} -function la(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="+ja.toString()],{type:"text/javascript"}))):new window.Worker(E(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 ma(a){Q.call(a,"add");Q.call(a,"append");Q.call(a,"search");Q.call(a,"update");Q.call(a,"remove")}function Q(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);b=this[a].apply(this,b);e&&(b.then?b.then(e):e(b));return b}};function na(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function oa(a,b){b||(b=new Map);for(let c=0,e;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} -function R(a){if(!this)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,k,h;gc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d=[];for(let n=0,p;ne)e-= +this.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 L(a){a.H=null;a.B.clear();a.G.clear()};async function ka(a){a=a.data;var b=self._index;const c=a.args;var e=a.task;switch(e){case "init":e=a.options||{};(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new M(e);postMessage({id:a.id});break;default:a=a.id,b=b[e].apply(b,c),postMessage("search"===e?{id:a,msg:b}:{id:a})}};let la=0; +function N(a={}){function b(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[++la]=function(){h(d)};d.worker.postMessage({id:la,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==N)return new N(a);let c="undefined"!==typeof self?self._factory:"undefined"!== +typeof window?window._factory:null;c&&(c=c.toString());const e="undefined"===typeof window,d=this,f=ma(c,e,a.worker);return f.then?f.then(function(g){return b.call(d,g)}):b.call(this,f)}O("add");O("append");O("search");O("update");O("remove"); +function O(a){N.prototype[a]=N.prototype[a+"Async"]=async function(){const b=this,c=[].slice.call(arguments);var e=c[c.length-1];let d;"function"===typeof e&&(d=e,c.splice(c.length-1,1));e=new Promise(function(f){b.h[++la]=f;b.worker.postMessage({task:a,id:la,args:c})});return d?(e.then(d),this):e}} +function ma(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(E(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 na(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let Q,oa;const pa={},R={};function qa(a){Q=0;pa[a]=R[a]} +function P(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]);Q||(Q=setTimeout(qa,0,a),oa=Date.now());R[a]||(R[a]=pa[a]=1E3);if(!--pa[a]){pa[a]=R[a]=R[a]*this.priority*this.priority*3/(Date.now()-oa)|0||1;Q=clearTimeout(Q);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}};function ra(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function sa(a,b){b||(b=new Map);for(let c=0,e;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} +function S(a){if(!this)return new S(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,k,h;gc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.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}h=1b?b?a.slice(c,c+b):a.slice(c):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?V.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Aa(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:k,offset:h,enrich:l,resolve:m,suggest:n}=Da(this,"and",arguments);return Fa.call(this,f,g,k,h,l,m,n)}return d?this.resolve(b,c,e):this}; -function Fa(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=ba(a))return this.result=za(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}=Da(this,"xor",arguments);return Ga.call(this,a,b,c,e,d,f,g)}; -function Ga(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Ha.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 Ha(a,b,c,e,d){const f=[],g=B();let k=0;for(let h=0,l;hb?b?a.slice(c,c+b):a.slice(c):a,e?W.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?W.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ea(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};X.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:k,offset:h,enrich:l,resolve:m,suggest:n}=Ha(this,"and",arguments);return Ja.call(this,f,g,k,h,l,m,n)}return d?this.resolve(b,c,e):this}; +function Ja(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Da(a,b,c,e,g,this.h,f),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};X.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ha(this,"xor",arguments);return Ka.call(this,a,b,c,e,d,f,g)}; +function Ka(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=La.call(this,a,c,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} +function La(a,b,c,e,d){const f=[],g=B();let k=0;for(let h=0,l;hc||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||e)a=a.slice(e,e+c);d&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;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 Qa={normalize:function(a){return a.toLowerCase()},numeric:!1,dedupe:!1};const Ra=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 Sa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ta=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Ua={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};const Va=/[\x00-\x7F]+/g;const Wa=/[\x00-\x7F]+/g;const Xa=/[\x00-\x7F]+/g;var Ya={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Qa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ra},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ra,matcher:Sa,replacer:Ta},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ra,replacer:Ta.concat([/(?!^)[aeo]/g,""]),matcher:Sa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;k--){g=r.substring(f,k);var h=this.score?this.score(b,r,q,g,f):$a(p,e,q,d,f);Y(this,m,g,h,a,c)}break}case "reverse":if(1< -d){for(k=d-1;0g?0:1),e,q,k-1,h-1),v=this.bidirectional&&r>f;Y(this,l,v?f:r,u,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& -(b||this.commit_task.push({del:a}),this.T&&ab(this));return this};function Y(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=B()),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[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new R(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} -function $a(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};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;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else fb(this.map,a),this.depth&&fb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&ab(this));this.cache&&this.cache.remove(a);return this}; -function fb(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ethis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.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};Y.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Ua={normalize:function(a){return a.toLowerCase()}};const Va=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 Wa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Xa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Ya={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};const Za=/[\x00-\x7F]+/g;const $a=/[\x00-\x7F]+/g;const ab=/[\x00-\x7F]+/g;var bb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ua,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Va},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Va,matcher:Wa,replacer:Xa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Va,replacer:Xa.concat([/(?!^)[aeo]/g,""]),matcher:Wa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;k--){g=r.substring(f,k);var h=this.score?this.score(b,r,q,g,f):db(p,e,q,d,f);eb(this,m,g,h,a,c)}break}case "reverse":if(1< +d){for(k=d-1;0g?0:1),e,q,k-1,h-1),v=this.bidirectional&&r>f;eb(this,l,v?f:r,u,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& +(b||this.commit_task.push({del:a}),this.T&&fb(this));return this};function eb(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=B()),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[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new S(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} +function db(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};M.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;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else kb(this.map,a),this.depth&&kb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&fb(this));this.cache&&this.cache.remove(a);return this}; +function kb(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ec.add(a,b)):this.add(a,b)}; -function gb(a){let b=0;if(a.constructor===Array)for(let c=0,e;c{d.objectStoreNames.contains(f)||d.createObjectStore(f)})};e.onblocked=function(d){console.error("blocked",d);c()};e.onerror=function(d){console.error(this.error,d);c()};e.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; -t.close=function(){this.db.close();this.db=null};t.destroy=function(){const a=hb.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};t.clear=function(){const a=this.db.transaction(ib,"readwrite");for(let b=0;b{d.objectStoreNames.contains(f)||d.createObjectStore(f)})};e.onblocked=function(d){console.error("blocked",d);c()};e.onerror=function(d){console.error(this.error,d);c()};e.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; +t.close=function(){this.db.close();this.db=null};t.destroy=function(){const a=mb.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};t.clear=function(){const a=this.db.transaction(nb,"readwrite");for(let b=0;b=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;em&&!f&&"string"===typeof n&&!isNaN(n)&&(m=h.indexOf(parseInt(n,10)))&&(f=1),0<=m)if(d=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};const mb={Index:N,Charset:Ya,Encoder:L,Document:U,Worker:O,Resolver:W,IndexedDB:kb,Language:{}},nb=self;let ob;(ob=nb.define)&&ob.amd?ob([],function(){return mb}):"object"===typeof nb.exports?nb.exports=mb:nb.FlexSearch=mb;}(this||self)); +function qb(a,b,c){const e=a.value;let d,f,g=0;for(let k=0,h;km&&!f&&"string"===typeof n&&!isNaN(n)&&(m=h.indexOf(parseInt(n,10)))&&(f=1),0<=m)if(d=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};const rb={Index:M,Charset:bb,Encoder:J,Document:V,Worker:N,Resolver:X,IndexedDB:pb,Language:{}},sb=self;let tb;(tb=sb.define)&&tb.amd?tb([],function(){return rb}):"object"===typeof sb.exports?sb.exports=rb:sb.FlexSearch=rb;}(this||self)); diff --git a/dist/flexsearch.bundle.module.debug.js b/dist/flexsearch.bundle.module.debug.js index 02b8c57..31699d5 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.105 (Bundle/Module/Debug) + * FlexSearch.js v0.8.107 (Bundle/Module/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -59,7 +59,7 @@ function aa(a) { } return b; } -function J(a, b) { +function ba(a, b) { if (E(b)) { a = a[b]; } else { @@ -69,14 +69,14 @@ function J(a, b) { } return a; } -function ba(a) { +function ca(a) { let b = 0; for (let c = 0, e; c < a.length; c++) { (e = a[c]) && b < e.length && (b = e.length); } return b; } -;var ca = [["\u00aa", "a"], ["\u00b2", "2"], ["\u00b3", "3"], ["\u00b9", "1"], ["\u00ba", "o"], ["\u00bc", "1\u20444"], ["\u00bd", "1\u20442"], ["\u00be", "3\u20444"], ["\u00e0", "a"], ["\u00e1", "a"], ["\u00e2", "a"], ["\u00e3", "a"], ["\u00e4", "a"], ["\u00e5", "a"], ["\u00e7", "c"], ["\u00e8", "e"], ["\u00e9", "e"], ["\u00ea", "e"], ["\u00eb", "e"], ["\u00ec", "i"], ["\u00ed", "i"], ["\u00ee", "i"], ["\u00ef", "i"], ["\u00f1", "n"], ["\u00f2", "o"], ["\u00f3", "o"], ["\u00f4", "o"], ["\u00f5", +;var da = [["\u00aa", "a"], ["\u00b2", "2"], ["\u00b3", "3"], ["\u00b9", "1"], ["\u00ba", "o"], ["\u00bc", "1\u20444"], ["\u00bd", "1\u20442"], ["\u00be", "3\u20444"], ["\u00e0", "a"], ["\u00e1", "a"], ["\u00e2", "a"], ["\u00e3", "a"], ["\u00e4", "a"], ["\u00e5", "a"], ["\u00e7", "c"], ["\u00e8", "e"], ["\u00e9", "e"], ["\u00ea", "e"], ["\u00eb", "e"], ["\u00ec", "i"], ["\u00ed", "i"], ["\u00ee", "i"], ["\u00ef", "i"], ["\u00f1", "n"], ["\u00f2", "o"], ["\u00f3", "o"], ["\u00f4", "o"], ["\u00f5", "o"], ["\u00f6", "o"], ["\u00f9", "u"], ["\u00fa", "u"], ["\u00fb", "u"], ["\u00fc", "u"], ["\u00fd", "y"], ["\u00ff", "y"], ["\u0101", "a"], ["\u0103", "a"], ["\u0105", "a"], ["\u0107", "c"], ["\u0109", "c"], ["\u010b", "c"], ["\u010d", "c"], ["\u010f", "d"], ["\u0113", "e"], ["\u0115", "e"], ["\u0117", "e"], ["\u0119", "e"], ["\u011b", "e"], ["\u011d", "g"], ["\u011f", "g"], ["\u0121", "g"], ["\u0123", "g"], ["\u0125", "h"], ["\u0129", "i"], ["\u012b", "i"], ["\u012d", "i"], ["\u012f", "i"], ["\u0133", "ij"], ["\u0135", "j"], ["\u0137", "k"], ["\u013a", "l"], ["\u013c", "l"], ["\u013e", "l"], ["\u0140", "l"], ["\u0144", "n"], ["\u0146", "n"], ["\u0148", "n"], ["\u0149", "n"], ["\u014d", "o"], ["\u014f", "o"], ["\u0151", "o"], ["\u0155", "r"], ["\u0157", "r"], ["\u0159", "r"], ["\u015b", "s"], ["\u015d", "s"], ["\u015f", "s"], ["\u0161", "s"], ["\u0163", "t"], ["\u0165", "t"], ["\u0169", "u"], ["\u016b", "u"], ["\u016d", "u"], ["\u016f", "u"], ["\u0171", "u"], ["\u0173", "u"], ["\u0175", "w"], ["\u0177", "y"], ["\u017a", "z"], ["\u017c", "z"], ["\u017e", "z"], ["\u017f", "s"], ["\u01a1", "o"], ["\u01b0", "u"], ["\u01c6", "dz"], ["\u01c9", "lj"], ["\u01cc", "nj"], ["\u01ce", "a"], ["\u01d0", "i"], ["\u01d2", "o"], ["\u01d4", "u"], ["\u01d6", "u"], ["\u01d8", "u"], ["\u01da", "u"], ["\u01dc", "u"], ["\u01df", "a"], ["\u01e1", "a"], ["\u01e3", "ae"], ["\u00e6", "ae"], ["\u01fd", "ae"], ["\u01e7", "g"], ["\u01e9", "k"], ["\u01eb", "o"], ["\u01ed", "o"], ["\u01ef", "\u0292"], ["\u01f0", "j"], ["\u01f3", @@ -84,16 +84,16 @@ function ba(a) { ["\u02b2", "j"], ["\u02b3", "r"], ["\u02b4", "\u0279"], ["\u02b5", "\u027b"], ["\u02b6", "\u0281"], ["\u02b7", "w"], ["\u02b8", "y"], ["\u02e0", "\u0263"], ["\u02e1", "l"], ["\u02e2", "s"], ["\u02e3", "x"], ["\u02e4", "\u0295"], ["\u0390", "\u03b9"], ["\u03ac", "\u03b1"], ["\u03ad", "\u03b5"], ["\u03ae", "\u03b7"], ["\u03af", "\u03b9"], ["\u03b0", "\u03c5"], ["\u03ca", "\u03b9"], ["\u03cb", "\u03c5"], ["\u03cc", "\u03bf"], ["\u03cd", "\u03c5"], ["\u03ce", "\u03c9"], ["\u03d0", "\u03b2"], ["\u03d1", "\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db", "\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]]; -const da = /[^\p{L}\p{N}]+/u, ea = /(\d{3})/g, fa = /(\D)(\d{3})/g, ha = /(\d{3})(\D)/g, ia = "".normalize && /[\u0300-\u036f]/g; -function L(a) { - if (!this || this.constructor !== L) { - return new L(...arguments); +const ea = /[^\p{L}\p{N}]+/u, fa = /(\d{3})/g, ha = /(\D)(\d{3})/g, ia = /(\d{3})(\D)/g, ja = "".normalize && /[\u0300-\u036f]/g; +function J(a) { + if (!this || this.constructor !== J) { + return new J(...arguments); } for (let b = 0; b < arguments.length; b++) { this.assign(arguments[b]); } } -t = L.prototype; +t = J.prototype; t.assign = function(a) { this.normalize = A(a.normalize, !0, this.normalize); let b = a.include, c = b || a.exclude || a.split, e; @@ -121,7 +121,7 @@ t.assign = function(a) { this.numeric = A(a.numeric, e); } else { try { - this.split = A(this.split, da); + this.split = A(this.split, ea); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } @@ -129,7 +129,7 @@ t.assign = function(a) { } this.prepare = A(a.prepare, null, this.prepare); this.finalize = A(a.finalize, null, this.finalize); - ia || (this.mapper = new Map(ca)); + ja || (this.mapper = new Map(da)); this.rtl = A(a.rtl, !1, this.rtl); this.dedupe = A(a.dedupe, !1, this.dedupe); this.filter = A((c = a.filter) && new Set(c), null, this.filter); @@ -163,13 +163,13 @@ t.addStemmer = function(a, b) { this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; this.N = null; - this.cache && M(this); + this.cache && L(this); return this; }; t.addFilter = function(a) { this.filter || (this.filter = new Set()); this.filter.add(a); - this.cache && M(this); + this.cache && L(this); return this; }; t.addMapper = function(a, b) { @@ -181,7 +181,7 @@ t.addMapper = function(a, b) { } this.mapper || (this.mapper = new Map()); this.mapper.set(a, b); - this.cache && M(this); + this.cache && L(this); return this; }; t.addMatcher = function(a, b) { @@ -195,7 +195,7 @@ t.addMatcher = function(a, b) { this.matcher.set(a, b); this.h += (this.h ? "|" : "") + a; this.M = null; - this.cache && M(this); + this.cache && L(this); return this; }; t.addReplacer = function(a, b) { @@ -204,7 +204,7 @@ t.addReplacer = function(a, b) { } this.replacer || (this.replacer = []); this.replacer.push(a, b); - this.cache && M(this); + this.cache && L(this); return this; }; t.encode = function(a) { @@ -214,12 +214,12 @@ t.encode = function(a) { return this.B.get(a); } } else { - this.H = setTimeout(M, 50, this); + this.H = setTimeout(L, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ia ? a.normalize("NFKD").replace(ia, "").toLowerCase() : a.toLowerCase()); + this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ja ? a.normalize("NFKD").replace(ja, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(fa, "$1 $2").replace(ha, "$1 $2").replace(ea, "$1 ")); + this.numeric && 3 < a.length && (a = a.replace(ha, "$1 $2").replace(ia, "$1 $2").replace(fa, "$1 ")); const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let c = [], e = this.split || "" === this.split ? a.split(this.split) : a; for (let f = 0, g, k; f < e.length; f++) { @@ -236,7 +236,7 @@ t.encode = function(a) { continue; } } else { - this.H = setTimeout(M, 50, this); + this.H = setTimeout(L, 50, this); } } this.stemmer && 2 < g.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), g = g.replace(this.N, h => this.stemmer.get(h)), g.length < this.minlength || this.filter && this.filter.has(g)) && (g = ""); @@ -263,12 +263,12 @@ t.encode = function(a) { 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 M(a) { +function L(a) { a.H = null; a.B.clear(); a.G.clear(); } -;async function ja(a) { +;async function ka(a) { a = a.data; var b = self._index; const c = a.args; @@ -276,15 +276,15 @@ function M(a) { switch(e) { case "init": e = a.options || {}; - (b = a.factory) ? (Function("return " + b)()(self), self._index = new self.FlexSearch.Index(e), delete self.FlexSearch) : self._index = new N(e); + (b = a.factory) ? (Function("return " + b)()(self), self._index = new self.FlexSearch.Index(e), delete self.FlexSearch) : self._index = new M(e); postMessage({id:a.id}); break; default: a = a.id, b = b[e].apply(b, c), postMessage("search" === e ? {id:a, msg:b} : {id:a}); } } -;let ka = 0; -function O(a = {}) { +;let la = 0; +function N(a = {}) { function b(g) { function k(h) { h = h.data || h; @@ -297,67 +297,86 @@ function O(a = {}) { e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { return new Promise(function(h) { - d.h[++ka] = function() { + d.h[++la] = function() { h(d); }; - d.worker.postMessage({id:ka, task:"init", factory:c, options:a}); + d.worker.postMessage({id:la, task:"init", factory:c, options:a}); }); } this.worker.postMessage({task:"init", factory:c, options:a}); return this; } } - if (!this || this.constructor !== O) { - return new O(a); + if (!this || this.constructor !== N) { + return new N(a); } let c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; c && (c = c.toString()); - const e = "undefined" === typeof window, d = this, f = la(c, e, a.worker); + const e = "undefined" === typeof window, d = this, f = ma(c, e, a.worker); return f.then ? f.then(function(g) { return b.call(d, g); }) : b.call(this, f); } -P("add"); -P("append"); -P("search"); -P("update"); -P("remove"); -function P(a) { - O.prototype[a] = O.prototype[a + "Async"] = async function() { +O("add"); +O("append"); +O("search"); +O("update"); +O("remove"); +function O(a) { + N.prototype[a] = N.prototype[a + "Async"] = async function() { const b = this, c = [].slice.call(arguments); var e = c[c.length - 1]; let d; "function" === typeof e && (d = e, c.splice(c.length - 1, 1)); e = new Promise(function(f) { - b.h[++ka] = f; - b.worker.postMessage({task:a, id:ka, args:c}); + b.h[++la] = f; + b.worker.postMessage({task:a, id:la, args:c}); }); return d ? (e.then(d), this) : e; }; } -function la(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"](import.meta.dirname + "/node/node.mjs"); }) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ja.toString()], {type:"text/javascript"}))) : new window.Worker(E(c) ? c : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function ma(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"](import.meta.dirname + "/node/node.mjs"); }) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker(E(c) ? c : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function ma(a) { - Q.call(a, "add"); - Q.call(a, "append"); - Q.call(a, "search"); - Q.call(a, "update"); - Q.call(a, "remove"); +;function na(a) { + P.call(a, "add"); + P.call(a, "append"); + P.call(a, "search"); + P.call(a, "update"); + P.call(a, "remove"); } -function Q(a) { +let Q, oa; +const pa = {}, R = {}; +function qa(a) { + Q = 0; + pa[a] = R[a]; +} +function P(a) { this[a + "Async"] = function() { - var b = arguments; - const c = b[b.length - 1]; + const b = arguments; + var c = b[b.length - 1]; let e; "function" === typeof c && (e = c, delete b[b.length - 1]); - b = this[a].apply(this, b); - e && (b.then ? b.then(e) : e(b)); - return b; + Q || (Q = setTimeout(qa, 0, a), oa = Date.now()); + R[a] || (R[a] = pa[a] = 1000); + if (!--pa[a]) { + pa[a] = R[a] = R[a] * this.priority * this.priority * 3 / (Date.now() - oa) | 0 || 1; + Q = clearTimeout(Q); + 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; }; } -;function na(a, b = 0) { +;function ra(a, b = 0) { let c = [], e = []; b && (b = 250000 / b * 5000 | 0); for (const d of a.entries()) { @@ -366,30 +385,30 @@ function Q(a) { e.length && c.push(e); return c; } -function oa(a, b) { +function sa(a, b) { b || (b = new Map()); for (let c = 0, e; c < a.length; c++) { e = a[c], b.set(e[0], e[1]); } return b; } -function pa(a, b = 0) { +function ta(a, b = 0) { let c = [], e = []; b && (b = 250000 / b * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], na(d[1])[0]]), e.length === b && (c.push(e), e = []); + e.push([d[0], ra(d[1])[0]]), e.length === b && (c.push(e), e = []); } e.length && c.push(e); return c; } -function qa(a, b) { +function ua(a, b) { b || (b = new Map()); for (let c = 0, e, d; c < a.length; c++) { - e = a[c], d = b.get(e[0]), b.set(e[0], oa(e[1], d)); + e = a[c], d = b.get(e[0]), b.set(e[0], sa(e[1], d)); } return b; } -function ra(a) { +function va(a) { let b = [], c = []; for (const e of a.keys()) { c.push(e), 250000 === c.length && (b.push(c), c = []); @@ -397,14 +416,14 @@ function ra(a) { c.length && b.push(c); return b; } -function sa(a, b) { +function wa(a, b) { b || (b = new Set()); for (let c = 0; c < a.length; c++) { b.add(a[c]); } return b; } -function ta(a, b, c, e, d, f, g = 0) { +function xa(a, b, c, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { @@ -413,12 +432,12 @@ function ta(a, b, c, e, d, f, g = 0) { if ((h = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(h))) && h.then) { const l = this; return h.then(function() { - return ta.call(l, a, b, c, k ? e : null, d, f, g + 1); + return xa.call(l, a, b, c, k ? e : null, d, f, g + 1); }); } - return ta.call(this, a, b, c, k ? e : null, d, f, g + 1); + return xa.call(this, a, b, c, k ? e : null, d, f, g + 1); } -;function ua(a, b, c, e) { +;function ya(a, b, c, e) { let d = []; for (let f = 0, g; f < a.index.length; f++) { if (g = a.index[f], b >= g.length) { @@ -434,9 +453,9 @@ function ta(a, b, c, e, d, f, g = 0) { } return d; } -function R(a) { +function S(a) { if (!this) { - return new R(a); + return new S(a); } this.index = a ? [a] : []; this.length = a ? a.length : 0; @@ -484,12 +503,12 @@ function R(a) { } if ("slice" === e) { return function(d, f) { - return ua(b, d || 0, f || b.length, !1); + return ya(b, d || 0, f || b.length, !1); }; } if ("splice" === e) { return function(d, f) { - return ua(b, d || 0, f || b.length, !0); + return ya(b, d || 0, f || b.length, !0); }; } if ("constructor" === e) { @@ -505,81 +524,81 @@ function R(a) { return !0; }}); } -R.prototype.clear = function() { +S.prototype.clear = function() { this.index.length = 0; }; -R.prototype.destroy = function() { +S.prototype.destroy = function() { this.proxy = this.index = null; }; -R.prototype.push = function() { -}; -function S(a = 8) { - if (!this) { - return new S(a); - } - this.index = B(); - this.B = []; - this.size = 0; - 32 < a ? (this.h = va, this.A = BigInt(a)) : (this.h = wa, this.A = a); -} -S.prototype.get = function(a) { - const b = this.index[this.h(a)]; - return b && b.get(a); -}; -S.prototype.set = function(a, b) { - var c = this.h(a); - let e = this.index[c]; - e ? (c = e.size, e.set(a, b), (c -= e.size) && this.size++) : (this.index[c] = e = new Map([[a, b]]), this.B.push(e)); +S.prototype.push = function() { }; function T(a = 8) { if (!this) { return new T(a); } this.index = B(); - this.h = []; - 32 < a ? (this.B = va, this.A = BigInt(a)) : (this.B = wa, this.A = a); + this.B = []; + this.size = 0; + 32 < a ? (this.h = za, this.A = BigInt(a)) : (this.h = Aa, this.A = a); } -T.prototype.add = function(a) { +T.prototype.get = function(a) { + const b = this.index[this.h(a)]; + return b && b.get(a); +}; +T.prototype.set = function(a, b) { + var c = this.h(a); + let e = this.index[c]; + e ? (c = e.size, e.set(a, b), (c -= e.size) && this.size++) : (this.index[c] = e = new Map([[a, b]]), this.B.push(e)); +}; +function U(a = 8) { + if (!this) { + return new U(a); + } + this.index = B(); + this.h = []; + 32 < a ? (this.B = za, this.A = BigInt(a)) : (this.B = Aa, this.A = a); +} +U.prototype.add = function(a) { 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)); }; -t = S.prototype; -t.has = T.prototype.has = function(a) { +t = T.prototype; +t.has = U.prototype.has = function(a) { const b = this.index[this.B(a)]; return b && b.has(a); }; -t.delete = T.prototype.delete = function(a) { +t.delete = U.prototype.delete = function(a) { const b = this.index[this.B(a)]; b && b.delete(a) && this.size--; }; -t.clear = T.prototype.clear = function() { +t.clear = U.prototype.clear = function() { this.index = B(); this.h = []; this.size = 0; }; -t.values = T.prototype.values = function*() { +t.values = U.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].values()) { yield b; } } }; -t.keys = T.prototype.keys = function*() { +t.keys = U.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].keys()) { yield b; } } }; -t.entries = T.prototype.entries = function*() { +t.entries = U.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].entries()) { yield b; } } }; -function wa(a) { +function Aa(a) { let b = 2 ** this.A - 1; if ("number" == typeof a) { return a & b; @@ -590,7 +609,7 @@ function wa(a) { } return 32 === this.A ? c + 2 ** 31 : c; } -function va(a) { +function za(a) { let b = BigInt(2) ** this.A - BigInt(1); var c = typeof a; if ("bigint" === c) { @@ -606,8 +625,8 @@ function va(a) { } return c; } -;U.prototype.add = function(a, b, c) { - I(a) && (b = a, a = J(b, this.key)); +;V.prototype.add = function(a, b, c) { + I(a) && (b = a, a = ba(b, this.key)); if (b && (a || 0 === a)) { if (!c && this.reg.has(a)) { return this.update(a, b); @@ -620,7 +639,7 @@ function va(a) { d && e.add(a, d, !1, !0); } else { if (d = h.I, !d || d(b)) { - h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), xa(b, h, this.J, 0, e, a, h[0], c); + h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Ba(b, h, this.J, 0, e, a, h[0], c); } } } @@ -639,14 +658,14 @@ function va(a) { continue; } f.constructor === String && (f = "" + f); - f = J(b, f); + f = ba(b, f); } if (d && f) { E(f) && (f = [f]); for (let h = 0, l, m; h < f.length; h++) { if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), !c || !m.includes(a))) { if (m.length === 2 ** 31 - 1) { - g = new R(m); + g = new S(m); if (this.fastupdate) { for (let n of this.reg.values()) { n.includes(m) && (n[n.indexOf(m)] = g); @@ -683,7 +702,7 @@ function va(a) { k[l] = b[l]; continue; } - ya(b, k, l, 0, l[0], m); + Ca(b, k, l, 0, l[0], m); } } this.store.set(a, k || b); @@ -691,21 +710,21 @@ function va(a) { } return this; }; -function ya(a, b, c, e, d, f) { +function Ca(a, b, c, e, d, f) { a = a[d]; if (e === c.length - 1) { b[d] = f || a; } else if (a) { if (a.constructor === Array) { for (b = b[d] = Array(a.length), d = 0; d < a.length; d++) { - ya(a, b, c, e, d); + Ca(a, b, c, e, d); } } else { - b = b[d] || (b[d] = B()), d = c[++e], ya(a, b, c, e, d); + b = b[d] || (b[d] = B()), d = c[++e], Ca(a, b, c, e, d); } } } -function xa(a, b, c, e, d, f, g, k) { +function Ba(a, b, c, e, d, f, g, k) { if (a = a[g]) { if (e === b.length - 1) { if (a.constructor === Array) { @@ -721,17 +740,17 @@ function xa(a, b, c, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - xa(a, b, c, e, d, f, g, k); + Ba(a, b, c, e, d, f, g, k); } } else { - g = b[++e], xa(a, b, c, e, d, f, g, k); + g = b[++e], Ba(a, b, c, e, d, f, g, k); } } } else { d.db && d.remove(f); } } -;function za(a, b, c, e, d, f, g) { +;function Da(a, b, c, e, d, f, g) { const k = a.length; let h = [], l; var m; @@ -747,7 +766,7 @@ function xa(a, b, c, e, d, f, g, k) { } if (a = h.length) { if (d) { - h = 1 < h.length ? Aa(h, c, e, g, f) : (h = h[0]).length > c || e ? h.slice(e, c + e) : h; + h = 1 < h.length ? Ea(h, c, e, g, f) : (h = h[0]).length > c || e ? h.slice(e, c + e) : h; } else { if (a < k) { return []; @@ -780,7 +799,7 @@ function xa(a, b, c, e, d, f, g, k) { } return h; } -function Aa(a, b, c, e, d) { +function Ea(a, b, c, e, d) { const f = [], g = B(); let k; var h = a.length; @@ -825,7 +844,7 @@ function Aa(a, b, c, e, d) { } return f; } -function Ba(a, b, c) { +function Fa(a, b, c) { const e = B(), d = []; for (let f = 0, g; f < b.length; f++) { g = b[f]; @@ -846,12 +865,12 @@ function Ba(a, b, c) { } return d; } -;function Ca(a, b, c, e) { +;function Ga(a, b, c, e) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : 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, e ? W.call(this, a) : a; } let d = []; for (let f = 0, g, k; f < a.length; f++) { @@ -865,7 +884,7 @@ function Ba(a, b, c) { } k > b && (g = g.slice(0, b), k = b); if (!d.length && k >= b) { - return e ? V.call(this, g) : g; + return e ? W.call(this, g) : g; } d.push(g); b -= k; @@ -875,9 +894,9 @@ function Ba(a, b, c) { } } d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? V.call(this, d) : d; + return e ? W.call(this, d) : d; } -;function Da(a, b, c) { +;function Ha(a, b, c) { var e = c[0]; if (e.then) { return Promise.all(c).then(function(m) { @@ -892,7 +911,7 @@ function Ba(a, b, c) { for (let m = 0, n; m < c.length; m++) { if (n = c[m]) { let p; - if (n.constructor === W) { + if (n.constructor === X) { p = n.result; } else if (n.constructor === Array) { p = n; @@ -923,11 +942,11 @@ function Ba(a, b, c) { } return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; } -;W.prototype.or = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f} = Da(this, "or", arguments); - return Ea.call(this, a, b, c, e, d, f); +;X.prototype.or = function() { + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f} = Ha(this, "or", arguments); + return Ia.call(this, a, b, c, e, d, f); }; -function Ea(a, b, c, e, d, f) { +function Ia(a, b, c, e, d, f) { if (b.length) { const g = this; return Promise.all(b).then(function(k) { @@ -935,25 +954,25 @@ function Ea(a, b, c, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return Ea.call(g, a, [], c, e, d, f); + return Ia.call(g, a, [], c, e, d, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Aa(a, c, e, !1, this.h), e = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ea(a, c, e, !1, this.h), e = 0)); return f ? this.resolve(c, e, d) : this; } -;W.prototype.and = function() { +;X.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:k, offset:h, enrich:l, resolve:m, suggest:n} = Da(this, "and", arguments); - return Fa.call(this, f, g, k, h, l, m, n); + const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:n} = Ha(this, "and", arguments); + return Ja.call(this, f, g, k, h, l, m, n); } return d ? this.resolve(b, c, e) : this; }; -function Fa(a, b, c, e, d, f, g) { +function Ja(a, b, c, e, d, f, g) { if (b.length) { const k = this; return Promise.all(b).then(function(h) { @@ -961,15 +980,15 @@ function Fa(a, b, c, e, d, f, g) { for (let l = 0, m; l < h.length; l++) { (m = h[l]).length && (a[l] = m); } - return Fa.call(k, a, [], c, e, d, f, g); + return Ja.call(k, a, [], c, e, d, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (b = ba(a)) { - return this.result = za(a, b, c, e, g, this.h, f), f ? d ? V.call(this.index, this.result) : this.result : this; + if (b = ca(a)) { + return this.result = Da(a, b, c, e, g, this.h, f), f ? d ? W.call(this.index, this.result) : this.result : this; } this.result = []; } @@ -978,11 +997,11 @@ function Fa(a, b, c, e, d, f, g) { } 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} = Da(this, "xor", arguments); - return Ga.call(this, a, b, c, e, d, f, g); +;X.prototype.xor = function() { + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ha(this, "xor", arguments); + return Ka.call(this, a, b, c, e, d, f, g); }; -function Ga(a, b, c, e, d, f, g) { +function Ka(a, b, c, e, d, f, g) { if (b.length) { const k = this; return Promise.all(b).then(function(h) { @@ -990,21 +1009,21 @@ function Ga(a, b, c, e, d, f, g) { for (let l = 0, m; l < h.length; l++) { (m = h[l]).length && (a[l] = m); } - return Ga.call(k, a, [], c, e, d, f, g); + return Ka.call(k, a, [], c, e, d, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = Ha.call(this, a, c, e, f, this.h), f ? d ? V.call(this.index, this.result) : this.result : this; + return this.result = La.call(this, a, c, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(c, e, d) : this; } -function Ha(a, b, c, e, d) { +function La(a, b, c, e, d) { const f = [], g = B(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -1049,11 +1068,11 @@ function Ha(a, b, c, e, d) { } return f; } -;W.prototype.not = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Da(this, "not", arguments); - return Ia.call(this, a, b, c, e, d, f, g); +;X.prototype.not = function() { + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ha(this, "not", arguments); + return Ma.call(this, a, b, c, e, d, f, g); }; -function Ia(a, b, c, e, d, f, g) { +function Ma(a, b, c, e, d, f, g) { if (b.length) { const k = this; return Promise.all(b).then(function(h) { @@ -1061,17 +1080,17 @@ function Ia(a, b, c, e, d, f, g) { for (let l = 0, m; l < h.length; l++) { (m = h[l]).length && (a[l] = m); } - return Ia.call(k, a, [], c, e, d, f, g); + return Ma.call(k, a, [], c, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Ja.call(this, a, c, e, f); + this.result = Na.call(this, a, c, e, f); } else if (f) { return this.resolve(c, e, d); } - return f ? d ? V.call(this.index, this.result) : this.result : this; + return f ? d ? W.call(this.index, this.result) : this.result : this; } -function Ja(a, b, c, e) { +function Na(a, b, c, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, k = 0; f < this.result.length; f++) { @@ -1097,9 +1116,9 @@ function Ja(a, b, c, e) { } return d; } -;function W(a) { - if (!this || this.constructor !== W) { - return new W(a); +;function X(a) { + if (!this || this.constructor !== X) { + return new X(a); } if (a && a.index) { return a.resolve = !1, this.index = a.index, this.h = a.boost || 0, this.result = a.index.search(a).result, this; @@ -1108,44 +1127,48 @@ function Ja(a, b, c, e) { this.result = a || []; this.h = 0; } -W.prototype.limit = function(a) { +X.prototype.limit = function(a) { if (this.result.length) { const b = []; - let c = 0; - for (let e = 0, d; e < this.result.length; e++) { - if (d = this.result[e], d.length + c < a) { - b[e] = d, c += d.length; - } else { - b[e] = d.slice(0, a - c); - this.result = b; - break; + for (let c = 0, e; c < this.result.length; c++) { + if (e = this.result[c]) { + if (e.length <= a) { + if (b[c] = e, a -= e.length, !a) { + break; + } + } else { + b[c] = e.slice(0, a); + break; + } } } - } - return this; -}; -W.prototype.offset = function(a) { - if (this.result.length) { - const b = []; - let c = 0; - for (let e = 0, d; e < this.result.length; e++) { - d = this.result[e], d.length + c < a ? c += d.length : (b[e] = d.slice(a - c), c = a); - } this.result = b; } return this; }; -W.prototype.boost = function(a) { +X.prototype.offset = function(a) { + if (this.result.length) { + const b = []; + for (let c = 0, e; c < this.result.length; c++) { + if (e = this.result[c]) { + e.length <= a ? a -= e.length : (b[c] = e.slice(a), a = 0); + } + } + this.result = b; + } + return this; +}; +X.prototype.boost = function(a) { this.h += a; return this; }; -W.prototype.resolve = function(a, b, c) { +X.prototype.resolve = function(a, b, c) { const e = this.result, d = this.index; this.result = this.index = null; - return e.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ca.call(d, e, a || 100, b, c)) : e; + return e.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ga.call(d, e, a || 100, b, c)) : e; }; B(); -U.prototype.search = function(a, b, c, e) { +V.prototype.search = function(a, b, c, e) { c || (!b && I(a) ? (c = a, a = "") : I(b) && (c = b, b = 0)); let d = [], f = [], g; let k; @@ -1221,7 +1244,7 @@ U.prototype.search = function(a, b, c, e) { } q.push(r = r.db.tag(v[p + 1], b, l, u)); } else { - r = Ka.call(this, v[p], v[p + 1], b, l, u); + r = Oa.call(this, v[p], v[p + 1], b, l, u); } d.push({field:v[p], tag:v[p + 1], result:r}); } @@ -1268,32 +1291,32 @@ U.prototype.search = function(a, b, c, e) { if (K && K.length) { y++, x.push(K); } else if (!q) { - return r ? d : new W(d); + return r ? d : new X(d); } } } } else { - for (let G = 0, K, hb; G < p.length; G += 2) { + for (let G = 0, K, mb; G < p.length; G += 2) { K = this.tag.get(p[G]); if (!K) { if (console.warn("Tag '" + p[G] + ":" + p[G + 1] + "' will be skipped because there is no field '" + p[G] + "'."), q) { continue; } else { - return r ? d : new W(d); + return r ? d : new X(d); } } - if (hb = (K = K && K.get(p[G + 1])) && K.length) { + if (mb = (K = K && K.get(p[G + 1])) && K.length) { y++, x.push(K); } else if (!q) { - return r ? d : new W(d); + return r ? d : new X(d); } } } if (y) { - w = Ba(w, x, r); + w = Fa(w, x, r); H = w.length; if (!H && !q) { - return r ? w : new W(w); + return r ? w : new X(w); } y--; } @@ -1301,7 +1324,7 @@ U.prototype.search = function(a, b, c, e) { if (H) { f[m] = D, d.push(w), m++; } else if (1 === h.length) { - return r ? d : new W(d); + return r ? d : new X(d); } } if (v) { @@ -1312,7 +1335,7 @@ U.prototype.search = function(a, b, c, e) { if (console.warn("Tag '" + p[u] + ":" + p[u + 1] + "' was not found because there is no field '" + p[u] + "'."), q) { continue; } else { - return r ? d : new W(d); + return r ? d : new X(d); } } v.push(e.db.tag(p[u + 1], b, l, !1)); @@ -1324,7 +1347,7 @@ U.prototype.search = function(a, b, c, e) { }); } if (!m) { - return r ? d : new W(d); + return r ? d : new X(d); } if (g && (!u || !this.store)) { return d[0]; @@ -1332,9 +1355,9 @@ U.prototype.search = function(a, b, c, e) { v = []; for (let z = 0, w; z < f.length; z++) { w = d[z]; - u && w.length && !w[0].doc && (this.db ? v.push(w = this.index.get(this.field[0]).db.enrich(w)) : w = V.call(this, w)); + u && w.length && !w[0].doc && (this.db ? v.push(w = this.index.get(this.field[0]).db.enrich(w)) : w = W.call(this, w)); if (g) { - return r ? w : new W(w); + return r ? w : new X(w); } d[z] = {field:f[z], result:w}; } @@ -1344,12 +1367,12 @@ U.prototype.search = function(a, b, c, e) { for (let D = 0; D < w.length; D++) { d[D].result = w[D]; } - return k ? La(d, b) : n ? Ma(d, a, z.index, z.field, z.D, n) : d; + return k ? Pa(d, b) : n ? Qa(d, a, z.index, z.field, z.D, n) : d; }); } - return k ? La(d, b) : n ? Ma(d, a, this.index, this.field, this.D, n) : d; + return k ? Pa(d, b) : n ? Qa(d, a, this.index, this.field, this.D, n) : d; }; -function Ma(a, b, c, e, d, f) { +function Qa(a, b, c, e, d, f) { let g, k, h; for (let m = 0, n, p, q, r, u; m < a.length; m++) { n = a[m].result; @@ -1361,7 +1384,7 @@ function Ma(a, b, c, e, d, f) { q !== g && (g = q, k = g.encode(b)); for (let v = 0; v < n.length; v++) { let x = ""; - var l = J(n[v].doc, u); + var l = ba(n[v].doc, u); let y = g.encode(l); l = l.split(g.split); for (let F = 0, z, w; F < y.length; F++) { @@ -1391,7 +1414,7 @@ function Ma(a, b, c, e, d, f) { } return a; } -function La(a, b) { +function Pa(a, b) { const c = [], e = B(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1410,7 +1433,7 @@ function La(a, b) { } return c; } -function Ka(a, b, c, e, d) { +function Oa(a, b, c, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1419,11 +1442,11 @@ function Ka(a, b, c, e, d) { if (a > c || e) { f = f.slice(e, e + c); } - d && (f = V.call(this, f)); + d && (f = W.call(this, f)); return f; } } -function V(a) { +function W(a) { if (!this || !this.store) { return a; } @@ -1433,24 +1456,24 @@ function V(a) { } return b; } -;function U(a) { - if (!this || this.constructor !== U) { - return new U(a); +;function V(a) { + if (!this || this.constructor !== V) { + return new V(a); } const b = a.document || a.doc || a; let c, e; this.D = []; this.field = []; this.J = []; - this.key = (c = b.key || b.id) && Na(c, this.J) || "id"; + this.key = (c = b.key || b.id) && Ra(c, this.J) || "id"; (e = a.keystore || 0) && (this.keystore = e); - this.reg = (this.fastupdate = !!a.fastupdate) ? e ? new S(e) : new Map() : e ? new T(e) : new Set(); + this.reg = (this.fastupdate = !!a.fastupdate) ? e ? new T(e) : new Map() : e ? new U(e) : new Set(); this.C = (c = b.store || null) && c && !0 !== c && []; - this.store = c && (e ? new S(e) : new Map()); - this.cache = (c = a.cache || null) && new X(c); + this.store = c && (e ? new T(e) : new Map()); + this.cache = (c = a.cache || null) && new Y(c); a.cache = !1; this.worker = a.worker; - this.index = Oa.call(this, a, b); + this.index = Sa.call(this, a, b); this.tag = null; if (c = b.tag) { if ("string" === typeof c && (c = [c]), c.length) { @@ -1463,7 +1486,7 @@ function V(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.F[d] = f.custom : (this.F[d] = Na(g, this.J), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = f.filter)); + f.custom ? this.F[d] = f.custom : (this.F[d] = Ra(g, this.J), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = f.filter)); this.R[d] = g; this.tag.set(g, new Map()); } @@ -1489,14 +1512,14 @@ function V(a) { a.db && this.mount(a.db); } } -t = U.prototype; +t = V.prototype; t.mount = function(a) { let b = this.field; if (this.tag) { for (let d = 0, f; d < this.R.length; d++) { f = this.R[d]; var c = void 0; - this.index.set(f, c = new N({}, this.reg)); + this.index.set(f, c = new M({}, this.reg)); b === this.field && (b = b.slice(0)); b.push(f); c.tag = this.tag.get(f); @@ -1531,7 +1554,7 @@ t.destroy = function() { } return Promise.all(a); }; -function Oa(a, b) { +function Sa(a, b) { const c = new Map(); let e = b.index || b.field || b; E(e) && (e = [e]); @@ -1540,23 +1563,23 @@ function Oa(a, b) { E(f) || (g = f, f = f.field); g = I(g) ? Object.assign({}, a, g) : a; if (this.worker) { - const k = new O(g); + const k = new N(g); c.set(f, k); } - this.worker || c.set(f, new N(g, this.reg)); - g.custom ? this.D[d] = g.custom : (this.D[d] = Na(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); + this.worker || c.set(f, new M(g, this.reg)); + g.custom ? this.D[d] = g.custom : (this.D[d] = Ra(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); this.field[d] = f; } if (this.C) { a = b.store; E(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] = Na(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = Ra(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); } } return c; } -function Na(a, b) { +function Ra(a, b) { const c = a.split(":"); let e = 0; for (let d = 0; d < c.length; d++) { @@ -1572,7 +1595,7 @@ t.update = function(a, b) { return this.remove(a).add(a, b); }; t.remove = function(a) { - I(a) && (a = J(a, this.key)); + I(a) && (a = ba(a, this.key)); for (var b of this.index.values()) { b.remove(a, !0); } @@ -1622,7 +1645,7 @@ t.set = function(a, b) { this.store.set(a, b); return this; }; -t.searchCache = Pa; +t.searchCache = Ta; t.export = function(a, b, c = 0, e = 0) { if (c < this.field.length) { const g = this.field[c]; @@ -1638,28 +1661,27 @@ t.export = function(a, b, c = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = ra(this.reg); + f = va(this.reg); b = null; break; case 1: d = "tag"; - f = pa(this.tag, this.reg.size); + f = ta(this.tag, this.reg.size); b = null; break; case 2: d = "doc"; - f = na(this.store); + f = ra(this.store); b = null; break; case 3: d = "cfg"; - f = {}; - b = null; + b = f = null; break; default: return; } - return ta.call(this, a, b, d, f, c, e); + return xa.call(this, a, b, d, f, c, e); }; t.import = function(a, b) { if (b) { @@ -1674,23 +1696,23 @@ t.import = function(a, b) { switch(a) { case "reg": this.fastupdate = !1; - this.reg = sa(b, this.reg); + this.reg = wa(b, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; case "tag": - this.tag = qa(b, this.tag); + this.tag = ua(b, this.tag); break; case "doc": - this.store = oa(b, this.store); + this.store = sa(b, this.store); } } }; -ma(U.prototype); -function Pa(a, b, c) { +na(V.prototype); +function Ta(a, b, c) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new X()); + this.cache || (this.cache = new Y()); let e = this.cache.get(a); if (!e) { e = this.search(a, b, c); @@ -1705,56 +1727,56 @@ function Pa(a, b, c) { } return e; } -function X(a) { +function Y(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -X.prototype.set = function(a, b) { +Y.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) { +Y.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) { +Y.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() { +Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Qa = {normalize:function(a) { +const Ua = {normalize:function(a) { return a.toLowerCase(); -}, numeric:!1, dedupe:!1}; -const Ra = 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 Sa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Ta = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -const Ua = {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}; -const Va = /[\x00-\x7F]+/g; -const Wa = /[\x00-\x7F]+/g; -const Xa = /[\x00-\x7F]+/g; -var Ya = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Qa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ra}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ra, matcher:Sa, replacer:Ta}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ra, replacer:Ta.concat([/(?!^)[aeo]/g, ""]), matcher:Sa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +}}; +const Va = 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 Wa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Xa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const Ya = {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}; +const Za = /[\x00-\x7F]+/g; +const $a = /[\x00-\x7F]+/g; +const ab = /[\x00-\x7F]+/g; +var bb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ua, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Va}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Va, matcher:Wa, replacer:Xa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Va, replacer:Xa.concat([/(?!^)[aeo]/g, ""]), matcher:Wa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let c = 0; c < a.length; c++) { var b = a[c]; - let e = b.charAt(0), d = Ua[e]; - for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = Ua[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = b.charAt(0), d = Ya[e]; + for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = Ya[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[c] = e; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Va, " "); + return ("" + a).replace(Za, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Wa, ""); + return ("" + a).replace($a, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Xa, " "); + return ("" + a).replace(ab, " "); }}}; -const Za = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; -N.prototype.add = function(a, b, c, e) { +const cb = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +M.prototype.add = function(a, b, c, e) { if (b && (a || 0 === a)) { if (!e && !c && this.reg.has(a)) { return this.update(a, b); @@ -1766,15 +1788,15 @@ N.prototype.add = function(a, b, c, e) { let r = b[this.rtl ? e - 1 - q : q]; var d = r.length; if (d && (n || !m[r])) { - var f = this.score ? this.score(b, r, q, null, 0) : $a(p, e, q), g = ""; + var f = this.score ? this.score(b, r, q, null, 0) : db(p, e, q), g = ""; switch(this.tokenize) { case "full": if (2 < d) { for (f = 0; f < d; f++) { for (var k = d; k > f; k--) { g = r.substring(f, k); - var h = this.score ? this.score(b, r, q, g, f) : $a(p, e, q, d, f); - Y(this, m, g, h, a, c); + var h = this.score ? this.score(b, r, q, g, f) : db(p, e, q, d, f); + eb(this, m, g, h, a, c); } } break; @@ -1782,24 +1804,24 @@ N.prototype.add = function(a, b, c, e) { case "reverse": if (1 < d) { for (k = d - 1; 0 < k; k--) { - g = r[k] + g, h = this.score ? this.score(b, r, q, g, k) : $a(p, e, q, d, k), Y(this, m, g, h, a, c); + g = r[k] + g, h = this.score ? this.score(b, r, q, g, k) : db(p, e, q, d, k), eb(this, m, g, h, a, c); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += r[k], Y(this, m, g, f, a, c); + g += r[k], eb(this, m, g, f, a, c); } break; } default: - if (Y(this, m, r, f, a, c), n && 1 < e && q < e - 1) { + if (eb(this, m, r, f, a, c), n && 1 < e && q < e - 1) { for (d = B(), g = this.U, f = r, k = Math.min(n + 1, e - q), d[f] = 1, h = 1; h < k; h++) { if ((r = b[this.rtl ? e - 1 - q - h : q + h]) && !d[r]) { d[r] = 1; - const u = this.score ? this.score(b, f, q, r, h) : $a(g + (e / 2 > g ? 0 : 1), e, q, k - 1, h - 1), v = this.bidirectional && r > f; - Y(this, l, v ? f : r, u, a, c, v ? r : f); + const u = this.score ? this.score(b, f, q, r, h) : db(g + (e / 2 > g ? 0 : 1), e, q, k - 1, h - 1), v = this.bidirectional && r > f; + eb(this, l, v ? f : r, u, a, c, v ? r : f); } } } @@ -1811,15 +1833,15 @@ N.prototype.add = function(a, b, c, e) { b = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.T && ab(this)); + this.db && (b || this.commit_task.push({del:a}), this.T && fb(this)); return this; }; -function Y(a, b, c, e, d, f, g) { +function eb(a, b, c, e, d, f, g) { let k = g ? a.ctx : a.map, h; if (!b[c] || g && !(h = b[c])[g]) { if (g ? (b = h || (b[c] = B()), 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[e] || (k[e] = []), !f || !k.includes(d)) { if (k.length === 2 ** 31 - 1) { - b = new R(k); + b = new S(k); if (a.fastupdate) { for (let l of a.reg.values()) { l.includes(k) && (l[l.indexOf(k)] = b); @@ -1832,10 +1854,10 @@ function Y(a, b, c, e, d, f, g) { } } } -function $a(a, b, c, e, d) { +function db(a, b, c, e, d) { return c && 1 < a ? b + (e || 0) <= a ? c + (d || 0) : (a - 1) / (b + (e || 0)) * (c + (d || 0)) + 1 | 0 : 0; } -;N.prototype.search = function(a, b, c) { +;M.prototype.search = function(a, b, c) { c || (!b && I(a) ? (c = a, a = "") : I(b) && (c = b, b = 0)); let e = [], d, f, g, k = 0, h, l, m, n, p; c ? (a = c.query || a, b = c.limit || b, k = c.offset || 0, f = c.context, g = c.suggest, p = (h = !1 !== c.resolve) && c.enrich, m = c.boost, n = c.resolution, l = this.db && c.tag) : h = this.resolve; @@ -1843,11 +1865,11 @@ function $a(a, b, c, e, d) { d = q.length; b = b || (h ? 100 : 0); if (1 === d) { - return bb.call(this, q[0], "", b, k, h, p, l); + return gb.call(this, q[0], "", b, k, h, p, l); } f = this.depth && !1 !== f; if (2 === d && f && !g) { - return bb.call(this, q[0], q[1], b, k, h, p, l); + return gb.call(this, q[0], q[1], b, k, h, p, l); } let r = B(), u = 0, v; 1 < d && f && (v = q[0], u = 1); @@ -1861,8 +1883,8 @@ function $a(a, b, c, e, d) { for (let y, F; u < d; u++) { if ((F = q[u]) && !r[F]) { r[F] = 1; - y = await cb(x, F, v, 0, 0, !1, !1); - if (y = db(y, e, g, n)) { + y = await hb(x, F, v, 0, 0, !1, !1); + if (y = ib(y, e, g, n)) { e = y; break; } @@ -1870,14 +1892,14 @@ function $a(a, b, c, e, d) { } g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); } - return eb(e, n, b, k, g, m, h); + return jb(e, n, b, k, g, m, h); }(); } for (let x, y; u < d; u++) { if ((y = q[u]) && !r[y]) { r[y] = 1; - x = cb(this, y, v, 0, 0, !1, !1); - if (x = db(x, e, g, n)) { + x = hb(this, y, v, 0, 0, !1, !1); + if (x = ib(x, e, g, n)) { e = x; break; } @@ -1885,24 +1907,24 @@ function $a(a, b, c, e, d) { } g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); } - return eb(e, n, b, k, g, m, h); + return jb(e, n, b, k, g, m, h); }; -function eb(a, b, c, e, d, f, g) { +function jb(a, b, c, e, d, f, g) { let k = a.length, h = a; if (1 < k) { - h = za(a, b, c, e, d, f, g); + h = Da(a, b, c, e, d, f, g); } else if (1 === k) { - return g ? Ca.call(null, a[0], c, e) : new W(a[0]); + return g ? Ga.call(null, a[0], c, e) : new X(a[0]); } - return g ? h : new W(h); + return g ? h : new X(h); } -function bb(a, b, c, e, d, f, g) { - a = cb(this, a, b, c, e, d, f, g); +function gb(a, b, c, e, d, f, g) { + a = hb(this, a, b, c, e, d, f, g); return this.db ? a.then(function(k) { - return d ? k || [] : new W(k); - }) : a && a.length ? d ? Ca.call(this, a, c, e) : new W(a) : d ? [] : new W(); + return d ? k || [] : new X(k); + }) : a && a.length ? d ? Ga.call(this, a, c, e) : new X(a) : d ? [] : new X(); } -function db(a, b, c, e) { +function ib(a, b, c, e) { let d = []; if (a && a.length) { if (a.length <= e) { @@ -1923,7 +1945,7 @@ function db(a, b, c, e) { return d; } } -function cb(a, b, c, e, d, f, g, k) { +function hb(a, b, c, e, d, f, g, k) { let h; c && (h = a.bidirectional && b > c) && (h = c, c = b, b = h); if (a.db) { @@ -1932,7 +1954,7 @@ function cb(a, b, c, e, d, f, g, k) { a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); return a; } -;N.prototype.remove = function(a, b) { +;M.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) { @@ -1947,15 +1969,15 @@ function cb(a, b, c, e, d, f, g, k) { } } } else { - fb(this.map, a), this.depth && fb(this.ctx, a); + kb(this.map, a), this.depth && kb(this.ctx, a); } b || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.T && ab(this)); + this.db && (this.commit_task.push({del:a}), this.T && fb(this)); this.cache && this.cache.remove(a); return this; }; -function fb(a, b) { +function kb(a, b) { let c = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1970,25 +1992,25 @@ function fb(a, b) { } } else { for (let e of a.entries()) { - const d = e[0], f = fb(e[1], b); + const d = e[0], f = kb(e[1], b); f ? c += f : a.delete(d); } } return c; } -;function N(a, b) { - if (!this || this.constructor !== N) { - return new N(a); +;function M(a, b) { + if (!this || this.constructor !== M) { + return new M(a); } if (a) { var c = E(a) ? a : a.preset; - c && (Za[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Za[c], a)); + c && (cb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, cb[c], a)); } else { a = {}; } c = a.context; - const e = !0 === c ? {depth:1} : c || {}, d = E(a.encoder) ? Ya[a.encoder] : a.encode || a.encoder || Qa; - this.encoder = d.encode ? d : "object" === typeof d ? new L(d) : {encode:d}; + const e = !0 === c ? {depth:1} : c || {}, d = E(a.encoder) ? bb[a.encoder] : a.encode || a.encoder || Ua; + this.encoder = d.encode ? d : "object" === typeof d ? new J(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = c = a.tokenize || "strict"; this.depth = "strict" === c && e.depth || 0; @@ -1996,12 +2018,12 @@ function fb(a, b) { 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.map = c ? new T(c) : new Map(); + this.ctx = c ? new T(c) : new Map(); + this.reg = b || (this.fastupdate ? c ? new T(c) : new Map() : c ? new U(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.cache = (c = a.cache || null) && new Y(c); this.resolve = !1 !== a.resolve; if (c = a.db) { this.db = this.mount(c); @@ -2009,8 +2031,9 @@ function fb(a, b) { this.T = !1 !== a.commit; this.commit_task = []; this.commit_timer = null; + this.priority = a.priority || 4; } -t = N.prototype; +t = M.prototype; t.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); @@ -2023,7 +2046,7 @@ t.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function ab(a) { +function fb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); @@ -2047,7 +2070,7 @@ 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); }; -function gb(a) { +function lb(a) { let b = 0; if (a.constructor === Array) { for (let c = 0, e; c < a.length; c++) { @@ -2055,7 +2078,7 @@ function gb(a) { } } else { for (const c of a) { - const e = c[0], d = gb(c[1]); + const e = c[0], d = lb(c[1]); d ? b += d : a.delete(e); } } @@ -2065,47 +2088,47 @@ t.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - gb(this.map); - this.depth && gb(this.ctx); + lb(this.map); + this.depth && lb(this.ctx); return this; }; -t.searchCache = Pa; +t.searchCache = Ta; t.export = function(a, b, c = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = ra(this.reg); + f = va(this.reg); break; case 1: d = "cfg"; - f = {}; + f = null; break; case 2: d = "map"; - f = na(this.map, this.reg.size); + f = ra(this.map, this.reg.size); break; case 3: d = "ctx"; - f = pa(this.ctx, this.reg.size); + f = ta(this.ctx, this.reg.size); break; default: return; } - return ta.call(this, a, b, d, f, c, e); + return xa.call(this, a, b, d, f, c, e); }; 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(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = sa(b, this.reg); + this.reg = wa(b, this.reg); break; case "map": - this.map = oa(b, this.map); + this.map = sa(b, this.map); break; case "ctx": - this.ctx = qa(b, this.ctx); + this.ctx = ua(b, this.ctx); } } }; @@ -2159,11 +2182,11 @@ t.serialize = function(a = !0) { d = "index.ctx=new Map([" + d + "]);"; return a ? "function inject(index){" + b + e + d + "}" : b + e + d; }; -ma(N.prototype); -const ib = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), jb = ["map", "ctx", "tag", "reg", "cfg"]; -function kb(a, b = {}) { +na(M.prototype); +const nb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), ob = ["map", "ctx", "tag", "reg", "cfg"]; +function pb(a, b = {}) { if (!this) { - return new kb(a, b); + return new pb(a, b); } "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -2174,7 +2197,7 @@ function kb(a, b = {}) { this.db = null; this.h = {}; } -t = kb.prototype; +t = pb.prototype; t.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -2186,10 +2209,10 @@ t.open = function() { let a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { - const e = ib.open(a.id + (a.field ? ":" + a.field : ""), 1); + const e = nb.open(a.id + (a.field ? ":" + a.field : ""), 1); e.onupgradeneeded = function() { const d = a.db = this.result; - jb.forEach(f => { + ob.forEach(f => { d.objectStoreNames.contains(f) || d.createObjectStore(f); }); }; @@ -2215,13 +2238,13 @@ t.close = function() { this.db = null; }; t.destroy = function() { - const a = ib.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); + const a = nb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); return Z(a); }; t.clear = function() { - const a = this.db.transaction(jb, "readwrite"); - for (let b = 0; b < jb.length; b++) { - a.objectStore(jb[b]).clear(); + const a = this.db.transaction(ob, "readwrite"); + for (let b = 0; b < ob.length; b++) { + a.objectStore(ob[b]).clear(); } return Z(a); }; @@ -2405,7 +2428,7 @@ t.commit = async function(a, b, c) { } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function lb(a, b, c) { +function qb(a, b, c) { const e = a.value; let d, f, g = 0; for (let k = 0, h; k < e.length; k++) { @@ -2434,17 +2457,17 @@ t.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && lb(c, a); + c && qb(c, a); }; }), this.transaction("ctx", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && lb(c, a); + c && qb(c, a); }; }), this.transaction("tag", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && lb(c, a, !0); + c && qb(c, a, !0); }; }), this.transaction("reg", "readwrite", function(b) { for (let c = 0; c < a.length; c++) { @@ -2464,6 +2487,6 @@ function Z(a) { a = null; }); } -;export default {Index:N, Charset:Ya, Encoder:L, Document:U, Worker:O, Resolver:W, IndexedDB:kb, Language:{}}; +;export default {Index:M, Charset:bb, Encoder:J, Document:V, Worker:N, Resolver:X, IndexedDB:pb, Language:{}}; -export const Index=N;export const Charset=Ya;export const Encoder=L;export const Document=U;export const Worker=O;export const Resolver=W;export const IndexedDB=kb;export const Language={}; \ No newline at end of file +export const Index=M;export const Charset=bb;export const Encoder=J;export const Document=V;export const Worker=N;export const Resolver=X;export const IndexedDB=pb;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js index 9040322..d359d0a 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -1,91 +1,92 @@ /**! - * FlexSearch.js v0.8.105 (Bundle/Module) + * FlexSearch.js v0.8.107 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ var t;function A(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(k){return a(c(k))};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 B(){return Object.create(null)}function E(a){return"string"===typeof a} -function I(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function J(a,b){if(E(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,da)}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);ia||(this.mapper=new Map(ca));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((c=a.filter)&&new Set(c),null,this.filter);this.matcher=A((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=A((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= +this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ea)}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);ja||(this.mapper=new Map(da));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((c=a.filter)&&new Set(c),null,this.filter);this.matcher=A((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=A((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= A((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=A(a.replacer,null,this.replacer);this.minlength=A(a.minlength,1,this.minlength);this.maxlength=A(a.maxlength,0,this.maxlength);if(this.cache=c=A(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&&M(this);return this};t.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&M(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&&M(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&&M(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(M,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.stemmer.get(h)),g.lengtha.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&&L(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&&L(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(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ja?a.normalize("NFKD").replace(ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),g.lengththis.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&d -this.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 M(a){a.H=null;a.B.clear();a.G.clear()};async function ja(a){a=a.data;var b=self._index;const c=a.args;var e=a.task;switch(e){case "init":e=a.options||{};(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new N(e);postMessage({id:a.id});break;default:a=a.id,b=b[e].apply(b,c),postMessage("search"===e?{id:a,msg:b}:{id:a})}};let ka=0; -function O(a={}){function b(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[++ka]=function(){h(d)};d.worker.postMessage({id:ka,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==O)return new O(a);let c="undefined"!==typeof self?self._factory:"undefined"!== -typeof window?window._factory:null;c&&(c=c.toString());const e="undefined"===typeof window,d=this,f=la(c,e,a.worker);return f.then?f.then(function(g){return b.call(d,g)}):b.call(this,f)}P("add");P("append");P("search");P("update");P("remove"); -function P(a){O.prototype[a]=O.prototype[a+"Async"]=async function(){const b=this,c=[].slice.call(arguments);var e=c[c.length-1];let d;"function"===typeof e&&(d=e,c.splice(c.length-1,1));e=new Promise(function(f){b.h[++ka]=f;b.worker.postMessage({task:a,id:ka,args:c})});return d?(e.then(d),this):e}} -function la(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"](import.meta.dirname + "/node/node.mjs"); }):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ja.toString()],{type:"text/javascript"}))):new window.Worker(E(c)?c:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", -"module/worker/worker.js"),{type:"module"})};function ma(a){Q.call(a,"add");Q.call(a,"append");Q.call(a,"search");Q.call(a,"update");Q.call(a,"remove")}function Q(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);b=this[a].apply(this,b);e&&(b.then?b.then(e):e(b));return b}};function na(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function oa(a,b){b||(b=new Map);for(let c=0,e;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} -function R(a){if(!this)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,k,h;gc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d=[];for(let n=0,p;ne)e-= +this.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 L(a){a.H=null;a.B.clear();a.G.clear()};async function ka(a){a=a.data;var b=self._index;const c=a.args;var e=a.task;switch(e){case "init":e=a.options||{};(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new M(e);postMessage({id:a.id});break;default:a=a.id,b=b[e].apply(b,c),postMessage("search"===e?{id:a,msg:b}:{id:a})}};let la=0; +function N(a={}){function b(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[++la]=function(){h(d)};d.worker.postMessage({id:la,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==N)return new N(a);let c="undefined"!==typeof self?self._factory:"undefined"!== +typeof window?window._factory:null;c&&(c=c.toString());const e="undefined"===typeof window,d=this,f=ma(c,e,a.worker);return f.then?f.then(function(g){return b.call(d,g)}):b.call(this,f)}O("add");O("append");O("search");O("update");O("remove"); +function O(a){N.prototype[a]=N.prototype[a+"Async"]=async function(){const b=this,c=[].slice.call(arguments);var e=c[c.length-1];let d;"function"===typeof e&&(d=e,c.splice(c.length-1,1));e=new Promise(function(f){b.h[++la]=f;b.worker.postMessage({task:a,id:la,args:c})});return d?(e.then(d),this):e}} +function ma(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"](import.meta.dirname + "/node/node.mjs"); }):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ka.toString()],{type:"text/javascript"}))):new window.Worker(E(c)?c:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", +"module/worker/worker.js"),{type:"module"})};function na(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let Q,oa;const pa={},R={};function qa(a){Q=0;pa[a]=R[a]} +function P(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]);Q||(Q=setTimeout(qa,0,a),oa=Date.now());R[a]||(R[a]=pa[a]=1E3);if(!--pa[a]){pa[a]=R[a]=R[a]*this.priority*this.priority*3/(Date.now()-oa)|0||1;Q=clearTimeout(Q);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}};function ra(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function sa(a,b){b||(b=new Map);for(let c=0,e;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} +function S(a){if(!this)return new S(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,k,h;gc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.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}h=1b?b?a.slice(c,c+b):a.slice(c):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?V.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Aa(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:k,offset:h,enrich:l,resolve:m,suggest:n}=Da(this,"and",arguments);return Fa.call(this,f,g,k,h,l,m,n)}return d?this.resolve(b,c,e):this}; -function Fa(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=ba(a))return this.result=za(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}=Da(this,"xor",arguments);return Ga.call(this,a,b,c,e,d,f,g)}; -function Ga(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Ha.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 Ha(a,b,c,e,d){const f=[],g=B();let k=0;for(let h=0,l;hb?b?a.slice(c,c+b):a.slice(c):a,e?W.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?W.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ea(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};X.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:k,offset:h,enrich:l,resolve:m,suggest:n}=Ha(this,"and",arguments);return Ja.call(this,f,g,k,h,l,m,n)}return d?this.resolve(b,c,e):this}; +function Ja(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Da(a,b,c,e,g,this.h,f),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};X.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ha(this,"xor",arguments);return Ka.call(this,a,b,c,e,d,f,g)}; +function Ka(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=La.call(this,a,c,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} +function La(a,b,c,e,d){const f=[],g=B();let k=0;for(let h=0,l;hc||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||e)a=a.slice(e,e+c);d&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;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 Qa={normalize:function(a){return a.toLowerCase()},numeric:!1,dedupe:!1};const Ra=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 Sa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ta=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Ua={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};const Va=/[\x00-\x7F]+/g;const Wa=/[\x00-\x7F]+/g;const Xa=/[\x00-\x7F]+/g;var Ya={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Qa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ra},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ra,matcher:Sa,replacer:Ta},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ra,replacer:Ta.concat([/(?!^)[aeo]/g,""]),matcher:Sa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;k--){g=r.substring(f,k);var h=this.score?this.score(b,r,q,g,f):$a(p,e,q,d,f);Y(this,m,g,h,a,c)}break}case "reverse":if(1< -d){for(k=d-1;0g?0:1),e,q,k-1,h-1),v=this.bidirectional&&r>f;Y(this,l,v?f:r,u,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& -(b||this.commit_task.push({del:a}),this.T&&ab(this));return this};function Y(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=B()),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[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new R(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} -function $a(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};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;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else fb(this.map,a),this.depth&&fb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&ab(this));this.cache&&this.cache.remove(a);return this}; -function fb(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ethis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.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};Y.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Ua={normalize:function(a){return a.toLowerCase()}};const Va=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 Wa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Xa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Ya={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};const Za=/[\x00-\x7F]+/g;const $a=/[\x00-\x7F]+/g;const ab=/[\x00-\x7F]+/g;var bb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ua,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Va},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Va,matcher:Wa,replacer:Xa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Va,replacer:Xa.concat([/(?!^)[aeo]/g,""]),matcher:Wa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;k--){g=r.substring(f,k);var h=this.score?this.score(b,r,q,g,f):db(p,e,q,d,f);eb(this,m,g,h,a,c)}break}case "reverse":if(1< +d){for(k=d-1;0g?0:1),e,q,k-1,h-1),v=this.bidirectional&&r>f;eb(this,l,v?f:r,u,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& +(b||this.commit_task.push({del:a}),this.T&&fb(this));return this};function eb(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=B()),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[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new S(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} +function db(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};M.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;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else kb(this.map,a),this.depth&&kb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&fb(this));this.cache&&this.cache.remove(a);return this}; +function kb(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ec.add(a,b)):this.add(a,b)}; -function hb(a){let b=0;if(a.constructor===Array)for(let c=0,e;c{d.objectStoreNames.contains(f)||d.createObjectStore(f)})};e.onblocked=function(d){console.error("blocked",d);c()};e.onerror=function(d){console.error(this.error,d);c()};e.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; -t.close=function(){this.db.close();this.db=null};t.destroy=function(){const a=ib.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};t.clear=function(){const a=this.db.transaction(jb,"readwrite");for(let b=0;b{d.objectStoreNames.contains(f)||d.createObjectStore(f)})};e.onblocked=function(d){console.error("blocked",d);c()};e.onerror=function(d){console.error(this.error,d);c()};e.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; +t.close=function(){this.db.close();this.db=null};t.destroy=function(){const a=nb.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};t.clear=function(){const a=this.db.transaction(ob,"readwrite");for(let b=0;b=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;em&&!f&&"string"===typeof n&&!isNaN(n)&&(m=h.indexOf(parseInt(n,10)))&&(f=1),0<=m)if(d=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};export default {Index:N,Charset:Ya,Encoder:L,Document:U,Worker:O,Resolver:W,IndexedDB:kb,Language:{}}; -export const Index=N;export const Charset=Ya;export const Encoder=L;export const Document=U;export const Worker=O;export const Resolver=W;export const IndexedDB=kb;export const Language={}; \ No newline at end of file +function qb(a,b,c){const e=a.value;let d,f,g=0;for(let k=0,h;km&&!f&&"string"===typeof n&&!isNaN(n)&&(m=h.indexOf(parseInt(n,10)))&&(f=1),0<=m)if(d=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};export default {Index:M,Charset:bb,Encoder:J,Document:V,Worker:N,Resolver:X,IndexedDB:pb,Language:{}}; +export const Index=M;export const Charset=bb;export const Encoder=J;export const Document=V;export const Worker=N;export const Resolver=X;export const IndexedDB=pb;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.debug.js b/dist/flexsearch.compact.debug.js index 831b51b..dc68519 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.105 (Bundle/Debug) + * FlexSearch.js v0.8.107 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -78,16 +78,16 @@ function aa(a) { ["\u02b2", "j"], ["\u02b3", "r"], ["\u02b4", "\u0279"], ["\u02b5", "\u027b"], ["\u02b6", "\u0281"], ["\u02b7", "w"], ["\u02b8", "y"], ["\u02e0", "\u0263"], ["\u02e1", "l"], ["\u02e2", "s"], ["\u02e3", "x"], ["\u02e4", "\u0295"], ["\u0390", "\u03b9"], ["\u03ac", "\u03b1"], ["\u03ad", "\u03b5"], ["\u03ae", "\u03b7"], ["\u03af", "\u03b9"], ["\u03b0", "\u03c5"], ["\u03ca", "\u03b9"], ["\u03cb", "\u03c5"], ["\u03cc", "\u03bf"], ["\u03cd", "\u03c5"], ["\u03ce", "\u03c9"], ["\u03d0", "\u03b2"], ["\u03d1", "\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db", "\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]]; -const ca = /[^\p{L}\p{N}]+/u, da = /(\d{3})/g, ea = /(\D)(\d{3})/g, fa = /(\d{3})(\D)/g, K = "".normalize && /[\u0300-\u036f]/g; -function L(a) { - if (!this || this.constructor !== L) { - return new L(...arguments); +const ca = /[^\p{L}\p{N}]+/u, da = /(\d{3})/g, ea = /(\D)(\d{3})/g, fa = /(\d{3})(\D)/g, ha = "".normalize && /[\u0300-\u036f]/g; +function K(a) { + if (!this || this.constructor !== K) { + return new K(...arguments); } for (let c = 0; c < arguments.length; c++) { this.assign(arguments[c]); } } -w = L.prototype; +w = K.prototype; w.assign = function(a) { this.normalize = A(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, e; @@ -123,7 +123,7 @@ w.assign = function(a) { } this.prepare = A(a.prepare, null, this.prepare); this.finalize = A(a.finalize, null, this.finalize); - K || (this.mapper = new Map(ba)); + ha || (this.mapper = new Map(ba)); this.rtl = A(a.rtl, !1, this.rtl); this.dedupe = A(a.dedupe, !1, this.dedupe); this.filter = A((b = a.filter) && new Set(b), null, this.filter); @@ -157,13 +157,13 @@ w.addStemmer = function(a, c) { this.stemmer.set(a, c); this.D += (this.D ? "|" : "") + a; this.N = null; - this.cache && M(this); + this.cache && L(this); return this; }; w.addFilter = function(a) { this.filter || (this.filter = new Set()); this.filter.add(a); - this.cache && M(this); + this.cache && L(this); return this; }; w.addMapper = function(a, c) { @@ -175,7 +175,7 @@ w.addMapper = function(a, c) { } this.mapper || (this.mapper = new Map()); this.mapper.set(a, c); - this.cache && M(this); + this.cache && L(this); return this; }; w.addMatcher = function(a, c) { @@ -189,7 +189,7 @@ w.addMatcher = function(a, c) { this.matcher.set(a, c); this.h += (this.h ? "|" : "") + a; this.M = null; - this.cache && M(this); + this.cache && L(this); return this; }; w.addReplacer = function(a, c) { @@ -198,7 +198,7 @@ w.addReplacer = function(a, c) { } this.replacer || (this.replacer = []); this.replacer.push(a, c); - this.cache && M(this); + this.cache && L(this); return this; }; w.encode = function(a) { @@ -208,10 +208,10 @@ w.encode = function(a) { return this.F.get(a); } } else { - this.H = setTimeout(M, 50, this); + this.H = setTimeout(L, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = K ? a.normalize("NFKD").replace(K, "").toLowerCase() : a.toLowerCase()); + 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 && 3 < a.length && (a = a.replace(ea, "$1 $2").replace(fa, "$1 $2").replace(da, "$1 ")); const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); @@ -230,7 +230,7 @@ w.encode = function(a) { continue; } } else { - this.H = setTimeout(M, 50, this); + this.H = setTimeout(L, 50, this); } } this.stemmer && 2 < g.length && (this.N || (this.N = new RegExp("(?!^)(" + this.D + ")$")), g = g.replace(this.N, k => this.stemmer.get(k)), g.length < this.minlength || this.filter && this.filter.has(g)) && (g = ""); @@ -257,30 +257,49 @@ w.encode = function(a) { 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 M(a) { +function L(a) { a.H = null; a.F.clear(); a.G.clear(); } -;function ha(a) { - N.call(a, "add"); - N.call(a, "append"); - N.call(a, "search"); - N.call(a, "update"); - N.call(a, "remove"); +;function ia(a) { + M.call(a, "add"); + M.call(a, "append"); + M.call(a, "search"); + M.call(a, "update"); + M.call(a, "remove"); } -function N(a) { +let N, ja; +const O = {}, P = {}; +function ka(a) { + N = 0; + O[a] = P[a]; +} +function M(a) { this[a + "Async"] = function() { - var c = arguments; - const b = c[c.length - 1]; + const c = arguments; + var b = c[c.length - 1]; let e; "function" === typeof b && (e = b, delete c[c.length - 1]); - c = this[a].apply(this, c); - e && (c.then ? c.then(e) : e(c)); - return c; + N || (N = setTimeout(ka, 0, a), ja = Date.now()); + P[a] || (P[a] = O[a] = 1000); + if (!--O[a]) { + O[a] = P[a] = P[a] * this.priority * this.priority * 3 / (Date.now() - ja) | 0 || 1; + N = clearTimeout(N); + 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; }; } -;function O(a, c = 0) { +;function la(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { @@ -289,30 +308,30 @@ function N(a) { e.length && b.push(e); return b; } -function ia(a, c) { +function ma(a, c) { c || (c = new Map()); for (let b = 0, e; b < a.length; b++) { e = a[b], c.set(e[0], e[1]); } return c; } -function ja(a, c = 0) { +function na(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], O(d[1])[0]]), e.length === c && (b.push(e), e = []); + e.push([d[0], la(d[1])[0]]), e.length === c && (b.push(e), e = []); } e.length && b.push(e); return b; } -function ka(a, c) { +function oa(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], ia(e[1], d)); + e = a[b], d = c.get(e[0]), c.set(e[0], ma(e[1], d)); } return c; } -function la(a) { +function pa(a) { let c = [], b = []; for (const e of a.keys()) { b.push(e), 250000 === b.length && (c.push(b), b = []); @@ -320,14 +339,14 @@ function la(a) { b.length && c.push(b); return c; } -function ma(a, c) { +function qa(a, c) { c || (c = new Set()); for (let b = 0; b < a.length; b++) { c.add(a[b]); } return c; } -function P(a, c, b, e, d, f, g = 0) { +function Q(a, c, b, e, d, f, g = 0) { const h = e && e.constructor === Array; var k = h ? e.shift() : e; if (!k) { @@ -336,12 +355,12 @@ function P(a, c, b, e, d, f, g = 0) { if ((k = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(k))) && k.then) { const l = this; return k.then(function() { - return P.call(l, a, c, b, h ? e : null, d, f, g + 1); + return Q.call(l, a, c, b, h ? e : null, d, f, g + 1); }); } - return P.call(this, a, c, b, h ? e : null, d, f, g + 1); + return Q.call(this, a, c, b, h ? e : null, d, f, g + 1); } -;Q.prototype.add = function(a, c, b) { +;R.prototype.add = function(a, c, b) { I(a) && (c = a, a = J(c, this.key)); if (c && (a || 0 === a)) { if (!b && this.reg.has(a)) { @@ -355,7 +374,7 @@ function P(a, c, b, e, d, f, g = 0) { d && e.add(a, d, !1, !0); } else { if (d = k.I, !d || d(c)) { - k.constructor === String ? k = ["" + k] : E(k) && (k = [k]), na(c, k, this.J, 0, e, a, k[0], b); + k.constructor === String ? k = ["" + k] : E(k) && (k = [k]), ra(c, k, this.J, 0, e, a, k[0], b); } } } @@ -406,7 +425,7 @@ function P(a, c, b, e, d, f, g = 0) { h[l] = c[l]; continue; } - oa(c, h, l, 0, l[0], m); + sa(c, h, l, 0, l[0], m); } } this.store.set(a, h || c); @@ -414,21 +433,21 @@ function P(a, c, b, e, d, f, g = 0) { } return this; }; -function oa(a, c, b, e, d, f) { +function sa(a, c, b, e, d, f) { a = a[d]; if (e === b.length - 1) { c[d] = f || a; } else if (a) { if (a.constructor === Array) { for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { - oa(a, c, b, e, d); + sa(a, c, b, e, d); } } else { - c = c[d] || (c[d] = C()), d = b[++e], oa(a, c, b, e, d); + c = c[d] || (c[d] = C()), d = b[++e], sa(a, c, b, e, d); } } } -function na(a, c, b, e, d, f, g, h) { +function ra(a, c, b, e, d, f, g, h) { if (a = a[g]) { if (e === c.length - 1) { if (a.constructor === Array) { @@ -444,15 +463,15 @@ function na(a, c, b, e, d, f, g, h) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - na(a, c, b, e, d, f, g, h); + ra(a, c, b, e, d, f, g, h); } } else { - g = c[++e], na(a, c, b, e, d, f, g, h); + g = c[++e], ra(a, c, b, e, d, f, g, h); } } } } -;function pa(a, c, b, e, d) { +;function ta(a, c, b, e, d) { const f = a.length; let g = [], h, k; h = C(); @@ -467,7 +486,7 @@ function na(a, c, b, e, d, f, g, h) { } if (a = g.length) { if (d) { - g = 1 < g.length ? qa(g, b, e) : (g = g[0]).length > b || e ? g.slice(e, b + e) : g; + g = 1 < g.length ? ua(g, b, e) : (g = g[0]).length > b || e ? g.slice(e, b + e) : g; } else { if (a < f) { return []; @@ -482,7 +501,7 @@ function na(a, c, b, e, d, f, g, h) { } return g; } -function qa(a, c, b) { +function ua(a, c, b) { const e = [], d = C(); let f; var g = a.length; @@ -504,7 +523,7 @@ function qa(a, c, b) { } return e; } -function ra(a, c, b) { +function va(a, c, b) { const e = C(), d = []; for (let f = 0, g; f < c.length; f++) { g = c[f]; @@ -525,12 +544,12 @@ function ra(a, c, b) { } return d; } -;function sa(a, c, b, e) { +;function wa(a, c, b, e) { 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 ? R.call(this, a) : a; + return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, e ? S.call(this, a) : a; } let d = []; for (let f = 0, g, h; f < a.length; f++) { @@ -544,7 +563,7 @@ function ra(a, c, b) { } h > c && (g = g.slice(0, c), h = c); if (!d.length && h >= c) { - return e ? R.call(this, g) : g; + return e ? S.call(this, g) : g; } d.push(g); c -= h; @@ -554,9 +573,9 @@ function ra(a, c, b) { } } d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? R.call(this, d) : d; + return e ? S.call(this, d) : d; } -;function S(a, c, b) { +;function T(a, c, b) { var e = b[0]; if (e.then) { return Promise.all(b).then(function(m) { @@ -571,7 +590,7 @@ function ra(a, c, b) { for (let m = 0, n; m < b.length; m++) { if (n = b[m]) { let t; - if (n.constructor === T) { + if (n.constructor === U) { t = n.result; } else if (n.constructor === Array) { t = n; @@ -602,11 +621,11 @@ function ra(a, c, b) { } return {O:e, P:d, limit:f, offset:g, enrich:h, resolve:k, suggest:l}; } -;T.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = S(this, "or", arguments); - return ta.call(this, a, c, b, e, d, f); +;U.prototype.or = function() { + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = T(this, "or", arguments); + return xa.call(this, a, c, b, e, d, f); }; -function ta(a, c, b, e, d, f) { +function xa(a, c, b, e, d, f) { if (c.length) { const g = this; return Promise.all(c).then(function(h) { @@ -614,25 +633,25 @@ function ta(a, c, b, e, d, f) { for (let k = 0, l; k < h.length; k++) { (l = h[k]).length && (a[k] = l); } - return ta.call(g, a, [], b, e, d, f); + return xa.call(g, a, [], b, e, d, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = qa(a, b, e), e = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = ua(a, b, e), e = 0)); return f ? this.resolve(b, e, d) : this; } -;T.prototype.and = function() { +;U.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:h, offset:k, enrich:l, resolve:m, suggest:n} = S(this, "and", arguments); - return ua.call(this, f, g, h, k, l, m, n); + const {O:f, P:g, limit:h, offset:k, enrich:l, resolve:m, suggest:n} = T(this, "and", arguments); + return ya.call(this, f, g, h, k, l, m, n); } return d ? this.resolve(c, b, e) : this; }; -function ua(a, c, b, e, d, f, g) { +function ya(a, c, b, e, d, f, g) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -640,7 +659,7 @@ function ua(a, c, b, e, d, f, g) { for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return ua.call(h, a, [], b, e, d, f, g); + return ya.call(h, a, [], b, e, d, f, g); }); } if (a.length) { @@ -648,7 +667,7 @@ function ua(a, c, b, e, d, f, g) { this.result = a[0]; } else { if (c = aa(a)) { - return this.result = pa(a, c, b, e, g), f ? d ? R.call(this.index, this.result) : this.result : this; + return this.result = ta(a, c, b, e, g), f ? d ? S.call(this.index, this.result) : this.result : this; } this.result = []; } @@ -657,11 +676,11 @@ function ua(a, c, b, e, d, f, g) { } return f ? this.resolve(b, e, d) : this; } -;T.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = S(this, "xor", arguments); - return va.call(this, a, c, b, e, d, f, g); +;U.prototype.xor = function() { + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = T(this, "xor", arguments); + return za.call(this, a, c, b, e, d, f, g); }; -function va(a, c, b, e, d, f, g) { +function za(a, c, b, e, d, f, g) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -669,21 +688,21 @@ function va(a, c, b, e, d, f, g) { for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return va.call(h, a, [], b, e, d, f, g); + return za.call(h, a, [], b, e, d, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = wa.call(this, a, b, e, f, this.h), f ? d ? R.call(this.index, this.result) : this.result : this; + return this.result = Aa.call(this, a, b, e, f, this.h), f ? d ? S.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(b, e, d) : this; } -function wa(a, c, b, e, d) { +function Aa(a, c, b, e, d) { const f = [], g = C(); let h = 0; for (let k = 0, l; k < a.length; k++) { @@ -728,11 +747,11 @@ function wa(a, c, b, e, d) { } return f; } -;T.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = S(this, "not", arguments); - return xa.call(this, a, c, b, e, d, f, g); +;U.prototype.not = function() { + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = T(this, "not", arguments); + return Ba.call(this, a, c, b, e, d, f, g); }; -function xa(a, c, b, e, d, f, g) { +function Ba(a, c, b, e, d, f, g) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -740,17 +759,17 @@ function xa(a, c, b, e, d, f, g) { for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return xa.call(h, a, [], b, e, d, f, g); + return Ba.call(h, a, [], b, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = ya.call(this, a, b, e, f); + this.result = Ca.call(this, a, b, e, f); } else if (f) { return this.resolve(b, e, d); } - return f ? d ? R.call(this.index, this.result) : this.result : this; + return f ? d ? S.call(this.index, this.result) : this.result : this; } -function ya(a, c, b, e) { +function Ca(a, c, b, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, h = 0; f < this.result.length; f++) { @@ -776,9 +795,9 @@ function ya(a, c, b, e) { } return d; } -;function T(a) { - if (!this || this.constructor !== T) { - return new T(a); +;function U(a) { + if (!this || this.constructor !== U) { + return new U(a); } if (a && a.index) { return a.resolve = !1, this.index = a.index, this.h = a.boost || 0, this.result = a.index.search(a).result, this; @@ -787,44 +806,48 @@ function ya(a, c, b, e) { this.result = a || []; this.h = 0; } -T.prototype.limit = function(a) { +U.prototype.limit = function(a) { if (this.result.length) { const c = []; - let b = 0; - for (let e = 0, d; e < this.result.length; e++) { - if (d = this.result[e], d.length + b < a) { - c[e] = d, b += d.length; - } else { - c[e] = d.slice(0, a - b); - this.result = c; - break; + 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) { + break; + } + } else { + c[b] = e.slice(0, a); + break; + } } } - } - return this; -}; -T.prototype.offset = function(a) { - if (this.result.length) { - const c = []; - let b = 0; - for (let e = 0, d; e < this.result.length; e++) { - d = this.result[e], d.length + b < a ? b += d.length : (c[e] = d.slice(a - b), b = a); - } this.result = c; } return this; }; -T.prototype.boost = function(a) { +U.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); + } + } + this.result = c; + } + return this; +}; +U.prototype.boost = function(a) { this.h += a; return this; }; -T.prototype.resolve = function(a, c, b) { +U.prototype.resolve = function(a, c, b) { const e = this.result, d = this.index; this.result = this.index = null; - return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), sa.call(d, e, a || 100, c, b)) : e; + return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), wa.call(d, e, a || 100, c, b)) : e; }; C(); -Q.prototype.search = function(a, c, b, e) { +R.prototype.search = function(a, c, b, e) { b || (!c && I(a) ? (b = a, a = "") : I(c) && (b = c, c = 0)); let d = []; var f = []; @@ -882,7 +905,7 @@ Q.prototype.search = function(a, c, b, e) { e = []; if (u.length) { for (f = 0; f < u.length; f += 2) { - y = za.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:y}); + y = Da.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:y}); } } return e.length ? Promise.all(e).then(function(x) { @@ -916,26 +939,26 @@ Q.prototype.search = function(a, c, b, e) { if (m && F) { v = []; z = 0; - for (let G = 0, H, Oa; G < m.length; G += 2) { + for (let G = 0, H, Ta; G < m.length; G += 2) { H = this.tag.get(m[G]); if (!H) { if (console.warn("Tag '" + m[G] + ":" + m[G + 1] + "' will be skipped because there is no field '" + m[G] + "'."), k) { continue; } else { - return p ? d : new T(d); + return p ? d : new U(d); } } - if (Oa = (H = H && H.get(m[G + 1])) && H.length) { + if (Ta = (H = H && H.get(m[G + 1])) && H.length) { z++, v.push(H); } else if (!k) { - return p ? d : new T(d); + return p ? d : new U(d); } } if (z) { - r = ra(r, v, p); + r = va(r, v, p); F = r.length; if (!F && !k) { - return p ? r : new T(r); + return p ? r : new U(r); } z--; } @@ -943,7 +966,7 @@ Q.prototype.search = function(a, c, b, e) { if (F) { f[t] = D, d.push(r), t++; } else if (1 === l.length) { - return p ? d : new T(d); + return p ? d : new U(d); } } if (u) { @@ -953,7 +976,7 @@ Q.prototype.search = function(a, c, b, e) { }); } if (!t) { - return p ? d : new T(d); + return p ? d : new U(d); } if (y && (!g || !this.store)) { return d[0]; @@ -961,15 +984,15 @@ Q.prototype.search = function(a, c, b, e) { u = []; for (let x = 0, r; x < f.length; x++) { r = d[x]; - g && r.length && !r[0].doc && (r = R.call(this, r)); + g && r.length && !r[0].doc && (r = S.call(this, r)); if (y) { - return p ? r : new T(r); + return p ? r : new U(r); } d[x] = {field:f[x], result:r}; } - return h ? Aa(d, c) : q ? Ba(d, a, this.index, this.field, this.C, q) : d; + return h ? Ea(d, c) : q ? Fa(d, a, this.index, this.field, this.C, q) : d; }; -function Ba(a, c, b, e, d, f) { +function Fa(a, c, b, e, d, f) { let g, h, k; for (let m = 0, n, t, p, q, y; m < a.length; m++) { n = a[m].result; @@ -1011,7 +1034,7 @@ function Ba(a, c, b, e, d, f) { } return a; } -function Aa(a, c) { +function Ea(a, c) { const b = [], e = C(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1030,7 +1053,7 @@ function Aa(a, c) { } return b; } -function za(a, c, b, e, d) { +function Da(a, c, b, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1039,11 +1062,11 @@ function za(a, c, b, e, d) { if (a > b || e) { f = f.slice(e, e + b); } - d && (f = R.call(this, f)); + d && (f = S.call(this, f)); return f; } } -function R(a) { +function S(a) { if (!this || !this.store) { return a; } @@ -1053,32 +1076,32 @@ function R(a) { } return c; } -;function Q(a) { - if (!this || this.constructor !== Q) { - return new Q(a); +;function R(a) { + if (!this || this.constructor !== R) { + return new R(a); } const c = a.document || a.doc || a; var b; this.C = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && U(b, this.J) || "id"; + this.key = (b = c.key || c.id) && V(b, this.J) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); this.A = (b = c.store || null) && b && !0 !== b && []; this.store = b && new Map(); - this.cache = (b = a.cache || null) && new V(b); + this.cache = (b = a.cache || null) && new W(b); a.cache = !1; b = new Map(); let e = c.index || c.field || c; E(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], E(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new W(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = U(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; + f = e[d], E(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new X(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = V(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; } if (this.A) { a = c.store; E(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = U(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = V(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); } } this.index = b; @@ -1094,14 +1117,14 @@ function R(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.B[d] = f.custom : (this.B[d] = U(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); + f.custom ? this.B[d] = f.custom : (this.B[d] = V(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); this.T[d] = g; this.tag.set(g, new Map()); } } } } -function U(a, c) { +function V(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { @@ -1110,7 +1133,7 @@ function U(a, c) { e < b.length && (b.length = e); return 1 < e ? b : b[0]; } -w = Q.prototype; +w = R.prototype; w.append = function(a, c) { return this.add(a, c, !0); }; @@ -1166,7 +1189,7 @@ w.set = function(a, c) { this.store.set(a, c); return this; }; -w.searchCache = Ca; +w.searchCache = Ga; w.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1182,28 +1205,27 @@ w.export = function(a, c, b = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = la(this.reg); + f = pa(this.reg); c = null; break; case 1: d = "tag"; - f = ja(this.tag, this.reg.size); + f = na(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = O(this.store); + f = la(this.store); c = null; break; case 3: d = "cfg"; - f = {}; - c = null; + c = f = null; break; default: return; } - return P.call(this, a, c, d, f, b, e); + return Q.call(this, a, c, d, f, b, e); }; w.import = function(a, c) { if (c) { @@ -1218,23 +1240,23 @@ w.import = function(a, c) { switch(a) { case "reg": this.fastupdate = !1; - this.reg = ma(c, this.reg); + this.reg = qa(c, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; case "tag": - this.tag = ka(c, this.tag); + this.tag = oa(c, this.tag); break; case "doc": - this.store = ia(c, this.store); + this.store = ma(c, this.store); } } }; -ha(Q.prototype); -function Ca(a, c, b) { +ia(R.prototype); +function Ga(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new V()); + this.cache || (this.cache = new W()); let e = this.cache.get(a); if (!e) { e = this.search(a, c, b); @@ -1249,56 +1271,56 @@ function Ca(a, c, b) { } return e; } -function V(a) { +function W(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -V.prototype.set = function(a, c) { +W.prototype.set = function(a, c) { this.cache.set(this.h = a, c); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -V.prototype.get = function(a) { +W.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; }; -V.prototype.remove = function(a) { +W.prototype.remove = function(a) { for (const c of this.cache) { const b = c[0]; c[1].includes(a) && this.cache.delete(b); } }; -V.prototype.clear = function() { +W.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Da = {normalize:function(a) { +const Ha = {normalize:function(a) { return a.toLowerCase(); -}, numeric:!1, dedupe:!1}; -const Ea = 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 Fa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Ga = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -const Ha = {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}; -const Ia = /[\x00-\x7F]+/g; -const Ja = /[\x00-\x7F]+/g; -const Ka = /[\x00-\x7F]+/g; -var La = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Da, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ea}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ea, matcher:Fa, replacer:Ga}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ea, replacer:Ga.concat([/(?!^)[aeo]/g, ""]), matcher:Fa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +}}; +const Ia = 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 Ja = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Ka = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const La = {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}; +const Ma = /[\x00-\x7F]+/g; +const Na = /[\x00-\x7F]+/g; +const Oa = /[\x00-\x7F]+/g; +var Pa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ha, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ia}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ia, matcher:Ja, replacer:Ka}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ia, replacer:Ka.concat([/(?!^)[aeo]/g, ""]), matcher:Ja}, LatinSoundex:{normalize:!0, 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 = Ha[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Ha[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = La[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = La[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ia, " "); + return ("" + a).replace(Ma, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Ja, ""); + return ("" + a).replace(Na, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ka, " "); + return ("" + a).replace(Oa, " "); }}}; -const Ma = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; -W.prototype.add = function(a, c, b, e) { +const Qa = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +X.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { return this.update(a, c); @@ -1310,15 +1332,15 @@ W.prototype.add = function(a, c, b, e) { let q = c[this.rtl ? e - 1 - p : p]; var d = q.length; if (d && (n || !m[q])) { - var f = this.score ? this.score(c, q, p, null, 0) : X(t, e, p), g = ""; + var f = this.score ? this.score(c, q, p, null, 0) : Y(t, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { for (f = 0; f < d; f++) { for (var h = d; h > f; h--) { g = q.substring(f, h); - var k = this.score ? this.score(c, q, p, g, f) : X(t, e, p, d, f); - Y(this, m, g, k, a, b); + var k = this.score ? this.score(c, q, p, g, f) : Y(t, e, p, d, f); + Z(this, m, g, k, a, b); } } break; @@ -1326,24 +1348,24 @@ W.prototype.add = function(a, c, b, e) { case "reverse": if (1 < d) { for (h = d - 1; 0 < h; h--) { - g = q[h] + g, k = this.score ? this.score(c, q, p, g, h) : X(t, e, p, d, h), Y(this, m, g, k, a, b); + g = q[h] + g, k = this.score ? this.score(c, q, p, g, h) : Y(t, e, p, d, h), Z(this, m, g, k, a, b); } g = ""; } case "forward": if (1 < d) { for (h = 0; h < d; h++) { - g += q[h], Y(this, m, g, f, a, b); + g += q[h], Z(this, m, g, f, a, b); } break; } default: - if (Y(this, m, q, f, a, b), n && 1 < e && p < e - 1) { + if (Z(this, m, q, f, a, b), n && 1 < e && p < e - 1) { for (d = C(), g = this.S, f = q, h = Math.min(n + 1, e - p), d[f] = 1, k = 1; k < h; k++) { if ((q = c[this.rtl ? e - 1 - p - k : p + k]) && !d[q]) { d[q] = 1; - const y = this.score ? this.score(c, f, p, q, k) : X(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), u = this.bidirectional && q > f; - Y(this, l, u ? f : q, y, a, b, u ? q : f); + const y = this.score ? this.score(c, f, p, q, k) : Y(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), u = this.bidirectional && q > f; + Z(this, l, u ? f : q, y, a, b, u ? q : f); } } } @@ -1355,16 +1377,16 @@ W.prototype.add = function(a, c, b, e) { } return this; }; -function Y(a, c, b, e, d, f, g) { +function Z(a, c, b, e, d, f, g) { let h = g ? a.ctx : a.map, k; if (!c[b] || g && !(k = c[b])[g]) { g ? (c = k || (c[b] = C()), 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 = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h]))); } } -function X(a, c, b, e, d) { +function Y(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; } -;W.prototype.search = function(a, c, b) { +;X.prototype.search = function(a, c, b) { b || (!c && I(a) ? (b = a, a = "") : I(c) && (b = c, c = 0)); var e = [], d = 0; if (b) { @@ -1382,11 +1404,11 @@ function X(a, c, b, e, d) { a = b.length; c = c || (h ? 100 : 0); if (1 === a) { - return Na.call(this, b[0], "", c, d, h); + return Ra.call(this, b[0], "", c, d, h); } f = this.depth && !1 !== f; if (2 === a && f && !g) { - return Na.call(this, b[0], b[1], c, d, h); + return Ra.call(this, b[0], b[1], c, d, h); } h = C(); let l = 0; @@ -1398,7 +1420,7 @@ function X(a, c, b, e, d) { for (let q, y; l < a; l++) { if ((y = b[l]) && !h[y]) { h[y] = 1; - q = Pa(this, y, m); + q = Sa(this, y, m); a: { f = q; var n = e, t = g, p = k; @@ -1434,27 +1456,27 @@ function X(a, c, b, e, d) { m = e.length; a = e; if (1 < m) { - a = pa(e, k, c, d, g); + a = ta(e, k, c, d, g); } else if (1 === m) { - g = sa.call(null, e[0], c, d); + g = wa.call(null, e[0], c, d); break a; } g = a; } return g; }; -function Na(a, c, b, e, d) { - a = Pa(this, a, c); +function Ra(a, c, b, e, d) { + a = Sa(this, a, c); d = !0; - return a && a.length ? d ? sa.call(this, a, b, e) : new T(a) : d ? [] : new T(); + return a && a.length ? d ? wa.call(this, a, b, e) : new U(a) : d ? [] : new U(); } -function Pa(a, c, b) { +function Sa(a, c, b) { let e; b && (e = a.bidirectional && c > b) && (e = b, b = c, c = e); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } -;W.prototype.remove = function(a, c) { +;X.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) { @@ -1469,14 +1491,14 @@ function Pa(a, c, b) { } } } else { - Qa(this.map, a), this.depth && Qa(this.ctx, a); + Ua(this.map, a), this.depth && Ua(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function Qa(a, c) { +function Ua(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1491,25 +1513,25 @@ function Qa(a, c) { } } else { for (let e of a.entries()) { - const d = e[0], f = Qa(e[1], c); + const d = e[0], f = Ua(e[1], c); f ? b += f : a.delete(d); } } return b; } -;function W(a, c) { - if (!this || this.constructor !== W) { - return new W(a); +;function X(a, c) { + if (!this || this.constructor !== X) { + return new X(a); } if (a) { var b = E(a) ? a : a.preset; - b && (Ma[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Ma[b], a)); + b && (Qa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Qa[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = E(a.encoder) ? La[a.encoder] : a.encode || a.encoder || Da; - this.encoder = d.encode ? d : "object" === typeof d ? new L(d) : {encode:d}; + const e = !0 === b ? {depth:1} : b || {}, d = E(a.encoder) ? Pa[a.encoder] : a.encode || a.encoder || Ha; + this.encoder = d.encode ? d : "object" === typeof d ? new K(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = b = a.tokenize || "strict"; this.depth = "strict" === b && e.depth || 0; @@ -1522,9 +1544,10 @@ function Qa(a, c) { 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 V(b); + this.cache = (b = a.cache || null) && new W(b); + this.priority = a.priority || 4; } -w = W.prototype; +w = X.prototype; w.clear = function() { this.map.clear(); this.ctx.clear(); @@ -1542,7 +1565,7 @@ w.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); }; -function Ra(a) { +function Va(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1550,7 +1573,7 @@ function Ra(a) { } } else { for (const b of a) { - const e = b[0], d = Ra(b[1]); + const e = b[0], d = Va(b[1]); d ? c += d : a.delete(e); } } @@ -1560,47 +1583,47 @@ w.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Ra(this.map); - this.depth && Ra(this.ctx); + Va(this.map); + this.depth && Va(this.ctx); return this; }; -w.searchCache = Ca; +w.searchCache = Ga; w.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = la(this.reg); + f = pa(this.reg); break; case 1: d = "cfg"; - f = {}; + f = null; break; case 2: d = "map"; - f = O(this.map, this.reg.size); + f = la(this.map, this.reg.size); break; case 3: d = "ctx"; - f = ja(this.ctx, this.reg.size); + f = na(this.ctx, this.reg.size); break; default: return; } - return P.call(this, a, c, d, f, b, e); + return Q.call(this, a, c, d, f, b, e); }; w.import = function(a, c) { if (c) { switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = ma(c, this.reg); + this.reg = qa(c, this.reg); break; case "map": - this.map = ia(c, this.map); + this.map = ma(c, this.map); break; case "ctx": - this.ctx = ka(c, this.ctx); + this.ctx = oa(c, this.ctx); } } }; @@ -1654,10 +1677,10 @@ w.serialize = function(a = !0) { d = "index.ctx=new Map([" + d + "]);"; return a ? "function inject(index){" + c + e + d + "}" : c + e + d; }; -ha(W.prototype); -const Sa = {Index:W, Charset:La, Encoder:L, Document:Q, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, Z = self; -let Ta; -(Ta = Z.define) && Ta.amd ? Ta([], function() { - return Sa; -}) : "object" === typeof Z.exports ? Z.exports = Sa : Z.FlexSearch = Sa; +ia(X.prototype); +const Wa = {Index:X, Charset:Pa, Encoder:K, Document:R, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, Xa = self; +let Ya; +(Ya = Xa.define) && Ya.amd ? Ya([], function() { + return Wa; +}) : "object" === typeof Xa.exports ? Xa.exports = Wa : Xa.FlexSearch = Wa; }(this||self)); diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index 2820069..1bacee9 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -1,64 +1,65 @@ /**! - * FlexSearch.js v0.8.105 (Bundle) + * FlexSearch.js v0.8.107 (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 v;function A(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 C(){return Object.create(null)}function E(a){return"string"===typeof a} -function H(a){return"object"===typeof a}function J(a,b){if(E(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ca)}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);K||(this.mapper=new Map(ba));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((c=a.filter)&&new Set(c),null,this.filter);this.matcher=A((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=A((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= -A((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=A(a.replacer,null,this.replacer);this.minlength=A(a.minlength,1,this.minlength);this.maxlength=A(a.maxlength,0,this.maxlength);if(this.cache=c=A(a.cache,!0,this.cache))this.H=null,this.R="number"===typeof c?c:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.D="";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.D+= -(this.D?"|":"")+d;return this};v.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.D+=(this.D?"|":"")+a;this.N=null;this.cache&&M(this);return this};v.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&M(this);return this};v.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&&M(this);return this};v.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&M(this);return this}; -v.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(M,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=K?a.normalize("NFKD").replace(K,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),g.lengththis.matcher.get(k)));if(g&&this.replacer)for(d=0;g&&dthis.R&& -(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.F.set(a,c),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return c};function M(a){a.H=null;a.F.clear();a.G.clear()};function ha(a){N.call(a,"add");N.call(a,"append");N.call(a,"search");N.call(a,"update");N.call(a,"remove")}function N(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);b=this[a].apply(this,b);e&&(b.then?b.then(e):e(b));return b}};function O(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function ia(a,b){b||(b=new Map);for(let c=0,e;cc||e?g.slice(e,c+e):g;else{if(ac||e)g=g.slice(e,c+e)}return g} -function qa(a,b,c){const e=[],d=C();let f;var g=a.length;let h;for(let k=g-1;0<=k;k--)if(h=(g=a[k])&&g.length)for(let l=0;lb?b?a.slice(c,c+b):a.slice(c):a,e?R.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?R.call(this,g):g;d.push(g);b-=h;if(!b)break}d=1a.length?this.result=a[0]:(this.result=qa(a,c,e),e=0));return f?this.resolve(c,e,d):this};T.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}=S(this,"and",arguments);return ua.call(this,f,g,h,k,l,m,n)}return d?this.resolve(b,c,e):this}; -function ua(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=aa(a))return this.result=pa(a,b,c,e,g),f?d?R.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};T.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=S(this,"xor",arguments);return va.call(this,a,b,c,e,d,f,g)}; -function va(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=wa.call(this,a,c,e,f,this.h),f?d?R.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function wa(a,b,c,e,d){const f=[],g=C();let h=0;for(let k=0,l;k"a1a".split(b).length; +this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ca)}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);ha||(this.mapper=new Map(ba));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((b=a.filter)&&new Set(b),null,this.filter);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,0,this.maxlength);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.D="";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.D+= +(this.D?"|":"")+d;return this};v.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.D+=(this.D?"|":"")+a;this.N=null;this.cache&&L(this);return this};v.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&L(this);return this};v.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&&L(this);return this};v.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&L(this);return this}; +v.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(L,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.stemmer.get(k)),g.lengththis.matcher.get(k)));if(g&&this.replacer)for(d=0;g&&d +this.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 L(a){a.H=null;a.F.clear();a.G.clear()};function ia(a){M.call(a,"add");M.call(a,"append");M.call(a,"search");M.call(a,"update");M.call(a,"remove")}let N,ja;const O={},P={};function ka(a){N=0;O[a]=P[a]} +function M(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]);N||(N=setTimeout(ka,0,a),ja=Date.now());P[a]||(P[a]=O[a]=1E3);if(!--O[a]){O[a]=P[a]=P[a]*this.priority*this.priority*3/(Date.now()-ja)|0||1;N=clearTimeout(N);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}};function la(a,c=0){let b=[],e=[];c&&(c=25E4/c*5E3|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 ma(a,c){c||(c=new Map);for(let b=0,e;bb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} +function ua(a,c,b){const e=[],d=C();let f;var g=a.length;let h;for(let k=g-1;0<=k;k--)if(h=(g=a[k])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?S.call(this,a):a;let d=[];for(let f=0,g,h;f=h){b-=h;continue}bc&&(g=g.slice(0,c),h=c);if(!d.length&&h>=c)return e?S.call(this,g):g;d.push(g);c-=h;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ua(a,b,e),e=0));return f?this.resolve(b,e,d):this};U.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:h,offset:k,enrich:l,resolve:m,suggest:n}=T(this,"and",arguments);return ya.call(this,f,g,h,k,l,m,n)}return d?this.resolve(c,b,e):this}; +function ya(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(c=aa(a))return this.result=ta(a,c,b,e,g),f?d?S.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};U.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=T(this,"xor",arguments);return za.call(this,a,c,b,e,d,f,g)}; +function za(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Aa.call(this,a,b,e,f,this.h),f?d?S.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} +function Aa(a,c,b,e,d){const f=[],g=C();let h=0;for(let k=0,l;kc||e)a=a.slice(e,e+c);d&&(a=R.call(this,a));return a}} -function R(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -V.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};V.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};V.prototype.clear=function(){this.cache.clear();this.h=""};const Da={normalize:function(a){return a.toLowerCase()},numeric:!1,dedupe:!1};const Ea=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 Fa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ga=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Ha={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};const Ia=/[\x00-\x7F]+/g;const Ja=/[\x00-\x7F]+/g;const Ka=/[\x00-\x7F]+/g;var La={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Da,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ea},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ea,matcher:Fa,replacer:Ga},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ea,replacer:Ga.concat([/(?!^)[aeo]/g,""]),matcher:Fa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;h--){g=q.substring(f,h);var k=this.score?this.score(b,q,p,g,f):X(t,e,p,d,f);Y(this,m,g,k,a,c)}break}case "reverse":if(1< -d){for(h=d-1;0g?0:1),e,p,h-1,k-1),w=this.bidirectional&&q>f;Y(this,l,w?f:q,y,a,c,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function Y(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])g?(b=k||(b[c]=C()),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=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((b=a.reg.get(d))?b.push(h):a.reg.set(d,[h])))}function X(a,b,c,e,d){return c&&1c)&&(e=c,c=b,b=e);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};W.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;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else Qa(this.map,a),this.depth&&Qa(this.ctx,a);b||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Qa(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ec.add(a,b)):this.add(a,b)}; -function Ra(a){let b=0;if(a.constructor===Array)for(let c=0,e;cb||e)a=a.slice(e,e+b);d&&(a=S.call(this,a));return a}} +function S(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)}; +W.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};W.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};W.prototype.clear=function(){this.cache.clear();this.h=""};const Ha={normalize:function(a){return a.toLowerCase()}};const Ia=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 Ja=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ka=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const La={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};const Ma=/[\x00-\x7F]+/g;const Na=/[\x00-\x7F]+/g;const Oa=/[\x00-\x7F]+/g;var Pa={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ha,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ia},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ia,matcher:Ja,replacer:Ka},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ia,replacer:Ka.concat([/(?!^)[aeo]/g,""]),matcher:Ja},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bf;h--){g=q.substring(f,h);var k=this.score?this.score(c,q,p,g,f):Y(t,e,p,d,f);Z(this,m,g,k,a,b)}break}case "reverse":if(1< +d){for(h=d-1;0g?0:1),e,p,h-1,k-1),w=this.bidirectional&&q>f;Z(this,l,w?f:q,y,a,b,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function Z(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])g?(c=k||(c[b]=C()),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=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function Y(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};X.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 e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Ua(this.map,a),this.depth&&Ua(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Ua(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};function Va(a){let c=0;if(a.constructor===Array)for(let b=0,e;b this.stemmer.get(k)), g.length < this.minlength || this.filter && this.filter.has(g)) && (g = ""); @@ -256,30 +256,49 @@ w.encode = function(a) { 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 M(a) { +function L(a) { a.H = null; a.F.clear(); a.G.clear(); } -;function ha(a) { - N.call(a, "add"); - N.call(a, "append"); - N.call(a, "search"); - N.call(a, "update"); - N.call(a, "remove"); +;function ia(a) { + M.call(a, "add"); + M.call(a, "append"); + M.call(a, "search"); + M.call(a, "update"); + M.call(a, "remove"); } -function N(a) { +let N, ja; +const O = {}, P = {}; +function ka(a) { + N = 0; + O[a] = P[a]; +} +function M(a) { this[a + "Async"] = function() { - var c = arguments; - const b = c[c.length - 1]; + const c = arguments; + var b = c[c.length - 1]; let e; "function" === typeof b && (e = b, delete c[c.length - 1]); - c = this[a].apply(this, c); - e && (c.then ? c.then(e) : e(c)); - return c; + N || (N = setTimeout(ka, 0, a), ja = Date.now()); + P[a] || (P[a] = O[a] = 1000); + if (!--O[a]) { + O[a] = P[a] = P[a] * this.priority * this.priority * 3 / (Date.now() - ja) | 0 || 1; + N = clearTimeout(N); + 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; }; } -;function O(a, c = 0) { +;function la(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { @@ -288,30 +307,30 @@ function N(a) { e.length && b.push(e); return b; } -function P(a, c) { +function ma(a, c) { c || (c = new Map()); for (let b = 0, e; b < a.length; b++) { e = a[b], c.set(e[0], e[1]); } return c; } -function ia(a, c = 0) { +function na(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], O(d[1])[0]]), e.length === c && (b.push(e), e = []); + e.push([d[0], la(d[1])[0]]), e.length === c && (b.push(e), e = []); } e.length && b.push(e); return b; } -function ja(a, c) { +function oa(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], P(e[1], d)); + e = a[b], d = c.get(e[0]), c.set(e[0], ma(e[1], d)); } return c; } -function ka(a) { +function pa(a) { let c = [], b = []; for (const e of a.keys()) { b.push(e), 250000 === b.length && (c.push(b), b = []); @@ -319,7 +338,7 @@ function ka(a) { b.length && c.push(b); return c; } -function la(a, c) { +function qa(a, c) { c || (c = new Set()); for (let b = 0; b < a.length; b++) { c.add(a[b]); @@ -354,7 +373,7 @@ function Q(a, c, b, e, d, f, g = 0) { d && e.add(a, d, !1, !0); } else { if (d = k.I, !d || d(c)) { - k.constructor === String ? k = ["" + k] : E(k) && (k = [k]), ma(c, k, this.J, 0, e, a, k[0], b); + k.constructor === String ? k = ["" + k] : E(k) && (k = [k]), ra(c, k, this.J, 0, e, a, k[0], b); } } } @@ -405,7 +424,7 @@ function Q(a, c, b, e, d, f, g = 0) { h[l] = c[l]; continue; } - na(c, h, l, 0, l[0], m); + sa(c, h, l, 0, l[0], m); } } this.store.set(a, h || c); @@ -413,21 +432,21 @@ function Q(a, c, b, e, d, f, g = 0) { } return this; }; -function na(a, c, b, e, d, f) { +function sa(a, c, b, e, d, f) { a = a[d]; if (e === b.length - 1) { c[d] = f || a; } else if (a) { if (a.constructor === Array) { for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { - na(a, c, b, e, d); + sa(a, c, b, e, d); } } else { - c = c[d] || (c[d] = C()), d = b[++e], na(a, c, b, e, d); + c = c[d] || (c[d] = C()), d = b[++e], sa(a, c, b, e, d); } } } -function ma(a, c, b, e, d, f, g, h) { +function ra(a, c, b, e, d, f, g, h) { if (a = a[g]) { if (e === c.length - 1) { if (a.constructor === Array) { @@ -443,15 +462,15 @@ function ma(a, c, b, e, d, f, g, h) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - ma(a, c, b, e, d, f, g, h); + ra(a, c, b, e, d, f, g, h); } } else { - g = c[++e], ma(a, c, b, e, d, f, g, h); + g = c[++e], ra(a, c, b, e, d, f, g, h); } } } } -;function oa(a, c, b, e, d) { +;function ta(a, c, b, e, d) { const f = a.length; let g = [], h, k; h = C(); @@ -466,7 +485,7 @@ function ma(a, c, b, e, d, f, g, h) { } if (a = g.length) { if (d) { - g = 1 < g.length ? pa(g, b, e) : (g = g[0]).length > b || e ? g.slice(e, b + e) : g; + g = 1 < g.length ? ua(g, b, e) : (g = g[0]).length > b || e ? g.slice(e, b + e) : g; } else { if (a < f) { return []; @@ -481,7 +500,7 @@ function ma(a, c, b, e, d, f, g, h) { } return g; } -function pa(a, c, b) { +function ua(a, c, b) { const e = [], d = C(); let f; var g = a.length; @@ -503,7 +522,7 @@ function pa(a, c, b) { } return e; } -function qa(a, c, b) { +function va(a, c, b) { const e = C(), d = []; for (let f = 0, g; f < c.length; f++) { g = c[f]; @@ -524,7 +543,7 @@ function qa(a, c, b) { } return d; } -;function ra(a, c, b, e) { +;function wa(a, c, b, e) { if (!a.length) { return a; } @@ -603,9 +622,9 @@ function qa(a, c, b) { } ;U.prototype.or = function() { const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = T(this, "or", arguments); - return sa.call(this, a, c, b, e, d, f); + return xa.call(this, a, c, b, e, d, f); }; -function sa(a, c, b, e, d, f) { +function xa(a, c, b, e, d, f) { if (c.length) { const g = this; return Promise.all(c).then(function(h) { @@ -613,10 +632,10 @@ function sa(a, c, b, e, d, f) { for (let k = 0, l; k < h.length; k++) { (l = h[k]).length && (a[k] = l); } - return sa.call(g, a, [], b, e, d, f); + return xa.call(g, a, [], b, e, d, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = pa(a, b, e), e = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = ua(a, b, e), e = 0)); return f ? this.resolve(b, e, d) : this; } ;U.prototype.and = function() { @@ -627,11 +646,11 @@ function sa(a, c, b, e, d, f) { } if (a) { const {O:f, P:g, limit:h, offset:k, enrich:l, resolve:m, suggest:n} = T(this, "and", arguments); - return ta.call(this, f, g, h, k, l, m, n); + return ya.call(this, f, g, h, k, l, m, n); } return d ? this.resolve(c, b, e) : this; }; -function ta(a, c, b, e, d, f, g) { +function ya(a, c, b, e, d, f, g) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -639,7 +658,7 @@ function ta(a, c, b, e, d, f, g) { for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return ta.call(h, a, [], b, e, d, f, g); + return ya.call(h, a, [], b, e, d, f, g); }); } if (a.length) { @@ -647,7 +666,7 @@ function ta(a, c, b, e, d, f, g) { this.result = a[0]; } else { if (c = aa(a)) { - return this.result = oa(a, c, b, e, g), f ? d ? S.call(this.index, this.result) : this.result : this; + return this.result = ta(a, c, b, e, g), f ? d ? S.call(this.index, this.result) : this.result : this; } this.result = []; } @@ -658,9 +677,9 @@ function ta(a, c, b, e, d, f, g) { } ;U.prototype.xor = function() { const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = T(this, "xor", arguments); - return ua.call(this, a, c, b, e, d, f, g); + return za.call(this, a, c, b, e, d, f, g); }; -function ua(a, c, b, e, d, f, g) { +function za(a, c, b, e, d, f, g) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -668,21 +687,21 @@ function ua(a, c, b, e, d, f, g) { for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return ua.call(h, a, [], b, e, d, f, g); + return za.call(h, a, [], b, e, d, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = va.call(this, a, b, e, f, this.h), f ? d ? S.call(this.index, this.result) : this.result : this; + return this.result = Aa.call(this, a, b, e, f, this.h), f ? d ? S.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(b, e, d) : this; } -function va(a, c, b, e, d) { +function Aa(a, c, b, e, d) { const f = [], g = C(); let h = 0; for (let k = 0, l; k < a.length; k++) { @@ -729,9 +748,9 @@ function va(a, c, b, e, d) { } ;U.prototype.not = function() { const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = T(this, "not", arguments); - return wa.call(this, a, c, b, e, d, f, g); + return Ba.call(this, a, c, b, e, d, f, g); }; -function wa(a, c, b, e, d, f, g) { +function Ba(a, c, b, e, d, f, g) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -739,17 +758,17 @@ function wa(a, c, b, e, d, f, g) { for (let l = 0, m; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return wa.call(h, a, [], b, e, d, f, g); + return Ba.call(h, a, [], b, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = xa.call(this, a, b, e, f); + this.result = Ca.call(this, a, b, e, f); } else if (f) { return this.resolve(b, e, d); } return f ? d ? S.call(this.index, this.result) : this.result : this; } -function xa(a, c, b, e) { +function Ca(a, c, b, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, h = 0; f < this.result.length; f++) { @@ -789,25 +808,29 @@ function xa(a, c, b, e) { U.prototype.limit = function(a) { if (this.result.length) { const c = []; - let b = 0; - for (let e = 0, d; e < this.result.length; e++) { - if (d = this.result[e], d.length + b < a) { - c[e] = d, b += d.length; - } else { - c[e] = d.slice(0, a - b); - this.result = c; - break; + 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) { + break; + } + } else { + c[b] = e.slice(0, a); + break; + } } } + this.result = c; } return this; }; U.prototype.offset = function(a) { if (this.result.length) { const c = []; - let b = 0; - for (let e = 0, d; e < this.result.length; e++) { - d = this.result[e], d.length + b < a ? b += d.length : (c[e] = d.slice(a - b), b = a); + 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); + } } this.result = c; } @@ -820,7 +843,7 @@ U.prototype.boost = function(a) { U.prototype.resolve = function(a, c, b) { const e = this.result, d = this.index; this.result = this.index = null; - return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), ra.call(d, e, a || 100, c, b)) : e; + return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), wa.call(d, e, a || 100, c, b)) : e; }; C(); R.prototype.search = function(a, c, b, e) { @@ -881,7 +904,7 @@ R.prototype.search = function(a, c, b, e) { e = []; if (u.length) { for (f = 0; f < u.length; f += 2) { - y = ya.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:y}); + y = Da.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:y}); } } return e.length ? Promise.all(e).then(function(x) { @@ -915,7 +938,7 @@ R.prototype.search = function(a, c, b, e) { if (m && F) { v = []; z = 0; - for (let G = 0, H, La; G < m.length; G += 2) { + for (let G = 0, H, Qa; G < m.length; G += 2) { H = this.tag.get(m[G]); if (!H) { if (console.warn("Tag '" + m[G] + ":" + m[G + 1] + "' will be skipped because there is no field '" + m[G] + "'."), k) { @@ -924,14 +947,14 @@ R.prototype.search = function(a, c, b, e) { return p ? d : new U(d); } } - if (La = (H = H && H.get(m[G + 1])) && H.length) { + if (Qa = (H = H && H.get(m[G + 1])) && H.length) { z++, v.push(H); } else if (!k) { return p ? d : new U(d); } } if (z) { - r = qa(r, v, p); + r = va(r, v, p); F = r.length; if (!F && !k) { return p ? r : new U(r); @@ -966,9 +989,9 @@ R.prototype.search = function(a, c, b, e) { } d[x] = {field:f[x], result:r}; } - return h ? za(d, c) : q ? Aa(d, a, this.index, this.field, this.C, q) : d; + return h ? Ea(d, c) : q ? Fa(d, a, this.index, this.field, this.C, q) : d; }; -function Aa(a, c, b, e, d, f) { +function Fa(a, c, b, e, d, f) { let g, h, k; for (let m = 0, n, t, p, q, y; m < a.length; m++) { n = a[m].result; @@ -1010,7 +1033,7 @@ function Aa(a, c, b, e, d, f) { } return a; } -function za(a, c) { +function Ea(a, c) { const b = [], e = C(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1029,7 +1052,7 @@ function za(a, c) { } return b; } -function ya(a, c, b, e, d) { +function Da(a, c, b, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1165,7 +1188,7 @@ w.set = function(a, c) { this.store.set(a, c); return this; }; -w.searchCache = Ba; +w.searchCache = Ga; w.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1181,23 +1204,22 @@ w.export = function(a, c, b = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = ka(this.reg); + f = pa(this.reg); c = null; break; case 1: d = "tag"; - f = ia(this.tag, this.reg.size); + f = na(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = O(this.store); + f = la(this.store); c = null; break; case 3: d = "cfg"; - f = {}; - c = null; + c = f = null; break; default: return; @@ -1217,21 +1239,21 @@ w.import = function(a, c) { switch(a) { case "reg": this.fastupdate = !1; - this.reg = la(c, this.reg); + this.reg = qa(c, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; case "tag": - this.tag = ja(c, this.tag); + this.tag = oa(c, this.tag); break; case "doc": - this.store = P(c, this.store); + this.store = ma(c, this.store); } } }; -ha(R.prototype); -function Ba(a, c, b) { +ia(R.prototype); +function Ga(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new W()); let e = this.cache.get(a); @@ -1272,31 +1294,31 @@ W.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Ca = {normalize:function(a) { +const Ha = {normalize:function(a) { return a.toLowerCase(); -}, numeric:!1, dedupe:!1}; -const Da = 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 Ea = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Fa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -const Ga = {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}; -const Ha = /[\x00-\x7F]+/g; -const Ia = /[\x00-\x7F]+/g; -const Ja = /[\x00-\x7F]+/g; -var Ka = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ca, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Da}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Da, matcher:Ea, replacer:Fa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Da, replacer:Fa.concat([/(?!^)[aeo]/g, ""]), matcher:Ea}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +}}; +const Ia = 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 Ja = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Ka = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const La = {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}; +const Ma = /[\x00-\x7F]+/g; +const Na = /[\x00-\x7F]+/g; +const Oa = /[\x00-\x7F]+/g; +var Pa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ha, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ia}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ia, matcher:Ja, replacer:Ka}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ia, replacer:Ka.concat([/(?!^)[aeo]/g, ""]), matcher:Ja}, LatinSoundex:{normalize:!0, 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 = Ga[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Ga[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = La[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = La[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ha, " "); + return ("" + a).replace(Ma, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Ia, ""); + return ("" + a).replace(Na, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ja, " "); + return ("" + a).replace(Oa, " "); }}}; -const Ma = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +const Ra = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; X.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { @@ -1381,11 +1403,11 @@ function Y(a, c, b, e, d) { a = b.length; c = c || (h ? 100 : 0); if (1 === a) { - return Na.call(this, b[0], "", c, d, h); + return Sa.call(this, b[0], "", c, d, h); } f = this.depth && !1 !== f; if (2 === a && f && !g) { - return Na.call(this, b[0], b[1], c, d, h); + return Sa.call(this, b[0], b[1], c, d, h); } h = C(); let l = 0; @@ -1397,7 +1419,7 @@ function Y(a, c, b, e, d) { for (let q, y; l < a; l++) { if ((y = b[l]) && !h[y]) { h[y] = 1; - q = Oa(this, y, m); + q = Ta(this, y, m); a: { f = q; var n = e, t = g, p = k; @@ -1433,21 +1455,21 @@ function Y(a, c, b, e, d) { m = e.length; a = e; if (1 < m) { - a = oa(e, k, c, d, g); + a = ta(e, k, c, d, g); } else if (1 === m) { - g = ra.call(null, e[0], c, d); + g = wa.call(null, e[0], c, d); break a; } g = a; } return g; }; -function Na(a, c, b, e, d) { - a = Oa(this, a, c); +function Sa(a, c, b, e, d) { + a = Ta(this, a, c); d = !0; - return a && a.length ? d ? ra.call(this, a, b, e) : new U(a) : d ? [] : new U(); + return a && a.length ? d ? wa.call(this, a, b, e) : new U(a) : d ? [] : new U(); } -function Oa(a, c, b) { +function Ta(a, c, b) { let e; b && (e = a.bidirectional && c > b) && (e = b, b = c, c = e); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); @@ -1468,14 +1490,14 @@ function Oa(a, c, b) { } } } else { - Pa(this.map, a), this.depth && Pa(this.ctx, a); + Ua(this.map, a), this.depth && Ua(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function Pa(a, c) { +function Ua(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1490,7 +1512,7 @@ function Pa(a, c) { } } else { for (let e of a.entries()) { - const d = e[0], f = Pa(e[1], c); + const d = e[0], f = Ua(e[1], c); f ? b += f : a.delete(d); } } @@ -1502,13 +1524,13 @@ function Pa(a, c) { } if (a) { var b = E(a) ? a : a.preset; - b && (Ma[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Ma[b], a)); + b && (Ra[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Ra[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = E(a.encoder) ? Ka[a.encoder] : a.encode || a.encoder || Ca; - this.encoder = d.encode ? d : "object" === typeof d ? new L(d) : {encode:d}; + const e = !0 === b ? {depth:1} : b || {}, d = E(a.encoder) ? Pa[a.encoder] : a.encode || a.encoder || Ha; + this.encoder = d.encode ? d : "object" === typeof d ? new K(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = b = a.tokenize || "strict"; this.depth = "strict" === b && e.depth || 0; @@ -1522,6 +1544,7 @@ function Pa(a, c) { this.S = e.resolution || 3; this.rtl = d.rtl || a.rtl || !1; this.cache = (b = a.cache || null) && new W(b); + this.priority = a.priority || 4; } w = X.prototype; w.clear = function() { @@ -1541,7 +1564,7 @@ w.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); }; -function Qa(a) { +function Va(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1549,7 +1572,7 @@ function Qa(a) { } } else { for (const b of a) { - const e = b[0], d = Qa(b[1]); + const e = b[0], d = Va(b[1]); d ? c += d : a.delete(e); } } @@ -1559,29 +1582,29 @@ w.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Qa(this.map); - this.depth && Qa(this.ctx); + Va(this.map); + this.depth && Va(this.ctx); return this; }; -w.searchCache = Ba; +w.searchCache = Ga; w.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = ka(this.reg); + f = pa(this.reg); break; case 1: d = "cfg"; - f = {}; + f = null; break; case 2: d = "map"; - f = O(this.map, this.reg.size); + f = la(this.map, this.reg.size); break; case 3: d = "ctx"; - f = ia(this.ctx, this.reg.size); + f = na(this.ctx, this.reg.size); break; default: return; @@ -1593,13 +1616,13 @@ w.import = function(a, c) { switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = la(c, this.reg); + this.reg = qa(c, this.reg); break; case "map": - this.map = P(c, this.map); + this.map = ma(c, this.map); break; case "ctx": - this.ctx = ja(c, this.ctx); + this.ctx = oa(c, this.ctx); } } }; @@ -1653,7 +1676,7 @@ w.serialize = function(a = !0) { d = "index.ctx=new Map([" + d + "]);"; return a ? "function inject(index){" + c + e + d + "}" : c + e + d; }; -ha(X.prototype); -export default {Index:X, Charset:Ka, Encoder:L, Document:R, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; +ia(X.prototype); +export default {Index:X, Charset:Pa, Encoder:K, Document:R, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; -export const Index=X;export const Charset=Ka;export const Encoder=L;export const Document=R;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file +export const Index=X;export const Charset=Pa;export const Encoder=K;export const Document=R;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/flexsearch.compact.module.min.js b/dist/flexsearch.compact.module.min.js index 57ebffe..d9a9ddf 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -1,65 +1,66 @@ /**! - * FlexSearch.js v0.8.105 (Bundle) + * FlexSearch.js v0.8.107 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var v;function A(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 C(){return Object.create(null)}function E(a){return"string"===typeof a} -function H(a){return"object"===typeof a}function J(a,b){if(E(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ca)}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);K||(this.mapper=new Map(ba));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((c=a.filter)&&new Set(c),null,this.filter);this.matcher=A((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=A((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= -A((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=A(a.replacer,null,this.replacer);this.minlength=A(a.minlength,1,this.minlength);this.maxlength=A(a.maxlength,0,this.maxlength);if(this.cache=c=A(a.cache,!0,this.cache))this.H=null,this.R="number"===typeof c?c:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.D="";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.D+= -(this.D?"|":"")+d;return this};v.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.D+=(this.D?"|":"")+a;this.N=null;this.cache&&M(this);return this};v.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&M(this);return this};v.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&&M(this);return this};v.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&M(this);return this}; -v.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(M,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=K?a.normalize("NFKD").replace(K,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),g.lengththis.matcher.get(k)));if(g&&this.replacer)for(d=0;g&&dthis.R&& -(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.F.set(a,c),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return c};function M(a){a.H=null;a.F.clear();a.G.clear()};function ha(a){N.call(a,"add");N.call(a,"append");N.call(a,"search");N.call(a,"update");N.call(a,"remove")}function N(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);b=this[a].apply(this,b);e&&(b.then?b.then(e):e(b));return b}};function O(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function P(a,b){b||(b=new Map);for(let c=0,e;cc||e?g.slice(e,c+e):g;else{if(ac||e)g=g.slice(e,c+e)}return g} -function pa(a,b,c){const e=[],d=C();let f;var g=a.length;let h;for(let k=g-1;0<=k;k--)if(h=(g=a[k])&&g.length)for(let l=0;lb?b?a.slice(c,c+b):a.slice(c):a,e?S.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?S.call(this,g):g;d.push(g);b-=h;if(!b)break}d=1a.length?this.result=a[0]:(this.result=pa(a,c,e),e=0));return f?this.resolve(c,e,d):this};U.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}=T(this,"and",arguments);return ta.call(this,f,g,h,k,l,m,n)}return d?this.resolve(b,c,e):this}; -function ta(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=aa(a))return this.result=oa(a,b,c,e,g),f?d?S.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};U.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=T(this,"xor",arguments);return ua.call(this,a,b,c,e,d,f,g)}; -function ua(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=va.call(this,a,c,e,f,this.h),f?d?S.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function va(a,b,c,e,d){const f=[],g=C();let h=0;for(let k=0,l;k"a1a".split(b).length; +this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ca)}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);ha||(this.mapper=new Map(ba));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((b=a.filter)&&new Set(b),null,this.filter);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,0,this.maxlength);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.D="";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.D+= +(this.D?"|":"")+d;return this};v.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.D+=(this.D?"|":"")+a;this.N=null;this.cache&&L(this);return this};v.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&L(this);return this};v.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&&L(this);return this};v.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&L(this);return this}; +v.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(L,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.stemmer.get(k)),g.lengththis.matcher.get(k)));if(g&&this.replacer)for(d=0;g&&d +this.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 L(a){a.H=null;a.F.clear();a.G.clear()};function ia(a){M.call(a,"add");M.call(a,"append");M.call(a,"search");M.call(a,"update");M.call(a,"remove")}let N,ja;const O={},P={};function ka(a){N=0;O[a]=P[a]} +function M(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]);N||(N=setTimeout(ka,0,a),ja=Date.now());P[a]||(P[a]=O[a]=1E3);if(!--O[a]){O[a]=P[a]=P[a]*this.priority*this.priority*3/(Date.now()-ja)|0||1;N=clearTimeout(N);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}};function la(a,c=0){let b=[],e=[];c&&(c=25E4/c*5E3|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 ma(a,c){c||(c=new Map);for(let b=0,e;bb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} +function ua(a,c,b){const e=[],d=C();let f;var g=a.length;let h;for(let k=g-1;0<=k;k--)if(h=(g=a[k])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?S.call(this,a):a;let d=[];for(let f=0,g,h;f=h){b-=h;continue}bc&&(g=g.slice(0,c),h=c);if(!d.length&&h>=c)return e?S.call(this,g):g;d.push(g);c-=h;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ua(a,b,e),e=0));return f?this.resolve(b,e,d):this};U.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:h,offset:k,enrich:l,resolve:m,suggest:n}=T(this,"and",arguments);return ya.call(this,f,g,h,k,l,m,n)}return d?this.resolve(c,b,e):this}; +function ya(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(c=aa(a))return this.result=ta(a,c,b,e,g),f?d?S.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};U.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=T(this,"xor",arguments);return za.call(this,a,c,b,e,d,f,g)}; +function za(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Aa.call(this,a,b,e,f,this.h),f?d?S.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} +function Aa(a,c,b,e,d){const f=[],g=C();let h=0;for(let k=0,l;kc||e)a=a.slice(e,e+c);d&&(a=S.call(this,a));return a}} -function S(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -W.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};W.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};W.prototype.clear=function(){this.cache.clear();this.h=""};const Ca={normalize:function(a){return a.toLowerCase()},numeric:!1,dedupe:!1};const Da=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 Ea=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Fa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Ga={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};const Ha=/[\x00-\x7F]+/g;const Ia=/[\x00-\x7F]+/g;const Ja=/[\x00-\x7F]+/g;var La={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ca,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Da},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Da,matcher:Ea,replacer:Fa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Da,replacer:Fa.concat([/(?!^)[aeo]/g,""]),matcher:Ea},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;h--){g=q.substring(f,h);var k=this.score?this.score(b,q,p,g,f):Y(t,e,p,d,f);Z(this,m,g,k,a,c)}break}case "reverse":if(1< -d){for(h=d-1;0g?0:1),e,p,h-1,k-1),w=this.bidirectional&&q>f;Z(this,l,w?f:q,y,a,c,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function Z(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])g?(b=k||(b[c]=C()),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=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((b=a.reg.get(d))?b.push(h):a.reg.set(d,[h])))}function Y(a,b,c,e,d){return c&&1c)&&(e=c,c=b,b=e);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};X.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;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else Pa(this.map,a),this.depth&&Pa(this.ctx,a);b||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Pa(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ec.add(a,b)):this.add(a,b)}; -function Qa(a){let b=0;if(a.constructor===Array)for(let c=0,e;cb||e)a=a.slice(e,e+b);d&&(a=S.call(this,a));return a}} +function S(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)}; +W.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};W.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};W.prototype.clear=function(){this.cache.clear();this.h=""};const Ha={normalize:function(a){return a.toLowerCase()}};const Ia=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 Ja=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ka=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const La={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};const Ma=/[\x00-\x7F]+/g;const Na=/[\x00-\x7F]+/g;const Oa=/[\x00-\x7F]+/g;var Qa={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ha,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ia},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ia,matcher:Ja,replacer:Ka},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ia,replacer:Ka.concat([/(?!^)[aeo]/g,""]),matcher:Ja},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bf;h--){g=q.substring(f,h);var k=this.score?this.score(c,q,p,g,f):Y(t,e,p,d,f);Z(this,m,g,k,a,b)}break}case "reverse":if(1< +d){for(h=d-1;0g?0:1),e,p,h-1,k-1),w=this.bidirectional&&q>f;Z(this,l,w?f:q,y,a,b,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function Z(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])g?(c=k||(c[b]=C()),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=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function Y(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};X.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 e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Ua(this.map,a),this.depth&&Ua(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Ua(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};function Va(a){let c=0;if(a.constructor===Array)for(let b=0,e;b= g.length) { b -= g.length; @@ -1330,12 +1350,12 @@ function S(a) { } if ("slice" === d) { return function(e, f) { - return Wa(b, e || 0, f || b.length, !1); + return ab(b, e || 0, f || b.length, !1); }; } if ("splice" === d) { return function(e, f) { - return Wa(b, e || 0, f || b.length, !0); + return ab(b, e || 0, f || b.length, !0); }; } if ("constructor" === d) { @@ -1367,7 +1387,7 @@ function T(a) { this.index = J(); this.B = []; this.size = 0; - 32 < a ? (this.h = Xa, this.A = BigInt(a)) : (this.h = Ya, this.A = a); + 32 < a ? (this.h = bb, this.A = BigInt(a)) : (this.h = cb, this.A = a); } T.prototype.get = function(a) { var b = this.h(a); @@ -1384,7 +1404,7 @@ function U(a) { } this.index = J(); this.h = []; - 32 < a ? (this.B = Xa, this.A = BigInt(a)) : (this.B = Ya, this.A = a); + 32 < a ? (this.B = bb, this.A = BigInt(a)) : (this.B = cb, this.A = a); } U.prototype.add = function(a) { var b = this.B(a), c = this.index[b]; @@ -1404,9 +1424,9 @@ u.clear = U.prototype.clear = function() { this.h = []; this.size = 0; }; -u.values = U.prototype.values = function Za() { +u.values = U.prototype.values = function db() { var b, c = this, d, e, f; - return ra(Za, function(g) { + return ra(db, function(g) { switch(g.h) { case 1: b = 0; @@ -1430,9 +1450,9 @@ u.values = U.prototype.values = function Za() { } }); }; -u.keys = U.prototype.keys = function $a() { +u.keys = U.prototype.keys = function eb() { var b, c = this, d, e, f; - return ra($a, function(g) { + return ra(eb, function(g) { switch(g.h) { case 1: b = 0; @@ -1456,9 +1476,9 @@ u.keys = U.prototype.keys = function $a() { } }); }; -u.entries = U.prototype.entries = function ab() { +u.entries = U.prototype.entries = function fb() { var b, c = this, d, e, f; - return ra(ab, function(g) { + return ra(fb, function(g) { switch(g.h) { case 1: b = 0; @@ -1482,7 +1502,7 @@ u.entries = U.prototype.entries = function ab() { } }); }; -function Ya(a) { +function cb(a) { var b = Math.pow(2, this.A) - 1; if ("number" == typeof a) { return a & b; @@ -1492,7 +1512,7 @@ function Ya(a) { } return 32 === this.A ? c + Math.pow(2, 31) : c; } -function Xa() { +function bb() { throw Error("The keystore is limited to 32 for EcmaScript5"); } ;V.prototype.add = function(a, b, c) { @@ -1509,7 +1529,7 @@ function Xa() { } else { var g = e.R; if (!g || g(b)) { - e.constructor === String ? e = ["" + e] : K(e) && (e = [e]), bb(b, e, this.S, 0, f, a, e[0], c); + e.constructor === String ? e = ["" + e] : K(e) && (e = [e]), gb(b, e, this.S, 0, f, a, e[0], c); } } } @@ -1574,7 +1594,7 @@ function Xa() { q[d] = b[d]; continue; } - cb(b, q, d, 0, d[0], f); + hb(b, q, d, 0, d[0], f); } } } @@ -1583,21 +1603,21 @@ function Xa() { } return this; }; -function cb(a, b, c, d, e, f) { +function hb(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 (b = b[e] = Array(a.length), e = 0; e < a.length; e++) { - cb(a, b, c, d, e); + hb(a, b, c, d, e); } } else { - b = b[e] || (b[e] = J()), e = c[++d], cb(a, b, c, d, e); + b = b[e] || (b[e] = J()), e = c[++d], hb(a, b, c, d, e); } } } -function bb(a, b, c, d, e, f, g, h) { +function gb(a, b, c, d, e, f, g, h) { if (a = a[g]) { if (d === b.length - 1) { if (a.constructor === Array) { @@ -1613,17 +1633,17 @@ function bb(a, b, c, d, e, f, g, h) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - bb(a, b, c, d, e, f, g, h); + gb(a, b, c, d, e, f, g, h); } } else { - g = b[++d], bb(a, b, c, d, e, f, g, h); + g = b[++d], gb(a, b, c, d, e, f, g, h); } } } else { e.db && e.remove(f); } } -;function db(a, b, c, d, e, f, g) { +;function ib(a, b, c, d, e, f, g) { var h = a.length, k = [], l; var m = J(); for (var n = 0, p = void 0, q; n < b; n++) { @@ -1644,7 +1664,7 @@ function bb(a, b, c, d, e, f, g, h) { } if (a = k.length) { if (e) { - k = 1 < k.length ? eb(k, c, d, g, f) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; + k = 1 < k.length ? jb(k, c, d, g, f) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; } else { if (a < h) { return []; @@ -1677,7 +1697,7 @@ function bb(a, b, c, d, e, f, g, h) { } return k; } -function eb(a, b, c, d, e) { +function jb(a, b, c, d, e) { var f = [], g = J(), h = a.length, k; if (d) { for (e = h - 1; 0 <= e; e--) { @@ -1720,7 +1740,7 @@ function eb(a, b, c, d, e) { } return f; } -function fb(a, b, c) { +function kb(a, b, c) { for (var d = J(), e = [], f = 0, g; f < b.length; f++) { g = b[f]; for (var h = 0; h < g.length; h++) { @@ -1740,7 +1760,7 @@ function fb(a, b, c) { } return e; } -;function gb(a, b, c, d) { +;function lb(a, b, c, d) { if (!a.length) { return a; } @@ -1770,7 +1790,7 @@ function fb(a, b, c) { e = 1 < e.length ? [].concat.apply([], e) : e[0]; return d ? W.call(this, e) : e; } -;function hb(a, b, c) { +;function mb(a, b, c) { var d = c[0]; if (d.then) { return Promise.all(c).then(function(q) { @@ -1816,10 +1836,10 @@ function fb(a, b, c) { return {W:d, $:e, limit:f, offset:g, enrich:h, resolve:k, suggest:l}; } ;X.prototype.or = function() { - var a = hb(this, "or", arguments); - return ib.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve); + var a = mb(this, "or", arguments); + return nb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve); }; -function ib(a, b, c, d, e, f) { +function nb(a, b, c, d, e, f) { if (b.length) { var g = this; return Promise.all(b).then(function(h) { @@ -1827,10 +1847,10 @@ function ib(a, b, c, d, e, f) { for (var k = 0, l = void 0; k < h.length; k++) { (l = h[k]).length && (a[k] = l); } - return ib.call(g, a, [], c, d, e, f); + 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 = eb(a, c, d, !1, this.h), d = 0)); + 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 f ? this.resolve(c, d, e) : this; } ;X.prototype.and = function() { @@ -1845,9 +1865,9 @@ function ib(a, b, c, d, e, f) { var f = b.enrich && c; } } - return a ? (a = hb(this, "and", arguments), jb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest)) : c ? this.resolve(d, e, f) : 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 jb(a, b, c, d, e, f, g) { +function ob(a, b, c, d, e, f, g) { if (b.length) { var h = this; return Promise.all(b).then(function(k) { @@ -1855,7 +1875,7 @@ function jb(a, b, c, d, e, f, g) { for (var l = 0, m = void 0; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return jb.call(h, a, [], c, d, e, f, g); + return ob.call(h, a, [], c, d, e, f, g); }); } if (a.length) { @@ -1863,7 +1883,7 @@ function jb(a, b, c, d, e, f, g) { this.result = a[0]; } else { if (b = za(a)) { - return this.result = db(a, b, c, d, g, this.h, f), f ? 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 = []; } @@ -1873,10 +1893,10 @@ function jb(a, b, c, d, e, f, g) { return f ? this.resolve(c, d, e) : this; } ;X.prototype.xor = function() { - var a = hb(this, "xor", arguments); - return kb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); + var a = mb(this, "xor", arguments); + return pb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); }; -function kb(a, b, c, d, e, f, g) { +function pb(a, b, c, d, e, f, g) { if (b.length) { var h = this; return Promise.all(b).then(function(k) { @@ -1884,21 +1904,21 @@ function kb(a, b, c, d, e, f, g) { for (var l = 0, m = void 0; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return kb.call(h, a, [], c, d, e, f, g); + return pb.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 = lb.call(this, a, c, d, f, this.h), f ? 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 { g || (this.result = a); } return f ? this.resolve(c, d, e) : this; } -function lb(a, b, c, d, e) { +function qb(a, b, c, d, e) { for (var f = [], g = J(), h = 0, k = 0, l; k < a.length; k++) { if (l = a[k]) { h < l.length && (h = l.length); @@ -1942,10 +1962,10 @@ function lb(a, b, c, d, e) { return f; } ;X.prototype.not = function() { - var a = hb(this, "not", arguments); - return mb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); + var a = mb(this, "not", arguments); + return rb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); }; -function mb(a, b, c, d, e, f, g) { +function rb(a, b, c, d, e, f, g) { if (b.length) { var h = this; return Promise.all(b).then(function(k) { @@ -1953,17 +1973,17 @@ function mb(a, b, c, d, e, f, g) { for (var l = 0, m = void 0; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return mb.call(h, a, [], c, d, e, f, g); + return rb.call(h, a, [], c, d, e, f, g); }); } if (a.length && this.result.length) { - this.result = nb.call(this, a, c, d, f); + this.result = sb.call(this, a, c, d, f); } else if (f) { return this.resolve(c, d, e); } return f ? e ? W.call(this.index, this.result) : this.result : this; } -function nb(a, b, c, d) { +function sb(a, b, c, d) { var e = []; a = new Set(a.flat().flat()); for (var f = 0, g, h = 0; f < this.result.length; f++) { @@ -2002,22 +2022,28 @@ function nb(a, b, c, d) { } X.prototype.limit = function(a) { if (this.result.length) { - for (var b = [], c = 0, d = 0, e; d < this.result.length; d++) { - if (e = this.result[d], e.length + c < a) { - b[d] = e, c += e.length; - } else { - b[d] = e.slice(0, a - c); - this.result = b; - break; + for (var b = [], 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 { + b[c] = d.slice(0, a); + break; + } } } + this.result = b; } return this; }; X.prototype.offset = function(a) { if (this.result.length) { - for (var b = [], c = 0, d = 0, e; d < this.result.length; d++) { - e = this.result[d], e.length + c < a ? c += e.length : (b[d] = e.slice(a - c), c = a); + for (var b = [], 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 = b; } @@ -2030,7 +2056,7 @@ X.prototype.boost = function(a) { X.prototype.resolve = function(a, b, c) { var d = this.result, e = this.index; this.result = this.index = null; - return d.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), gb.call(e, d, a || 100, b, c)) : d; + return d.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), lb.call(e, d, a || 100, b, c)) : d; }; J(); V.prototype.search = function(a, b, c, d) { @@ -2106,7 +2132,7 @@ V.prototype.search = function(a, b, c, d) { } p.push(h = h.db.tag(r[f + 1], b, x, q)); } else { - h = ob.call(this, r[f], r[f + 1], b, x, q); + h = tb.call(this, r[f], r[f + 1], b, x, q); } e.push({field:r[f], tag:r[f + 1], result:h}); } @@ -2136,10 +2162,10 @@ V.prototype.search = function(a, b, c, d) { if (m) { if (this.db) { y.tag = m; - var Ea = v.db.support_tag_search; + var Ha = v.db.support_tag_search; y.field = l; } - Ea || (y.enrich = !1); + Ha || (y.enrich = !1); } if (r) { r[A] = v.search(a, b, y); @@ -2154,7 +2180,7 @@ V.prototype.search = function(a, b, c, d) { D = []; F = 0; if (this.db && d) { - if (!Ea) { + if (!Ha) { for (G = l.length; G < d.length; G++) { var L = d[G]; if (L && L.length) { @@ -2166,7 +2192,7 @@ V.prototype.search = function(a, b, c, d) { } } else { G = 0; - for (var Qb = L = void 0; G < m.length; G += 2) { + for (var Vb = L = void 0; G < m.length; G += 2) { L = this.tag.get(m[G]); if (!L) { if (console.warn("Tag '" + m[G] + ":" + m[G + 1] + "' will be skipped because there is no field '" + m[G] + "'."), n) { @@ -2175,7 +2201,7 @@ V.prototype.search = function(a, b, c, d) { return p ? e : new X(e); } } - if (Qb = (L = L && L.get(m[G + 1])) && L.length) { + if (Vb = (L = L && L.get(m[G + 1])) && L.length) { F++, D.push(L); } else if (!n) { return p ? e : new X(e); @@ -2183,7 +2209,7 @@ V.prototype.search = function(a, b, c, d) { } } if (F) { - v = fb(v, D, p); + v = kb(v, D, p); y = v.length; if (!y && !n) { return p ? v : new X(v); @@ -2199,7 +2225,7 @@ V.prototype.search = function(a, b, c, d) { } } if (r) { - if (this.db && m && m.length && !Ea) { + if (this.db && m && m.length && !Ha) { for (q = 0; q < m.length; q += 2) { f = this.index.get(m[q]); if (!f) { @@ -2212,9 +2238,9 @@ V.prototype.search = function(a, b, c, d) { r.push(f.db.tag(m[q + 1], b, x, !1)); } } - var Rb = this; + var Wb = this; return Promise.all(r).then(function(P) { - return P.length ? Rb.search(a, b, c, P) : P; + return P.length ? Wb.search(a, b, c, P) : P; }); } if (!g) { @@ -2234,17 +2260,17 @@ V.prototype.search = function(a, b, c, d) { e[x] = {field:f[x], result:n}; } if (q && this.db && r.length) { - var Fa = this; + var Ia = this; return Promise.all(r).then(function(P) { for (var Q = 0; Q < P.length; Q++) { e[Q].result = P[Q]; } - return k ? pb(e, b) : t ? qb(e, a, Fa.index, Fa.field, Fa.J, t) : e; + return k ? ub(e, b) : t ? vb(e, a, Ia.index, Ia.field, Ia.J, t) : e; }); } - return k ? pb(e, b) : t ? qb(e, a, this.index, this.field, this.J, t) : e; + return k ? ub(e, b) : t ? vb(e, a, this.index, this.field, this.J, t) : e; }; -function qb(a, b, c, d, e, f) { +function vb(a, b, c, d, e, f) { for (var g, h, k, l = 0, m, n, p; l < a.length; l++) { for (m = a[l].result, n = a[l].field, k = c.get(n), p = k.encoder, k = k.tokenize, n = e[d.indexOf(n)], p !== g && (g = p, h = g.encode(b)), p = 0; p < m.length; p++) { var q = "", t = ya(m[p].doc, n), x = g.encode(t); @@ -2275,7 +2301,7 @@ function qb(a, b, c, d, e, f) { } return a; } -function pb(a, b) { +function ub(a, b) { for (var c = [], d = J(), e = 0, f, g; e < a.length; e++) { f = a[e]; g = f.result; @@ -2293,7 +2319,7 @@ function pb(a, b) { } return c; } -function ob(a, b, c, d, e) { +function tb(a, b, c, d, e) { var f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -2323,7 +2349,7 @@ function W(a) { this.J = []; this.field = []; this.S = []; - this.key = (c = b.key || b.id) && rb(c, this.S) || "id"; + this.key = (c = b.key || b.id) && wb(c, this.S) || "id"; (d = a.keystore || 0) && (this.keystore = d); this.reg = (this.fastupdate = !!a.fastupdate) ? d ? new T(d) : new Map() : d ? new U(d) : new Set(); this.I = (c = b.store || null) && c && !0 !== c && []; @@ -2331,7 +2357,7 @@ function W(a) { this.cache = (c = a.cache || null) && new Y(c); a.cache = !1; this.worker = a.worker; - this.index = sb.call(this, a, b); + this.index = xb.call(this, a, b); this.tag = null; if (c = b.tag) { if ("string" === typeof c && (c = [c]), c.length) { @@ -2345,7 +2371,7 @@ function W(a) { if (!e) { throw Error("The tag field from the document descriptor is undefined."); } - d.custom ? this.L[b] = d.custom : (this.L[b] = rb(e, this.S), d.filter && ("string" === typeof this.L[b] && (this.L[b] = new String(this.L[b])), this.L[b].R = d.filter)); + d.custom ? this.L[b] = d.custom : (this.L[b] = wb(e, this.S), d.filter && ("string" === typeof this.L[b] && (this.L[b] = new String(this.L[b])), this.L[b].R = d.filter)); this.aa[b] = e; this.tag.set(e, new Map()); } @@ -2421,7 +2447,7 @@ u.destroy = function() { } return Promise.all(a); }; -function sb(a, b) { +function xb(a, b) { var c = new Map(), d = b.index || b.field || b; K(d) && (d = [d]); for (var e = 0, f, g = void 0; e < d.length; e++) { @@ -2433,17 +2459,17 @@ function sb(a, b) { c.set(f, h); } this.worker || c.set(f, new O(g, this.reg)); - g.custom ? this.J[e] = g.custom : (this.J[e] = rb(f, this.S), g.filter && ("string" === typeof this.J[e] && (this.J[e] = new String(this.J[e])), this.J[e].R = g.filter)); + g.custom ? this.J[e] = g.custom : (this.J[e] = wb(f, this.S), g.filter && ("string" === typeof this.J[e] && (this.J[e] = new String(this.J[e])), this.J[e].R = g.filter)); this.field[e] = f; } if (this.I) { for (a = b.store, K(a) && (a = [a]), b = 0; b < a.length; b++) { - d = a[b], e = d.field || d, d.custom ? (this.I[b] = d.custom, d.custom.ja = e) : (this.I[b] = rb(e, this.S), d.filter && ("string" === typeof this.I[b] && (this.I[b] = new String(this.I[b])), this.I[b].R = d.filter)); + d = a[b], e = d.field || d, d.custom ? (this.I[b] = d.custom, d.custom.ja = e) : (this.I[b] = wb(e, this.S), d.filter && ("string" === typeof this.I[b] && (this.I[b] = new String(this.I[b])), this.I[b].R = d.filter)); } } return c; } -function rb(a, b) { +function wb(a, b) { for (var c = a.split(":"), d = 0, 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); } @@ -2510,7 +2536,7 @@ u.set = function(a, b) { this.store.set(a, b); return this; }; -u.searchCache = tb; +u.searchCache = yb; u.export = function(a, b, c, d) { c = void 0 === c ? 0 : c; d = void 0 === d ? 0 : d; @@ -2527,28 +2553,27 @@ u.export = function(a, b, c, d) { switch(d) { case 0: var g = "reg"; - var h = Ta(this.reg); + var h = Ya(this.reg); b = null; break; case 1: g = "tag"; - h = Ra(this.tag, this.reg.size); + h = Wa(this.tag, this.reg.size); b = null; break; case 2: g = "doc"; - h = Pa(this.store); + h = Ua(this.store); b = null; break; case 3: g = "cfg"; - h = {}; - b = null; + b = h = null; break; default: return; } - return Va.call(this, a, b, g, h, c, d); + return $a.call(this, a, b, g, h, c, d); }; u.import = function(a, b) { if (b) { @@ -2563,21 +2588,21 @@ u.import = function(a, b) { switch(a) { case "reg": this.fastupdate = !1; - this.reg = Ua(b, this.reg); + this.reg = Za(b, this.reg); for (b = 0; b < this.field.length; b++) { c = this.index.get(this.field[b]), c.fastupdate = !1, c.reg = this.reg; } break; case "tag": - this.tag = Sa(b, this.tag); + this.tag = Xa(b, this.tag); break; case "doc": - this.store = Qa(b, this.store); + this.store = Va(b, this.store); } } }; Na(V.prototype); -function tb(a, b, c) { +function yb(a, b, c) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Y()); var d = this.cache.get(a); @@ -2619,29 +2644,29 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -var ub = {normalize:function(a) { +var zb = {normalize:function(a) { return a.toLowerCase(); -}, numeric:!1, dedupe:!1}; -var vb = 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 wb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), xb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -var yb = {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 zb = /[\x00-\x7F]+/g; -var Ab = /[\x00-\x7F]+/g; -var Bb = /[\x00-\x7F]+/g; -var Cb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:ub, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:vb}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:vb, matcher:wb, replacer:xb}, LatinExtra:{normalize:!0, dedupe:!0, mapper:vb, replacer:xb.concat([/(?!^)[aeo]/g, ""]), matcher:wb}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +}}; +var Ab = 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 Bb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Cb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +var Db = {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 Eb = /[\x00-\x7F]+/g; +var Fb = /[\x00-\x7F]+/g; +var Gb = /[\x00-\x7F]+/g; +var Hb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:zb, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ab}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ab, matcher:Bb, replacer:Cb}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ab, replacer:Cb.concat([/(?!^)[aeo]/g, ""]), matcher:Bb}, LatinSoundex:{normalize:!0, 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 = yb[d], f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = yb[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { + for (var c = a[b], d = c.charAt(0), e = Db[d], f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Db[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { } a[b] = d; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(zb, " "); + return ("" + a).replace(Eb, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Ab, ""); + return ("" + a).replace(Fb, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Bb, " "); + return ("" + a).replace(Gb, " "); }}}; -var Db = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +var Ib = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; O.prototype.add = function(a, b, c, d) { if (b && (a || 0 === a)) { if (!d && !c && this.reg.has(a)) { @@ -2652,15 +2677,15 @@ O.prototype.add = function(a, b, c, d) { for (var e = J(), f = J(), g = this.depth, h = this.resolution, k = 0; k < d; k++) { var l = b[this.rtl ? d - 1 - k : k], m = l.length; if (m && (g || !f[l])) { - var n = this.score ? this.score(b, l, k, null, 0) : Eb(h, d, k), p = ""; + var n = this.score ? this.score(b, l, k, null, 0) : Jb(h, d, k), p = ""; switch(this.tokenize) { case "full": if (2 < m) { for (n = 0; n < m; n++) { for (var q = m; q > n; q--) { p = l.substring(n, q); - var t = this.score ? this.score(b, l, k, p, n) : Eb(h, d, k, m, n); - Fb(this, f, p, t, a, c); + var t = this.score ? this.score(b, l, k, p, n) : Jb(h, d, k, m, n); + Kb(this, f, p, t, a, c); } } break; @@ -2668,24 +2693,24 @@ O.prototype.add = function(a, b, c, d) { case "reverse": if (1 < m) { for (q = m - 1; 0 < q; q--) { - p = l[q] + p, t = this.score ? this.score(b, l, k, p, q) : Eb(h, d, k, m, q), Fb(this, f, p, t, a, c); + p = l[q] + p, t = this.score ? this.score(b, l, k, p, q) : Jb(h, d, k, m, q), Kb(this, f, p, t, a, c); } p = ""; } case "forward": if (1 < m) { for (q = 0; q < m; q++) { - p += l[q], Fb(this, f, p, n, a, c); + p += l[q], Kb(this, f, p, n, a, c); } break; } default: - if (Fb(this, f, l, n, a, c), g && 1 < d && k < d - 1) { + if (Kb(this, f, l, n, a, c), g && 1 < d && k < d - 1) { for (m = J(), p = this.da, n = l, q = Math.min(g + 1, d - k), t = m[n] = 1; t < q; t++) { if ((l = b[this.rtl ? d - 1 - k - t : k + t]) && !m[l]) { m[l] = 1; - var x = this.score ? this.score(b, n, k, l, t) : Eb(p + (d / 2 > p ? 0 : 1), d, k, q - 1, t - 1), r = this.bidirectional && l > n; - Fb(this, e, r ? n : l, x, a, c, r ? l : n); + var x = this.score ? this.score(b, n, k, l, t) : Jb(p + (d / 2 > p ? 0 : 1), d, k, q - 1, t - 1), r = this.bidirectional && l > n; + Kb(this, e, r ? n : l, x, a, c, r ? l : n); } } } @@ -2697,10 +2722,10 @@ O.prototype.add = function(a, b, c, d) { b = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.ca && Gb(this)); + this.db && (b || this.commit_task.push({del:a}), this.ca && Lb(this)); return this; }; -function Fb(a, b, c, d, e, f, g) { +function Kb(a, b, c, d, e, f, g) { var h = g ? a.ctx : a.map, k; if (!b[c] || g && !(k = b[c])[g]) { if (g ? (b = k || (b[c] = J()), 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)) { @@ -2718,7 +2743,7 @@ function Fb(a, b, c, d, e, f, g) { } } } -function Eb(a, b, c, d, e) { +function Jb(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; } ;O.prototype.search = function(a, b, c) { @@ -2741,11 +2766,11 @@ function Eb(a, b, c, d, e) { var q = p.length; b = b || (f ? 100 : 0); if (1 === q) { - return Hb.call(this, p[0], "", b, e, f, k, n); + return Mb.call(this, p[0], "", b, e, f, k, n); } g = this.depth && !1 !== g; if (2 === q && g && !h) { - return Hb.call(this, p[0], p[1], b, e, f, k, n); + return Mb.call(this, p[0], p[1], b, e, f, k, n); } var t = J(), x = 0; if (1 < q && g) { @@ -2775,10 +2800,10 @@ function Eb(a, b, c, d, e) { break; } t[v] = 1; - return E(y, Ib(A, v, r, 0, 0, !1, !1), 6); + return E(y, Nb(A, v, r, 0, 0, !1, !1), 6); case 6: z = y.G; - if (z = Jb(z, d, h, m)) { + if (z = Ob(z, d, h, m)) { d = z; y.h = 4; break; @@ -2790,7 +2815,7 @@ function Eb(a, b, c, d, e) { y.h = 2; break; case 4: - return y.return(Kb(d, m, b, e, h, l, f)); + return y.return(Pb(d, m, b, e, h, l, f)); } }); }(); @@ -2798,8 +2823,8 @@ function Eb(a, b, c, d, e) { for (c = a = void 0; x < q; x++) { if ((c = p[x]) && !t[c]) { t[c] = 1; - a = Ib(this, c, r, 0, 0, !1, !1); - if (a = Jb(a, d, h, m)) { + a = Nb(this, c, r, 0, 0, !1, !1); + if (a = Ob(a, d, h, m)) { d = a; break; } @@ -2807,24 +2832,24 @@ function Eb(a, b, c, d, e) { } h && r && x === q - 1 && !d.length && (r = "", x = -1, t = J()); } - return Kb(d, m, b, e, h, l, f); + return Pb(d, m, b, e, h, l, f); }; -function Kb(a, b, c, d, e, f, g) { +function Pb(a, b, c, d, e, f, g) { var h = a.length, k = a; if (1 < h) { - k = db(a, b, c, d, e, f, g); + k = ib(a, b, c, d, e, f, g); } else if (1 === h) { - return g ? gb.call(null, a[0], c, d) : new X(a[0]); + return g ? lb.call(null, a[0], c, d) : new X(a[0]); } return g ? k : new X(k); } -function Hb(a, b, c, d, e, f, g) { - a = Ib(this, a, b, c, d, e, f, g); +function Mb(a, b, c, d, e, f, g) { + a = Nb(this, a, b, c, d, e, f, g); return this.db ? a.then(function(h) { return e ? h || [] : new X(h); - }) : a && a.length ? e ? gb.call(this, a, c, d) : new X(a) : e ? [] : new X(); + }) : a && a.length ? e ? lb.call(this, a, c, d) : new X(a) : e ? [] : new X(); } -function Jb(a, b, c, d) { +function Ob(a, b, c, d) { var e = []; if (a && a.length) { if (a.length <= d) { @@ -2845,7 +2870,7 @@ function Jb(a, b, c, d) { return e; } } -function Ib(a, b, c, d, e, f, g, h) { +function Nb(a, b, c, d, e, f, g, h) { var k; c && (k = a.bidirectional && b > c) && (k = c, c = b, b = k); if (a.db) { @@ -2869,15 +2894,15 @@ function Ib(a, b, c, d, e, f, g, h) { } } } else { - Lb(this.map, a), this.depth && Lb(this.ctx, a); + Qb(this.map, a), this.depth && Qb(this.ctx, a); } b || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.ca && Gb(this)); + this.db && (this.commit_task.push({del:a}), this.ca && Lb(this)); this.cache && this.cache.remove(a); return this; }; -function Lb(a, b) { +function Qb(a, b) { var c = 0; if (a.constructor === Array) { for (var d = 0, e = void 0, f; d < a.length; d++) { @@ -2892,7 +2917,7 @@ function Lb(a, b) { } } else { for (d = w(a.entries()), e = d.next(); !e.done; e = d.next()) { - f = e.value, e = f[0], (f = Lb(f[1], b)) ? c += f : a.delete(e); + f = e.value, e = f[0], (f = Qb(f[1], b)) ? c += f : a.delete(e); } } return c; @@ -2903,13 +2928,13 @@ function Lb(a, b) { } if (a) { var c = K(a) ? a : a.preset; - c && (Db[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Db[c], a)); + c && (Ib[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Ib[c], a)); } else { a = {}; } c = a.context; - var d = !0 === c ? {depth:1} : c || {}, e = K(a.encoder) ? Cb[a.encoder] : a.encode || a.encoder || ub; - this.encoder = e.encode ? e : "object" === typeof e ? new Ia(e) : {encode:e}; + var d = !0 === c ? {depth:1} : c || {}, e = K(a.encoder) ? Hb[a.encoder] : a.encode || a.encoder || zb; + this.encoder = e.encode ? e : "object" === typeof e ? new Ga(e) : {encode:e}; this.resolution = a.resolution || 9; this.tokenize = c = a.tokenize || "strict"; this.depth = "strict" === c && d.depth || 0; @@ -2930,6 +2955,7 @@ function Lb(a, b) { this.ca = !1 !== a.commit; this.commit_task = []; this.commit_timer = null; + this.priority = a.priority || 4; } u = O.prototype; u.mount = function(a) { @@ -2944,7 +2970,7 @@ u.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function Gb(a) { +function Lb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); @@ -2970,7 +2996,7 @@ u.update = function(a, b) { return c.add(a, b); }) : this.add(a, b); }; -function Mb(a) { +function Rb(a) { var b = 0; if (a.constructor === Array) { for (var c = 0, d = void 0; c < a.length; c++) { @@ -2980,7 +3006,7 @@ function Mb(a) { for (c = w(a), d = c.next(); !d.done; d = c.next()) { var e = d.value; d = e[0]; - (e = Mb(e[1])) ? b += e : a.delete(d); + (e = Rb(e[1])) ? b += e : a.delete(d); } } return b; @@ -2989,48 +3015,48 @@ u.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Mb(this.map); - this.depth && Mb(this.ctx); + Rb(this.map); + this.depth && Rb(this.ctx); return this; }; -u.searchCache = tb; +u.searchCache = yb; 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 f = Ta(this.reg); + var f = Ya(this.reg); break; case 1: e = "cfg"; - f = {}; + f = null; break; case 2: e = "map"; - f = Pa(this.map, this.reg.size); + f = Ua(this.map, this.reg.size); break; case 3: e = "ctx"; - f = Ra(this.ctx, this.reg.size); + f = Wa(this.ctx, this.reg.size); break; default: return; } - return Va.call(this, a, b, e, f, c, d); + return $a.call(this, a, b, e, f, 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(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = Ua(b, this.reg); + this.reg = Za(b, this.reg); break; case "map": - this.map = Qa(b, this.map); + this.map = Va(b, this.map); break; case "ctx": - this.ctx = Sa(b, this.ctx); + this.ctx = Xa(b, this.ctx); } } }; @@ -3087,11 +3113,11 @@ u.serialize = function(a) { return a ? "function inject(index){" + b + d + e + "}" : b + d + e; }; Na(O.prototype); -var Nb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Ob = ["map", "ctx", "tag", "reg", "cfg"]; -function Pb(a, b) { +var Sb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Tb = ["map", "ctx", "tag", "reg", "cfg"]; +function Ub(a, b) { b = void 0 === b ? {} : b; if (!this) { - return new Pb(a, b); + return new Ub(a, b); } "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -3102,7 +3128,7 @@ function Pb(a, b) { this.db = null; this.h = {}; } -u = Pb.prototype; +u = Ub.prototype; u.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -3114,10 +3140,10 @@ u.open = function() { var a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { - var d = Nb.open(a.id + (a.field ? ":" + a.field : ""), 1); + var d = Sb.open(a.id + (a.field ? ":" + a.field : ""), 1); d.onupgradeneeded = function() { var e = a.db = this.result; - Ob.forEach(function(f) { + Tb.forEach(function(f) { e.objectStoreNames.contains(f) || e.createObjectStore(f); }); }; @@ -3143,12 +3169,12 @@ u.close = function() { this.db = null; }; u.destroy = function() { - var a = Nb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); + var a = Sb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); return Z(a); }; u.clear = function() { - for (var a = this.db.transaction(Ob, "readwrite"), b = 0; b < Ob.length; b++) { - a.objectStore(Ob[b]).clear(); + for (var a = this.db.transaction(Tb, "readwrite"), b = 0; b < Tb.length; b++) { + a.objectStore(Tb[b]).clear(); } return Z(a); }; @@ -3296,8 +3322,8 @@ u.commit = function(a, b, c) { a.commit_task = []; case 3: return a.reg.size ? E(h, d.transaction("map", "readwrite", function(k) { - for (var l = w(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) { + for (var l = w(a.map), m = l.next(), n = {}; !m.done; n = {O:void 0, Z:void 0}, m = l.next()) { + m = m.value, n.Z = m[0], n.O = m[1], n.O.length && (b ? k.put(n.O, n.Z) : k.get(n.Z).onsuccess = function(p) { return function() { var q = this.result, t; if (q && q.length) { @@ -3316,7 +3342,7 @@ u.commit = function(a, b, c) { } else { q = p.O, t = 1; } - t && k.put(q, p.Y); + t && k.put(q, p.Z); }; }(n)); } @@ -3327,8 +3353,8 @@ u.commit = function(a, b, c) { m = m.value; n.V = m[0]; m = w(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, x) { + for (var p = m.next(), q = {}; !p.done; q = {P:void 0, Y:void 0}, p = m.next()) { + p = p.value, q.Y = p[0], q.P = p[1], q.P.length && (b ? k.put(q.P, n.V + ":" + q.Y) : k.get(n.V + ":" + q.Y).onsuccess = function(t, x) { return function() { var r = this.result, A; if (r && r.length) { @@ -3347,7 +3373,7 @@ u.commit = function(a, b, c) { } else { r = t.P, A = 1; } - A && k.put(r, x.V + ":" + t.Z); + A && k.put(r, x.V + ":" + t.Y); }; }(q, n)); } @@ -3394,7 +3420,7 @@ u.commit = function(a, b, c) { } }); }; -function Sb(a, b, c) { +function Xb(a, b, c) { for (var d = a.value, e, f, g = 0, h = 0, k; h < d.length; h++) { if (k = c ? d : d[h]) { for (var l = 0, m, n; l < b.length; l++) { @@ -3421,17 +3447,17 @@ u.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && Sb(c, a); + c && Xb(c, a); }; }), this.transaction("ctx", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && Sb(c, a); + c && Xb(c, a); }; }), this.transaction("tag", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && Sb(c, a, !0); + c && Xb(c, a, !0); }; }), this.transaction("reg", "readwrite", function(b) { for (var c = 0; c < a.length; c++) { @@ -3451,8 +3477,8 @@ function Z(a) { a = null; }); } -;var Tb = {Index:O, Charset:Cb, Encoder:Ia, Document:V, Worker:R, Resolver:X, IndexedDB:Pb, Language:{}}, Ub = self, Vb; -(Vb = Ub.define) && Vb.amd ? Vb([], function() { - return Tb; -}) : "object" === typeof Ub.exports ? Ub.exports = Tb : Ub.FlexSearch = Tb; +;var Yb = {Index:O, Charset:Hb, Encoder:Ga, Document:V, Worker:R, Resolver:X, IndexedDB:Ub, Language:{}}, Zb = self, $b; +($b = Zb.define) && $b.amd ? $b([], function() { + return Yb; +}) : "object" === typeof Zb.exports ? Zb.exports = Yb : Zb.FlexSearch = Yb; }(this||self)); diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js index 46f644b..beef916 100644 --- a/dist/flexsearch.es5.min.js +++ b/dist/flexsearch.es5.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.105 (ES5) + * FlexSearch.js v0.8.107 (ES5) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -41,14 +41,14 @@ function I(){return Object.create(null)}function K(a){return"string"===typeof a} "i"],["\u01d2","o"],["\u01d4","u"],["\u01d6","u"],["\u01d8","u"],["\u01da","u"],["\u01dc","u"],["\u01df","a"],["\u01e1","a"],["\u01e3","ae"],["\u00e6","ae"],["\u01fd","ae"],["\u01e7","g"],["\u01e9","k"],["\u01eb","o"],["\u01ed","o"],["\u01ef","\u0292"],["\u01f0","j"],["\u01f3","dz"],["\u01f5","g"],["\u01f9","n"],["\u01fb","a"],["\u01ff","\u00f8"],["\u0201","a"],["\u0203","a"],["\u0205","e"],["\u0207","e"],["\u0209","i"],["\u020b","i"],["\u020d","o"],["\u020f","o"],["\u0211","r"],["\u0213","r"],["\u0215", "u"],["\u0217","u"],["\u0219","s"],["\u021b","t"],["\u021f","h"],["\u0227","a"],["\u0229","e"],["\u022b","o"],["\u022d","o"],["\u022f","o"],["\u0231","o"],["\u0233","y"],["\u02b0","h"],["\u02b1","h"],["\u0266","h"],["\u02b2","j"],["\u02b3","r"],["\u02b4","\u0279"],["\u02b5","\u027b"],["\u02b6","\u0281"],["\u02b7","w"],["\u02b8","y"],["\u02e0","\u0263"],["\u02e1","l"],["\u02e2","s"],["\u02e3","x"],["\u02e4","\u0295"],["\u0390","\u03b9"],["\u03ac","\u03b1"],["\u03ad","\u03b5"],["\u03ae","\u03b7"],["\u03af", "\u03b9"],["\u03b0","\u03c5"],["\u03ca","\u03b9"],["\u03cb","\u03c5"],["\u03cc","\u03bf"],["\u03cd","\u03c5"],["\u03ce","\u03c9"],["\u03d0","\u03b2"],["\u03d1","\u03b8"],["\u03d2","\u03a5"],["\u03d3","\u03a5"],["\u03d4","\u03a5"],["\u03d5","\u03c6"],["\u03d6","\u03c0"],["\u03f0","\u03ba"],["\u03f1","\u03c1"],["\u03f2","\u03c2"],["\u03f5","\u03b5"],["\u0439","\u0438"],["\u0450","\u0435"],["\u0451","\u0435"],["\u0453","\u0433"],["\u0457","\u0456"],["\u045c","\u043a"],["\u045d","\u0438"],["\u045e","\u0443"], -["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];var Ba=/[^\p{L}\p{N}]+/u,Ca=/(\d{3})/g,Da=/(\D)(\d{3})/g,Ga=/(\d{3})(\D)/g,Ha="".normalize&&/[\u0300-\u036f]/g;function Ia(a){if(!this||this.constructor!==Ia){var b=Function.prototype.bind,c=b.apply,d=[null],e=d.concat;if(arguments instanceof Array)var g=arguments;else{g=w(arguments);for(var f,h=[];!(f=g.next()).done;)h.push(f.value);g=h}return new (c.call(b,Ia,e.call(d,g)))}for(b=0;b"a1a".split(c).length; -this.numeric=H(a.numeric,e)}else{try{this.split=H(this.split,Ba)}catch(g){this.split=/\s+/}this.numeric=H(a.numeric,H(this.numeric,!0))}this.prepare=H(a.prepare,null,this.prepare);this.finalize=H(a.finalize,null,this.finalize);Ha||(this.mapper=new Map(Aa));this.rtl=H(a.rtl,!1,this.rtl);this.dedupe=H(a.dedupe,!1,this.dedupe);this.filter=H((c=a.filter)&&new Set(c),null,this.filter);this.matcher=H((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=H((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= +this.numeric=H(a.numeric,e)}else{try{this.split=H(this.split,Ba)}catch(g){this.split=/\s+/}this.numeric=H(a.numeric,H(this.numeric,!0))}this.prepare=H(a.prepare,null,this.prepare);this.finalize=H(a.finalize,null,this.finalize);Fa||(this.mapper=new Map(Aa));this.rtl=H(a.rtl,!1,this.rtl);this.dedupe=H(a.dedupe,!1,this.dedupe);this.filter=H((c=a.filter)&&new Set(c),null,this.filter);this.matcher=H((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=H((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= H((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=H(a.replacer,null,this.replacer);this.minlength=H(a.minlength,1,this.minlength);this.maxlength=H(a.maxlength,0,this.maxlength);if(this.cache=c=H(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=w(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.h+=(this.h?"|":"")+b.value;if(this.stemmer)for(a=w(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&&N(this);return this};u.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&N(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&&N(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&&N(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(N,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.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 N(a){a.D=null;a.B.clear();a.C.clear()};function Ja(a){var b,c,d,e,g,f,h;return ta(function(k){a=a.data;b=self._index;c=a.args;d=a.task;switch(d){case "init":e=a.options||{};(g=a.factory)?(Function("return "+g)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new O(e);postMessage({id:a.id});break;default:f=a.id,h=b[d].apply(b,c),postMessage("search"===d?{id:f,msg:h}:{id:f})}k.h=0})};var Ka=0; @@ -56,79 +56,80 @@ function R(a){function b(f){function h(k){k=k.data||k;var l=k.id,m=l&&e.h[l];m&& "undefined"!==typeof window?window._factory:null;c&&(c=c.toString());var d="undefined"===typeof window,e=this,g=La(c,d,a.worker);return g.then?g.then(function(f){return b.call(e,f)}):b.call(this,g)}Ma("add");Ma("append");Ma("search");Ma("update");Ma("remove"); function Ma(a){R.prototype[a]=R.prototype[a+"Async"]=function(){var b=this,c=arguments,d,e,g,f,h;return ta(function(k){d=b;e=[].slice.call(c);g=e[e.length-1];"function"===typeof g&&(f=g,e.splice(e.length-1,1));h=new Promise(function(l){d.h[++Ka]=l;d.worker.postMessage({task:a,id:Ka,args:e})});return f?(h.then(f),k.return(b)):k.return(h)})}} function La(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="+Ja.toString()],{type:"text/javascript"}))):new window.Worker(K(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 Na(a){Oa.call(a,"add");Oa.call(a,"append");Oa.call(a,"search");Oa.call(a,"update");Oa.call(a,"remove")}function Oa(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]}b=this[a].apply(this,b);d&&(b.then?b.then(d):d(b));return b}};function Pa(a,b){b=void 0===b?0:b;var c=[],d=[];b&&(b=25E4/b*5E3|0);a=w(a.entries());for(var e=a.next();!e.done;e=a.next())d.push(e.value),d.length===b&&(c.push(d),d=[]);d.length&&c.push(d);return c}function Qa(a,b){b||(b=new Map);for(var c=0,d;c=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} +"module/worker/worker.js"),{type:"module"})};function Na(a){Oa.call(a,"add");Oa.call(a,"append");Oa.call(a,"search");Oa.call(a,"update");Oa.call(a,"remove")}var Pa,Qa,Ra={},Sa={};function Ta(a){Pa=0;Ra[a]=Sa[a]} +function Oa(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]}Pa||(Pa=setTimeout(Ta,0,a),Qa=Date.now());Sa[a]||(Sa[a]=Ra[a]=1E3);if(!--Ra[a]){Ra[a]=Sa[a]=Sa[a]*this.priority*this.priority*3/(Date.now()-Qa)|0||1;Pa=clearTimeout(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}};function Ua(a,b){b=void 0===b?0:b;var c=[],d=[];b&&(b=25E4/b*5E3|0);a=w(a.entries());for(var e=a.next();!e.done;e=a.next())d.push(e.value),d.length===b&&(c.push(d),d=[]);d.length&&c.push(d);return c}function Va(a,b){b||(b=new Map);for(var c=0,d;c=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 S(a){if(!this)return new S(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;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; +I();for(c=0;cc||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?W.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?W.call(this,f):f;e.push(f);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=eb(a,c,d,!1,this.h),d=0));return g?this.resolve(c,d,e):this};X.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=hb(this,"and",arguments),jb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)):c?this.resolve(d,e,g):this}; -function jb(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=za(a))return this.result=db(a,b,c,d,f,this.h,g),g?e?W.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?this.resolve(c,d,e):this};X.prototype.xor=function(){var a=hb(this,"xor",arguments);return kb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)}; -function kb(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=lb.call(this,a,c,d,g,this.h),g?e?W.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(c,d,e):this} -function lb(a,b,c,d,e){for(var g=[],f=I(),h=0,k=0,l;kb?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=h){c-=h;continue}cb&&(f=f.slice(0,b),h=b);if(!e.length&&h>=b)return d?W.call(this,f):f;e.push(f);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=jb(a,c,d,!1,this.h),d=0));return g?this.resolve(c,d,e):this};X.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=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}; +function ob(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=za(a))return this.result=ib(a,b,c,d,f,this.h,g),g?e?W.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?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){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=qb.call(this,a,c,d,g,this.h),g?e?W.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(c,d,e):this} +function qb(a,b,c,d,e){for(var g=[],f=I(),h=0,k=0,l;kc||d)a=a.slice(d,d+c);e&&(a=W.call(this,a));return a}} -function W(a){if(!this||!this.store)return a;for(var b=Array(a.length),c=0,d;cc||d)a=a.slice(d,d+c);e&&(a=W.call(this,a));return a}} +function W(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)}; -Y.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};Y.prototype.remove=function(a){for(var b=w(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)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};var ub={normalize:function(a){return a.toLowerCase()},numeric:!1,dedupe:!1};var vb=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 wb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),xb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];var yb={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 zb=/[\x00-\x7F]+/g;var Ab=/[\x00-\x7F]+/g;var Bb=/[\x00-\x7F]+/g;var Cb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:ub,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:vb},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:vb,matcher:wb,replacer:xb},LatinExtra:{normalize:!0,dedupe:!0,mapper:vb,replacer:xb.concat([/(?!^)[aeo]/g,""]),matcher:wb},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;bn;q--){p=l.substring(n,q);var r=this.score?this.score(b,l,k,p,n):Eb(h,d,k,m,n);Fb(this,g,p,r,a,c)}break}case "reverse":if(1< -m){for(q=m-1;0p?0:1),d,k,q-1,r-1),t=this.bidirectional&&l>n;Fb(this,e,t?n:l,x,a,c,t?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& -(b||this.commit_task.push({del:a}),this.ca&&Gb(this));return this}; -function Fb(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);if(a.fastupdate)for(c=w(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 Eb(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};O.prototype.remove=function(a,b){var c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(var d=0,e;de.length)e.pop();else{var g=e.indexOf(a);g===c.length-1?e.pop():e.splice(g,1)}}else Lb(this.map,a),this.depth&&Lb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Gb(this));this.cache&&this.cache.remove(a);return this}; -function Lb(a,b){var c=0;if(a.constructor===Array)for(var d=0,e=void 0,g;dthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.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};Y.prototype.remove=function(a){for(var b=w(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)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};var zb={normalize:function(a){return a.toLowerCase()}};var Ab=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 Bb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Cb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];var Db={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 Eb=/[\x00-\x7F]+/g;var Fb=/[\x00-\x7F]+/g;var Gb=/[\x00-\x7F]+/g;var Hb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:zb,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ab},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ab,matcher:Bb,replacer:Cb},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ab,replacer:Cb.concat([/(?!^)[aeo]/g,""]),matcher:Bb},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;bn;q--){p=l.substring(n,q);var r=this.score?this.score(b,l,k,p,n):Jb(h,d,k,m,n);Kb(this,g,p,r,a,c)}break}case "reverse":if(1< +m){for(q=m-1;0p?0:1),d,k,q-1,r-1),t=this.bidirectional&&l>n;Kb(this,e,t?n:l,x,a,c,t?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& +(b||this.commit_task.push({del:a}),this.ca&&Lb(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);if(a.fastupdate)for(c=w(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 Jb(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};O.prototype.remove=function(a,b){var c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(var d=0,e;de.length)e.pop();else{var g=e.indexOf(a);g===c.length-1?e.pop():e.splice(g,1)}}else Qb(this.map,a),this.depth&&Qb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Lb(this));this.cache&&this.cache.remove(a);return this}; +function Qb(a,b){var c=0;if(a.constructor===Array)for(var d=0,e=void 0,g;d=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length,p=d;p=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;dm&&!g&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(g=1),0<=m)if(e=1,1m&&!g&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(g=1),0<=m)if(e=1,1 "a1a".split(b).length; + this.split = b, d = !1 === b || 2 > "a1a".split(b).length; } - this.numeric = u(a.numeric, e); + this.numeric = u(a.numeric, d); } else { try { this.split = u(this.split, aa); - } 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 = u(a.numeric, u(this.numeric, !0)); @@ -116,13 +116,13 @@ t.assign = function(a) { this.h = ""; this.A = null; if (this.matcher) { - for (const d of this.matcher.keys()) { - this.g += (this.g ? "|" : "") + d; + for (const e of this.matcher.keys()) { + this.g += (this.g ? "|" : "") + e; } } if (this.stemmer) { - for (const d of this.stemmer.keys()) { - this.h += (this.h ? "|" : "") + d; + for (const e of this.stemmer.keys()) { + this.h += (this.h ? "|" : "") + e; } } return this; @@ -190,18 +190,18 @@ t.encode = function(a) { this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(ca, "$1 $2").replace(da, "$1 $2").replace(ba, "$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 g = 0, f, h; g < e.length; g++) { - if ((f = h = e[g]) && !(f.length < this.minlength)) { + let b = [], d = this.split || "" === this.split ? a.split(this.split) : a; + for (let g = 0, f, h; g < d.length; g++) { + if ((f = h = d[g]) && !(f.length < this.minlength)) { if (c) { b.push(f); } else { if (!this.filter || !this.filter.has(f)) { if (this.cache && f.length <= this.s) { if (this.l) { - var d = this.j.get(f); - if (d || "" === d) { - d && b.push(d); + var e = this.j.get(f); + if (e || "" === e) { + e && b.push(e); continue; } } else { @@ -210,16 +210,16 @@ t.encode = function(a) { } this.stemmer && 2 < f.length && (this.A || (this.A = new RegExp("(?!^)(" + this.h + ")$")), f = f.replace(this.A, k => this.stemmer.get(k)), f.length < this.minlength || this.filter && this.filter.has(f)) && (f = ""); if (f && (this.mapper || this.dedupe && 1 < f.length)) { - d = ""; + e = ""; for (let k = 0, l = "", n, m; k < f.length; k++) { - n = f.charAt(k), n === l && this.dedupe || ((m = this.mapper && this.mapper.get(n)) || "" === m ? m === l && this.dedupe || !(l = m) || (d += m) : d += l = n); + n = f.charAt(k), n === l && this.dedupe || ((m = this.mapper && this.mapper.get(n)) || "" === m ? m === l && this.dedupe || !(l = m) || (e += m) : e += l = n); } - f = d; + f = e; } this.matcher && 1 < f.length && (this.v || (this.v = new RegExp("(" + this.g + ")", "g")), f = f.replace(this.v, k => this.matcher.get(k))); if (f && this.replacer) { - for (d = 0; f && d < this.replacer.length; d += 2) { - f = f.replace(this.replacer[d], this.replacer[d + 1]); + for (e = 0; f && e < this.replacer.length; e += 2) { + f = f.replace(this.replacer[e], this.replacer[e + 1]); } } this.cache && h.length <= this.s && (this.j.set(h, f), this.j.size > this.C && (this.j.clear(), this.s = this.s / 1.1 | 0)); @@ -237,7 +237,7 @@ function B(a) { a.i.clear(); a.j.clear(); } -;function C(a, c, b, e, d) { +;function C(a, c, b, d, e) { const g = a.length; let f = [], h, k; h = w(); @@ -251,16 +251,16 @@ function B(a) { } } if (a = f.length) { - if (d) { - f = 1 < f.length ? D(f, b, e) : (f = f[0]).length > b || e ? f.slice(e, b + e) : f; + if (e) { + f = 1 < f.length ? D(f, b, d) : (f = f[0]).length > b || d ? f.slice(d, b + d) : f; } else { if (a < g) { return []; } f = f[a - 1]; - if (b || e) { - if (f.length > b || e) { - f = f.slice(e, b + e); + if (b || d) { + if (f.length > b || d) { + f = f.slice(d, b + d); } } } @@ -268,35 +268,35 @@ function B(a) { return f; } function D(a, c, b) { - const e = [], d = w(); + const d = [], e = w(); let g; var f = a.length; let h; for (let k = f - 1; 0 <= k; k--) { if (h = (f = a[k]) && f.length) { for (let l = 0; l < h; l++) { - if (g = f[l], !d[g]) { - if (d[g] = 1, b) { + if (g = f[l], !e[g]) { + if (e[g] = 1, b) { b--; } else { - if (e.push(g), e.length === c) { - return e; + if (d.push(g), d.length === c) { + return d; } } } } } } - return e; + return d; } -;function E(a, c, b, e) { +;function E(a, c, b, 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 ? F.call(this, a) : a; + return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, d ? F.call(this, a) : a; } - let d = []; + let e = []; for (let g = 0, f, h; g < a.length; g++) { if ((f = a[g]) && (h = f.length)) { if (b) { @@ -307,31 +307,31 @@ function D(a, c, b) { b < h && (f = c ? f.slice(b, b + c) : f.slice(b), h = f.length, b = 0); } h > c && (f = f.slice(0, c), h = c); - if (!d.length && h >= c) { - return e ? F.call(this, f) : f; + if (!e.length && h >= c) { + return d ? F.call(this, f) : f; } - d.push(f); + e.push(f); c -= h; if (!c) { break; } } } - d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? F.call(this, d) : d; + e = 1 < e.length ? [].concat.apply([], e) : e[0]; + return d ? F.call(this, e) : e; } ;function G(a, c, b) { - var e = b[0]; - if (e.then) { + var d = b[0]; + if (d.then) { return Promise.all(b).then(function(n) { return a[c].apply(a, n); }); } - if (e[0] && e[0].index) { - return a[c].apply(a, e); + if (d[0] && d[0].index) { + return a[c].apply(a, d); } - e = []; - let d = [], g = 0, f = 0, h, k, l; + d = []; + let e = [], g = 0, f = 0, h, k, l; for (let n = 0, m; n < b.length; n++) { if (m = b[n]) { let r; @@ -355,22 +355,22 @@ function D(a, c, b) { } } if (r.then) { - d.push(r); + e.push(r); } else if (r.length) { - e[n] = r; + d[n] = r; } else if (!l && ("and" === c || "xor" === c)) { - e = []; + d = []; break; } } } - return {m:e, u:d, limit:g, offset:f, enrich:h, resolve:k, suggest:l}; + return {m:d, u:e, limit:g, offset:f, enrich:h, resolve:k, suggest:l}; } ;I.prototype.or = function() { - const {m:a, u:c, limit:b, offset:e, enrich:d, resolve:g} = G(this, "or", arguments); - return J.call(this, a, c, b, e, d, g); + const {m:a, u:c, limit:b, offset:d, enrich:e, resolve:g} = G(this, "or", arguments); + return J.call(this, a, c, b, d, e, g); }; -function J(a, c, b, e, d, g) { +function J(a, c, b, d, e, g) { if (c.length) { const f = this; return Promise.all(c).then(function(h) { @@ -378,25 +378,25 @@ function J(a, c, b, e, d, g) { for (let k = 0, l; k < h.length; k++) { (l = h[k]).length && (a[k] = l); } - return J.call(f, a, [], b, e, d, g); + return J.call(f, a, [], b, d, e, g); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = D(a, b, e), e = 0)); - return g ? this.resolve(b, e, d) : this; + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = D(a, b, d), d = 0)); + return g ? this.resolve(b, d, e) : this; } ;I.prototype.and = function() { - let a = this.result.length, c, b, e, d; + let a = this.result.length, c, b, d, e; if (!a) { const g = arguments[0]; - g && (a = !!g.suggest, d = g.resolve, c = g.limit, b = g.offset, e = g.enrich && d); + g && (a = !!g.suggest, e = g.resolve, c = g.limit, b = g.offset, d = g.enrich && e); } if (a) { const {m:g, u:f, limit:h, offset:k, enrich:l, resolve:n, suggest:m} = G(this, "and", arguments); return K.call(this, g, f, h, k, l, n, m); } - return d ? this.resolve(c, b, e) : this; + return e ? this.resolve(c, b, d) : this; }; -function K(a, c, b, e, d, g, f) { +function K(a, c, b, d, e, g, f) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -404,7 +404,7 @@ function K(a, c, b, e, d, g, f) { for (let l = 0, n; l < k.length; l++) { (n = k[l]).length && (a[l] = n); } - return K.call(h, a, [], b, e, d, g, f); + return K.call(h, a, [], b, d, e, g, f); }); } if (a.length) { @@ -412,20 +412,20 @@ function K(a, c, b, e, d, g, f) { this.result = a[0]; } else { if (c = x(a)) { - return this.result = C(a, c, b, e, f), g ? d ? F.call(this.index, this.result) : this.result : this; + return this.result = C(a, c, b, d, f), g ? e ? F.call(this.index, this.result) : this.result : this; } this.result = []; } } else { f || (this.result = a); } - return g ? this.resolve(b, e, d) : this; + return g ? this.resolve(b, d, e) : this; } ;I.prototype.xor = function() { - const {m:a, u:c, limit:b, offset:e, enrich:d, resolve:g, suggest:f} = G(this, "xor", arguments); - return L.call(this, a, c, b, e, d, g, f); + const {m:a, u:c, limit:b, offset:d, enrich:e, resolve:g, suggest:f} = G(this, "xor", arguments); + return L.call(this, a, c, b, d, e, g, f); }; -function L(a, c, b, e, d, g, f) { +function L(a, c, b, d, e, g, f) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -433,21 +433,21 @@ function L(a, c, b, e, d, g, f) { for (let l = 0, n; l < k.length; l++) { (n = k[l]).length && (a[l] = n); } - return L.call(h, a, [], b, e, d, g, f); + return L.call(h, a, [], b, d, e, g, f); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = ea.call(this, a, b, e, g, this.g), g ? d ? F.call(this.index, this.result) : this.result : this; + return this.result = ea.call(this, a, b, d, g, this.g), g ? e ? F.call(this.index, this.result) : this.result : this; } } else { f || (this.result = a); } - return g ? this.resolve(b, e, d) : this; + return g ? this.resolve(b, d, e) : this; } -function ea(a, c, b, e, d) { +function ea(a, c, b, d, e) { const g = [], f = w(); let h = 0; for (let k = 0, l; k < a.length; k++) { @@ -471,12 +471,12 @@ function ea(a, c, b, e, d) { if (b) { b--; } else { - if (e) { + if (d) { if (g.push(p), g.length === c) { return g; } } else { - const v = k + (m ? d : 0); + const v = k + (m ? e : 0); g[v] || (g[v] = []); g[v].push(p); if (++n === c) { @@ -493,10 +493,10 @@ function ea(a, c, b, e, d) { return g; } ;I.prototype.not = function() { - const {m:a, u:c, limit:b, offset:e, enrich:d, resolve:g, suggest:f} = G(this, "not", arguments); - return M.call(this, a, c, b, e, d, g, f); + const {m:a, u:c, limit:b, offset:d, enrich:e, resolve:g, suggest:f} = G(this, "not", arguments); + return M.call(this, a, c, b, d, e, g, f); }; -function M(a, c, b, e, d, g, f) { +function M(a, c, b, d, e, g, f) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -504,18 +504,18 @@ function M(a, c, b, e, d, g, f) { for (let l = 0, n; l < k.length; l++) { (n = k[l]).length && (a[l] = n); } - return M.call(h, a, [], b, e, d, g, f); + return M.call(h, a, [], b, d, e, g, f); }); } if (a.length && this.result.length) { - this.result = fa.call(this, a, b, e, g); + this.result = fa.call(this, a, b, d, g); } else if (g) { - return this.resolve(b, e, d); + return this.resolve(b, d, e); } - return g ? d ? F.call(this.index, this.result) : this.result : this; + return g ? e ? F.call(this.index, this.result) : this.result : this; } -function fa(a, c, b, e) { - const d = []; +function fa(a, c, b, d) { + const e = []; a = new Set(a.flat().flat()); for (let g = 0, f, h = 0; g < this.result.length; g++) { if (f = this.result[g]) { @@ -524,13 +524,13 @@ function fa(a, c, b, e) { if (b) { b--; } else { - if (e) { - if (d.push(l), d.length === c) { - return d; + if (d) { + if (e.push(l), e.length === c) { + return e; } } else { - if (d[g] || (d[g] = []), d[g].push(l), ++h === c) { - return d; + if (e[g] || (e[g] = []), e[g].push(l), ++h === c) { + return e; } } } @@ -538,7 +538,7 @@ function fa(a, c, b, e) { } } } - return d; + return e; } ;function I(a) { if (!this || this.constructor !== I) { @@ -554,25 +554,29 @@ function fa(a, c, b, e) { I.prototype.limit = function(a) { if (this.result.length) { const c = []; - let b = 0; - for (let e = 0, d; e < this.result.length; e++) { - if (d = this.result[e], d.length + b < a) { - c[e] = d, b += d.length; - } else { - c[e] = d.slice(0, a - b); - this.result = c; - break; + for (let b = 0, d; b < this.result.length; b++) { + if (d = this.result[b]) { + if (d.length <= a) { + if (c[b] = d, a -= d.length, !a) { + break; + } + } else { + c[b] = d.slice(0, a); + break; + } } } + this.result = c; } return this; }; I.prototype.offset = function(a) { if (this.result.length) { const c = []; - let b = 0; - for (let e = 0, d; e < this.result.length; e++) { - d = this.result[e], d.length + b < a ? b += d.length : (c[e] = d.slice(a - b), b = a); + for (let b = 0, d; b < this.result.length; b++) { + if (d = this.result[b]) { + d.length <= a ? a -= d.length : (c[b] = d.slice(a), a = 0); + } } this.result = c; } @@ -583,9 +587,9 @@ I.prototype.boost = function(a) { return this; }; I.prototype.resolve = function(a, c, b) { - const e = this.result, d = this.index; + 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), E.call(d, e, a || 100, c, b)) : e; + return d.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), E.call(e, d, a || 100, c, b)) : d; }; w(); function F(a) { @@ -593,8 +597,8 @@ function F(a) { 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)}; + for (let b = 0, d; b < a.length; b++) { + d = a[b], c[b] = {id:d, doc:this.store.get(d)}; } return c; } @@ -624,53 +628,53 @@ N.prototype.clear = function() { }; const ha = {normalize:function(a) { return a.toLowerCase(); -}, numeric:!1, dedupe:!1}; +}}; const O = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; -P.prototype.add = function(a, c, b, e) { +P.prototype.add = function(a, c, b, d) { if (c && (a || 0 === a)) { - if (!e && !b && this.reg.has(a)) { + if (!d && !b && this.reg.has(a)) { return this.update(a, c); } c = this.encoder.encode(c); - if (e = c.length) { + if (d = c.length) { const l = w(), n = w(), m = this.depth, r = this.resolution; - for (let q = 0; q < e; q++) { - let p = c[this.rtl ? e - 1 - q : q]; - var d = p.length; - if (d && (m || !n[p])) { - var g = this.score ? this.score(c, p, q, null, 0) : Q(r, e, q), f = ""; + for (let q = 0; q < d; q++) { + let p = c[this.rtl ? d - 1 - q : q]; + var e = p.length; + if (e && (m || !n[p])) { + var g = this.score ? this.score(c, p, q, null, 0) : Q(r, d, q), f = ""; switch(this.tokenize) { case "full": - if (2 < d) { - for (g = 0; g < d; g++) { - for (var h = d; h > g; h--) { + if (2 < e) { + for (g = 0; g < e; g++) { + for (var h = e; h > g; h--) { f = p.substring(g, h); - var k = this.score ? this.score(c, p, q, f, g) : Q(r, e, q, d, g); + var k = this.score ? this.score(c, p, q, f, g) : Q(r, d, q, e, g); R(this, n, f, k, a, b); } } break; } case "reverse": - if (1 < d) { - for (h = d - 1; 0 < h; h--) { - f = p[h] + f, k = this.score ? this.score(c, p, q, f, h) : Q(r, e, q, d, h), R(this, n, f, k, a, b); + if (1 < e) { + for (h = e - 1; 0 < h; h--) { + f = p[h] + f, k = this.score ? this.score(c, p, q, f, h) : Q(r, d, q, e, h), R(this, n, f, k, a, b); } f = ""; } case "forward": - if (1 < d) { - for (h = 0; h < d; h++) { + if (1 < e) { + for (h = 0; h < e; h++) { f += p[h], R(this, n, f, g, a, b); } break; } default: - if (R(this, n, p, g, a, b), m && 1 < e && q < e - 1) { - for (d = w(), f = this.B, g = p, h = Math.min(m + 1, e - q), d[g] = 1, k = 1; k < h; k++) { - if ((p = c[this.rtl ? e - 1 - q - k : q + k]) && !d[p]) { - d[p] = 1; - const v = this.score ? this.score(c, g, q, p, k) : Q(f + (e / 2 > f ? 0 : 1), e, q, h - 1, k - 1), A = this.bidirectional && p > g; + if (R(this, n, p, g, a, b), m && 1 < d && q < d - 1) { + for (e = w(), f = this.B, g = p, h = Math.min(m + 1, d - q), e[g] = 1, k = 1; k < h; k++) { + if ((p = c[this.rtl ? d - 1 - q - k : q + k]) && !e[p]) { + e[p] = 1; + const v = this.score ? this.score(c, g, q, p, k) : Q(f + (d / 2 > f ? 0 : 1), d, q, h - 1, k - 1), A = this.bidirectional && p > g; R(this, l, A ? g : p, v, a, b, A ? p : g); } } @@ -683,22 +687,22 @@ P.prototype.add = function(a, c, b, e) { } return this; }; -function R(a, c, b, e, d, g, f) { +function R(a, c, b, d, e, g, f) { let h = f ? a.ctx : a.map, k; if (!c[b] || f && !(k = c[b])[f]) { - f ? (c = k || (c[b] = w()), c[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), g && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h]))); + f ? (c = k || (c[b] = w()), c[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[d] || (h[d] = []), g && h.includes(e) || (h.push(e), a.fastupdate && ((c = a.reg.get(e)) ? c.push(h) : a.reg.set(e, [h]))); } } -function Q(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 Q(a, c, b, d, e) { + return b && 1 < a ? c + (d || 0) <= a ? b + (e || 0) : (a - 1) / (c + (d || 0)) * (b + (e || 0)) + 1 | 0 : 0; } ;P.prototype.search = function(a, c, b) { b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); - var e = [], d = 0; + var d = [], e = 0; if (b) { a = b.query || a; c = b.limit || c; - d = b.offset || 0; + e = b.offset || 0; var g = b.context; var f = b.suggest; var h = !0; @@ -710,11 +714,11 @@ function Q(a, c, b, e, d) { a = b.length; c = c || (h ? 100 : 0); if (1 === a) { - return S.call(this, b[0], "", c, d, h); + return S.call(this, b[0], "", c, e, h); } g = this.depth && !1 !== g; if (2 === a && g && !f) { - return S.call(this, b[0], b[1], c, d, h); + return S.call(this, b[0], b[1], c, e, h); } h = w(); let l = 0; @@ -729,7 +733,7 @@ function Q(a, c, b, e, d) { p = T(this, v, n); a: { g = p; - var m = e, r = f, q = k; + var m = d, r = f, q = k; let A = []; if (g && g.length) { if (g.length <= q) { @@ -751,34 +755,34 @@ function Q(a, c, b, e, d) { p = r ? void 0 : A; } if (p) { - e = p; + d = p; break; } - n && (f && p && e.length || (n = v)); + n && (f && p && d.length || (n = v)); } - f && n && l === a - 1 && !e.length && (n = "", l = -1, h = w()); + f && n && l === a - 1 && !d.length && (n = "", l = -1, h = w()); } a: { - n = e.length; - a = e; + n = d.length; + a = d; if (1 < n) { - a = C(e, k, c, d, f); + a = C(d, k, c, e, f); } else if (1 === n) { - f = E.call(null, e[0], c, d); + f = E.call(null, d[0], c, e); break a; } f = a; } return f; }; -function S(a, c, b, e, d) { +function S(a, c, b, d, e) { a = T(this, a, c); - d = !0; - return a && a.length ? d ? E.call(this, a, b, e) : new I(a) : d ? [] : new I(); + e = !0; + return a && a.length ? e ? E.call(this, a, b, d) : new I(a) : e ? [] : new I(); } function T(a, c, b) { - let e; - b && (e = a.bidirectional && c > b) && (e = b, b = c, c = e); + let d; + b && (d = a.bidirectional && c > b) && (d = b, b = c, c = d); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } @@ -786,13 +790,13 @@ function T(a, c, b) { const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); if (b) { 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 < b.length; d++) { + if (e = b[d]) { + if (2 > e.length) { + e.pop(); } else { - const g = d.indexOf(a); - g === b.length - 1 ? d.pop() : d.splice(g, 1); + const g = e.indexOf(a); + g === b.length - 1 ? e.pop() : e.splice(g, 1); } } } @@ -807,10 +811,10 @@ function T(a, c, b) { function U(a, c) { let b = 0; if (a.constructor === Array) { - for (let e = 0, d, g; e < a.length; e++) { - if ((d = a[e]) && d.length) { - if (g = d.indexOf(c), 0 <= g) { - 1 < d.length ? (d.splice(g, 1), b++) : delete a[e]; + for (let d = 0, e, g; d < a.length; d++) { + if ((e = a[d]) && e.length) { + if (g = e.indexOf(c), 0 <= g) { + 1 < e.length ? (e.splice(g, 1), b++) : delete a[d]; break; } else { b++; @@ -818,9 +822,9 @@ function U(a, c) { } } } else { - for (let e of a.entries()) { - const d = e[0], g = U(e[1], c); - g ? b += g : a.delete(d); + for (let d of a.entries()) { + const e = d[0], g = U(d[1], c); + g ? b += g : a.delete(e); } } return b; @@ -836,20 +840,20 @@ function U(a, c) { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || ha; - this.encoder = d.encode ? d : "object" === typeof d ? new z(d) : {encode:d}; + const d = !0 === b ? {depth:1} : b || {}, e = a.encode || a.encoder || ha; + this.encoder = e.encode ? e : "object" === typeof e ? new z(e) : {encode:e}; this.resolution = a.resolution || 9; this.tokenize = b = a.tokenize || "strict"; - this.depth = "strict" === b && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.depth = "strict" === b && d.depth || 0; + this.bidirectional = !1 !== d.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.B = e.resolution || 3; - this.rtl = d.rtl || a.rtl || !1; + this.B = d.resolution || 3; + this.rtl = e.rtl || a.rtl || !1; this.cache = (b = a.cache || null) && new N(b); } t = P.prototype; @@ -867,19 +871,19 @@ t.contain = function(a) { return 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); + const b = this, d = this.remove(a); + return d && d.then ? d.then(() => b.add(a, c)) : this.add(a, c); }; function V(a) { let c = 0; if (a.constructor === Array) { - for (let b = 0, e; b < a.length; b++) { - (e = a[b]) && (c += e.length); + for (let b = 0, d; b < a.length; b++) { + (d = a[b]) && (c += d.length); } } else { for (const b of a) { - const e = b[0], d = V(b[1]); - d ? c += d : a.delete(e); + const d = b[0], e = V(b[1]); + e ? c += e : a.delete(d); } } return c; @@ -895,19 +899,19 @@ t.cleanup = function() { t.searchCache = function(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new N()); - let e = this.cache.get(a); - if (!e) { - e = this.search(a, c, b); - if (e.then) { - const d = this; - e.then(function(g) { - d.cache.set(a, g); + let d = this.cache.get(a); + if (!d) { + d = this.search(a, c, b); + if (d.then) { + const e = this; + d.then(function(g) { + e.cache.set(a, g); return g; }); } - this.cache.set(a, e); + this.cache.set(a, d); } - return e; + return d; }; const W = {Index:P, Charset:null, Encoder:z, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, X = self; let Z; diff --git a/dist/flexsearch.light.min.js b/dist/flexsearch.light.min.js index 92b6ffc..6f06d10 100644 --- a/dist/flexsearch.light.min.js +++ b/dist/flexsearch.light.min.js @@ -1,34 +1,34 @@ /**! - * FlexSearch.js v0.8.105 (Light) + * FlexSearch.js v0.8.107 (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 t;function u(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(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var f of a)g.set(f[0],f[1]);return g}if(c===Set){f=new Set(b);for(g of a.values())f.add(g);return f}}}return a}return b}return"undefined"===d?c:a}function w(){return Object.create(null)} -function x(a){let c=0;for(let b=0,e;b"a1a".split(b).length; -this.numeric=u(a.numeric,e)}else{try{this.split=u(this.split,y)}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);this.rtl=u(a.rtl,!1,this.rtl);this.dedupe=u(a.dedupe,!1,this.dedupe);this.filter=u((b=a.filter)&&new Set(b),null,this.filter);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,0,this.maxlength);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.C="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.s=this.o=128;this.g="";this.v=null;this.h="";this.A=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}; +(function(self){'use strict';var t;function u(a,c,b){const d=typeof b,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(b){if("function"===e&&d===e)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var f of a)g.set(f[0],f[1]);return g}if(c===Set){f=new Set(b);for(g of a.values())f.add(g);return f}}}return a}return b}return"undefined"===e?c:a}function w(){return Object.create(null)} +function x(a){let c=0;for(let b=0,d;b"a1a".split(b).length; +this.numeric=u(a.numeric,d)}else{try{this.split=u(this.split,y)}catch(e){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);this.rtl=u(a.rtl,!1,this.rtl);this.dedupe=u(a.dedupe,!1,this.dedupe);this.filter=u((b=a.filter)&&new Set(b),null,this.filter);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,0,this.maxlength);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.C="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.s=this.o=128;this.g="";this.v=null;this.h="";this.A=null;if(this.matcher)for(const e of this.matcher.keys())this.g+=(this.g?"|":"")+e;if(this.stemmer)for(const e of this.stemmer.keys())this.h+=(this.h?"|":"")+e;return this}; t.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.A=null;this.cache&&C(this);return this};t.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&C(this);return this};t.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.v=null;this.cache&&C(this);return this};t.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&C(this);return this}; t.encode=function(a){if(this.cache&&a.length<=this.o)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(C,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=z?a.normalize("NFKD").replace(z,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),f.lengththis.matcher.get(k)));if(f&&this.replacer)for(d=0;f&&dthis.C&& -(this.j.clear(),this.s=this.s/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.o&&(this.i.set(a,b),this.i.size>this.C&&(this.i.clear(),this.o=this.o/1.1|0));return b};function C(a){a.l=null;a.i.clear();a.j.clear()};function D(a,c,b,e,d){const g=a.length;let f=[],h,k;h=w();for(let l=0,n,m,r,q;lb||e?f.slice(e,b+e):f;else{if(ab||e)f=f.slice(e,b+e)}return f} -function E(a,c,b){const e=[],d=w();let g;var f=a.length;let h;for(let k=f-1;0<=k;k--)if(h=(f=a[k])&&f.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?G.call(this,a):a;let d=[];for(let g=0,f,h;g=h){b-=h;continue}bc&&(f=f.slice(0,c),h=c);if(!d.length&&h>=c)return e?G.call(this,f):f;d.push(f);c-=h;if(!c)break}d=1a.length?this.result=a[0]:(this.result=E(a,b,e),e=0));return g?this.resolve(b,e,d):this};J.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const g=arguments[0];g&&(a=!!g.suggest,d=g.resolve,c=g.limit,b=g.offset,e=g.enrich&&d)}if(a){const {m:g,u:f,limit:h,offset:k,enrich:l,resolve:n,suggest:m}=I(this,"and",arguments);return L.call(this,g,f,h,k,l,n,m)}return d?this.resolve(c,b,e):this}; -function L(a,c,b,e,d,g,f){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(c=x(a))return this.result=D(a,c,b,e,f),g?d?G.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?this.resolve(b,e,d):this};J.prototype.xor=function(){const {m:a,u:c,limit:b,offset:e,enrich:d,resolve:g,suggest:f}=I(this,"xor",arguments);return M.call(this,a,c,b,e,d,g,f)}; -function M(a,c,b,e,d,g,f){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=da.call(this,a,b,e,g,this.g),g?d?G.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(b,e,d):this} -function da(a,c,b,e,d){const g=[],f=w();let h=0;for(let k=0,l;kthis.limit&&this.cache.delete(this.cache.keys().next().value)};O.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};O.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}}; -O.prototype.clear=function(){this.cache.clear();this.g=""};const fa={normalize:function(a){return a.toLowerCase()},numeric:!1,dedupe:!1};const ha={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};P.prototype.add=function(a,c,b,e){if(c&&(a||0===a)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(e=c.length){const l=w(),n=w(),m=this.depth,r=this.resolution;for(let q=0;qg;h--){f=p.substring(g,h);var k=this.score?this.score(c,p,q,f,g):Q(r,e,q,d,g);R(this,n,f,k,a,b)}break}case "reverse":if(1< -d){for(h=d-1;0f?0:1),e,q,h-1,k-1),A=this.bidirectional&&p>g;R(this,l,A?g:p,v,a,b,A?p:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function R(a,c,b,e,d,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=w()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function Q(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};P.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 e=0,d;ed.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else U(this.map,a),this.depth&&U(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function U(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,g;eb.add(a,c)):this.add(a,c)}; -function V(a){let c=0;if(a.constructor===Array)for(let b=0,e;bthis.stemmer.get(k)),f.lengththis.matcher.get(k)));if(f&&this.replacer)for(e=0;f&&ethis.C&& +(this.j.clear(),this.s=this.s/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.o&&(this.i.set(a,b),this.i.size>this.C&&(this.i.clear(),this.o=this.o/1.1|0));return b};function C(a){a.l=null;a.i.clear();a.j.clear()};function D(a,c,b,d,e){const g=a.length;let f=[],h,k;h=w();for(let l=0,n,m,r,q;lb||d?f.slice(d,b+d):f;else{if(ab||d)f=f.slice(d,b+d)}return f} +function E(a,c,b){const d=[],e=w();let g;var f=a.length;let h;for(let k=f-1;0<=k;k--)if(h=(f=a[k])&&f.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,d?G.call(this,a):a;let e=[];for(let g=0,f,h;g=h){b-=h;continue}bc&&(f=f.slice(0,c),h=c);if(!e.length&&h>=c)return d?G.call(this,f):f;e.push(f);c-=h;if(!c)break}e=1a.length?this.result=a[0]:(this.result=E(a,b,d),d=0));return g?this.resolve(b,d,e):this};J.prototype.and=function(){let a=this.result.length,c,b,d,e;if(!a){const g=arguments[0];g&&(a=!!g.suggest,e=g.resolve,c=g.limit,b=g.offset,d=g.enrich&&e)}if(a){const {m:g,u:f,limit:h,offset:k,enrich:l,resolve:n,suggest:m}=I(this,"and",arguments);return L.call(this,g,f,h,k,l,n,m)}return e?this.resolve(c,b,d):this}; +function L(a,c,b,d,e,g,f){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(c=x(a))return this.result=D(a,c,b,d,f),g?e?G.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?this.resolve(b,d,e):this};J.prototype.xor=function(){const {m:a,u:c,limit:b,offset:d,enrich:e,resolve:g,suggest:f}=I(this,"xor",arguments);return M.call(this,a,c,b,d,e,g,f)}; +function M(a,c,b,d,e,g,f){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=da.call(this,a,b,d,g,this.g),g?e?G.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(b,d,e):this} +function da(a,c,b,d,e){const g=[],f=w();let h=0;for(let k=0,l;kthis.limit&&this.cache.delete(this.cache.keys().next().value)};O.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};O.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}}; +O.prototype.clear=function(){this.cache.clear();this.g=""};const fa={normalize:function(a){return a.toLowerCase()}};const ha={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};P.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const l=w(),n=w(),m=this.depth,r=this.resolution;for(let q=0;qg;h--){f=p.substring(g,h);var k=this.score?this.score(c,p,q,f,g):Q(r,d,q,e,g);R(this,n,f,k,a,b)}break}case "reverse":if(1< +e){for(h=e-1;0f?0:1),d,q,h-1,k-1),A=this.bidirectional&&p>g;R(this,l,A?g:p,v,a,b,A?p:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function R(a,c,b,d,e,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=w()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),g&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.reg.get(e))?c.push(h):a.reg.set(e,[h])))}function Q(a,c,b,d,e){return b&&1b)&&(d=b,b=c,c=d);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};P.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 d=0,e;de.length)e.pop();else{const g=e.indexOf(a);g===b.length-1?e.pop():e.splice(g,1)}}else U(this.map,a),this.depth&&U(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function U(a,c){let b=0;if(a.constructor===Array)for(let d=0,e,g;db.add(a,c)):this.add(a,c)}; +function V(a){let c=0;if(a.constructor===Array)for(let b=0,d;b "a1a".split(b).length; + this.split = b, d = !1 === b || 2 > "a1a".split(b).length; } - this.numeric = u(a.numeric, e); + this.numeric = u(a.numeric, d); } else { try { this.split = u(this.split, y); - } 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 = u(a.numeric, u(this.numeric, !0)); @@ -115,13 +115,13 @@ t.assign = function(a) { this.h = ""; this.A = null; if (this.matcher) { - for (const d of this.matcher.keys()) { - this.g += (this.g ? "|" : "") + d; + for (const e of this.matcher.keys()) { + this.g += (this.g ? "|" : "") + e; } } if (this.stemmer) { - for (const d of this.stemmer.keys()) { - this.h += (this.h ? "|" : "") + d; + for (const e of this.stemmer.keys()) { + this.h += (this.h ? "|" : "") + e; } } return this; @@ -189,18 +189,18 @@ t.encode = function(a) { this.prepare && (a = this.prepare(a)); this.numeric && 3 < a.length && (a = a.replace(B, "$1 $2").replace(aa, "$1 $2").replace(z, "$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 g = 0, f, h; g < e.length; g++) { - if ((f = h = e[g]) && !(f.length < this.minlength)) { + let b = [], d = this.split || "" === this.split ? a.split(this.split) : a; + for (let g = 0, f, h; g < d.length; g++) { + if ((f = h = d[g]) && !(f.length < this.minlength)) { if (c) { b.push(f); } else { if (!this.filter || !this.filter.has(f)) { if (this.cache && f.length <= this.s) { if (this.l) { - var d = this.j.get(f); - if (d || "" === d) { - d && b.push(d); + var e = this.j.get(f); + if (e || "" === e) { + e && b.push(e); continue; } } else { @@ -209,16 +209,16 @@ t.encode = function(a) { } this.stemmer && 2 < f.length && (this.A || (this.A = new RegExp("(?!^)(" + this.h + ")$")), f = f.replace(this.A, k => this.stemmer.get(k)), f.length < this.minlength || this.filter && this.filter.has(f)) && (f = ""); if (f && (this.mapper || this.dedupe && 1 < f.length)) { - d = ""; + e = ""; for (let k = 0, l = "", n, m; k < f.length; k++) { - n = f.charAt(k), n === l && this.dedupe || ((m = this.mapper && this.mapper.get(n)) || "" === m ? m === l && this.dedupe || !(l = m) || (d += m) : d += l = n); + n = f.charAt(k), n === l && this.dedupe || ((m = this.mapper && this.mapper.get(n)) || "" === m ? m === l && this.dedupe || !(l = m) || (e += m) : e += l = n); } - f = d; + f = e; } this.matcher && 1 < f.length && (this.v || (this.v = new RegExp("(" + this.g + ")", "g")), f = f.replace(this.v, k => this.matcher.get(k))); if (f && this.replacer) { - for (d = 0; f && d < this.replacer.length; d += 2) { - f = f.replace(this.replacer[d], this.replacer[d + 1]); + for (e = 0; f && e < this.replacer.length; e += 2) { + f = f.replace(this.replacer[e], this.replacer[e + 1]); } } this.cache && h.length <= this.s && (this.j.set(h, f), this.j.size > this.C && (this.j.clear(), this.s = this.s / 1.1 | 0)); @@ -236,7 +236,7 @@ function E(a) { a.i.clear(); a.j.clear(); } -;function F(a, c, b, e, d) { +;function F(a, c, b, d, e) { const g = a.length; let f = [], h, k; h = w(); @@ -250,16 +250,16 @@ function E(a) { } } if (a = f.length) { - if (d) { - f = 1 < f.length ? G(f, b, e) : (f = f[0]).length > b || e ? f.slice(e, b + e) : f; + if (e) { + f = 1 < f.length ? G(f, b, d) : (f = f[0]).length > b || d ? f.slice(d, b + d) : f; } else { if (a < g) { return []; } f = f[a - 1]; - if (b || e) { - if (f.length > b || e) { - f = f.slice(e, b + e); + if (b || d) { + if (f.length > b || d) { + f = f.slice(d, b + d); } } } @@ -267,35 +267,35 @@ function E(a) { return f; } function G(a, c, b) { - const e = [], d = w(); + const d = [], e = w(); let g; var f = a.length; let h; for (let k = f - 1; 0 <= k; k--) { if (h = (f = a[k]) && f.length) { for (let l = 0; l < h; l++) { - if (g = f[l], !d[g]) { - if (d[g] = 1, b) { + if (g = f[l], !e[g]) { + if (e[g] = 1, b) { b--; } else { - if (e.push(g), e.length === c) { - return e; + if (d.push(g), d.length === c) { + return d; } } } } } } - return e; + return d; } -;function I(a, c, b, e) { +;function I(a, c, b, 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 ? J.call(this, a) : a; + return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, d ? J.call(this, a) : a; } - let d = []; + let e = []; for (let g = 0, f, h; g < a.length; g++) { if ((f = a[g]) && (h = f.length)) { if (b) { @@ -306,31 +306,31 @@ function G(a, c, b) { b < h && (f = c ? f.slice(b, b + c) : f.slice(b), h = f.length, b = 0); } h > c && (f = f.slice(0, c), h = c); - if (!d.length && h >= c) { - return e ? J.call(this, f) : f; + if (!e.length && h >= c) { + return d ? J.call(this, f) : f; } - d.push(f); + e.push(f); c -= h; if (!c) { break; } } } - d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? J.call(this, d) : d; + e = 1 < e.length ? [].concat.apply([], e) : e[0]; + return d ? J.call(this, e) : e; } ;function K(a, c, b) { - var e = b[0]; - if (e.then) { + var d = b[0]; + if (d.then) { return Promise.all(b).then(function(n) { return a[c].apply(a, n); }); } - if (e[0] && e[0].index) { - return a[c].apply(a, e); + if (d[0] && d[0].index) { + return a[c].apply(a, d); } - e = []; - let d = [], g = 0, f = 0, h, k, l; + d = []; + let e = [], g = 0, f = 0, h, k, l; for (let n = 0, m; n < b.length; n++) { if (m = b[n]) { let r; @@ -354,22 +354,22 @@ function G(a, c, b) { } } if (r.then) { - d.push(r); + e.push(r); } else if (r.length) { - e[n] = r; + d[n] = r; } else if (!l && ("and" === c || "xor" === c)) { - e = []; + d = []; break; } } } - return {m:e, u:d, limit:g, offset:f, enrich:h, resolve:k, suggest:l}; + return {m:d, u:e, limit:g, offset:f, enrich:h, resolve:k, suggest:l}; } ;L.prototype.or = function() { - const {m:a, u:c, limit:b, offset:e, enrich:d, resolve:g} = K(this, "or", arguments); - return M.call(this, a, c, b, e, d, g); + const {m:a, u:c, limit:b, offset:d, enrich:e, resolve:g} = K(this, "or", arguments); + return M.call(this, a, c, b, d, e, g); }; -function M(a, c, b, e, d, g) { +function M(a, c, b, d, e, g) { if (c.length) { const f = this; return Promise.all(c).then(function(h) { @@ -377,25 +377,25 @@ function M(a, c, b, e, d, g) { for (let k = 0, l; k < h.length; k++) { (l = h[k]).length && (a[k] = l); } - return M.call(f, a, [], b, e, d, g); + return M.call(f, a, [], b, d, e, g); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = G(a, b, e), e = 0)); - return g ? this.resolve(b, e, d) : this; + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = G(a, b, d), d = 0)); + return g ? this.resolve(b, d, e) : this; } ;L.prototype.and = function() { - let a = this.result.length, c, b, e, d; + let a = this.result.length, c, b, d, e; if (!a) { const g = arguments[0]; - g && (a = !!g.suggest, d = g.resolve, c = g.limit, b = g.offset, e = g.enrich && d); + g && (a = !!g.suggest, e = g.resolve, c = g.limit, b = g.offset, d = g.enrich && e); } if (a) { const {m:g, u:f, limit:h, offset:k, enrich:l, resolve:n, suggest:m} = K(this, "and", arguments); return N.call(this, g, f, h, k, l, n, m); } - return d ? this.resolve(c, b, e) : this; + return e ? this.resolve(c, b, d) : this; }; -function N(a, c, b, e, d, g, f) { +function N(a, c, b, d, e, g, f) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -403,7 +403,7 @@ function N(a, c, b, e, d, g, f) { for (let l = 0, n; l < k.length; l++) { (n = k[l]).length && (a[l] = n); } - return N.call(h, a, [], b, e, d, g, f); + return N.call(h, a, [], b, d, e, g, f); }); } if (a.length) { @@ -411,20 +411,20 @@ function N(a, c, b, e, d, g, f) { this.result = a[0]; } else { if (c = x(a)) { - return this.result = F(a, c, b, e, f), g ? d ? J.call(this.index, this.result) : this.result : this; + return this.result = F(a, c, b, d, f), g ? e ? J.call(this.index, this.result) : this.result : this; } this.result = []; } } else { f || (this.result = a); } - return g ? this.resolve(b, e, d) : this; + return g ? this.resolve(b, d, e) : this; } ;L.prototype.xor = function() { - const {m:a, u:c, limit:b, offset:e, enrich:d, resolve:g, suggest:f} = K(this, "xor", arguments); - return O.call(this, a, c, b, e, d, g, f); + const {m:a, u:c, limit:b, offset:d, enrich:e, resolve:g, suggest:f} = K(this, "xor", arguments); + return O.call(this, a, c, b, d, e, g, f); }; -function O(a, c, b, e, d, g, f) { +function O(a, c, b, d, e, g, f) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -432,21 +432,21 @@ function O(a, c, b, e, d, g, f) { for (let l = 0, n; l < k.length; l++) { (n = k[l]).length && (a[l] = n); } - return O.call(h, a, [], b, e, d, g, f); + return O.call(h, a, [], b, d, e, g, f); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = ba.call(this, a, b, e, g, this.g), g ? d ? J.call(this.index, this.result) : this.result : this; + return this.result = ba.call(this, a, b, d, g, this.g), g ? e ? J.call(this.index, this.result) : this.result : this; } } else { f || (this.result = a); } - return g ? this.resolve(b, e, d) : this; + return g ? this.resolve(b, d, e) : this; } -function ba(a, c, b, e, d) { +function ba(a, c, b, d, e) { const g = [], f = w(); let h = 0; for (let k = 0, l; k < a.length; k++) { @@ -470,12 +470,12 @@ function ba(a, c, b, e, d) { if (b) { b--; } else { - if (e) { + if (d) { if (g.push(p), g.length === c) { return g; } } else { - const v = k + (m ? d : 0); + const v = k + (m ? e : 0); g[v] || (g[v] = []); g[v].push(p); if (++n === c) { @@ -492,10 +492,10 @@ function ba(a, c, b, e, d) { return g; } ;L.prototype.not = function() { - const {m:a, u:c, limit:b, offset:e, enrich:d, resolve:g, suggest:f} = K(this, "not", arguments); - return P.call(this, a, c, b, e, d, g, f); + const {m:a, u:c, limit:b, offset:d, enrich:e, resolve:g, suggest:f} = K(this, "not", arguments); + return P.call(this, a, c, b, d, e, g, f); }; -function P(a, c, b, e, d, g, f) { +function P(a, c, b, d, e, g, f) { if (c.length) { const h = this; return Promise.all(c).then(function(k) { @@ -503,18 +503,18 @@ function P(a, c, b, e, d, g, f) { for (let l = 0, n; l < k.length; l++) { (n = k[l]).length && (a[l] = n); } - return P.call(h, a, [], b, e, d, g, f); + return P.call(h, a, [], b, d, e, g, f); }); } if (a.length && this.result.length) { - this.result = ca.call(this, a, b, e, g); + this.result = ca.call(this, a, b, d, g); } else if (g) { - return this.resolve(b, e, d); + return this.resolve(b, d, e); } - return g ? d ? J.call(this.index, this.result) : this.result : this; + return g ? e ? J.call(this.index, this.result) : this.result : this; } -function ca(a, c, b, e) { - const d = []; +function ca(a, c, b, d) { + const e = []; a = new Set(a.flat().flat()); for (let g = 0, f, h = 0; g < this.result.length; g++) { if (f = this.result[g]) { @@ -523,13 +523,13 @@ function ca(a, c, b, e) { if (b) { b--; } else { - if (e) { - if (d.push(l), d.length === c) { - return d; + if (d) { + if (e.push(l), e.length === c) { + return e; } } else { - if (d[g] || (d[g] = []), d[g].push(l), ++h === c) { - return d; + if (e[g] || (e[g] = []), e[g].push(l), ++h === c) { + return e; } } } @@ -537,7 +537,7 @@ function ca(a, c, b, e) { } } } - return d; + return e; } ;function L(a) { if (!this || this.constructor !== L) { @@ -553,25 +553,29 @@ function ca(a, c, b, e) { L.prototype.limit = function(a) { if (this.result.length) { const c = []; - let b = 0; - for (let e = 0, d; e < this.result.length; e++) { - if (d = this.result[e], d.length + b < a) { - c[e] = d, b += d.length; - } else { - c[e] = d.slice(0, a - b); - this.result = c; - break; + for (let b = 0, d; b < this.result.length; b++) { + if (d = this.result[b]) { + if (d.length <= a) { + if (c[b] = d, a -= d.length, !a) { + break; + } + } else { + c[b] = d.slice(0, a); + break; + } } } + this.result = c; } return this; }; L.prototype.offset = function(a) { if (this.result.length) { const c = []; - let b = 0; - for (let e = 0, d; e < this.result.length; e++) { - d = this.result[e], d.length + b < a ? b += d.length : (c[e] = d.slice(a - b), b = a); + for (let b = 0, d; b < this.result.length; b++) { + if (d = this.result[b]) { + d.length <= a ? a -= d.length : (c[b] = d.slice(a), a = 0); + } } this.result = c; } @@ -582,9 +586,9 @@ L.prototype.boost = function(a) { return this; }; L.prototype.resolve = function(a, c, b) { - const e = this.result, d = this.index; + 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), I.call(d, e, a || 100, c, b)) : e; + return d.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), I.call(e, d, a || 100, c, b)) : d; }; w(); function J(a) { @@ -592,8 +596,8 @@ function J(a) { 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)}; + for (let b = 0, d; b < a.length; b++) { + d = a[b], c[b] = {id:d, doc:this.store.get(d)}; } return c; } @@ -623,53 +627,53 @@ Q.prototype.clear = function() { }; const da = {normalize:function(a) { return a.toLowerCase(); -}, numeric:!1, dedupe:!1}; +}}; const R = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; -S.prototype.add = function(a, c, b, e) { +S.prototype.add = function(a, c, b, d) { if (c && (a || 0 === a)) { - if (!e && !b && this.reg.has(a)) { + if (!d && !b && this.reg.has(a)) { return this.update(a, c); } c = this.encoder.encode(c); - if (e = c.length) { + if (d = c.length) { const l = w(), n = w(), m = this.depth, r = this.resolution; - for (let q = 0; q < e; q++) { - let p = c[this.rtl ? e - 1 - q : q]; - var d = p.length; - if (d && (m || !n[p])) { - var g = this.score ? this.score(c, p, q, null, 0) : T(r, e, q), f = ""; + for (let q = 0; q < d; q++) { + let p = c[this.rtl ? d - 1 - q : q]; + var e = p.length; + if (e && (m || !n[p])) { + var g = this.score ? this.score(c, p, q, null, 0) : T(r, d, q), f = ""; switch(this.tokenize) { case "full": - if (2 < d) { - for (g = 0; g < d; g++) { - for (var h = d; h > g; h--) { + if (2 < e) { + for (g = 0; g < e; g++) { + for (var h = e; h > g; h--) { f = p.substring(g, h); - var k = this.score ? this.score(c, p, q, f, g) : T(r, e, q, d, g); + var k = this.score ? this.score(c, p, q, f, g) : T(r, d, q, e, g); U(this, n, f, k, a, b); } } break; } case "reverse": - if (1 < d) { - for (h = d - 1; 0 < h; h--) { - f = p[h] + f, k = this.score ? this.score(c, p, q, f, h) : T(r, e, q, d, h), U(this, n, f, k, a, b); + if (1 < e) { + for (h = e - 1; 0 < h; h--) { + f = p[h] + f, k = this.score ? this.score(c, p, q, f, h) : T(r, d, q, e, h), U(this, n, f, k, a, b); } f = ""; } case "forward": - if (1 < d) { - for (h = 0; h < d; h++) { + if (1 < e) { + for (h = 0; h < e; h++) { f += p[h], U(this, n, f, g, a, b); } break; } default: - if (U(this, n, p, g, a, b), m && 1 < e && q < e - 1) { - for (d = w(), f = this.B, g = p, h = Math.min(m + 1, e - q), d[g] = 1, k = 1; k < h; k++) { - if ((p = c[this.rtl ? e - 1 - q - k : q + k]) && !d[p]) { - d[p] = 1; - const v = this.score ? this.score(c, g, q, p, k) : T(f + (e / 2 > f ? 0 : 1), e, q, h - 1, k - 1), A = this.bidirectional && p > g; + if (U(this, n, p, g, a, b), m && 1 < d && q < d - 1) { + for (e = w(), f = this.B, g = p, h = Math.min(m + 1, d - q), e[g] = 1, k = 1; k < h; k++) { + if ((p = c[this.rtl ? d - 1 - q - k : q + k]) && !e[p]) { + e[p] = 1; + const v = this.score ? this.score(c, g, q, p, k) : T(f + (d / 2 > f ? 0 : 1), d, q, h - 1, k - 1), A = this.bidirectional && p > g; U(this, l, A ? g : p, v, a, b, A ? p : g); } } @@ -682,22 +686,22 @@ S.prototype.add = function(a, c, b, e) { } return this; }; -function U(a, c, b, e, d, g, f) { +function U(a, c, b, d, e, g, f) { let h = f ? a.ctx : a.map, k; if (!c[b] || f && !(k = c[b])[f]) { - f ? (c = k || (c[b] = w()), c[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), g && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h]))); + f ? (c = k || (c[b] = w()), c[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[d] || (h[d] = []), g && h.includes(e) || (h.push(e), a.fastupdate && ((c = a.reg.get(e)) ? c.push(h) : a.reg.set(e, [h]))); } } -function T(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 T(a, c, b, d, e) { + return b && 1 < a ? c + (d || 0) <= a ? b + (e || 0) : (a - 1) / (c + (d || 0)) * (b + (e || 0)) + 1 | 0 : 0; } ;S.prototype.search = function(a, c, b) { b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); - var e = [], d = 0; + var d = [], e = 0; if (b) { a = b.query || a; c = b.limit || c; - d = b.offset || 0; + e = b.offset || 0; var g = b.context; var f = b.suggest; var h = !0; @@ -709,11 +713,11 @@ function T(a, c, b, e, d) { a = b.length; c = c || (h ? 100 : 0); if (1 === a) { - return W.call(this, b[0], "", c, d, h); + return W.call(this, b[0], "", c, e, h); } g = this.depth && !1 !== g; if (2 === a && g && !f) { - return W.call(this, b[0], b[1], c, d, h); + return W.call(this, b[0], b[1], c, e, h); } h = w(); let l = 0; @@ -728,7 +732,7 @@ function T(a, c, b, e, d) { p = X(this, v, n); a: { g = p; - var m = e, r = f, q = k; + var m = d, r = f, q = k; let A = []; if (g && g.length) { if (g.length <= q) { @@ -750,34 +754,34 @@ function T(a, c, b, e, d) { p = r ? void 0 : A; } if (p) { - e = p; + d = p; break; } - n && (f && p && e.length || (n = v)); + n && (f && p && d.length || (n = v)); } - f && n && l === a - 1 && !e.length && (n = "", l = -1, h = w()); + f && n && l === a - 1 && !d.length && (n = "", l = -1, h = w()); } a: { - n = e.length; - a = e; + n = d.length; + a = d; if (1 < n) { - a = F(e, k, c, d, f); + a = F(d, k, c, e, f); } else if (1 === n) { - f = I.call(null, e[0], c, d); + f = I.call(null, d[0], c, e); break a; } f = a; } return f; }; -function W(a, c, b, e, d) { +function W(a, c, b, d, e) { a = X(this, a, c); - d = !0; - return a && a.length ? d ? I.call(this, a, b, e) : new L(a) : d ? [] : new L(); + e = !0; + return a && a.length ? e ? I.call(this, a, b, d) : new L(a) : e ? [] : new L(); } function X(a, c, b) { - let e; - b && (e = a.bidirectional && c > b) && (e = b, b = c, c = e); + let d; + b && (d = a.bidirectional && c > b) && (d = b, b = c, c = d); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); return a; } @@ -785,13 +789,13 @@ function X(a, c, b) { const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); if (b) { 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 < b.length; d++) { + if (e = b[d]) { + if (2 > e.length) { + e.pop(); } else { - const g = d.indexOf(a); - g === b.length - 1 ? d.pop() : d.splice(g, 1); + const g = e.indexOf(a); + g === b.length - 1 ? e.pop() : e.splice(g, 1); } } } @@ -806,10 +810,10 @@ function X(a, c, b) { function Y(a, c) { let b = 0; if (a.constructor === Array) { - for (let e = 0, d, g; e < a.length; e++) { - if ((d = a[e]) && d.length) { - if (g = d.indexOf(c), 0 <= g) { - 1 < d.length ? (d.splice(g, 1), b++) : delete a[e]; + for (let d = 0, e, g; d < a.length; d++) { + if ((e = a[d]) && e.length) { + if (g = e.indexOf(c), 0 <= g) { + 1 < e.length ? (e.splice(g, 1), b++) : delete a[d]; break; } else { b++; @@ -817,9 +821,9 @@ function Y(a, c) { } } } else { - for (let e of a.entries()) { - const d = e[0], g = Y(e[1], c); - g ? b += g : a.delete(d); + for (let d of a.entries()) { + const e = d[0], g = Y(d[1], c); + g ? b += g : a.delete(e); } } return b; @@ -835,20 +839,20 @@ function Y(a, c) { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || da; - this.encoder = d.encode ? d : "object" === typeof d ? new D(d) : {encode:d}; + const d = !0 === b ? {depth:1} : b || {}, e = a.encode || a.encoder || da; + this.encoder = e.encode ? e : "object" === typeof e ? new D(e) : {encode:e}; this.resolution = a.resolution || 9; this.tokenize = b = a.tokenize || "strict"; - this.depth = "strict" === b && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; + this.depth = "strict" === b && d.depth || 0; + this.bidirectional = !1 !== d.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.B = e.resolution || 3; - this.rtl = d.rtl || a.rtl || !1; + this.B = d.resolution || 3; + this.rtl = e.rtl || a.rtl || !1; this.cache = (b = a.cache || null) && new Q(b); } t = S.prototype; @@ -866,19 +870,19 @@ t.contain = function(a) { return 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); + const b = this, d = this.remove(a); + return d && d.then ? d.then(() => b.add(a, c)) : this.add(a, c); }; function Z(a) { let c = 0; if (a.constructor === Array) { - for (let b = 0, e; b < a.length; b++) { - (e = a[b]) && (c += e.length); + for (let b = 0, d; b < a.length; b++) { + (d = a[b]) && (c += d.length); } } else { for (const b of a) { - const e = b[0], d = Z(b[1]); - d ? c += d : a.delete(e); + const d = b[0], e = Z(b[1]); + e ? c += e : a.delete(d); } } return c; @@ -894,19 +898,19 @@ t.cleanup = function() { t.searchCache = function(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Q()); - let e = this.cache.get(a); - if (!e) { - e = this.search(a, c, b); - if (e.then) { - const d = this; - e.then(function(g) { - d.cache.set(a, g); + let d = this.cache.get(a); + if (!d) { + d = this.search(a, c, b); + if (d.then) { + const e = this; + d.then(function(g) { + e.cache.set(a, g); return g; }); } - this.cache.set(a, e); + this.cache.set(a, d); } - return e; + return d; }; export default {Index:S, Charset:null, Encoder:D, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; diff --git a/dist/flexsearch.light.module.min.js b/dist/flexsearch.light.module.min.js index 2dbe6ac..39dbe84 100644 --- a/dist/flexsearch.light.module.min.js +++ b/dist/flexsearch.light.module.min.js @@ -1,35 +1,35 @@ /**! - * FlexSearch.js v0.8.105 (Bundle) + * FlexSearch.js v0.8.107 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var t;function u(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(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var f of a)g.set(f[0],f[1]);return g}if(c===Set){f=new Set(b);for(g of a.values())f.add(g);return f}}}return a}return b}return"undefined"===d?c:a}function w(){return Object.create(null)} -function x(a){let c=0;for(let b=0,e;b"a1a".split(b).length; -this.numeric=u(a.numeric,e)}else{try{this.split=u(this.split,y)}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);this.rtl=u(a.rtl,!1,this.rtl);this.dedupe=u(a.dedupe,!1,this.dedupe);this.filter=u((b=a.filter)&&new Set(b),null,this.filter);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,0,this.maxlength);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.C="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.s=this.o=128;this.g="";this.v=null;this.h="";this.A=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}; +var t;function u(a,c,b){const d=typeof b,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(b){if("function"===e&&d===e)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var f of a)g.set(f[0],f[1]);return g}if(c===Set){f=new Set(b);for(g of a.values())f.add(g);return f}}}return a}return b}return"undefined"===e?c:a}function w(){return Object.create(null)} +function x(a){let c=0;for(let b=0,d;b"a1a".split(b).length; +this.numeric=u(a.numeric,d)}else{try{this.split=u(this.split,y)}catch(e){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);this.rtl=u(a.rtl,!1,this.rtl);this.dedupe=u(a.dedupe,!1,this.dedupe);this.filter=u((b=a.filter)&&new Set(b),null,this.filter);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,0,this.maxlength);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.C="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.s=this.o=128;this.g="";this.v=null;this.h="";this.A=null;if(this.matcher)for(const e of this.matcher.keys())this.g+=(this.g?"|":"")+e;if(this.stemmer)for(const e of this.stemmer.keys())this.h+=(this.h?"|":"")+e;return this}; t.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.A=null;this.cache&&F(this);return this};t.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&F(this);return this};t.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.v=null;this.cache&&F(this);return this};t.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&F(this);return this}; -t.encode=function(a){if(this.cache&&a.length<=this.o)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(F,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=D?a.normalize("NFKD").replace(D,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),f.lengththis.matcher.get(k)));if(f&&this.replacer)for(d=0;f&&dthis.C&& -(this.j.clear(),this.s=this.s/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.o&&(this.i.set(a,b),this.i.size>this.C&&(this.i.clear(),this.o=this.o/1.1|0));return b};function F(a){a.l=null;a.i.clear();a.j.clear()};function G(a,c,b,e,d){const g=a.length;let f=[],h,k;h=w();for(let l=0,n,m,r,q;lb||e?f.slice(e,b+e):f;else{if(ab||e)f=f.slice(e,b+e)}return f} -function I(a,c,b){const e=[],d=w();let g;var f=a.length;let h;for(let k=f-1;0<=k;k--)if(h=(f=a[k])&&f.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?K.call(this,a):a;let d=[];for(let g=0,f,h;g=h){b-=h;continue}bc&&(f=f.slice(0,c),h=c);if(!d.length&&h>=c)return e?K.call(this,f):f;d.push(f);c-=h;if(!c)break}d=1a.length?this.result=a[0]:(this.result=I(a,b,e),e=0));return g?this.resolve(b,e,d):this};M.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const g=arguments[0];g&&(a=!!g.suggest,d=g.resolve,c=g.limit,b=g.offset,e=g.enrich&&d)}if(a){const {m:g,u:f,limit:h,offset:k,enrich:l,resolve:n,suggest:m}=L(this,"and",arguments);return O.call(this,g,f,h,k,l,n,m)}return d?this.resolve(c,b,e):this}; -function O(a,c,b,e,d,g,f){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(c=x(a))return this.result=G(a,c,b,e,f),g?d?K.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?this.resolve(b,e,d):this};M.prototype.xor=function(){const {m:a,u:c,limit:b,offset:e,enrich:d,resolve:g,suggest:f}=L(this,"xor",arguments);return P.call(this,a,c,b,e,d,g,f)}; -function P(a,c,b,e,d,g,f){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=aa.call(this,a,b,e,g,this.g),g?d?K.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(b,e,d):this} -function aa(a,c,b,e,d){const g=[],f=w();let h=0;for(let k=0,l;kthis.limit&&this.cache.delete(this.cache.keys().next().value)};R.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};R.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}}; -R.prototype.clear=function(){this.cache.clear();this.g=""};const ca={normalize:function(a){return a.toLowerCase()},numeric:!1,dedupe:!1};const da={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};S.prototype.add=function(a,c,b,e){if(c&&(a||0===a)){if(!e&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(e=c.length){const l=w(),n=w(),m=this.depth,r=this.resolution;for(let q=0;qg;h--){f=p.substring(g,h);var k=this.score?this.score(c,p,q,f,g):T(r,e,q,d,g);V(this,n,f,k,a,b)}break}case "reverse":if(1< -d){for(h=d-1;0f?0:1),e,q,h-1,k-1),A=this.bidirectional&&p>g;V(this,l,A?g:p,v,a,b,A?p:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function V(a,c,b,e,d,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=w()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function T(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};S.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 e=0,d;ed.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,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;if(a.constructor===Array)for(let e=0,d,g;eb.add(a,c)):this.add(a,c)}; -function Z(a){let c=0;if(a.constructor===Array)for(let b=0,e;bthis.stemmer.get(k)),f.lengththis.matcher.get(k)));if(f&&this.replacer)for(e=0;f&&ethis.C&& +(this.j.clear(),this.s=this.s/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.o&&(this.i.set(a,b),this.i.size>this.C&&(this.i.clear(),this.o=this.o/1.1|0));return b};function F(a){a.l=null;a.i.clear();a.j.clear()};function G(a,c,b,d,e){const g=a.length;let f=[],h,k;h=w();for(let l=0,n,m,r,q;lb||d?f.slice(d,b+d):f;else{if(ab||d)f=f.slice(d,b+d)}return f} +function I(a,c,b){const d=[],e=w();let g;var f=a.length;let h;for(let k=f-1;0<=k;k--)if(h=(f=a[k])&&f.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,d?K.call(this,a):a;let e=[];for(let g=0,f,h;g=h){b-=h;continue}bc&&(f=f.slice(0,c),h=c);if(!e.length&&h>=c)return d?K.call(this,f):f;e.push(f);c-=h;if(!c)break}e=1a.length?this.result=a[0]:(this.result=I(a,b,d),d=0));return g?this.resolve(b,d,e):this};M.prototype.and=function(){let a=this.result.length,c,b,d,e;if(!a){const g=arguments[0];g&&(a=!!g.suggest,e=g.resolve,c=g.limit,b=g.offset,d=g.enrich&&e)}if(a){const {m:g,u:f,limit:h,offset:k,enrich:l,resolve:n,suggest:m}=L(this,"and",arguments);return O.call(this,g,f,h,k,l,n,m)}return e?this.resolve(c,b,d):this}; +function O(a,c,b,d,e,g,f){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(c=x(a))return this.result=G(a,c,b,d,f),g?e?K.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?this.resolve(b,d,e):this};M.prototype.xor=function(){const {m:a,u:c,limit:b,offset:d,enrich:e,resolve:g,suggest:f}=L(this,"xor",arguments);return P.call(this,a,c,b,d,e,g,f)}; +function P(a,c,b,d,e,g,f){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=aa.call(this,a,b,d,g,this.g),g?e?K.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(b,d,e):this} +function aa(a,c,b,d,e){const g=[],f=w();let h=0;for(let k=0,l;kthis.limit&&this.cache.delete(this.cache.keys().next().value)};R.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};R.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}}; +R.prototype.clear=function(){this.cache.clear();this.g=""};const ca={normalize:function(a){return a.toLowerCase()}};const da={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};S.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const l=w(),n=w(),m=this.depth,r=this.resolution;for(let q=0;qg;h--){f=p.substring(g,h);var k=this.score?this.score(c,p,q,f,g):T(r,d,q,e,g);V(this,n,f,k,a,b)}break}case "reverse":if(1< +e){for(h=e-1;0f?0:1),d,q,h-1,k-1),A=this.bidirectional&&p>g;V(this,l,A?g:p,v,a,b,A?p:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function V(a,c,b,d,e,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=w()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),g&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.reg.get(e))?c.push(h):a.reg.set(e,[h])))}function T(a,c,b,d,e){return b&&1b)&&(d=b,b=c,c=d);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};S.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 d=0,e;de.length)e.pop();else{const g=e.indexOf(a);g===b.length-1?e.pop():e.splice(g,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;if(a.constructor===Array)for(let d=0,e,g;db.add(a,c)):this.add(a,c)}; +function Z(a){let c=0;if(a.constructor===Array)for(let b=0,d;b setTimeout(tick, 0, resolve)) - // ); - // - // // apply different performance budgets - // if(key === "update" || key === "remove" && this.fastupdate === false){ - // budget += 1000 * this.resolution; - // if(this.depth) - // budget += 1000 * this.resolution_ctx; - // } - // else if(key === "search"){ - // budget++; - // } - // else{ - // budget += 20 * this.resolution; - // if(this.depth) - // budget += 20 * this.resolution_ctx; - // } - // - // // wait for the event loop cycle - // if(budget >= 1e6){ - // await cycle; - // } - const args = /*[].slice.call*/arguments, arg = args[args.length - 1]; @@ -62,12 +36,37 @@ function register(key) { delete args[args.length - 1]; } + // balance when polling the event loop + if (!timer) { + timer = setTimeout(tick, 0, key); + timestamp = Date.now(); + } + if (!limit[key]) { + limit[key] = current[key] = 1000; + } + if (! --current[key]) { + const now = Date.now(), + duration = now - timestamp, + target = 3 * (this.priority * this.priority); + + current[key] = limit[key] = 0 | limit[key] * target / duration || 1; + timer = clearTimeout(timer); + const self = this; + return new Promise(resolve => { + setTimeout(function () { + resolve(self[key + "Async"].apply(self, args)); + }, 0); + }); + } + //this.async = true; - const res = this[key].apply(this, args); + const res = this[key].apply(this, args), + promise = res.then ? res : new Promise(resolve => resolve(res)); + //this.async = false; if (callback) { - res.then ? res.then(callback) : callback(res); + promise.then(callback); } - return res; + return promise; }; } \ No newline at end of file diff --git a/dist/module-debug/bundle.js b/dist/module-debug/bundle.js index d75e3d5..318ee70 100644 --- a/dist/module-debug/bundle.js +++ b/dist/module-debug/bundle.js @@ -76,6 +76,13 @@ import Charset from "./charset.js"; /** @export */Document.prototype.get; /** @export */Document.prototype.set; +/** @export */Document.prototype.field; +/** @export */Document.prototype.index; +/** @export */Document.prototype.reg; +/** @export */Document.prototype.tag; +/** @export */Document.prototype.store; +/** @export */Document.prototype.fastupdate; + /** @export */Resolver.prototype.limit; /** @export */Resolver.prototype.offset; /** @export */Resolver.prototype.boost; @@ -130,6 +137,7 @@ import Charset from "./charset.js"; /** @export */IndexOptions.db; /** @export */IndexOptions.worker; // worker url /** @export */IndexOptions.config; // config url +/** @export */IndexOptions.priority; /** @export */FieldOptions.preset; /** @export */FieldOptions.context; @@ -164,6 +172,7 @@ import Charset from "./charset.js"; /** @export */DocumentOptions.doc; /** @export */DocumentOptions.document; /** @export */DocumentOptions.worker; +/** @export */DocumentOptions.priority; /** @export */ContextOptions.depth; /** @export */ContextOptions.bidirectional; diff --git a/dist/module-debug/charset/arabic/default.js b/dist/module-debug/charset/arabic/default.js index 3071aff..45a512f 100644 --- a/dist/module-debug/charset/arabic/default.js +++ b/dist/module-debug/charset/arabic/default.js @@ -1,4 +1,5 @@ import { EncoderOptions } from "../../type.js"; +// non ascii control chars 0-31 const regex = /[\x00-\x7F]+/g, split = /\s+/, options = { diff --git a/dist/module-debug/charset/cjk/default.js b/dist/module-debug/charset/cjk/default.js index 9f95137..7e1a110 100644 --- a/dist/module-debug/charset/cjk/default.js +++ b/dist/module-debug/charset/cjk/default.js @@ -1,4 +1,5 @@ import { EncoderOptions } from "../../type.js"; +// non ascii control chars 0-31 const regex = /[\x00-\x7F]+/g, options = { normalize: !1, diff --git a/dist/module-debug/charset/cyrillic/default.js b/dist/module-debug/charset/cyrillic/default.js index 85b2ac6..f2937b2 100644 --- a/dist/module-debug/charset/cyrillic/default.js +++ b/dist/module-debug/charset/cyrillic/default.js @@ -1,4 +1,5 @@ import { EncoderOptions } from "../../type.js"; +// non ascii control chars 0-31 const regex = /[\x00-\x7F]+/g, options = { normalize: !1, diff --git a/dist/module-debug/charset/latin/default.js b/dist/module-debug/charset/latin/default.js index 34e758d..29822e5 100644 --- a/dist/module-debug/charset/latin/default.js +++ b/dist/module-debug/charset/latin/default.js @@ -4,8 +4,8 @@ import { EncoderOptions } from "../../type.js"; const options = { normalize: function (str) { return str.toLowerCase(); - }, - numeric: !1, - dedupe: !1 + } + //numeric: false, + //dedupe: false }; export default options; \ No newline at end of file diff --git a/dist/module-debug/index.js b/dist/module-debug/index.js index 420f860..dfca438 100644 --- a/dist/module-debug/index.js +++ b/dist/module-debug/index.js @@ -72,6 +72,8 @@ export default function Index(options, _register) { this.commit_auto = !1 !== options.commit; this.commit_task = []; this.commit_timer = null; + + this.priority = options.priority || 4; } Index.prototype.mount = function (db) { diff --git a/dist/module-debug/index/search.js b/dist/module-debug/index/search.js index b3ab191..b9f773d 100644 --- a/dist/module-debug/index/search.js +++ b/dist/module-debug/index/search.js @@ -266,6 +266,7 @@ Index.prototype.search = function (query, limit, options) { term = query_terms[index]; + // todo should the dupe check applied on [keyword:term]? if (term && !dupes[term]) { dupes[term] = 1; @@ -322,9 +323,9 @@ function return_result(result, resolution, limit, offset, suggest, boost, resolv if (1 < length) { - final = intersect(result, resolution, /** @type {number} */limit, offset, suggest, boost, resolve); + final = intersect(result, resolution, limit, offset, suggest, boost, resolve); } else if (1 === length) { - return resolve ? resolve_default.call(null, result[0], /** @type {number} */limit, offset) : new Resolver(result[0]); + return resolve ? resolve_default.call(null, result[0], limit, offset) : new Resolver(result[0]); } return resolve ? final : new Resolver(final); @@ -348,6 +349,7 @@ function return_result(result, resolution, limit, offset, suggest, boost, resolv function single_term_query(term, keyword, limit, offset, resolve, enrich, tag) { const result = this.get_array(term, keyword, limit, offset, resolve, enrich, tag); + resolve = resolve; if (this.db) { diff --git a/dist/module-debug/resolver.js b/dist/module-debug/resolver.js index 4f80ec8..6fdd07f 100644 --- a/dist/module-debug/resolver.js +++ b/dist/module-debug/resolver.js @@ -45,19 +45,21 @@ export default function Resolver(result) { */ Resolver.prototype.limit = function (limit) { if (this.result.length) { + /** @type {IntermediateSearchResults} */ const final = []; - let count = 0; for (let j = 0, ids; j < this.result.length; j++) { - ids = this.result[j]; - if (ids.length + count < limit) { - final[j] = ids; - count += ids.length; - } else { - final[j] = ids.slice(0, limit - count); - this.result = final; - break; + if (ids = this.result[j]) { + if (ids.length <= limit) { + final[j] = ids; + limit -= ids.length; + if (!limit) break; + } else { + final[j] = ids.slice(0, limit); + break; + } } } + this.result = final; } return this; }; @@ -67,15 +69,16 @@ Resolver.prototype.limit = function (limit) { */ Resolver.prototype.offset = function (offset) { if (this.result.length) { + /** @type {IntermediateSearchResults} */ const final = []; - let count = 0; for (let j = 0, ids; j < this.result.length; j++) { - ids = this.result[j]; - if (ids.length + count < offset) { - count += ids.length; - } else { - final[j] = ids.slice(offset - count); - count = offset; + if (ids = this.result[j]) { + if (ids.length <= offset) { + offset -= ids.length; + } else { + final[j] = ids.slice(offset); + offset = 0; + } } } this.result = final; diff --git a/dist/module-debug/serialize.js b/dist/module-debug/serialize.js index 67e6878..111be1e 100644 --- a/dist/module-debug/serialize.js +++ b/dist/module-debug/serialize.js @@ -1,6 +1,7 @@ import Index from "./index.js"; import Document from "./document.js"; import { is_string } from "./common.js"; +import { IntermediateSearchResults } from "./type.js"; const chunk_size_reg = 250000, chunk_size_map = 5000, @@ -8,7 +9,7 @@ const chunk_size_reg = 250000, /** - * @param {Map} map + * @param {Map} map * @param {number=} size * @return {Array} */ @@ -32,8 +33,8 @@ function map_to_json(map, size = 0) { /** * @param {Array} json - * @param {Map=} map - * @return {Map} + * @param {Map} map + * @return {Map} */ function json_to_map(json, map) { map || (map = new Map()); @@ -45,6 +46,11 @@ function json_to_map(json, map) { ); } +/** + * @param {Map>} ctx + * @param {number=} size + * @return {Array} + */ function ctx_to_json(ctx, size = 0) { let chunk = [], json = []; @@ -66,6 +72,11 @@ function ctx_to_json(ctx, size = 0) { return chunk; } +/** + * @param {Array} json + * @param {Map>} ctx + * @return {Map>} + */ function json_to_ctx(json, ctx) { ctx || (ctx = new Map()); for (let i = 0, entry, map; i < json.length; i++) { @@ -76,6 +87,10 @@ function json_to_ctx(json, ctx) { return ctx; } +/** + * @param {Set} reg + * @return {Array>} + */ function reg_to_json(reg) { let chunk = [], json = []; @@ -91,6 +106,11 @@ function reg_to_json(reg) { return chunk; } +/** + * @param {Array} json + * @param {Set} reg + * @return {Set} + */ function json_to_reg(json, reg) { reg || (reg = new Set()); for (let i = 0; i < json.length; i++) { @@ -155,7 +175,7 @@ export function exportIndex(callback, _field, _index_doc = 0, _index_obj = 0) { // todo key = "cfg"; - chunk = {}; + chunk = null; break; case 2: @@ -209,7 +229,7 @@ export function importIndex(key, data) { // fast update isn't supported by export/import this.fastupdate = /* suggest */ /* append: */ /* enrich */ /* resolve: */!1; - this.reg = json_to_reg(data, this.reg); + this.reg = json_to_reg( /** @type {Array} */data, this.reg); break; case "map": @@ -278,7 +298,7 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) case 3: key = "cfg"; - chunk = {}; + chunk = null; _field = null; break; @@ -321,7 +341,7 @@ export function importDocument(key, data) { // fast update isn't supported by export/import this.fastupdate = !1; - this.reg = json_to_reg(data, this.reg); + this.reg = json_to_reg( /** @type {Array} */data, this.reg); for (let i = 0, idx; i < this.field.length; i++) { idx = this.index.get(this.field[i]); diff --git a/dist/module-debug/type.js b/dist/module-debug/type.js index 9c0e2c6..799b141 100644 --- a/dist/module-debug/type.js +++ b/dist/module-debug/type.js @@ -20,7 +20,8 @@ import StorageInterface from "./db/interface.js"; * db: (StorageInterface|undefined), * commit: (boolean|undefined), * worker: (string|undefined), - * config: (string|undefined) + * config: (string|undefined), + * priority: (number|undefined) * }} */ export let IndexOptions = {}; @@ -64,6 +65,7 @@ export let FieldOptions = {}; * doc: (DocumentDescriptor|Array|undefined), * document: (DocumentDescriptor|Array|undefined), * worker: (boolean|string|undefined), + * priority: (number|undefined) * }} */ export let DocumentOptions = {}; diff --git a/dist/module-min/async.js b/dist/module-min/async.js index fbaa2dc..f2487ae 100644 --- a/dist/module-min/async.js +++ b/dist/module-min/async.js @@ -1 +1 @@ -import Document from"./document.js";import Index from"./index.js";export default function(a){register.call(a,"add"),register.call(a,"append"),register.call(a,"search"),register.call(a,"update"),register.call(a,"remove")}function register(a){this[a+"Async"]=function(){const b=arguments,c=b[b.length-1];let d;"function"==typeof c&&(d=c,delete b[b.length-1]);const e=this[a].apply(this,b);return d&&(e.then?e.then(d):d(e)),e}} \ No newline at end of file +import Document from"./document.js";import Index from"./index.js";export default function(a){register.call(a,"add"),register.call(a,"append"),register.call(a,"search"),register.call(a,"update"),register.call(a,"remove")}let timer,timestamp;const current={},limit={};function tick(a){timer=0,current[a]=limit[a]}function register(a){this[a+"Async"]=function(){const b=arguments,c=b[b.length-1];let d;if("function"==typeof c&&(d=c,delete b[b.length-1]),timer||(timer=setTimeout(tick,0,a),timestamp=Date.now()),limit[a]||(limit[a]=current[a]=1000),! --current[a]){const c=Date.now(),d=c-timestamp,e=3*(this.priority*this.priority);current[a]=limit[a]=0|limit[a]*e/d||1,timer=clearTimeout(timer);const f=this;return new Promise(c=>{setTimeout(function(){c(f[a+"Async"].apply(f,b))},0)})}const e=this[a].apply(this,b),f=e.then?e:new Promise(a=>a(e));return d&&f.then(d),f}} \ No newline at end of file diff --git a/dist/module-min/bundle.js b/dist/module-min/bundle.js index cfe2e59..552302e 100644 --- a/dist/module-min/bundle.js +++ b/dist/module-min/bundle.js @@ -1 +1 @@ -import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,FieldOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions,PersistentOptions,ResolverOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/index.js";import Charset from"./charset.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.serialize,Index.prototype.mount,Index.prototype.commit,Index.prototype.destroy,Index.prototype.reg,Index.prototype.map,Index.prototype.ctx,Index.prototype.db,Index.prototype.tag,Index.prototype.store,Index.prototype.depth,Index.prototype.bidirectional,Index.prototype.commit_task,Index.prototype.commit_timer,Index.prototype.cache,Index.prototype.bypass,Index.prototype.document,Index.prototype.encoder,Encoder.prototype.assign,Encoder.prototype.encode,Encoder.prototype.addMatcher,Encoder.prototype.addStemmer,Encoder.prototype.addFilter,Encoder.prototype.addMapper,Encoder.prototype.addReplacer,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.prototype.destroy,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Resolver.prototype.result,StorageInterface.db,StorageInterface.id,StorageInterface.support_tag_search,StorageInterface.fastupdate,StorageInterface.prototype.mount,StorageInterface.prototype.open,StorageInterface.prototype.close,StorageInterface.prototype.destroy,StorageInterface.prototype.clear,StorageInterface.prototype.get,StorageInterface.prototype.tag,StorageInterface.prototype.enrich,StorageInterface.prototype.has,StorageInterface.prototype.search,StorageInterface.prototype.info,StorageInterface.prototype.commit,StorageInterface.prototype.remove,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.worker,IndexOptions.config,FieldOptions.preset,FieldOptions.context,FieldOptions.encoder,FieldOptions.encode,FieldOptions.resolution,FieldOptions.tokenize,FieldOptions.fastupdate,FieldOptions.score,FieldOptions.keystore,FieldOptions.rtl,FieldOptions.cache,FieldOptions.db,FieldOptions.config,FieldOptions.resolve,FieldOptions.field,FieldOptions.filter,FieldOptions.custom,FieldOptions.worker,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,SearchOptions.resolution,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,DocumentSearchOptions.highlight,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char,PersistentOptions.name,PersistentOptions.field,PersistentOptions.type,PersistentOptions.db,ResolverOptions.index,ResolverOptions.query,ResolverOptions.limit,ResolverOptions.offset,ResolverOptions.enrich,ResolverOptions.resolve,ResolverOptions.suggest,ResolverOptions.and,ResolverOptions.or,ResolverOptions.xor,ResolverOptions.not;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{FlexSearch.Language={};const a=self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}export default FlexSearch;export{Index,Document,Encoder,Charset,WorkerIndex as Worker,Resolver,IdxDB as IndexedDB}; \ No newline at end of file +import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,FieldOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions,PersistentOptions,ResolverOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/index.js";import Charset from"./charset.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.serialize,Index.prototype.mount,Index.prototype.commit,Index.prototype.destroy,Index.prototype.reg,Index.prototype.map,Index.prototype.ctx,Index.prototype.db,Index.prototype.tag,Index.prototype.store,Index.prototype.depth,Index.prototype.bidirectional,Index.prototype.commit_task,Index.prototype.commit_timer,Index.prototype.cache,Index.prototype.bypass,Index.prototype.document,Index.prototype.encoder,Encoder.prototype.assign,Encoder.prototype.encode,Encoder.prototype.addMatcher,Encoder.prototype.addStemmer,Encoder.prototype.addFilter,Encoder.prototype.addMapper,Encoder.prototype.addReplacer,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.prototype.destroy,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Document.prototype.field,Document.prototype.index,Document.prototype.reg,Document.prototype.tag,Document.prototype.store,Document.prototype.fastupdate,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Resolver.prototype.result,StorageInterface.db,StorageInterface.id,StorageInterface.support_tag_search,StorageInterface.fastupdate,StorageInterface.prototype.mount,StorageInterface.prototype.open,StorageInterface.prototype.close,StorageInterface.prototype.destroy,StorageInterface.prototype.clear,StorageInterface.prototype.get,StorageInterface.prototype.tag,StorageInterface.prototype.enrich,StorageInterface.prototype.has,StorageInterface.prototype.search,StorageInterface.prototype.info,StorageInterface.prototype.commit,StorageInterface.prototype.remove,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.worker,IndexOptions.config,IndexOptions.priority,FieldOptions.preset,FieldOptions.context,FieldOptions.encoder,FieldOptions.encode,FieldOptions.resolution,FieldOptions.tokenize,FieldOptions.fastupdate,FieldOptions.score,FieldOptions.keystore,FieldOptions.rtl,FieldOptions.cache,FieldOptions.db,FieldOptions.config,FieldOptions.resolve,FieldOptions.field,FieldOptions.filter,FieldOptions.custom,FieldOptions.worker,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,DocumentOptions.priority,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,SearchOptions.resolution,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,DocumentSearchOptions.highlight,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char,PersistentOptions.name,PersistentOptions.field,PersistentOptions.type,PersistentOptions.db,ResolverOptions.index,ResolverOptions.query,ResolverOptions.limit,ResolverOptions.offset,ResolverOptions.enrich,ResolverOptions.resolve,ResolverOptions.suggest,ResolverOptions.and,ResolverOptions.or,ResolverOptions.xor,ResolverOptions.not;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{FlexSearch.Language={};const a=self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}export default FlexSearch;export{Index,Document,Encoder,Charset,WorkerIndex as Worker,Resolver,IdxDB as IndexedDB}; \ No newline at end of file diff --git a/dist/module-min/charset/latin/default.js b/dist/module-min/charset/latin/default.js index 793c84b..3e2e7ef 100644 --- a/dist/module-min/charset/latin/default.js +++ b/dist/module-min/charset/latin/default.js @@ -1 +1 @@ -import{EncoderOptions}from"../../type.js";const options={normalize:function(a){return a.toLowerCase()},numeric:!1,dedupe:!1};export default options; \ No newline at end of file +import{EncoderOptions}from"../../type.js";const options={normalize:function(a){return a.toLowerCase()}};export default options; \ No newline at end of file diff --git a/dist/module-min/index.js b/dist/module-min/index.js index 4348180..844aff3 100644 --- a/dist/module-min/index.js +++ b/dist/module-min/index.js @@ -1 +1 @@ -import{IndexOptions,ContextOptions,EncoderOptions}from"./type.js";import Encoder from"./encoder.js";import Cache,{searchCache}from"./cache.js";import Charset from"./charset.js";import{KeystoreMap,KeystoreSet}from"./keystore.js";import{is_array,is_string}from"./common.js";import{exportIndex,importIndex,serialize}from"./serialize.js";import default_encoder from"./charset/latin/default.js";import apply_preset from"./preset.js";import apply_async from"./async.js";import tick from"./profiler.js";import"./index/add.js";import"./index/search.js";import"./index/remove.js";export default function Index(a,b){if(!this||this.constructor!==Index)return new Index(a);!1,a=a?apply_preset(a):{};let c=a.context;const d=!0===c?{depth:1}:c||{},e=is_string(a.encoder)?Charset[a.encoder]:a.encode||a.encoder||default_encoder;this.encoder=e.encode?e:"object"==typeof e?new Encoder(e):{encode:e},this.compress=a.compress||a.compression||!1,this.resolution=a.resolution||9,this.tokenize=c=a.tokenize||"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,c&&(this.keystore=c),this.map=c&&!0?new KeystoreMap(c):new Map,this.ctx=c&&!0?new KeystoreMap(c):new Map,this.reg=b||(this.fastupdate?c&&!0?new KeystoreMap(c):new Map:c&&!0?new KeystoreSet(c):new Set),this.resolution_ctx=d.resolution||3,this.rtl=e.rtl||a.rtl||!1,this.cache=(c=a.cache||null)&&new Cache(c),this.resolve=!1!==a.resolve,(c=a.db)&&(this.db=this.mount(c)),this.commit_auto=!1!==a.commit,this.commit_task=[],this.commit_timer=null}Index.prototype.mount=function(a){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),a.mount(this)},Index.prototype.commit=function(a,b){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.commit(this,a,b)},Index.prototype.destroy=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.destroy()};export function autoCommit(a,b,c){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null,a.db.commit(a,b,c)},0))}Index.prototype.clear=function(){return 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}]),this},Index.prototype.append=function(a,b){return this.add(a,b,!0)},Index.prototype.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)},Index.prototype.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)};function cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;dc.add(a,b)):this.add(a,b)};function cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;d setTimeout(tick, 0, resolve)) - // ); - // - // // apply different performance budgets - // if(key === "update" || key === "remove" && this.fastupdate === false){ - // budget += 1000 * this.resolution; - // if(this.depth) - // budget += 1000 * this.resolution_ctx; - // } - // else if(key === "search"){ - // budget++; - // } - // else{ - // budget += 20 * this.resolution; - // if(this.depth) - // budget += 20 * this.resolution_ctx; - // } - // - // // wait for the event loop cycle - // if(budget >= 1e6){ - // await cycle; - // } - const args = /*[].slice.call*/arguments, arg = args[args.length - 1]; @@ -62,12 +36,37 @@ function register(key) { delete args[args.length - 1]; } + // balance when polling the event loop + if (!timer) { + timer = setTimeout(tick, 0, key); + timestamp = Date.now(); + } + if (!limit[key]) { + limit[key] = current[key] = 1000; + } + if (! --current[key]) { + const now = Date.now(), + duration = now - timestamp, + target = 3 * (this.priority * this.priority); + + current[key] = limit[key] = 0 | limit[key] * target / duration || 1; + timer = clearTimeout(timer); + const self = this; + return new Promise(resolve => { + setTimeout(function () { + resolve(self[key + "Async"].apply(self, args)); + }, 0); + }); + } + //this.async = true; - const res = this[key].apply(this, args); + const res = this[key].apply(this, args), + promise = res.then ? res : new Promise(resolve => resolve(res)); + //this.async = false; if (callback) { - res.then ? res.then(callback) : callback(res); + promise.then(callback); } - return res; + return promise; }; } \ No newline at end of file diff --git a/dist/module/bundle.js b/dist/module/bundle.js index d75e3d5..318ee70 100644 --- a/dist/module/bundle.js +++ b/dist/module/bundle.js @@ -76,6 +76,13 @@ import Charset from "./charset.js"; /** @export */Document.prototype.get; /** @export */Document.prototype.set; +/** @export */Document.prototype.field; +/** @export */Document.prototype.index; +/** @export */Document.prototype.reg; +/** @export */Document.prototype.tag; +/** @export */Document.prototype.store; +/** @export */Document.prototype.fastupdate; + /** @export */Resolver.prototype.limit; /** @export */Resolver.prototype.offset; /** @export */Resolver.prototype.boost; @@ -130,6 +137,7 @@ import Charset from "./charset.js"; /** @export */IndexOptions.db; /** @export */IndexOptions.worker; // worker url /** @export */IndexOptions.config; // config url +/** @export */IndexOptions.priority; /** @export */FieldOptions.preset; /** @export */FieldOptions.context; @@ -164,6 +172,7 @@ import Charset from "./charset.js"; /** @export */DocumentOptions.doc; /** @export */DocumentOptions.document; /** @export */DocumentOptions.worker; +/** @export */DocumentOptions.priority; /** @export */ContextOptions.depth; /** @export */ContextOptions.bidirectional; diff --git a/dist/module/charset/arabic/default.js b/dist/module/charset/arabic/default.js index 3071aff..45a512f 100644 --- a/dist/module/charset/arabic/default.js +++ b/dist/module/charset/arabic/default.js @@ -1,4 +1,5 @@ import { EncoderOptions } from "../../type.js"; +// non ascii control chars 0-31 const regex = /[\x00-\x7F]+/g, split = /\s+/, options = { diff --git a/dist/module/charset/cjk/default.js b/dist/module/charset/cjk/default.js index 9f95137..7e1a110 100644 --- a/dist/module/charset/cjk/default.js +++ b/dist/module/charset/cjk/default.js @@ -1,4 +1,5 @@ import { EncoderOptions } from "../../type.js"; +// non ascii control chars 0-31 const regex = /[\x00-\x7F]+/g, options = { normalize: !1, diff --git a/dist/module/charset/cyrillic/default.js b/dist/module/charset/cyrillic/default.js index 85b2ac6..f2937b2 100644 --- a/dist/module/charset/cyrillic/default.js +++ b/dist/module/charset/cyrillic/default.js @@ -1,4 +1,5 @@ import { EncoderOptions } from "../../type.js"; +// non ascii control chars 0-31 const regex = /[\x00-\x7F]+/g, options = { normalize: !1, diff --git a/dist/module/charset/latin/default.js b/dist/module/charset/latin/default.js index 34e758d..29822e5 100644 --- a/dist/module/charset/latin/default.js +++ b/dist/module/charset/latin/default.js @@ -4,8 +4,8 @@ import { EncoderOptions } from "../../type.js"; const options = { normalize: function (str) { return str.toLowerCase(); - }, - numeric: !1, - dedupe: !1 + } + //numeric: false, + //dedupe: false }; export default options; \ No newline at end of file diff --git a/dist/module/index.js b/dist/module/index.js index 0a43890..61d8de7 100644 --- a/dist/module/index.js +++ b/dist/module/index.js @@ -72,6 +72,8 @@ export default function Index(options, _register) { this.commit_auto = !1 !== options.commit; this.commit_task = []; this.commit_timer = null; + + this.priority = options.priority || 4; } Index.prototype.mount = function (db) { diff --git a/dist/module/index/search.js b/dist/module/index/search.js index b3ab191..b9f773d 100644 --- a/dist/module/index/search.js +++ b/dist/module/index/search.js @@ -266,6 +266,7 @@ Index.prototype.search = function (query, limit, options) { term = query_terms[index]; + // todo should the dupe check applied on [keyword:term]? if (term && !dupes[term]) { dupes[term] = 1; @@ -322,9 +323,9 @@ function return_result(result, resolution, limit, offset, suggest, boost, resolv if (1 < length) { - final = intersect(result, resolution, /** @type {number} */limit, offset, suggest, boost, resolve); + final = intersect(result, resolution, limit, offset, suggest, boost, resolve); } else if (1 === length) { - return resolve ? resolve_default.call(null, result[0], /** @type {number} */limit, offset) : new Resolver(result[0]); + return resolve ? resolve_default.call(null, result[0], limit, offset) : new Resolver(result[0]); } return resolve ? final : new Resolver(final); @@ -348,6 +349,7 @@ function return_result(result, resolution, limit, offset, suggest, boost, resolv function single_term_query(term, keyword, limit, offset, resolve, enrich, tag) { const result = this.get_array(term, keyword, limit, offset, resolve, enrich, tag); + resolve = resolve; if (this.db) { diff --git a/dist/module/resolver.js b/dist/module/resolver.js index 4f80ec8..6fdd07f 100644 --- a/dist/module/resolver.js +++ b/dist/module/resolver.js @@ -45,19 +45,21 @@ export default function Resolver(result) { */ Resolver.prototype.limit = function (limit) { if (this.result.length) { + /** @type {IntermediateSearchResults} */ const final = []; - let count = 0; for (let j = 0, ids; j < this.result.length; j++) { - ids = this.result[j]; - if (ids.length + count < limit) { - final[j] = ids; - count += ids.length; - } else { - final[j] = ids.slice(0, limit - count); - this.result = final; - break; + if (ids = this.result[j]) { + if (ids.length <= limit) { + final[j] = ids; + limit -= ids.length; + if (!limit) break; + } else { + final[j] = ids.slice(0, limit); + break; + } } } + this.result = final; } return this; }; @@ -67,15 +69,16 @@ Resolver.prototype.limit = function (limit) { */ Resolver.prototype.offset = function (offset) { if (this.result.length) { + /** @type {IntermediateSearchResults} */ const final = []; - let count = 0; for (let j = 0, ids; j < this.result.length; j++) { - ids = this.result[j]; - if (ids.length + count < offset) { - count += ids.length; - } else { - final[j] = ids.slice(offset - count); - count = offset; + if (ids = this.result[j]) { + if (ids.length <= offset) { + offset -= ids.length; + } else { + final[j] = ids.slice(offset); + offset = 0; + } } } this.result = final; diff --git a/dist/module/serialize.js b/dist/module/serialize.js index 67e6878..111be1e 100644 --- a/dist/module/serialize.js +++ b/dist/module/serialize.js @@ -1,6 +1,7 @@ import Index from "./index.js"; import Document from "./document.js"; import { is_string } from "./common.js"; +import { IntermediateSearchResults } from "./type.js"; const chunk_size_reg = 250000, chunk_size_map = 5000, @@ -8,7 +9,7 @@ const chunk_size_reg = 250000, /** - * @param {Map} map + * @param {Map} map * @param {number=} size * @return {Array} */ @@ -32,8 +33,8 @@ function map_to_json(map, size = 0) { /** * @param {Array} json - * @param {Map=} map - * @return {Map} + * @param {Map} map + * @return {Map} */ function json_to_map(json, map) { map || (map = new Map()); @@ -45,6 +46,11 @@ function json_to_map(json, map) { ); } +/** + * @param {Map>} ctx + * @param {number=} size + * @return {Array} + */ function ctx_to_json(ctx, size = 0) { let chunk = [], json = []; @@ -66,6 +72,11 @@ function ctx_to_json(ctx, size = 0) { return chunk; } +/** + * @param {Array} json + * @param {Map>} ctx + * @return {Map>} + */ function json_to_ctx(json, ctx) { ctx || (ctx = new Map()); for (let i = 0, entry, map; i < json.length; i++) { @@ -76,6 +87,10 @@ function json_to_ctx(json, ctx) { return ctx; } +/** + * @param {Set} reg + * @return {Array>} + */ function reg_to_json(reg) { let chunk = [], json = []; @@ -91,6 +106,11 @@ function reg_to_json(reg) { return chunk; } +/** + * @param {Array} json + * @param {Set} reg + * @return {Set} + */ function json_to_reg(json, reg) { reg || (reg = new Set()); for (let i = 0; i < json.length; i++) { @@ -155,7 +175,7 @@ export function exportIndex(callback, _field, _index_doc = 0, _index_obj = 0) { // todo key = "cfg"; - chunk = {}; + chunk = null; break; case 2: @@ -209,7 +229,7 @@ export function importIndex(key, data) { // fast update isn't supported by export/import this.fastupdate = /* suggest */ /* append: */ /* enrich */ /* resolve: */!1; - this.reg = json_to_reg(data, this.reg); + this.reg = json_to_reg( /** @type {Array} */data, this.reg); break; case "map": @@ -278,7 +298,7 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) case 3: key = "cfg"; - chunk = {}; + chunk = null; _field = null; break; @@ -321,7 +341,7 @@ export function importDocument(key, data) { // fast update isn't supported by export/import this.fastupdate = !1; - this.reg = json_to_reg(data, this.reg); + this.reg = json_to_reg( /** @type {Array} */data, this.reg); for (let i = 0, idx; i < this.field.length; i++) { idx = this.index.get(this.field[i]); diff --git a/dist/module/type.js b/dist/module/type.js index 9c0e2c6..799b141 100644 --- a/dist/module/type.js +++ b/dist/module/type.js @@ -20,7 +20,8 @@ import StorageInterface from "./db/interface.js"; * db: (StorageInterface|undefined), * commit: (boolean|undefined), * worker: (string|undefined), - * config: (string|undefined) + * config: (string|undefined), + * priority: (number|undefined) * }} */ export let IndexOptions = {}; @@ -64,6 +65,7 @@ export let FieldOptions = {}; * doc: (DocumentDescriptor|Array|undefined), * document: (DocumentDescriptor|Array|undefined), * worker: (boolean|string|undefined), + * priority: (number|undefined) * }} */ export let DocumentOptions = {}; diff --git a/doc/custom-builds.md b/doc/custom-builds.md index 67f327e..2103590 100644 --- a/doc/custom-builds.md +++ b/doc/custom-builds.md @@ -2,8 +2,8 @@ The `/src/` folder of this repository requires some compilation to resolve the build flags. Those are your options: -- Closure Compiler (Advanced Compilation) (used by this library here) -- Babel + Plugin `babel-plugin-conditional-compile` (used by this library here) +- Closure Compiler (Advanced Compilation) +- Babel + Plugin `babel-plugin-conditional-compile` You can't resolve build flags with: @@ -18,7 +18,6 @@ These are some of the basic builds located in the `/dist/` folder: npm run build:bundle npm run build:light npm run build:module -npm run build:es5 ``` Perform a custom build (UMD bundle) by passing build flags: @@ -41,6 +40,12 @@ npm run build:custom DEBUG=true SUPPORT_DOCUMENT=true SUPPORT_TAGS=true > On custom builds each build flag will be set to `false` by default when not passed. +Just build the core library: + +```bash +npm run build:custom +``` + The custom build will be saved to `dist/flexsearch.custom.xxxx.min.js` or when format is module to `dist/flexsearch.custom.module.xxxx.min.js` (the "xxxx" is a hash based on the used build flags). diff --git a/example/nodejs-commonjs/.document-worker-persistent/package.json b/example/nodejs-commonjs/.document-worker-persistent/package.json index 06712a4..53bff67 100644 --- a/example/nodejs-commonjs/.document-worker-persistent/package.json +++ b/example/nodejs-commonjs/.document-worker-persistent/package.json @@ -1,7 +1,7 @@ { "name": "nodejs-worker-persistent", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview", + "flexsearch": "^0.8.105", "sqlite3": "^5.1.7" } } diff --git a/example/nodejs-commonjs/basic-export-import/package.json b/example/nodejs-commonjs/basic-export-import/package.json index 914e4d5..07f5257 100644 --- a/example/nodejs-commonjs/basic-export-import/package.json +++ b/example/nodejs-commonjs/basic-export-import/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-commonjs-basic-export-import", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/basic-persistent/package.json b/example/nodejs-commonjs/basic-persistent/package.json index 19b2f61..989322e 100644 --- a/example/nodejs-commonjs/basic-persistent/package.json +++ b/example/nodejs-commonjs/basic-persistent/package.json @@ -1,7 +1,7 @@ { "name": "nodejs-commonjs-basic-persistent", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview", + "flexsearch": "^0.8.105", "sqlite3": "^5.1.7" } } diff --git a/example/nodejs-commonjs/basic-resolver/package.json b/example/nodejs-commonjs/basic-resolver/package.json index c947a79..49fe952 100644 --- a/example/nodejs-commonjs/basic-resolver/package.json +++ b/example/nodejs-commonjs/basic-resolver/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-commonjs-basic-resolver", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/basic-suggestion/package.json b/example/nodejs-commonjs/basic-suggestion/package.json index 4863964..feaa871 100644 --- a/example/nodejs-commonjs/basic-suggestion/package.json +++ b/example/nodejs-commonjs/basic-suggestion/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-commonjs-basic-suggestion", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/basic-worker-extern-config/package.json b/example/nodejs-commonjs/basic-worker-extern-config/package.json index d7c1a89..340dea6 100644 --- a/example/nodejs-commonjs/basic-worker-extern-config/package.json +++ b/example/nodejs-commonjs/basic-worker-extern-config/package.json @@ -1,7 +1,6 @@ { - "name": "nodejs-esm-basic-worker-extern-config", - "type": "module", + "name": "nodejs-commonjs-basic-worker-extern-config", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/basic-worker/package.json b/example/nodejs-commonjs/basic-worker/package.json index 6cf6e7a..a2452a8 100644 --- a/example/nodejs-commonjs/basic-worker/package.json +++ b/example/nodejs-commonjs/basic-worker/package.json @@ -1,7 +1,6 @@ { - "name": "nodejs-esm-basic-worker", - "type": "module", + "name": "nodejs-commonjs-basic-worker", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/basic/package.json b/example/nodejs-commonjs/basic/package.json index 63d6f1c..bf5e849 100644 --- a/example/nodejs-commonjs/basic/package.json +++ b/example/nodejs-commonjs/basic/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-commonjs-basic", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/document-export-import/package.json b/example/nodejs-commonjs/document-export-import/package.json index a48b758..e4f982c 100644 --- a/example/nodejs-commonjs/document-export-import/package.json +++ b/example/nodejs-commonjs/document-export-import/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-commonjs-document-export-import", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/document-persistent/package.json b/example/nodejs-commonjs/document-persistent/package.json index 20bc525..e7b9060 100644 --- a/example/nodejs-commonjs/document-persistent/package.json +++ b/example/nodejs-commonjs/document-persistent/package.json @@ -1,7 +1,7 @@ { "name": "nodejs-commonjs-document-persistent", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview", + "flexsearch": "^0.8.105", "sqlite3": "^5.1.7" } } diff --git a/example/nodejs-commonjs/document-worker-extern-config/package.json b/example/nodejs-commonjs/document-worker-extern-config/package.json index e715c7b..155ea5f 100644 --- a/example/nodejs-commonjs/document-worker-extern-config/package.json +++ b/example/nodejs-commonjs/document-worker-extern-config/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-commonjs-document-worker-extern-config", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/document-worker/package.json b/example/nodejs-commonjs/document-worker/package.json index cdf2c51..f7fbdc0 100644 --- a/example/nodejs-commonjs/document-worker/package.json +++ b/example/nodejs-commonjs/document-worker/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-commonjs-document-worker", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/document/package.json b/example/nodejs-commonjs/document/package.json index 2fbc471..a2716c5 100644 --- a/example/nodejs-commonjs/document/package.json +++ b/example/nodejs-commonjs/document/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-commonjs-document", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-commonjs/language-pack/package.json b/example/nodejs-commonjs/language-pack/package.json index 1143c66..bd9a5fe 100644 --- a/example/nodejs-commonjs/language-pack/package.json +++ b/example/nodejs-commonjs/language-pack/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-commonjs-language-pack", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/basic-export-import/package.json b/example/nodejs-esm/basic-export-import/package.json index fe3354b..6c68c7a 100644 --- a/example/nodejs-esm/basic-export-import/package.json +++ b/example/nodejs-esm/basic-export-import/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-basic-export-import", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/basic-persistent/package.json b/example/nodejs-esm/basic-persistent/package.json index 0f3dc72..b3540c0 100644 --- a/example/nodejs-esm/basic-persistent/package.json +++ b/example/nodejs-esm/basic-persistent/package.json @@ -2,7 +2,7 @@ "name": "nodejs-esm-basic-persistent", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview", + "flexsearch": "^0.8.105", "sqlite3": "^5.1.7" } } diff --git a/example/nodejs-esm/basic-resolver/package.json b/example/nodejs-esm/basic-resolver/package.json index 23972d1..b0f0538 100644 --- a/example/nodejs-esm/basic-resolver/package.json +++ b/example/nodejs-esm/basic-resolver/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-basic-resolver", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/basic-suggestion/package.json b/example/nodejs-esm/basic-suggestion/package.json index 9daf7f5..474ed2f 100644 --- a/example/nodejs-esm/basic-suggestion/package.json +++ b/example/nodejs-esm/basic-suggestion/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-basic-suggestion", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/basic-worker-extern-config/package.json b/example/nodejs-esm/basic-worker-extern-config/package.json index d7c1a89..c179cf9 100644 --- a/example/nodejs-esm/basic-worker-extern-config/package.json +++ b/example/nodejs-esm/basic-worker-extern-config/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-basic-worker-extern-config", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/basic-worker/package.json b/example/nodejs-esm/basic-worker/package.json index 6cf6e7a..488627a 100644 --- a/example/nodejs-esm/basic-worker/package.json +++ b/example/nodejs-esm/basic-worker/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-basic-worker", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/basic/package.json b/example/nodejs-esm/basic/package.json index 7ef8fc4..0d1121c 100644 --- a/example/nodejs-esm/basic/package.json +++ b/example/nodejs-esm/basic/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-basic", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/document-export-import/package.json b/example/nodejs-esm/document-export-import/package.json index 62db8c9..bbe1be9 100644 --- a/example/nodejs-esm/document-export-import/package.json +++ b/example/nodejs-esm/document-export-import/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-document-export-import", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/document-persistent/package.json b/example/nodejs-esm/document-persistent/package.json index b5e5d6e..cc51618 100644 --- a/example/nodejs-esm/document-persistent/package.json +++ b/example/nodejs-esm/document-persistent/package.json @@ -2,7 +2,7 @@ "name": "nodejs-esm-document-persistent", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview", + "flexsearch": "^0.8.105", "sqlite3": "^5.1.7" } } diff --git a/example/nodejs-esm/document-worker-extern-config/package.json b/example/nodejs-esm/document-worker-extern-config/package.json index 4f2a428..bd2e334 100644 --- a/example/nodejs-esm/document-worker-extern-config/package.json +++ b/example/nodejs-esm/document-worker-extern-config/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-document-worker-extern-config", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/document-worker/package.json b/example/nodejs-esm/document-worker/package.json index b98f398..541bcf9 100644 --- a/example/nodejs-esm/document-worker/package.json +++ b/example/nodejs-esm/document-worker/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-document-worker", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/document/package.json b/example/nodejs-esm/document/package.json index 6153cac..07f1c11 100644 --- a/example/nodejs-esm/document/package.json +++ b/example/nodejs-esm/document/package.json @@ -2,6 +2,6 @@ "name": "nodejs-esm-document", "type": "module", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/example/nodejs-esm/language-pack/package.json b/example/nodejs-esm/language-pack/package.json index 8e49be9..7da2925 100644 --- a/example/nodejs-esm/language-pack/package.json +++ b/example/nodejs-esm/language-pack/package.json @@ -1,6 +1,6 @@ { "name": "nodejs-esm-language-pack", "dependencies": { - "flexsearch": "github:nextapps-de/flexsearch#v0.8-preview" + "flexsearch": "^0.8.105" } } diff --git a/index.d.ts b/index.d.ts index 70956ff..8625632 100644 --- a/index.d.ts +++ b/index.d.ts @@ -172,6 +172,7 @@ declare module "flexsearch" { context?: ContextOptions | boolean; keystore?: number; fastupdate?: boolean; + priority?: number; score?: ( content: string[], term: string, @@ -251,43 +252,36 @@ declare module "flexsearch" { destroy(): Promise; // Async Methods - /** @deprecated The "async" variants are deprecated, instead use the default variant */ addAsync( id: Id, content: string, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ appendAsync( id: Id, content: string, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ updateAsync( id: Id, content: string, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ removeAsync( id: Id, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ searchAsync( query: string, options?: Limit | SearchOptions, callback?: AsyncCallback ): Promise - /** @deprecated The "async" variants are deprecated, instead use the default variant */ searchAsync( query: string, limit: Limit, options?: SearchOptions, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ searchAsync( options: SearchOptions, callback?: AsyncCallback @@ -449,63 +443,52 @@ declare module "flexsearch" { destroy(): Promise; // Async Methods - /** @deprecated The "async" variants are deprecated, instead use the default variant */ addAsync( id: Id, document: DocumentData, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ addAsync( document: DocumentData, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ appendAsync( id: Id, document: DocumentData, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ appendAsync( document: DocumentData, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ updateAsync( id: Id, document: DocumentData, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ updateAsync( document: DocumentData, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ removeAsync( id: Id, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ removeAsync( document: DocumentData, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ searchAsync( query: string, options?: Limit | DocumentSearchOptions, callback?: AsyncCallback ): Promise - /** @deprecated The "async" variants are deprecated, instead use the default variant */ searchAsync( query: string, limit: number, options?: DocumentSearchOptions, callback?: AsyncCallback ): Promise; - /** @deprecated The "async" variants are deprecated, instead use the default variant */ searchAsync( options: DocumentSearchOptions, callback?: AsyncCallback diff --git a/package-lock.json b/package-lock.json index c1594be..d24f6ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "flexsearch", - "version": "0.8.105", + "version": "0.8.107", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "flexsearch", - "version": "0.8.105", + "version": "0.8.107", "funding": [ { "type": "github", diff --git a/package.json b/package.json index d794c0d..c2e7b14 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "public": true, "preferGlobal": false, "name": "flexsearch", - "version": "0.8.105", + "version": "0.8.107", "description": "Next-Generation full-text search library for Browser and Node.js", "homepage": "https://github.com/nextapps-de/flexsearch/", "author": "Thomas Wilkerling", @@ -37,6 +37,7 @@ "./esm/lang/*": "./dist/module/lang/*.js", "./esm/db/*": "./dist/module/db/*/index.js", "./debug": "./dist/flexsearch.bundle.debug.js", + "./debug/": "./dist/flexsearch.bundle.debug.js", "./debug/lang/*": "./dist/lang/*.min.js", "./debug/db/*": "./dist/db/*/index.cjs", "./esm/debug": "./dist/flexsearch.bundle.module.debug.js", @@ -82,7 +83,8 @@ "build:module:light:debug": "node task/build RELEASE=light.module DEBUG=true PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=true SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", "build:all": "npm version --no-git-tag-version patch && npm run build:bundle && npm run build:bundle:debug && npm run build:light && npm run build:light:debug && npm run build:compact && npm run build:compact:debug && npm run build:module && npm run build:module:debug && npm run build:module:min && npm run build:module:bundle && npm run build:module:bundle:debug && npm run build:module:light && npm run build:module:light:debug && npm run build:module:compact && npm run build:module:compact:debug && npm run build:es5 && npm run build:es5:debug && npm run build:lang && npm run build:db", "build:custom": "node task/build RELEASE=custom", - "test": "cd test && npm install && npm run test" + "test": "cd test && npm install && npm run test && cd ..", + "test:all": "npm run test && cd test && npm run test:all && cd .." }, "files": [ "dist/**", diff --git a/src/async.js b/src/async.js index 918c1b0..bf7dc29 100644 --- a/src/async.js +++ b/src/async.js @@ -9,14 +9,15 @@ export default function(prototype){ register.call(prototype, "remove"); } -// let cycle; -// let budget = 0; -// -// function tick(resolve){ -// cycle = null; -// budget = 0; -// resolve(); -// } +let timer; +let timestamp; +const current = {}; +const limit = {}; + +function tick(key){ + timer = 0; + current[key] = limit[key]; +} /** * @param {!string} key @@ -26,32 +27,6 @@ export default function(prototype){ function register(key){ this[key + "Async"] = function(){ - // // prevent stack overflow of adding too much tasks to the same event loop - // // actually limit stack to 1,000,000 tasks every ~4ms - // cycle || ( - // cycle = new Promise(resolve => setTimeout(tick, 0, resolve)) - // ); - // - // // apply different performance budgets - // if(key === "update" || key === "remove" && this.fastupdate === false){ - // budget += 1000 * this.resolution; - // if(this.depth) - // budget += 1000 * this.resolution_ctx; - // } - // else if(key === "search"){ - // budget++; - // } - // else{ - // budget += 20 * this.resolution; - // if(this.depth) - // budget += 20 * this.resolution_ctx; - // } - // - // // wait for the event loop cycle - // if(budget >= 1e6){ - // await cycle; - // } - const args = /*[].slice.call*/(arguments); const arg = args[args.length - 1]; let callback; @@ -61,14 +36,35 @@ function register(key){ delete args[args.length - 1]; } + // balance when polling the event loop + if(!timer){ + timer = setTimeout(tick, 0, key); + timestamp = Date.now(); + } + if(!limit[key]){ + limit[key] = current[key] = 1000; + } + if(!--current[key]){ + const now = Date.now(); + const duration = now - timestamp; + const target = this.priority * this.priority * 3; + current[key] = limit[key] = (limit[key] * target / duration | 0) || 1; + timer = clearTimeout(timer); + const self = this; + return new Promise(resolve => { + setTimeout(function(){ + resolve(self[key + "Async"].apply(self, args)); + }, 0) + }) + } + //this.async = true; const res = this[key].apply(this, args); + const promise = res.then ? res : new Promise(resolve => resolve(res)); //this.async = false; if(callback){ - res.then - ? res.then(callback) - : callback(res); + promise.then(callback); } - return res; + return promise; }; } diff --git a/src/bundle.js b/src/bundle.js index dc95714..ac905d8 100644 --- a/src/bundle.js +++ b/src/bundle.js @@ -105,6 +105,15 @@ if(SUPPORT_PERSISTENT){ /** @export */ Document.prototype.get; /** @export */ Document.prototype.set; +if(SUPPORT_SERIALIZE){ +/** @export */ Document.prototype.field; +/** @export */ Document.prototype.index; +/** @export */ Document.prototype.reg; +/** @export */ Document.prototype.tag; +/** @export */ Document.prototype.store; +/** @export */ Document.prototype.fastupdate; +} + /** @export */ Resolver.prototype.limit; /** @export */ Resolver.prototype.offset; /** @export */ Resolver.prototype.boost; @@ -159,6 +168,7 @@ if(SUPPORT_PERSISTENT){ /** @export */ IndexOptions.db; /** @export */ IndexOptions.worker; // worker url /** @export */ IndexOptions.config; // config url +/** @export */ IndexOptions.priority; /** @export */ FieldOptions.preset; /** @export */ FieldOptions.context; @@ -193,6 +203,7 @@ if(SUPPORT_PERSISTENT){ /** @export */ DocumentOptions.doc; /** @export */ DocumentOptions.document; /** @export */ DocumentOptions.worker; +/** @export */ DocumentOptions.priority; /** @export */ ContextOptions.depth; /** @export */ ContextOptions.bidirectional; diff --git a/src/charset/arabic/default.js b/src/charset/arabic/default.js index 107a8a8..218a7c4 100644 --- a/src/charset/arabic/default.js +++ b/src/charset/arabic/default.js @@ -1,4 +1,5 @@ import { EncoderOptions } from "../../type.js"; +// non ascii control chars 0-31 const regex = /[\x00-\x7F]+/g; const split = /\s+/; diff --git a/src/charset/cjk/default.js b/src/charset/cjk/default.js index 90f5183..f3b8338 100644 --- a/src/charset/cjk/default.js +++ b/src/charset/cjk/default.js @@ -1,4 +1,5 @@ import { EncoderOptions } from "../../type.js"; +// non ascii control chars 0-31 const regex = /[\x00-\x7F]+/g; /** @type EncoderOptions */ diff --git a/src/charset/cyrillic/default.js b/src/charset/cyrillic/default.js index 699b40f..18cc7a1 100644 --- a/src/charset/cyrillic/default.js +++ b/src/charset/cyrillic/default.js @@ -1,4 +1,5 @@ import { EncoderOptions } from "../../type.js"; +// non ascii control chars 0-31 const regex = /[\x00-\x7F]+/g; /** @type EncoderOptions */ diff --git a/src/charset/latin/default.js b/src/charset/latin/default.js index d1b2a3e..4c55e28 100644 --- a/src/charset/latin/default.js +++ b/src/charset/latin/default.js @@ -5,6 +5,7 @@ const options = { normalize: function(str){ return str.toLowerCase(); }, - dedupe: false + //numeric: false, + //dedupe: false }; export default options; diff --git a/src/index.js b/src/index.js index c048a78..c9a7d26 100644 --- a/src/index.js +++ b/src/index.js @@ -118,6 +118,10 @@ export default function Index(options, _register){ this.commit_task = []; this.commit_timer = null; } + + if(SUPPORT_ASYNC){ + this.priority = options.priority || 4; + } } if(SUPPORT_PERSISTENT){ diff --git a/src/index/search.js b/src/index/search.js index fbd0eb5..9f4b5e0 100644 --- a/src/index/search.js +++ b/src/index/search.js @@ -297,6 +297,7 @@ Index.prototype.search = function(query, limit, options){ term = query_terms[index]; + // todo should the dupe check applied on [keyword:term]? if(term && !dupes[term]){ dupes[term] = 1; @@ -360,11 +361,23 @@ function return_result(result, resolution, limit, offset, suggest, boost, resolv let final = result; if(length > 1){ - final = intersect(result, resolution, /** @type {number} */ (limit), offset, suggest, boost, resolve); + final = intersect( + result, + resolution, + limit, + offset, + suggest, + boost, + resolve + ); } else if(length === 1){ return !SUPPORT_RESOLVER || resolve - ? resolve_default.call(null, result[0], /** @type {number} */ (limit), offset) + ? resolve_default.call(null, + result[0], + limit, + offset + ) : new Resolver(result[0]); } @@ -390,7 +403,16 @@ function return_result(result, resolution, limit, offset, suggest, boost, resolv function single_term_query(term, keyword, limit, offset, resolve, enrich, tag){ - const result = this.get_array(term, keyword, limit, offset, resolve, enrich, tag); + const result = this.get_array( + term, + keyword, + limit, + offset, + resolve, + enrich, + tag + ); + resolve = !SUPPORT_RESOLVER || resolve; if(SUPPORT_PERSISTENT && this.db){ diff --git a/src/resolver.js b/src/resolver.js index 9580f64..1317d33 100644 --- a/src/resolver.js +++ b/src/resolver.js @@ -46,20 +46,22 @@ export default function Resolver(result){ */ Resolver.prototype.limit = function(limit){ if(this.result.length){ + /** @type {IntermediateSearchResults} */ const final = []; - let count = 0; for(let j = 0, ids; j < this.result.length; j++){ - ids = this.result[j]; - if(ids.length + count < limit){ - final[j] = ids; - count += ids.length; - } - else{ - final[j] = ids.slice(0, limit - count); - this.result = final; - break; + if((ids = this.result[j])){ + if(ids.length <= limit){ + final[j] = ids; + limit -= ids.length; + if(!limit) break; + } + else{ + final[j] = ids.slice(0, limit); + break; + } } } + this.result = final; } return this; }; @@ -69,16 +71,17 @@ Resolver.prototype.limit = function(limit){ */ Resolver.prototype.offset = function(offset){ if(this.result.length){ + /** @type {IntermediateSearchResults} */ const final = []; - let count = 0; for(let j = 0, ids; j < this.result.length; j++){ - ids = this.result[j]; - if(ids.length + count < offset){ - count += ids.length; - } - else{ - final[j] = ids.slice(offset - count); - count = offset; + if((ids = this.result[j])){ + if(ids.length <= offset){ + offset -= ids.length; + } + else{ + final[j] = ids.slice(offset); + offset = 0; + } } } this.result = final; diff --git a/src/serialize.js b/src/serialize.js index 2cd8858..efff5d3 100644 --- a/src/serialize.js +++ b/src/serialize.js @@ -1,13 +1,14 @@ import Index from "./index.js"; import Document from "./document.js"; import { is_string } from "./common.js"; +import { IntermediateSearchResults } from "./type.js"; const chunk_size_reg = 250000; const chunk_size_map = 5000; const chunk_size_ctx = 1000; /** - * @param {Map} map + * @param {Map} map * @param {number=} size * @return {Array} */ @@ -30,8 +31,8 @@ function map_to_json(map, size = 0){ /** * @param {Array} json - * @param {Map=} map - * @return {Map} + * @param {Map} map + * @return {Map} */ function json_to_map(json, map){ map || (map = new Map()); @@ -42,6 +43,11 @@ function json_to_map(json, map){ return /** @type {Map} */ (map); } +/** + * @param {Map>} ctx + * @param {number=} size + * @return {Array} + */ function ctx_to_json(ctx, size = 0){ let chunk = []; let json = []; @@ -61,6 +67,11 @@ function ctx_to_json(ctx, size = 0){ return chunk; } +/** + * @param {Array} json + * @param {Map>} ctx + * @return {Map>} + */ function json_to_ctx(json, ctx){ ctx || (ctx = new Map()); for(let i = 0, entry, map; i < json.length; i++) { @@ -71,6 +82,10 @@ function json_to_ctx(json, ctx){ return ctx; } +/** + * @param {Set} reg + * @return {Array>} + */ function reg_to_json(reg){ let chunk = []; let json = []; @@ -85,6 +100,11 @@ function reg_to_json(reg){ return chunk; } +/** + * @param {Array} json + * @param {Set} reg + * @return {Set} + */ function json_to_reg(json, reg){ reg || (reg = new Set()); for(let i = 0; i < json.length; i++) { @@ -173,7 +193,7 @@ export function exportIndex(callback, _field, _index_doc = 0, _index_obj = 0){ // todo key = "cfg"; - chunk = {}; + chunk = null; break; case 2: @@ -236,7 +256,7 @@ export function importIndex(key, data){ // fast update isn't supported by export/import this.fastupdate = false; - this.reg = json_to_reg(data, this.reg); + this.reg = json_to_reg(/** @type {Array} */ (data), this.reg); break; case "map": @@ -307,7 +327,7 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) case 3: key = "cfg"; - chunk = {}; + chunk = null; _field = null; break; @@ -359,7 +379,7 @@ export function importDocument(key, data){ // fast update isn't supported by export/import this.fastupdate = false; - this.reg = json_to_reg(data, this.reg); + this.reg = json_to_reg(/** @type {Array} */ (data), this.reg); for(let i = 0, idx; i < this.field.length; i++){ idx = this.index.get(this.field[i]); diff --git a/src/type.js b/src/type.js index 9c1c98d..d343c8d 100644 --- a/src/type.js +++ b/src/type.js @@ -20,7 +20,8 @@ import StorageInterface from "./db/interface.js"; * db: (StorageInterface|undefined), * commit: (boolean|undefined), * worker: (string|undefined), - * config: (string|undefined) + * config: (string|undefined), + * priority: (number|undefined) * }} */ export let IndexOptions = {}; @@ -64,6 +65,7 @@ export let FieldOptions = {}; * doc: (DocumentDescriptor|Array|undefined), * document: (DocumentDescriptor|Array|undefined), * worker: (boolean|string|undefined), + * priority: (number|undefined) * }} */ export let DocumentOptions = {};