diff --git a/README.md b/README.md index 56f025d..c5f13c6 100644 --- a/README.md +++ b/README.md @@ -1609,7 +1609,7 @@ The first index returns ID 1 in the first slot for the best pick, because matche Number Sets the scoring resolution for the context. - 1 + 3 diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js deleted file mode 100644 index c844cad..0000000 --- a/dist/flexsearch.bundle.debug.js +++ /dev/null @@ -1,2513 +0,0 @@ -/**! - * FlexSearch.js v0.8.149 (Bundle/Debug) - * 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 v; -function z(a, c, b) { - const e = typeof b, d = typeof a; - if ("undefined" !== e) { - if ("undefined" !== d) { - if (b) { - if ("function" === d && e === d) { - return function(k) { - return a(b(k)); - }; - } - c = a.constructor; - if (c === b.constructor) { - if (c === Array) { - return b.concat(a); - } - if (c === Map) { - var f = new Map(b); - for (var g of a) { - f.set(g[0], g[1]); - } - return f; - } - if (c === Set) { - g = new Set(b); - for (f of a.values()) { - g.add(f); - } - return g; - } - } - } - return a; - } - return b; - } - return "undefined" === d ? c : a; -} -function B() { - return Object.create(null); -} -function F(a) { - return "string" === typeof a; -} -function H(a) { - return "object" === typeof a; -} -function aa(a) { - const c = []; - for (const b of a.keys()) { - c.push(b); - } - return c; -} -function ba(a, c) { - if (F(c)) { - a = a[c]; - } else { - for (let b = 0; a && b < c.length; b++) { - a = a[c[b]]; - } - } - return a; -} -function ca(a) { - let c = 0; - for (let b = 0, e; b < a.length; b++) { - (e = a[b]) && c < e.length && (c = e.length); - } - return c; -} -;const da = /[^\p{L}\p{N}]+/u, ea = /(\d{3})/g, fa = /(\D)(\d{3})/g, ha = /(\d{3})(\D)/g, ia = /[\u0300-\u036f]/g; -function ja(a = {}) { - if (!this || this.constructor !== ja) { - return new ja(...arguments); - } - if (arguments.length) { - for (a = 0; a < arguments.length; a++) { - this.assign(arguments[a]); - } - } else { - this.assign(a); - } -} -v = ja.prototype; -v.assign = function(a) { - this.normalize = z(a.normalize, !0, this.normalize); - let c = a.include, b = c || a.exclude || a.split, e; - if (b || "" === b) { - if ("object" === typeof b && b.constructor !== RegExp) { - let d = ""; - e = !c; - c || (d += "\\p{Z}"); - b.letter && (d += "\\p{L}"); - b.number && (d += "\\p{N}", e = !!c); - b.symbol && (d += "\\p{S}"); - b.punctuation && (d += "\\p{P}"); - b.control && (d += "\\p{C}"); - if (b = b.char) { - d += "object" === typeof b ? b.join("") : b; - } - try { - this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u"); - } catch (f) { - console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; - } - } else { - this.split = b, e = !1 === b || 2 > "a1a".split(b).length; - } - this.numeric = z(a.numeric, e); - } else { - try { - this.split = z(this.split, da); - } catch (d) { - console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; - } - this.numeric = z(a.numeric, z(this.numeric, !0)); - } - this.prepare = z(a.prepare, null, this.prepare); - this.finalize = z(a.finalize, null, this.finalize); - b = a.filter; - this.filter = "function" === typeof b ? b : z(b && new Set(b), null, this.filter); - this.dedupe = z(a.dedupe, !1, this.dedupe); - this.matcher = z((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = z((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = z((b = a.stemmer) && new Map(b), null, this.stemmer); - this.replacer = z(a.replacer, null, this.replacer); - this.minlength = z(a.minlength, 1, this.minlength); - this.maxlength = z(a.maxlength, 0, this.maxlength); - this.rtl = z(a.rtl, !1, this.rtl); - if (this.cache = b = z(a.cache, !0, this.cache)) { - this.H = null, this.S = "number" === typeof b ? b : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; - } - 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; -}; -v.addStemmer = function(a, c) { - this.stemmer || (this.stemmer = new Map()); - this.stemmer.set(a, c); - this.A += (this.A ? "|" : "") + a; - this.N = null; - this.cache && I(this); - return this; -}; -v.addFilter = function(a) { - "function" === typeof a ? this.filter = a : (this.filter || (this.filter = new Set()), this.filter.add(a)); - this.cache && I(this); - return this; -}; -v.addMapper = function(a, c) { - if ("object" === typeof a) { - return this.addReplacer(a, c); - } - if (1 < a.length) { - return this.addMatcher(a, c); - } - this.mapper || (this.mapper = new Map()); - this.mapper.set(a, c); - this.cache && I(this); - return this; -}; -v.addMatcher = function(a, c) { - if ("object" === typeof a) { - return this.addReplacer(a, c); - } - if (2 > a.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 && I(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 && I(this); - return this; -}; -v.encode = function(a) { - if (this.cache && a.length <= this.K) { - if (this.H) { - if (this.B.has(a)) { - return this.B.get(a); - } - } else { - this.H = setTimeout(I, 50, this); - } - } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ia ? a.normalize("NFKD").replace(ia, "").toLowerCase() : a.toLowerCase()); - this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(fa, "$1 $2").replace(ha, "$1 $2").replace(ea, "$1 ")); - const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); - let b = [], e = this.split || "" === this.split ? a.split(this.split) : a; - for (let f = 0, g, k; f < e.length; f++) { - if ((g = k = e[f]) && !(g.length < this.minlength)) { - if (c) { - b.push(g); - } else { - if (!this.filter || ("function" === typeof this.filter ? this.filter(g) : !this.filter.has(g))) { - if (this.cache && g.length <= this.L) { - if (this.H) { - var d = this.G.get(g); - if (d || "" === d) { - d && b.push(d); - continue; - } - } else { - this.H = setTimeout(I, 50, this); - } - } - this.stemmer && 2 < g.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), d = g, g = g.replace(this.N, h => this.stemmer.get(h)), d !== g && this.filter && g.length >= this.minlength && ("function" === typeof this.filter ? !this.filter(g) : this.filter.has(g)) && (g = "")); - if (g && (this.mapper || this.dedupe && 1 < g.length)) { - d = ""; - for (let h = 0, l = "", n, m; h < g.length; h++) { - n = g.charAt(h), n === l && this.dedupe || ((m = this.mapper && this.mapper.get(n)) || "" === m ? m === l && this.dedupe || !(l = m) || (d += m) : d += l = n); - } - g = d; - } - this.matcher && 1 < g.length && (this.M || (this.M = new RegExp("(" + this.h + ")", "g")), g = g.replace(this.M, h => this.matcher.get(h))); - if (g && this.replacer) { - for (d = 0; g && d < this.replacer.length; d += 2) { - g = g.replace(this.replacer[d], this.replacer[d + 1]); - } - } - this.cache && k.length <= this.L && (this.G.set(k, g), this.G.size > this.S && (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.B.set(a, b), this.B.size > this.S && (this.B.clear(), this.K = this.K / 1.1 | 0)); - return b; -}; -function I(a) { - a.H = null; - a.B.clear(); - a.G.clear(); -} -;let J, M; -async function ka(a) { - a = a.data; - var c = a.task; - const b = a.id; - let e = a.args; - switch(c) { - case "init": - M = a.options || {}; - (c = a.factory) ? (Function("return " + c)()(self), J = new self.FlexSearch.Index(M), delete self.FlexSearch) : J = new N(M); - postMessage({id:b}); - break; - default: - let d; - if ("export" === c) { - if (!M.export || "function" !== typeof M.export) { - throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "export".'); - } - e[1] ? (e[0] = M.export, e[2] = 0, e[3] = 1) : e = null; - } - if ("import" === c) { - if (!M.import || "function" !== typeof M.import) { - throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); - } - e[0] && (a = await M.import.call(J, e[0]), J.import(e[0], a)); - } else { - (d = e && J[c].apply(J, e)) && d.then && (d = await d); - } - postMessage("search" === c ? {id:b, msg:d} : {id:b}); - } -} -;function la(a) { - ma.call(a, "add"); - ma.call(a, "append"); - ma.call(a, "search"); - ma.call(a, "update"); - ma.call(a, "remove"); -} -let na, oa, pa; -function qa() { - na = pa = 0; -} -function ma(a) { - this[a + "Async"] = function() { - const c = arguments; - var b = c[c.length - 1]; - let e; - "function" === typeof b && (e = b, delete c[c.length - 1]); - na ? pa || (pa = Date.now() - oa >= this.priority * this.priority * 3) : (na = setTimeout(qa, 0), oa = Date.now()); - if (pa) { - const f = this; - return new Promise(g => { - setTimeout(function() { - g(f[a + "Async"].apply(f, c)); - }, 0); - }); - } - const d = this[a].apply(this, c); - b = d.then ? d : new Promise(f => f(d)); - e && b.then(e); - return b; - }; -} -;let O = 0; -function P(a = {}) { - function c(g) { - function k(h) { - h = h.data || h; - const l = h.id, n = l && d.h[l]; - n && (n(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[++O] = function() { - h(d); - 1e9 < O && (O = 0); - }; - d.worker.postMessage({id:O, task:"init", factory:b, options:a}); - }); - } - this.worker.postMessage({task:"init", factory:b, options:a}); - this.priority = a.priority || 4; - return this; - } - } - if (!this || this.constructor !== P) { - return new P(a); - } - let b = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; - b && (b = b.toString()); - const e = "undefined" === typeof window, d = this, f = ra(b, e, a.worker); - return f.then ? f.then(function(g) { - return c.call(d, g); - }) : c.call(this, f); -} -Q("add"); -Q("append"); -Q("search"); -Q("update"); -Q("remove"); -Q("clear"); -Q("export"); -Q("import"); -la(P.prototype); -function Q(a) { - P.prototype[a] = function() { - const c = this, b = [].slice.call(arguments); - var e = b[b.length - 1]; - let d; - "function" === typeof e && (d = e, b.pop()); - e = new Promise(function(f) { - "export" === a && "function" === typeof b[0] && (b[0] = null); - c.h[++O] = f; - c.worker.postMessage({task:a, id:O, args:b}); - }); - return d ? (e.then(d), this) : e; - }; -} -function ra(a, c, b) { - return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/node/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)("import.meta.dirname")+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", - "module/worker/worker.js"), {type:"module"}); -} -;function sa(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 5000 | 0); - for (const d of a.entries()) { - e.push(d), e.length === c && (b.push(e), e = []); - } - e.length && b.push(e); - return b; -} -function ta(a, c) { - c || (c = new Map()); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c.set(e[0], e[1]); - } - return c; -} -function ua(a, c = 0) { - let b = [], e = []; - c && (c = 250000 / c * 1000 | 0); - for (const d of a.entries()) { - e.push([d[0], sa(d[1])[0]]), e.length === c && (b.push(e), e = []); - } - e.length && b.push(e); - return b; -} -function va(a, c) { - c || (c = new Map()); - for (let b = 0, e, d; b < a.length; b++) { - e = a[b], d = c.get(e[0]), c.set(e[0], ta(e[1], d)); - } - return c; -} -function wa(a) { - let c = [], b = []; - for (const e of a.keys()) { - b.push(e), 250000 === b.length && (c.push(b), b = []); - } - b.length && c.push(b); - return c; -} -function xa(a, c) { - c || (c = new Set()); - for (let b = 0; b < a.length; b++) { - c.add(a[b]); - } - return c; -} -function ya(a, c, b, e, d, f, g = 0) { - const k = e && e.constructor === Array; - var h = k ? e.shift() : e; - if (!h) { - return this.export(a, c, d, f + 1); - } - if ((h = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(h))) && h.then) { - const l = this; - return h.then(function() { - return ya.call(l, a, c, b, k ? e : null, d, f, g + 1); - }); - } - return ya.call(this, a, c, b, k ? e : null, d, f, g + 1); -} -function za(a, c) { - let b = ""; - for (const e of a.entries()) { - a = e[0]; - const d = e[1]; - let f = ""; - for (let g = 0, k; g < d.length; g++) { - k = d[g] || [""]; - let h = ""; - for (let l = 0; l < k.length; l++) { - h += (h ? "," : "") + ("string" === c ? '"' + k[l] + '"' : k[l]); - } - h = "[" + h + "]"; - f += (f ? "," : "") + h; - } - f = '["' + a + '",[' + f + "]]"; - b += (b ? "," : "") + f; - } - return b; -} -;function Aa(a, c, b, e) { - let d = []; - for (let f = 0, g; f < a.index.length; f++) { - if (g = a.index[f], c >= g.length) { - c -= g.length; - } else { - c = g[e ? "splice" : "slice"](c, b); - const k = c.length; - if (k && (d = d.length ? d.concat(c) : c, b -= k, e && (a.length -= k), !b)) { - break; - } - c = 0; - } - } - return d; -} -function R(a) { - if (!this || this.constructor !== R) { - return new R(a); - } - this.index = a ? [a] : []; - this.length = a ? a.length : 0; - const c = this; - return new Proxy([], {get(b, e) { - if ("length" === e) { - return c.length; - } - if ("push" === e) { - return function(d) { - c.index[c.index.length - 1].push(d); - c.length++; - }; - } - if ("pop" === e) { - return function() { - if (c.length) { - return c.length--, c.index[c.index.length - 1].pop(); - } - }; - } - if ("indexOf" === e) { - return function(d) { - let f = 0; - for (let g = 0, k, h; g < c.index.length; g++) { - k = c.index[g]; - h = k.indexOf(d); - if (0 <= h) { - return f + h; - } - f += k.length; - } - return -1; - }; - } - if ("includes" === e) { - return function(d) { - for (let f = 0; f < c.index.length; f++) { - if (c.index[f].includes(d)) { - return !0; - } - } - return !1; - }; - } - if ("slice" === e) { - return function(d, f) { - return Aa(c, d || 0, f || c.length, !1); - }; - } - if ("splice" === e) { - return function(d, f) { - return Aa(c, d || 0, f || c.length, !0); - }; - } - if ("constructor" === e) { - return Array; - } - if ("symbol" !== typeof e) { - return (b = c.index[e / 2 ** 31 | 0]) && b[e]; - } - }, set(b, e, d) { - b = e / 2 ** 31 | 0; - (c.index[b] || (c.index[b] = []))[e] = d; - c.length++; - return !0; - }}); -} -R.prototype.clear = function() { - this.index.length = 0; -}; -R.prototype.destroy = function() { - this.proxy = this.index = null; -}; -R.prototype.push = function() { -}; -function S(a = 8) { - if (!this || this.constructor !== S) { - return new S(a); - } - this.index = B(); - this.h = []; - this.size = 0; - 32 < a ? (this.B = Ba, this.A = BigInt(a)) : (this.B = Ca, this.A = a); -} -S.prototype.get = function(a) { - const c = this.index[this.B(a)]; - return c && c.get(a); -}; -S.prototype.set = function(a, c) { - var b = this.B(a); - let e = this.index[b]; - e ? (b = e.size, e.set(a, c), (b -= e.size) && this.size++) : (this.index[b] = e = new Map([[a, c]]), this.h.push(e), this.size++); -}; -function T(a = 8) { - if (!this || this.constructor !== T) { - return new T(a); - } - this.index = B(); - this.h = []; - this.size = 0; - 32 < a ? (this.B = Ba, this.A = BigInt(a)) : (this.B = Ca, this.A = a); -} -T.prototype.add = function(a) { - var c = this.B(a); - let b = this.index[c]; - b ? (c = b.size, b.add(a), (c -= b.size) && this.size++) : (this.index[c] = b = new Set([a]), this.h.push(b), this.size++); -}; -v = S.prototype; -v.has = T.prototype.has = function(a) { - const c = this.index[this.B(a)]; - return c && c.has(a); -}; -v.delete = T.prototype.delete = function(a) { - const c = this.index[this.B(a)]; - c && c.delete(a) && this.size--; -}; -v.clear = T.prototype.clear = function() { - this.index = B(); - this.h = []; - this.size = 0; -}; -v.values = T.prototype.values = function*() { - for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].values()) { - yield c; - } - } -}; -v.keys = T.prototype.keys = function*() { - for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].keys()) { - yield c; - } - } -}; -v.entries = T.prototype.entries = function*() { - for (let a = 0; a < this.h.length; a++) { - for (let c of this.h[a].entries()) { - yield c; - } - } -}; -function Ca(a) { - let c = 2 ** this.A - 1; - if ("number" == typeof a) { - return a & c; - } - let b = 0, e = this.A + 1; - for (let d = 0; d < a.length; d++) { - b = (b * e ^ a.charCodeAt(d)) & c; - } - return 32 === this.A ? b + 2 ** 31 : b; -} -function Ba(a) { - let c = BigInt(2) ** this.A - BigInt(1); - var b = typeof a; - if ("bigint" === b) { - return a & c; - } - if ("number" === b) { - return BigInt(a) & c; - } - b = BigInt(0); - let e = this.A + BigInt(1); - for (let d = 0; d < a.length; d++) { - b = (b * e ^ BigInt(a.charCodeAt(d))) & c; - } - return b; -} -;U.prototype.add = function(a, c, b) { - H(a) && (c = a, a = ba(c, this.key)); - if (c && (a || 0 === a)) { - if (!b && this.reg.has(a)) { - return this.update(a, c); - } - for (let k = 0, h; k < this.field.length; k++) { - h = this.D[k]; - var e = this.index.get(this.field[k]); - if ("function" === typeof h) { - var d = h(c); - d && e.add(a, d, !1, !0); - } else { - if (d = h.I, !d || d(c)) { - h.constructor === String ? h = ["" + h] : F(h) && (h = [h]), Da(c, h, this.J, 0, e, a, h[0], b); - } - } - } - if (this.tag) { - for (e = 0; e < this.F.length; e++) { - var f = this.F[e], g = this.R[e]; - d = this.tag.get(g); - let k = B(); - if ("function" === typeof f) { - if (f = f(c), !f) { - continue; - } - } else { - const h = f.I; - if (h && !h(c)) { - continue; - } - f.constructor === String && (f = "" + f); - f = ba(c, f); - } - if (d && f) { - F(f) && (f = [f]); - for (let h = 0, l, n; h < f.length; h++) { - if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? n = g : d.set(l, n = []), !b || !n.includes(a))) { - if (n.length === 2 ** 31 - 1) { - g = new R(n); - if (this.fastupdate) { - for (let m of this.reg.values()) { - m.includes(n) && (m[m.indexOf(n)] = g); - } - } - d.set(l, n = g); - } - n.push(a); - this.fastupdate && ((g = this.reg.get(a)) ? g.push(n) : this.reg.set(a, [n])); - } - } - } else { - d || console.warn("Tag '" + g + "' was not found"); - } - } - } - if (this.store && (!b || !this.store.has(a))) { - let k; - if (this.C) { - k = B(); - for (let h = 0, l; h < this.C.length; h++) { - l = this.C[h]; - if ((b = l.I) && !b(c)) { - continue; - } - let n; - if ("function" === typeof l) { - n = l(c); - if (!n) { - continue; - } - l = [l.V]; - } else if (F(l) || l.constructor === String) { - k[l] = c[l]; - continue; - } - Ea(c, k, l, 0, l[0], n); - } - } - this.store.set(a, k || c); - } - this.worker && (this.fastupdate || this.reg.add(a)); - } - return this; -}; -function Ea(a, c, b, e, d, f) { - a = a[d]; - if (e === b.length - 1) { - c[d] = f || a; - } else if (a) { - if (a.constructor === Array) { - for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) { - Ea(a, c, b, e, d); - } - } else { - c = c[d] || (c[d] = B()), d = b[++e], Ea(a, c, b, e, d); - } - } -} -function Da(a, c, b, e, d, f, g, k) { - if (a = a[g]) { - if (e === c.length - 1) { - if (a.constructor === Array) { - if (b[e]) { - for (c = 0; c < a.length; c++) { - d.add(f, a[c], !0, !0); - } - return; - } - a = a.join(" "); - } - d.add(f, a, k, !0); - } else { - if (a.constructor === Array) { - for (g = 0; g < a.length; g++) { - Da(a, c, b, e, d, f, g, k); - } - } else { - g = c[++e], Da(a, c, b, e, d, f, g, k); - } - } - } else { - d.db && d.remove(f); - } -} -;function Fa(a, c, b, e, d, f, g) { - const k = a.length; - let h = [], l, n; - l = B(); - for (let m = 0, q, p, r, u; m < c; m++) { - for (let t = 0; t < k; t++) { - if (r = a[t], m < r.length && (q = r[m])) { - for (let w = 0; w < q.length; w++) { - p = q[w]; - (n = l[p]) ? l[p]++ : (n = 0, l[p] = 1); - u = h[n] || (h[n] = []); - if (!g) { - let y = m + (t || !d ? 0 : f || 0); - u = u[y] || (u[y] = []); - } - u.push(p); - if (g && b && n === k - 1 && u.length - e === b) { - return e ? u.slice(e) : u; - } - } - } - } - } - if (a = h.length) { - if (d) { - h = 1 < h.length ? Ga(h, b, e, g, f) : (h = h[0]).length > b || e ? h.slice(e, b + e) : h; - } else { - if (a < k) { - return []; - } - h = h[a - 1]; - if (b || e) { - if (g) { - if (h.length > b || e) { - h = h.slice(e, b + e); - } - } else { - d = []; - for (let m = 0, q; m < h.length; m++) { - if (q = h[m], q.length > e) { - e -= q.length; - } else { - if (q.length > b || e) { - q = q.slice(e, b + e), b -= q.length, e && (e -= q.length); - } - d.push(q); - if (!b) { - break; - } - } - } - h = 1 < d.length ? [].concat.apply([], d) : d[0]; - } - } - } - } - return h; -} -function Ga(a, c, b, e, d) { - const f = [], g = B(); - let k; - var h = a.length; - let l; - if (e) { - for (d = h - 1; 0 <= d; d--) { - if (l = (e = a[d]) && e.length) { - for (h = 0; h < l; h++) { - if (k = e[h], !g[k]) { - if (g[k] = 1, b) { - b--; - } else { - if (f.push(k), f.length === c) { - return f; - } - } - } - } - } - } - } else { - for (let n = h - 1, m, q = 0; 0 <= n; n--) { - m = a[n]; - for (let p = 0; p < m.length; p++) { - if (l = (e = m[p]) && e.length) { - for (let r = 0; r < l; r++) { - if (k = e[r], !g[k]) { - if (g[k] = 1, b) { - b--; - } else { - let u = (p + (n < h - 1 ? d || 0 : 0)) / (n + 1) | 0; - (f[u] || (f[u] = [])).push(k); - if (++q === c) { - return f; - } - } - } - } - } - } - } - } - return f; -} -function Ha(a, c, b) { - const e = B(), d = []; - for (let f = 0, g; f < c.length; f++) { - g = c[f]; - for (let k = 0; k < g.length; k++) { - e[g[k]] = 1; - } - } - if (b) { - for (let f = 0, g; f < a.length; f++) { - g = a[f], e[g] && (d.push(g), e[g] = 0); - } - } else { - for (let f = 0, g, k; f < a.result.length; f++) { - for (g = a.result[f], c = 0; c < g.length; c++) { - k = g[c], e[k] && ((d[f] || (d[f] = [])).push(k), e[k] = 0); - } - } - } - return d; -} -;function Ia(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 ? V.call(this, a) : a; - } - let d = []; - for (let f = 0, g, k; f < a.length; f++) { - if ((g = a[f]) && (k = g.length)) { - if (b) { - if (b >= k) { - b -= k; - continue; - } - b < k && (g = c ? g.slice(b, b + c) : g.slice(b), k = g.length, b = 0); - } - k > c && (g = g.slice(0, c), k = c); - if (!d.length && k >= c) { - return e ? V.call(this, g) : g; - } - d.push(g); - c -= k; - if (!c) { - break; - } - } - } - d = 1 < d.length ? [].concat.apply([], d) : d[0]; - return e ? V.call(this, d) : d; -} -;function Ja(a, c, b) { - var e = b[0]; - if (e.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); - } - e = []; - let d = [], f = 0, g = 0, k, h, l; - for (let n = 0, m; n < b.length; n++) { - if (m = b[n]) { - let q; - if (m.constructor === W) { - q = m.result; - } else if (m.constructor === Array) { - q = m; - } else { - if (f = m.limit || 0, g = m.offset || 0, l = m.suggest, h = m.resolve, k = m.enrich && h, m.index) { - m.resolve = !1, m.enrich = !1, q = m.index.search(m).result, m.resolve = h, m.enrich = k; - } else if (m.and) { - q = a.and(m.and); - } else if (m.or) { - q = a.or(m.or); - } else if (m.xor) { - q = a.xor(m.xor); - } else if (m.not) { - q = a.not(m.not); - } else { - continue; - } - } - if (q.then) { - d.push(q); - } else if (q.length) { - e[n] = q; - } else if (!l && ("and" === c || "xor" === c)) { - e = []; - break; - } - } - } - return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; -} -;W.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Ja(this, "or", arguments); - return Ka.call(this, a, c, b, e, d, f); -}; -function Ka(a, c, b, e, d, f) { - if (c.length) { - const g = this; - return Promise.all(c).then(function(k) { - a = []; - for (let h = 0, l; h < k.length; h++) { - (l = k[h]).length && (a[h] = l); - } - return Ka.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 = Ga(a, b, e, !1, this.h), e = 0)); - return f ? this.resolve(b, e, d) : this; -} -;W.prototype.and = function() { - let a = this.result.length, c, b, e, d; - if (!a) { - const f = arguments[0]; - f && (a = !!f.suggest, d = f.resolve, c = f.limit, b = f.offset, e = f.enrich && d); - } - if (a) { - const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:n, suggest:m} = Ja(this, "and", arguments); - return La.call(this, f, g, k, h, l, n, m); - } - return d ? this.resolve(c, b, e) : this; -}; -function La(a, c, b, e, d, f, g) { - if (c.length) { - const k = this; - return Promise.all(c).then(function(h) { - a = []; - for (let l = 0, n; l < h.length; l++) { - (n = h[l]).length && (a[l] = n); - } - return La.call(k, 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 { - if (c = ca(a)) { - return this.result = Fa(a, c, b, 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(b, e, d) : this; -} -;W.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "xor", arguments); - return Ma.call(this, a, c, b, e, d, f, g); -}; -function Ma(a, c, b, e, d, f, g) { - if (c.length) { - const k = this; - return Promise.all(c).then(function(h) { - a = []; - for (let l = 0, n; l < h.length; l++) { - (n = h[l]).length && (a[l] = n); - } - return Ma.call(k, 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 = Na.call(this, a, b, e, f, this.h), f ? d ? V.call(this.index, this.result) : this.result : this; - } - } else { - g || (this.result = a); - } - return f ? this.resolve(b, e, d) : this; -} -function Na(a, c, b, e, d) { - const f = [], g = B(); - let k = 0; - for (let h = 0, l; h < a.length; h++) { - if (l = a[h]) { - k < l.length && (k = l.length); - for (let n = 0, m; n < l.length; n++) { - if (m = l[n]) { - for (let q = 0, p; q < m.length; q++) { - p = m[q], g[p] = g[p] ? 2 : 1; - } - } - } - } - } - for (let h = 0, l, n = 0; h < k; h++) { - for (let m = 0, q; m < a.length; m++) { - if (q = a[m]) { - if (l = q[h]) { - for (let p = 0, r; p < l.length; p++) { - if (r = l[p], 1 === g[r]) { - if (b) { - b--; - } else { - if (e) { - if (f.push(r), f.length === c) { - return f; - } - } else { - const u = h + (m ? d : 0); - f[u] || (f[u] = []); - f[u].push(r); - if (++n === c) { - return f; - } - } - } - } - } - } - } - } - } - return f; -} -;W.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "not", arguments); - return Oa.call(this, a, c, b, e, d, f, g); -}; -function Oa(a, c, b, e, d, f, g) { - if (c.length) { - const k = this; - return Promise.all(c).then(function(h) { - a = []; - for (let l = 0, n; l < h.length; l++) { - (n = h[l]).length && (a[l] = n); - } - return Oa.call(k, a, [], b, e, d, f, g); - }); - } - if (a.length && this.result.length) { - this.result = Pa.call(this, a, b, e, f); - } else if (f) { - return this.resolve(b, e, d); - } - return f ? d ? V.call(this.index, this.result) : this.result : this; -} -function Pa(a, c, b, e) { - const d = []; - a = new Set(a.flat().flat()); - for (let f = 0, g, k = 0; f < this.result.length; f++) { - if (g = this.result[f]) { - for (let h = 0, l; h < g.length; h++) { - if (l = g[h], !a.has(l)) { - if (b) { - b--; - } else { - if (e) { - if (d.push(l), d.length === c) { - return d; - } - } else { - if (d[f] || (d[f] = []), d[f].push(l), ++k === c) { - return d; - } - } - } - } - } - } - } - return d; -} -;function W(a) { - if (!this || this.constructor !== W) { - return new W(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; - } - this.index = null; - this.result = a || []; - this.h = 0; -} -W.prototype.limit = function(a) { - if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - if (e.length <= a) { - if (c[b] = e, a -= e.length, !a) { - break; - } - } else { - c[b] = e.slice(0, a); - break; - } - } - } - this.result = c; - } - return this; -}; -W.prototype.offset = function(a) { - if (this.result.length) { - const c = []; - for (let b = 0, e; b < this.result.length; b++) { - if (e = this.result[b]) { - e.length <= a ? a -= e.length : (c[b] = e.slice(a), a = 0); - } - } - this.result = c; - } - return this; -}; -W.prototype.boost = function(a) { - this.h += a; - return this; -}; -W.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), Ia.call(d, e, a || 100, c, b)) : e; -}; -B(); -U.prototype.search = function(a, c, b, e) { - b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0)); - let d = []; - var f = [], g; - let k; - let h, l; - let n = 0; - var m = !0; - let q; - if (b) { - b.constructor === Array && (b = {index:b}); - a = b.query || a; - var p = b.pluck; - k = b.merge; - h = p || b.field || (h = b.index) && (h.index ? null : h); - l = this.tag && b.tag; - var r = b.suggest; - m = !1 !== b.resolve; - if (!m && !p) { - if (h = h || this.field) { - F(h) ? p = h : (h.constructor === Array && 1 === h.length && (h = h[0]), p = h.field || h.index); - } - if (!p) { - throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); - } - } - this.store && b.enrich && !m && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - q = (g = this.store && b.enrich && m) && b.highlight; - c = b.limit || c; - var u = b.offset || 0; - c || (c = 100); - if (l && (!this.db || !e)) { - l.constructor !== Array && (l = [l]); - var t = []; - for (let A = 0, x; A < l.length; A++) { - x = l[A]; - if (F(x)) { - throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); - } - if (x.field && x.tag) { - var w = x.tag; - if (w.constructor === Array) { - for (var y = 0; y < w.length; y++) { - t.push(x.field, w[y]); - } - } else { - t.push(x.field, w); - } - } else { - w = Object.keys(x); - for (let C = 0, G, D; C < w.length; C++) { - if (G = w[C], D = x[G], D.constructor === Array) { - for (y = 0; y < D.length; y++) { - t.push(G, D[y]); - } - } else { - t.push(G, D); - } - } - } - } - if (!t.length) { - throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); - } - l = t; - if (!a) { - m = []; - if (t.length) { - for (f = 0; f < t.length; f += 2) { - if (this.db) { - p = this.index.get(t[f]); - if (!p) { - console.warn("Tag '" + t[f] + ":" + t[f + 1] + "' will be skipped because there is no field '" + t[f] + "'."); - continue; - } - m.push(p = p.db.tag(t[f + 1], c, u, g)); - } else { - p = Qa.call(this, t[f], t[f + 1], c, u, g); - } - d.push({field:t[f], tag:t[f + 1], result:p}); - } - } - return m.length ? Promise.all(m).then(function(A) { - for (let x = 0; x < A.length; x++) { - d[x].result = A[x]; - } - return d; - }) : d; - } - } - h && h.constructor !== Array && (h = [h]); - } - h || (h = this.field); - t = !e && (this.worker || this.db) && []; - let E; - for (let A = 0, x, C, G; A < h.length; A++) { - C = h[A]; - if (this.db && this.tag && !this.D[A]) { - continue; - } - let D; - F(C) || (D = C, C = D.field, a = D.query || a, c = D.limit || c, u = D.offset || u, r = D.suggest || r, g = this.store && (D.enrich || g)); - if (e) { - x = e[A]; - } else { - if (w = D || b, y = this.index.get(C), l && (this.db && (w.tag = l, E = y.db.support_tag_search, w.field = h), E || (w.enrich = !1)), t) { - t[A] = y.search(a, c, w); - w && g && (w.enrich = g); - continue; - } else { - x = y.search(a, c, w), w && g && (w.enrich = g); - } - } - G = x && (m ? x.length : x.result.length); - if (l && G) { - w = []; - y = 0; - if (this.db && e) { - if (!E) { - for (let K = h.length; K < e.length; K++) { - let L = e[K]; - if (L && L.length) { - y++, w.push(L); - } else if (!r) { - return m ? d : new W(d); - } - } - } - } else { - for (let K = 0, L, rb; K < l.length; K += 2) { - L = this.tag.get(l[K]); - if (!L) { - if (console.warn("Tag '" + l[K] + ":" + l[K + 1] + "' will be skipped because there is no field '" + l[K] + "'."), r) { - continue; - } else { - return m ? d : new W(d); - } - } - if (rb = (L = L && L.get(l[K + 1])) && L.length) { - y++, w.push(L); - } else if (!r) { - return m ? d : new W(d); - } - } - } - if (y) { - x = Ha(x, w, m); - G = x.length; - if (!G && !r) { - return m ? x : new W(x); - } - y--; - } - } - if (G) { - f[n] = C, d.push(x), n++; - } else if (1 === h.length) { - return m ? d : new W(d); - } - } - if (t) { - if (this.db && l && l.length && !E) { - for (g = 0; g < l.length; g += 2) { - f = this.index.get(l[g]); - if (!f) { - if (console.warn("Tag '" + l[g] + ":" + l[g + 1] + "' was not found because there is no field '" + l[g] + "'."), r) { - continue; - } else { - return m ? d : new W(d); - } - } - t.push(f.db.tag(l[g + 1], c, u, !1)); - } - } - const A = this; - return Promise.all(t).then(function(x) { - return x.length ? A.search(a, c, b, x) : x; - }); - } - if (!n) { - return m ? d : new W(d); - } - if (p && (!g || !this.store)) { - return d[0]; - } - t = []; - for (u = 0; u < f.length; u++) { - r = d[u]; - g && r.length && "undefined" === typeof r[0].doc && (this.db ? t.push(r = this.index.get(this.field[0]).db.enrich(r)) : r = V.call(this, r)); - if (p) { - return m ? r : new W(r); - } - d[u] = {field:f[u], result:r}; - } - if (g && this.db && t.length) { - const A = this; - return Promise.all(t).then(function(x) { - for (let C = 0; C < x.length; C++) { - d[C].result = x[C]; - } - return k ? Ra(d, c) : q ? Sa(d, a, A.index, A.field, A.D, q) : d; - }); - } - return k ? Ra(d, c) : q ? Sa(d, a, this.index, this.field, this.D, q) : d; -}; -function Sa(a, c, b, e, d, f) { - let g, k, h; - for (let l = 0, n, m, q, p; l < a.length; l++) { - let r = a[l].result; - n = a[l].field; - q = b.get(n); - m = q.encoder; - h = q.tokenize; - p = d[e.indexOf(n)]; - m !== g && (g = m, k = g.encode(c)); - for (let u = 0; u < r.length; u++) { - let t = "", w = ba(r[u].doc, p).split(/\s+/); - for (let y = 0, E, A; y < w.length; y++) { - E = w[y]; - A = g.encode(E).join(" "); - let x; - if (A && E) { - for (let C = 0, G; C < k.length; C++) { - if (G = k[C], "strict" === h) { - if (A === G) { - t += (t ? " " : "") + f.replace("$1", E); - x = !0; - break; - } - } else { - const D = A.indexOf(G); - if (-1 < D) { - t += (t ? " " : "") + E.substring(0, D) + f.replace("$1", E.substring(D, G.length)) + E.substring(D + G.length); - x = !0; - break; - } - } - } - } - x || (t += (t ? " " : "") + w[y]); - } - r[u].highlight = t; - } - } - return a; -} -function Ra(a, c) { - const b = [], e = B(); - for (let d = 0, f, g; d < a.length; d++) { - f = a[d]; - g = f.result; - for (let k = 0, h, l, n; k < g.length; k++) { - if (l = g[k], "object" !== typeof l && (l = {id:l}), h = l.id, n = e[h]) { - n.push(f.field); - } else { - if (b.length === c) { - return b; - } - l.field = e[h] = [f.field]; - b.push(l); - } - } - } - return b; -} -function Qa(a, c, b, e, d) { - let f = this.tag.get(a); - if (!f) { - return console.warn("Tag '" + a + "' was not found"), []; - } - if ((a = (f = f && f.get(c)) && f.length - e) && 0 < a) { - if (a > b || e) { - f = f.slice(e, e + b); - } - d && (f = V.call(this, f)); - return f; - } -} -function V(a) { - if (!this || !this.store) { - return a; - } - const c = Array(a.length); - for (let b = 0, e; b < a.length; b++) { - e = a[b], c[b] = {id:e, doc:this.store.get(e)}; - } - return c; -} -;function U(a) { - if (!this || this.constructor !== U) { - return new U(a); - } - const c = a.document || a.doc || a; - let b, e; - this.D = []; - this.field = []; - this.J = []; - this.key = (b = c.key || c.id) && Ta(b, this.J) || "id"; - (e = a.keystore || 0) && (this.keystore = e); - this.fastupdate = !!a.fastupdate; - this.reg = !this.fastupdate || a.worker || a.db ? e ? new T(e) : new Set() : e ? new S(e) : new Map(); - this.C = (b = c.store || null) && b && !0 !== b && []; - this.store = b && (e ? new S(e) : new Map()); - this.cache = (b = a.cache || null) && new X(b); - a.cache = !1; - this.worker = a.worker; - this.priority = a.priority || 4; - this.index = Ua.call(this, a, c); - this.tag = null; - if (b = c.tag) { - if ("string" === typeof b && (b = [b]), b.length) { - this.tag = new Map(); - this.F = []; - this.R = []; - for (let d = 0, f, g; d < b.length; d++) { - f = b[d]; - g = f.field || f; - if (!g) { - throw Error("The tag field from the document descriptor is undefined."); - } - f.custom ? this.F[d] = f.custom : (this.F[d] = Ta(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()); - } - } - } - if (this.worker) { - this.fastupdate = !1; - a = []; - for (const d of this.index.values()) { - d.then && a.push(d); - } - if (a.length) { - const d = this; - return Promise.all(a).then(function(f) { - let g = 0; - for (const k of d.index.entries()) { - const h = k[0]; - k[1].then && d.index.set(h, f[g++]); - } - return d; - }); - } - } else { - a.db && (this.fastupdate = !1, this.mount(a.db)); - } -} -v = U.prototype; -v.mount = function(a) { - if (this.worker) { - throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); - } - let c = this.field; - if (this.tag) { - for (let d = 0, f; d < this.R.length; d++) { - f = this.R[d]; - var b = void 0; - this.index.set(f, b = new N({}, this.reg)); - c === this.field && (c = c.slice(0)); - c.push(f); - b.tag = this.tag.get(f); - } - } - b = []; - const e = {db:a.db, type:a.type, fastupdate:a.fastupdate}; - for (let d = 0, f, g; d < c.length; d++) { - e.field = g = c[d]; - f = this.index.get(g); - const k = new a.constructor(a.id, e); - k.id = a.id; - b[d] = k.mount(f); - f.document = !0; - d ? f.bypass = !0 : f.store = this.store; - } - this.db = !0; - return Promise.all(b); -}; -v.commit = async function(a, c) { - const b = []; - for (const e of this.index.values()) { - b.push(e.commit(a, c)); - } - await Promise.all(b); - this.reg.clear(); -}; -v.destroy = function() { - const a = []; - for (const c of this.index.values()) { - a.push(c.destroy()); - } - return Promise.all(a); -}; -function Ua(a, c) { - const b = new Map(); - let e = c.index || c.field || c; - F(e) && (e = [e]); - for (let d = 0, f, g; d < e.length; d++) { - f = e[d]; - F(f) || (g = f, f = f.field); - g = H(g) ? Object.assign({}, a, g) : a; - if (this.worker) { - const k = new P(g); - b.set(f, k); - } - this.worker || b.set(f, new N(g, this.reg)); - g.custom ? this.D[d] = g.custom : (this.D[d] = Ta(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 = c.store; - F(a) && (a = [a]); - for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = Ta(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); - } - } - return b; -} -function Ta(a, c) { - const b = a.split(":"); - let e = 0; - for (let d = 0; d < b.length; d++) { - a = b[d], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (c[e] = !0), a && (b[e++] = a); - } - e < b.length && (b.length = e); - return 1 < e ? b : b[0]; -} -v.append = function(a, c) { - return this.add(a, c, !0); -}; -v.update = function(a, c) { - return this.remove(a).add(a, c); -}; -v.remove = function(a) { - H(a) && (a = ba(a, this.key)); - for (var c of this.index.values()) { - c.remove(a, !0); - } - if (this.reg.has(a)) { - if (this.tag && !this.fastupdate) { - for (let b of this.tag.values()) { - for (let e of b) { - c = e[0]; - const d = e[1], f = d.indexOf(a); - -1 < f && (1 < d.length ? d.splice(f, 1) : b.delete(c)); - } - } - } - this.store && this.store.delete(a); - this.reg.delete(a); - } - this.cache && this.cache.remove(a); - return this; -}; -v.clear = function() { - const a = []; - for (const c of this.index.values()) { - const b = c.clear(); - b.then && a.push(b); - } - if (this.tag) { - for (const c of this.tag.values()) { - c.clear(); - } - } - this.store && this.store.clear(); - this.cache && this.cache.clear(); - return a.length ? Promise.all(a) : this; -}; -v.contain = function(a) { - return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a); -}; -v.cleanup = function() { - for (const a of this.index.values()) { - a.cleanup(); - } - return this; -}; -v.get = function(a) { - return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(c) { - return c[0] && c[0].doc || null; - }) : this.store.get(a) || null; -}; -v.set = function(a, c) { - "object" === typeof a && (c = a, a = ba(c, this.key)); - this.store.set(a, c); - return this; -}; -v.searchCache = Va; -v.export = function(a, c, b = 0, e = 0) { - if (b < this.field.length) { - const g = this.field[b]; - if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { - const k = this; - return c.then(function() { - return k.export(a, g, b + 1); - }); - } - return this.export(a, g, b + 1); - } - let d, f; - switch(e) { - case 0: - d = "reg"; - f = wa(this.reg); - c = null; - break; - case 1: - d = "tag"; - f = this.tag && ua(this.tag, this.reg.size); - c = null; - break; - case 2: - d = "doc"; - f = this.store && sa(this.store); - c = null; - break; - default: - return; - } - return ya.call(this, a, c, d, f, b, e); -}; -v.import = function(a, c) { - var b = a.split("."); - "json" === b[b.length - 1] && b.pop(); - const e = 2 < b.length ? b[0] : ""; - b = 2 < b.length ? b[2] : b[1]; - if (this.worker && e) { - return this.index.get(e).import(a); - } - if (c) { - "string" === typeof c && (c = JSON.parse(c)); - if (e) { - return this.index.get(e).import(b, c); - } - switch(b) { - case "reg": - this.fastupdate = !1; - this.reg = xa(c, this.reg); - for (let d = 0, f; d < this.field.length; d++) { - f = this.index.get(this.field[d]), f.fastupdate = !1, f.reg = this.reg; - } - if (this.worker) { - c = []; - for (const d of this.index.values()) { - c.push(d.import(a)); - } - return Promise.all(c); - } - break; - case "tag": - this.tag = va(c, this.tag); - break; - case "doc": - this.store = ta(c, this.store); - } - } -}; -la(U.prototype); -function Va(a, c, b) { - a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new X()); - let e = this.cache.get(a); - if (!e) { - e = this.search(a, c, b); - if (e.then) { - const d = this; - e.then(function(f) { - d.cache.set(a, f); - return f; - }); - } - this.cache.set(a, e); - } - return e; -} -function X(a) { - this.limit = a && !0 !== a ? a : 1000; - this.cache = new Map(); - this.h = ""; -} -X.prototype.set = function(a, c) { - this.cache.set(this.h = a, c); - this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); -}; -X.prototype.get = function(a) { - const c = this.cache.get(a); - c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c)); - return c; -}; -X.prototype.remove = function(a) { - for (const c of this.cache) { - const b = c[0]; - c[1].includes(a) && this.cache.delete(b); - } -}; -X.prototype.clear = function() { - this.cache.clear(); - this.h = ""; -}; -const Wa = {normalize:!1, numeric:!1}; -const Xa = {}; -const Ya = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); -const Za = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), $a = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const ab = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var bb = {X:Wa, W:Xa, Y:Xa, LatinBalance:{dedupe:!0, mapper:Ya}, LatinAdvanced:{dedupe:!0, mapper:Ya, matcher:Za, replacer:$a}, LatinExtra:{dedupe:!0, mapper:Ya, replacer:$a.concat([/(?!^)[aeo]/g, ""]), matcher:Za}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { - for (let b = 0; b < a.length; b++) { - var c = a[b]; - let e = c.charAt(0), d = ab[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = ab[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { - } - a[b] = e; - } -}}, LatinExact:Wa, LatinDefault:Xa, LatinSimple:Xa}; -N.prototype.remove = function(a, c) { - const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); - if (b) { - if (this.fastupdate) { - for (let e = 0, d; e < b.length; e++) { - if (d = b[e]) { - if (2 > d.length) { - d.pop(); - } else { - const f = d.indexOf(a); - f === b.length - 1 ? d.pop() : d.splice(f, 1); - } - } - } - } else { - cb(this.map, a), this.depth && cb(this.ctx, a); - } - c || this.reg.delete(a); - } - this.db && (this.commit_task.push({del:a}), this.T && db(this)); - this.cache && this.cache.remove(a); - return this; -}; -function cb(a, c) { - let b = 0; - var e = "undefined" === typeof c; - if (a.constructor === Array) { - for (let d = 0, f, g; d < a.length; d++) { - if ((f = a[d]) && f.length) { - if (e) { - b++; - } else { - if (g = f.indexOf(c), 0 <= g) { - 1 < f.length ? (f.splice(g, 1), b++) : delete a[d]; - break; - } else { - b++; - } - } - } - } - } else { - for (let d of a.entries()) { - e = d[0]; - const f = cb(d[1], c); - f ? b += f : a.delete(e); - } - } - return b; -} -;const eb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -N.prototype.add = function(a, c, b, e) { - if (c && (a || 0 === a)) { - if (!e && !b && this.reg.has(a)) { - return this.update(a, c); - } - c = this.encoder.encode(c); - if (e = c.length) { - const l = B(), n = B(), m = this.depth, q = this.resolution; - for (let p = 0; p < e; p++) { - let r = c[this.rtl ? e - 1 - p : p]; - var d = r.length; - if (d && (m || !n[r])) { - var f = this.score ? this.score(c, r, p, null, 0) : fb(q, e, p), g = ""; - switch(this.tokenize) { - case "full": - if (2 < d) { - for (let u = 0, t; u < d; u++) { - for (f = d; f > u; f--) { - g = r.substring(u, f); - t = this.rtl ? d - 1 - u : u; - var k = this.score ? this.score(c, r, p, g, t) : fb(q, e, p, d, t); - gb(this, n, g, k, a, b); - } - } - break; - } - case "bidirectional": - case "reverse": - if (1 < d) { - for (k = d - 1; 0 < k; k--) { - g = r[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, r, p, g, k) : fb(q, e, p, d, k); - gb(this, n, g, h, a, b); - } - g = ""; - } - case "forward": - if (1 < d) { - for (k = 0; k < d; k++) { - g += r[this.rtl ? d - 1 - k : k], gb(this, n, g, f, a, b); - } - break; - } - default: - if (gb(this, n, r, f, a, b), m && 1 < e && p < e - 1) { - for (d = B(), g = this.U, f = r, k = Math.min(m + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { - if ((r = c[this.rtl ? e - 1 - p - h : p + h]) && !d[r]) { - d[r] = 1; - const u = this.score ? this.score(c, f, p, r, h - 1) : fb(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), t = this.bidirectional && r > f; - gb(this, l, t ? f : r, u, a, b, t ? r : f); - } - } - } - } - } - } - this.fastupdate || this.reg.add(a); - } else { - c = ""; - } - } - this.db && (c || this.commit_task.push({del:a}), this.T && db(this)); - return this; -}; -function gb(a, c, b, e, d, f, g) { - let k = g ? a.ctx : a.map, h; - if (!c[b] || g && !(h = c[b])[g]) { - if (g ? (c = h || (c[b] = B()), c[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : c[b] = 1, (h = k.get(b)) ? k = h : k.set(b, k = h = []), k = k[e] || (k[e] = []), !f || !k.includes(d)) { - if (k.length === 2 ** 31 - 1) { - c = new R(k); - if (a.fastupdate) { - for (let l of a.reg.values()) { - l.includes(k) && (l[l.indexOf(k)] = c); - } - } - h[e] = k = c; - } - k.push(d); - a.fastupdate && ((e = a.reg.get(d)) ? e.push(k) : a.reg.set(d, [k])); - } - } -} -function fb(a, c, b, e, d) { - return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; -} -;N.prototype.search = function(a, c, b) { - b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0)); - let e = [], d, f, g, k = 0, h, l, n, m, q; - b ? (a = b.query || a, c = b.limit || c, k = b.offset || 0, f = b.context, g = b.suggest, q = (h = !1 !== b.resolve) && b.enrich, n = b.boost, m = b.resolution, l = this.db && b.tag) : h = this.resolve; - let p = this.encoder.encode(a); - d = p.length; - c = c || (h ? 100 : 0); - if (1 === d) { - return hb.call(this, p[0], "", c, k, h, q, l); - } - f = this.depth && !1 !== f; - if (2 === d && f && !g) { - return hb.call(this, p[1], p[0], c, k, h, q, l); - } - let r = B(), u = 0, t; - 1 < d && f && (t = p[0], u = 1); - m || 0 === m || (m = t ? this.U : this.resolution); - if (this.db) { - if (this.db.search && (a = this.db.search(this, p, c, k, g, h, q, l), !1 !== a)) { - return a; - } - const w = this; - return async function() { - for (let y, E; u < d; u++) { - if ((E = p[u]) && !r[E]) { - r[E] = 1; - y = await ib(w, E, t, 0, 0, !1, !1); - if (y = jb(y, e, g, m)) { - e = y; - break; - } - t && (g && y && e.length || (t = E)); - } - g && t && u === d - 1 && !e.length && (m = w.resolution, t = "", u = -1, r = B()); - } - return kb(e, m, c, k, g, n, h); - }(); - } - for (let w, y; u < d; u++) { - if ((y = p[u]) && !r[y]) { - r[y] = 1; - w = ib(this, y, t, 0, 0, !1, !1); - if (w = jb(w, e, g, m)) { - e = w; - break; - } - t && (g && w && e.length || (t = y)); - } - g && t && u === d - 1 && !e.length && (m = this.resolution, t = "", u = -1, r = B()); - } - return kb(e, m, c, k, g, n, h); -}; -function kb(a, c, b, e, d, f, g) { - let k = a.length, h = a; - if (1 < k) { - h = Fa(a, c, b, e, d, f, g); - } else if (1 === k) { - return g ? Ia.call(null, a[0], b, e) : new W(a[0]); - } - return g ? h : new W(h); -} -function hb(a, c, b, e, d, f, g) { - a = ib(this, a, c, b, e, d, f, g); - return this.db ? a.then(function(k) { - return d ? k || [] : new W(k); - }) : a && a.length ? d ? Ia.call(this, a, b, e) : new W(a) : d ? [] : new W(); -} -function jb(a, c, b, e) { - let d = []; - if (a && a.length) { - if (a.length <= e) { - c.push(a); - return; - } - for (let f = 0, g; f < e; f++) { - if (g = a[f]) { - d[f] = g; - } - } - if (d.length) { - c.push(d); - return; - } - } - if (!b) { - return d; - } -} -function ib(a, c, b, e, d, f, g, k) { - let h; - b && (h = a.bidirectional && c > b) && (h = b, b = c, c = h); - if (a.db) { - return a.db.get(c, b, e, d, f, g, k); - } - a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); - return a; -} -;function N(a, c) { - if (!this || this.constructor !== N) { - return new N(a); - } - if (a) { - var b = F(a) ? a : a.preset; - b && (eb[b] || console.warn("Preset not found: " + b), a = Object.assign({}, eb[b], a)); - } else { - a = {}; - } - b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = F(a.encoder) ? bb[a.encoder] : a.encode || a.encoder || {}; - this.encoder = d.encode ? d : "object" === typeof d ? new ja(d) : {encode:d}; - this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && "exact" !== b && b || "strict"; - this.depth = "strict" === b && e.depth || 0; - this.bidirectional = !1 !== e.bidirectional; - this.fastupdate = !!a.fastupdate; - this.score = a.score || null; - e && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); - (b = a.keystore || 0) && (this.keystore = b); - this.map = b ? new S(b) : new Map(); - this.ctx = b ? new S(b) : new Map(); - this.reg = c || (this.fastupdate ? b ? new S(b) : new Map() : b ? new T(b) : new Set()); - this.U = e.resolution || 3; - this.rtl = d.rtl || a.rtl || !1; - this.cache = (b = a.cache || null) && new X(b); - this.resolve = !1 !== a.resolve; - if (b = a.db) { - this.db = this.mount(b); - } - this.T = !1 !== a.commit; - this.commit_task = []; - this.commit_timer = null; - this.priority = a.priority || 4; -} -v = N.prototype; -v.mount = function(a) { - this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); - return a.mount(this); -}; -v.commit = function(a, c) { - this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); - return this.db.commit(this, a, c); -}; -v.destroy = function() { - this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); - return this.db.destroy(); -}; -function db(a) { - a.commit_timer || (a.commit_timer = setTimeout(function() { - a.commit_timer = null; - a.db.commit(a, void 0, void 0); - }, 1)); -} -v.clear = function() { - this.map.clear(); - this.ctx.clear(); - this.reg.clear(); - this.cache && this.cache.clear(); - this.db && (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [{clear:!0}]); - return this; -}; -v.append = function(a, c) { - return this.add(a, c, !0); -}; -v.contain = function(a) { - return this.db ? this.db.has(a) : this.reg.has(a); -}; -v.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); -}; -v.cleanup = function() { - if (!this.fastupdate) { - return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; - } - cb(this.map); - this.depth && cb(this.ctx); - return this; -}; -v.searchCache = Va; -v.export = function(a, c, b = 0, e = 0) { - let d, f; - switch(e) { - case 0: - d = "reg"; - f = wa(this.reg); - break; - case 1: - d = "cfg"; - f = null; - break; - case 2: - d = "map"; - f = sa(this.map, this.reg.size); - break; - case 3: - d = "ctx"; - f = ua(this.ctx, this.reg.size); - break; - default: - return; - } - return ya.call(this, a, c, d, f, b, e); -}; -v.import = function(a, c) { - if (c) { - switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { - case "reg": - this.fastupdate = !1; - this.reg = xa(c, this.reg); - break; - case "map": - this.map = ta(c, this.map); - break; - case "ctx": - this.ctx = va(c, this.ctx); - } - } -}; -v.serialize = function(a = !0) { - let c = "", b = "", e = ""; - if (this.reg.size) { - let f; - for (var d of this.reg.keys()) { - f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); - } - c = "index.reg=new Set([" + c + "]);"; - b = za(this.map, f); - b = "index.map=new Map([" + b + "]);"; - for (const g of this.ctx.entries()) { - d = g[0]; - let k = za(g[1], f); - k = "new Map([" + k + "])"; - k = '["' + d + '",' + k + "]"; - e += (e ? "," : "") + k; - } - e = "index.ctx=new Map([" + e + "]);"; - } - return a ? "function inject(index){" + c + b + e + "}" : c + b + e; -}; -la(N.prototype); -const lb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), mb = ["map", "ctx", "tag", "reg", "cfg"], Y = B(); -function nb(a, c = {}) { - if (!this) { - return new nb(a, c); - } - "object" === typeof a && (c = a, a = a.name); - a || console.info("Default storage space was used, because a name was not passed."); - this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""); - this.field = c.field ? c.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : ""; - this.type = c.type; - this.fastupdate = this.support_tag_search = !1; - this.db = null; - this.h = {}; -} -v = nb.prototype; -v.mount = function(a) { - if (!a.encoder) { - return a.mount(this); - } - a.db = this; - return this.open(); -}; -v.open = function() { - if (this.db) { - return this.db; - } - let a = this; - navigator.storage && navigator.storage.persist(); - Y[a.id] || (Y[a.id] = []); - Y[a.id].push(a.field); - const c = lb.open(a.id, 1); - c.onupgradeneeded = function() { - const b = a.db = this.result; - for (let e = 0, d; e < mb.length; e++) { - d = mb[e]; - for (let f = 0, g; f < Y[a.id].length; f++) { - g = Y[a.id][f], b.objectStoreNames.contains(d + ("reg" !== d ? g ? ":" + g : "" : "")) || b.createObjectStore(d + ("reg" !== d ? g ? ":" + g : "" : "")); - } - } - }; - return a.db = Z(c, function(b) { - a.db = b; - a.db.onversionchange = function() { - a.close(); - }; - }); -}; -v.close = function() { - this.db && this.db.close(); - this.db = null; -}; -v.destroy = function() { - const a = lb.deleteDatabase(this.id); - return Z(a); -}; -v.clear = function() { - const a = []; - for (let b = 0, e; b < mb.length; b++) { - e = mb[b]; - for (let d = 0, f; d < Y[this.id].length; d++) { - f = Y[this.id][d], a.push(e + ("reg" !== e ? f ? ":" + f : "" : "")); - } - } - const c = this.db.transaction(a, "readwrite"); - for (let b = 0; b < a.length; b++) { - c.objectStore(a[b]).clear(); - } - return Z(c); -}; -v.get = function(a, c, b = 0, e = 0, d = !0, f = !1) { - a = this.db.transaction((c ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((c ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(c ? c + ":" + a : a); - const g = this; - return Z(a).then(function(k) { - let h = []; - if (!k || !k.length) { - return h; - } - if (d) { - if (!b && !e && 1 === k.length) { - return k[0]; - } - for (let l = 0, n; l < k.length; l++) { - if ((n = k[l]) && n.length) { - if (e >= n.length) { - e -= n.length; - continue; - } - const m = b ? e + Math.min(n.length - e, b) : n.length; - for (let q = e; q < m; q++) { - h.push(n[q]); - } - e = 0; - if (h.length === b) { - break; - } - } - } - return f ? g.enrich(h) : h; - } - return k; - }); -}; -v.tag = function(a, c = 0, b = 0, e = !1) { - a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a); - const d = this; - return Z(a).then(function(f) { - if (!f || !f.length || b >= f.length) { - return []; - } - if (!c && !b) { - return f; - } - f = f.slice(b, b + c); - return e ? d.enrich(f) : f; - }); -}; -v.enrich = function(a) { - "object" !== typeof a && (a = [a]); - const c = this.db.transaction("reg", "readonly").objectStore("reg"), b = []; - for (let e = 0; e < a.length; e++) { - b[e] = Z(c.get(a[e])); - } - return Promise.all(b).then(function(e) { - for (let d = 0; d < e.length; d++) { - e[d] = {id:a[d], doc:e[d] ? JSON.parse(e[d]) : null}; - } - return e; - }); -}; -v.has = function(a) { - a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); - return Z(a).then(function(c) { - return !!c; - }); -}; -v.search = null; -v.info = function() { -}; -v.transaction = function(a, c, b) { - a += "reg" !== a ? this.field ? ":" + this.field : "" : ""; - let e = this.h[a + ":" + c]; - if (e) { - return b.call(this, e); - } - let d = this.db.transaction(a, c); - this.h[a + ":" + c] = e = d.objectStore(a); - const f = b.call(this, e); - this.h[a + ":" + c] = null; - return Z(d).finally(function() { - d = e = null; - return f; - }); -}; -v.commit = async function(a, c, b) { - if (c) { - await this.clear(), a.commit_task = []; - } else { - let e = a.commit_task; - a.commit_task = []; - for (let d = 0, f; d < e.length; d++) { - if (f = e[d], f.clear) { - await this.clear(); - c = !0; - break; - } else { - e[d] = f.del; - } - } - c || (b || (e = e.concat(aa(a.reg))), e.length && await this.remove(e)); - } - a.reg.size && (await this.transaction("map", "readwrite", function(e) { - for (const d of a.map) { - const f = d[0], g = d[1]; - g.length && (c ? e.put(g, f) : e.get(f).onsuccess = function() { - let k = this.result; - var h; - if (k && k.length) { - const l = Math.max(k.length, g.length); - for (let n = 0, m, q; n < l; n++) { - if ((q = g[n]) && q.length) { - if ((m = k[n]) && m.length) { - for (h = 0; h < q.length; h++) { - m.push(q[h]); - } - } else { - k[n] = q; - } - h = 1; - } - } - } else { - k = g, h = 1; - } - h && e.put(k, f); - }); - } - }), await this.transaction("ctx", "readwrite", function(e) { - for (const d of a.ctx) { - const f = d[0], g = d[1]; - for (const k of g) { - const h = k[0], l = k[1]; - l.length && (c ? e.put(l, f + ":" + h) : e.get(f + ":" + h).onsuccess = function() { - let n = this.result; - var m; - if (n && n.length) { - const q = Math.max(n.length, l.length); - for (let p = 0, r, u; p < q; p++) { - if ((u = l[p]) && u.length) { - if ((r = n[p]) && r.length) { - for (m = 0; m < u.length; m++) { - r.push(u[m]); - } - } else { - n[p] = u; - } - m = 1; - } - } - } else { - n = l, m = 1; - } - m && e.put(n, f + ":" + h); - }); - } - } - }), a.store ? await this.transaction("reg", "readwrite", function(e) { - for (const d of a.store) { - const f = d[0], g = d[1]; - e.put("object" === typeof g ? JSON.stringify(g) : 1, f); - } - }) : a.bypass || await this.transaction("reg", "readwrite", function(e) { - for (const d of a.reg.keys()) { - e.put(1, d); - } - }), a.tag && await this.transaction("tag", "readwrite", function(e) { - for (const d of a.tag) { - const f = d[0], g = d[1]; - g.length && (e.get(f).onsuccess = function() { - let k = this.result; - k = k && k.length ? k.concat(g) : g; - e.put(k, f); - }); - } - }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); -}; -function ob(a, c, b) { - const e = a.value; - let d, f = 0; - for (let g = 0, k; g < e.length; g++) { - if (k = b ? e : e[g]) { - for (let h = 0, l, n; h < c.length; h++) { - if (n = c[h], l = k.indexOf(n), 0 <= l) { - if (d = 1, 1 < k.length) { - k.splice(l, 1); - } else { - e[g] = []; - break; - } - } - } - f += k.length; - } - if (b) { - break; - } - } - f ? d && a.update(e) : a.delete(); - a.continue(); -} -v.remove = function(a) { - "object" !== typeof a && (a = [a]); - return Promise.all([this.transaction("map", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && ob(b, a); - }; - }), this.transaction("ctx", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && ob(b, a); - }; - }), this.transaction("tag", "readwrite", function(c) { - c.openCursor().onsuccess = function() { - const b = this.result; - b && ob(b, a, !0); - }; - }), this.transaction("reg", "readwrite", function(c) { - for (let b = 0; b < a.length; b++) { - c.delete(a[b]); - } - })]); -}; -function Z(a, c) { - return new Promise((b, e) => { - a.onsuccess = a.oncomplete = function() { - c && c(this.result); - c = null; - b(this.result); - }; - a.onerror = a.onblocked = e; - a = null; - }); -} -;const pb = {Index:N, Charset:bb, Encoder:ja, Document:U, Worker:P, Resolver:W, IndexedDB:nb, Language:{}}, qb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; -let sb; -(sb = qb.define) && sb.amd ? sb([], function() { - return pb; -}) : "object" === typeof qb.exports ? qb.exports = pb : qb.FlexSearch = pb; -}(this||self)); diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index 51df6b6..6e23ac9 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -1,94 +1,94 @@ /**! - * FlexSearch.js v0.8.149 (Bundle) + * FlexSearch.js v0.8.151 (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 u;function z(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function B(){return Object.create(null)}function F(a){return"string"===typeof a} +(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var u;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 F(a){return"string"===typeof a} function H(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function I(a,b){if(F(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,ca)}catch(d){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:z(c&&new Set(c),null,this.filter);this.dedupe=z(a.dedupe,!1,this.dedupe);this.matcher=z((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=z((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=z((c=a.stemmer)&&new Map(c), -null,this.stemmer);this.replacer=z(a.replacer,null,this.replacer);this.minlength=z(a.minlength,1,this.minlength);this.maxlength=z(a.maxlength,0,this.maxlength);this.rtl=z(a.rtl,!1,this.rtl);if(this.cache=c=z(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.A+= +u.assign=function(a){this.normalize=A(a.normalize,!0,this.normalize);let b=a.include,c=b||a.exclude||a.split,e;if(c||""===c){if("object"===typeof c&&c.constructor!==RegExp){let d="";e=!b;b||(d+="\\p{Z}");c.letter&&(d+="\\p{L}");c.number&&(d+="\\p{N}",e=!!b);c.symbol&&(d+="\\p{S}");c.punctuation&&(d+="\\p{P}");c.control&&(d+="\\p{C}");if(c=c.char)d+="object"===typeof c?c.join(""):c;try{this.split=new RegExp("["+(b?"^":"")+d+"]+","u")}catch(f){this.split=/\s+/}}else this.split=c,e=!1===c||2>"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);c=a.filter;this.filter="function"===typeof c?c:A(c&&new Set(c),null,this.filter);this.dedupe=A(a.dedupe,!0,this.dedupe);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,1024,this.maxlength);this.rtl=A(a.rtl,!1,this.rtl);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};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&&J(this);return this};u.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&J(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&&J(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&&J(this);return this}; u.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(J,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),d!==g&&this.filter&& -g.length>=this.minlength&&("function"===typeof this.filter?!this.filter(g):this.filter.has(g))&&(g=""));if(g&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(g&&this.replacer)for(d=0;g&&dthis.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function J(a){a.H=null;a.B.clear();a.G.clear()};let L,ja;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":ja=a.options||{};(b=a.factory)?(Function("return "+b)()(self),L=new self.FlexSearch.Index(ja),delete self.FlexSearch):L=new M(ja);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=ja.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await ja.import.call(L,e[0]),L.import(e[0],a)):(d=e&&L[b].apply(L,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} +[],e=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,k;fthis.maxlength))if(b)c.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.L)if(this.H){var d=this.G.get(g);if(d||""===d){d&&c.push(d);continue}}else this.H=setTimeout(J,50,this);this.stemmer&&2this.stemmer.get(h)), +d!==g&&this.filter&&g.length>=this.minlength&&("function"===typeof this.filter?!this.filter(g):this.filter.has(g))&&(g=""));if(g&&(this.mapper||this.dedupe&&1this.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&dthis.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function J(a){a.H=null;a.B.clear();a.G.clear()};let L,ja;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":ja=a.options||{};(b=a.factory)?(Function("return "+b)()(self),L=new self.FlexSearch.Index(ja),delete self.FlexSearch):L=new M(ja);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=ja.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await ja.import.call(L,e[0]),L.import(e[0],a)):(d=e&&L[b].apply(L,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);na?pa||(pa=Date.now()-oa>=this.priority*this.priority*3):(na=setTimeout(qa,0),oa=Date.now());if(pa){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let N=0; -function P(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,n=l&&d.h[l];n&&(n(k.msg),delete d.h[l])}this.worker=g;this.h=B();if(this.worker){e?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){d.h[++N]=function(){k(d);1E9=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const h=b.length;if(h&&(d=d.length?d.concat(b):b,c-=h,e&&(a.length-=h),!c))break;b=0}return d} -function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,h,k;g=g.length)b-=g.length;else{b=g[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||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,k,h;gc||e?k.slice(e,c+e):k;else{if(ac||e)k=k.slice(e,c+e)}else{d= -[];for(let m=0,q;me)e-=q.length;else{if(q.length>c||e)q=q.slice(e,c+e),c-=q.length,e&&(e-=q.length);d.push(q);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,e?V.call(this,a):a;let d=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!d.length&&h>=b)return e?V.call(this,g):g;d.push(g);b-=h;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ga(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};W.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:h,offset:k,enrich:l,resolve:n,suggest:m}=Ja(this,"and",arguments);return La.call(this,f,g,h,k,l,n,m)}return d?this.resolve(b,c,e):this}; -function La(a,b,c,e,d,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(b=ba(a))return this.result=Fa(a,b,c,e,g,this.h,f),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};W.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,e,d,f,g)}; -function Ma(a,b,c,e,d,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function Na(a,b,c,e,d){const f=[],g=B();let h=0;for(let k=0,l;kc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d= +[];for(let m=0,q;me)e-=q.length;else{if(q.length>c||e)q=q.slice(e,c+e),c-=q.length,e&&(e-=q.length);d.push(q);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=Ga(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};W.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:n,suggest:m}=Ja(this,"and",arguments);return La.call(this,f,g,k,h,l,n,m)}return d?this.resolve(b,c,e):this}; +function La(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,n;la.length)this.result=a[0];else{if(b=ba(a))return this.result=Fa(a,b,c,e,g,this.h,f),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};W.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,e,d,f,g)}; +function Ma(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} +function Na(a,b,c,e,d){const f=[],g=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;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -X.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:!1,numeric:!1};const Xa={};const Ya=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Za=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),$a=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ab={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var bb={X:Wa,W:Xa,Y:Xa,LatinBalance:{dedupe:!0,mapper:Ya},LatinAdvanced:{dedupe:!0,mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{dedupe:!0,mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cd.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else cb(this.map,a),this.depth&&cb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&db(this));this.cache&&this.cache.remove(a);return this}; -function cb(a,b){let c=0;var e="undefined"===typeof b;if(a.constructor===Array)for(let d=0,f,g;dt;f--){g=r.substring(t,f);v=this.rtl?d-1-t:t;var h=this.score?this.score(b,r,p,g,v):fb(q,e,p,d,v); -gb(this,n,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1), -e,p,h-1,k-1),v=this.bidirectional&&r>f;gb(this,l,v?f:r,t,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&db(this));return this}; -function gb(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=B()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){b=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[e]=h=b}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} -function fb(a,b,c,e,d){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,e,d,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=F(a)?a:a.preset;c&&(a=Object.assign({},eb[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=F(a.encoder)?bb[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new ia(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; +X.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:!1,numeric:!1,dedupe:!1};const Xa={};const Ya=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Za=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),$a=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ab={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var bb={Exact:Wa,Default:Xa,Normalize:Xa,LatinBalance:{mapper:Ya},LatinAdvanced:{mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cd.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else cb(this.map,a),this.depth&&cb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&db(this));this.cache&&this.cache.remove(a);return this}; +function cb(a,b){let c=0;var e="undefined"===typeof b;if(a.constructor===Array)for(let d=0,f,g;dt;f--){g=r.substring(t,f);v=this.rtl?d-1-t:t;var k=this.score?this.score(b,r,p,g,v):fb(q,e,p,d,v); +gb(this,n,g,k,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1), +e,p,k-1,h-1),v=this.bidirectional&&r>f;gb(this,l,v?f:r,t,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&db(this));return this}; +function gb(a,b,c,e,d,f,g){let 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 fb(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};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=F(a)?a:a.preset;c&&(a=Object.assign({},eb[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=F(a.encoder)?bb[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new ia(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.U=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new X(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}u=M.prototype; u.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};u.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};u.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function db(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};u.append=function(a,b){return this.add(a,b,!0)};u.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};u.update=function(a,b){const c=this,e=this.remove(a);return e&&e.then?e.then(()=>c.add(a,b)):this.add(a,b)}; u.cleanup=function(){if(!this.fastupdate)return this;cb(this.map);this.depth&&cb(this.ctx);return this};u.searchCache=Va;u.export=function(a,b,c=0,e=0){let d,f;switch(e){case 0:d="reg";f=wa(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=sa(this.map,this.reg.size);break;case 3:d="ctx";f=ua(this.ctx,this.reg.size);break;default:return}return ya.call(this,a,b,d,f,c,e)}; u.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=n.length){e-=n.length;continue}const m=c?e+Math.min(n.length-e,c):n.length;for(let q=e;q=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; +u.get=function(a,b,c=0,e=0,d=!0,f=!1){a=this.db.transaction((b?"ctx":"map")+(this.field?":"+this.field:""),"readonly").objectStore((b?"ctx":"map")+(this.field?":"+this.field:"")).get(b?b+":"+a:a);const g=this;return Z(a).then(function(k){let h=[];if(!k||!k.length)return h;if(d){if(!c&&!e&&1===k.length)return k[0];for(let l=0,n;l=n.length){e-=n.length;continue}const m=c?e+Math.min(n.length-e,c):n.length;for(let q=e;q=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; u.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};const pb={Index:M,Charset:bb,Encoder:ia,Document:U,Worker:P,Resolver:W,IndexedDB:nb,Language:{}},rb="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let sb;(sb=rb.define)&&sb.amd?sb([],function(){return pb}):"object"===typeof rb.exports?rb.exports=pb:rb.FlexSearch=pb;}(this||self)); diff --git a/dist/flexsearch.bundle.module.debug.js b/dist/flexsearch.bundle.module.debug.js index 66ddbbb..6f01cd8 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -1,12 +1,12 @@ /**! - * FlexSearch.js v0.8.149 (Bundle/Module/Debug) + * FlexSearch.js v0.8.151 (Bundle/Module/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ var v; -function z(a, c, b) { +function A(a, c, b) { const e = typeof b, d = typeof a; if ("undefined" !== e) { if ("undefined" !== d) { @@ -91,7 +91,7 @@ function ja(a = {}) { } v = ja.prototype; v.assign = function(a) { - this.normalize = z(a.normalize, !0, this.normalize); + this.normalize = A(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, e; if (b || "" === b) { if ("object" === typeof b && b.constructor !== RegExp) { @@ -114,28 +114,28 @@ v.assign = function(a) { } else { this.split = b, e = !1 === b || 2 > "a1a".split(b).length; } - this.numeric = z(a.numeric, e); + this.numeric = A(a.numeric, e); } else { try { - this.split = z(this.split, da); + this.split = A(this.split, da); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } - this.numeric = z(a.numeric, z(this.numeric, !0)); + this.numeric = A(a.numeric, A(this.numeric, !0)); } - this.prepare = z(a.prepare, null, this.prepare); - this.finalize = z(a.finalize, null, this.finalize); + this.prepare = A(a.prepare, null, this.prepare); + this.finalize = A(a.finalize, null, this.finalize); b = a.filter; - this.filter = "function" === typeof b ? b : z(b && new Set(b), null, this.filter); - this.dedupe = z(a.dedupe, !1, this.dedupe); - this.matcher = z((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = z((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = z((b = a.stemmer) && new Map(b), null, this.stemmer); - this.replacer = z(a.replacer, null, this.replacer); - this.minlength = z(a.minlength, 1, this.minlength); - this.maxlength = z(a.maxlength, 0, this.maxlength); - this.rtl = z(a.rtl, !1, this.rtl); - if (this.cache = b = z(a.cache, !0, this.cache)) { + this.filter = "function" === typeof b ? b : A(b && new Set(b), null, this.filter); + this.dedupe = A(a.dedupe, !0, this.dedupe); + this.matcher = A((b = a.matcher) && new Map(b), null, this.matcher); + this.mapper = A((b = a.mapper) && new Map(b), null, this.mapper); + this.stemmer = A((b = a.stemmer) && new Map(b), null, this.stemmer); + this.replacer = A(a.replacer, null, this.replacer); + this.minlength = A(a.minlength, 1, this.minlength); + this.maxlength = A(a.maxlength, 1024, this.maxlength); + this.rtl = A(a.rtl, !1, this.rtl); + if (this.cache = b = A(a.cache, !0, this.cache)) { this.H = null, this.S = "number" === typeof b ? b : 2e5, this.B = new Map(), this.G = new Map(), this.L = this.K = 128; } this.h = ""; @@ -218,7 +218,7 @@ v.encode = function(a) { const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let b = [], e = this.split || "" === this.split ? a.split(this.split) : a; for (let f = 0, g, k; f < e.length; f++) { - if ((g = k = e[f]) && !(g.length < this.minlength)) { + if ((g = k = e[f]) && !(g.length < this.minlength || g.length > this.maxlength)) { if (c) { b.push(g); } else { @@ -1246,8 +1246,8 @@ U.prototype.search = function(a, c, b, e) { if (l && (!this.db || !e)) { l.constructor !== Array && (l = [l]); var t = []; - for (let A = 0, x; A < l.length; A++) { - x = l[A]; + for (let z = 0, x; z < l.length; z++) { + x = l[z]; if (F(x)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } @@ -1294,9 +1294,9 @@ U.prototype.search = function(a, c, b, e) { d.push({field:t[f], tag:t[f + 1], result:p}); } } - return m.length ? Promise.all(m).then(function(A) { - for (let x = 0; x < A.length; x++) { - d[x].result = A[x]; + return m.length ? Promise.all(m).then(function(z) { + for (let x = 0; x < z.length; x++) { + d[x].result = z[x]; } return d; }) : d; @@ -1307,18 +1307,18 @@ U.prototype.search = function(a, c, b, e) { h || (h = this.field); t = !e && (this.worker || this.db) && []; let E; - for (let A = 0, x, C, G; A < h.length; A++) { - C = h[A]; - if (this.db && this.tag && !this.D[A]) { + for (let z = 0, x, C, G; z < h.length; z++) { + C = h[z]; + if (this.db && this.tag && !this.D[z]) { continue; } let D; F(C) || (D = C, C = D.field, a = D.query || a, c = D.limit || c, u = D.offset || u, r = D.suggest || r, g = this.store && (D.enrich || g)); if (e) { - x = e[A]; + x = e[z]; } else { if (w = D || b, y = this.index.get(C), l && (this.db && (w.tag = l, E = y.db.support_tag_search, w.field = h), E || (w.enrich = !1)), t) { - t[A] = y.search(a, c, w); + t[z] = y.search(a, c, w); w && g && (w.enrich = g); continue; } else { @@ -1386,9 +1386,9 @@ U.prototype.search = function(a, c, b, e) { t.push(f.db.tag(l[g + 1], c, u, !1)); } } - const A = this; + const z = this; return Promise.all(t).then(function(x) { - return x.length ? A.search(a, c, b, x) : x; + return x.length ? z.search(a, c, b, x) : x; }); } if (!n) { @@ -1407,21 +1407,24 @@ U.prototype.search = function(a, c, b, e) { d[u] = {field:f[u], result:r}; } if (g && this.db && t.length) { - const A = this; + const z = this; return Promise.all(t).then(function(x) { for (let C = 0; C < x.length; C++) { d[C].result = x[C]; } - return k ? Ra(d, c) : q ? Sa(d, a, A.index, A.field, A.D, q) : d; + return k ? Ra(d) : q ? Sa(d, a, z.index, z.field, z.D, q) : d; }); } - return k ? Ra(d, c) : q ? Sa(d, a, this.index, this.field, this.D, q) : d; + return k ? Ra(d) : q ? Sa(d, a, this.index, this.field, this.D, q) : d; }; function Sa(a, c, b, e, d, f) { let g, k, h; for (let l = 0, n, m, q, p; l < a.length; l++) { - let r = a[l].result; n = a[l].field; + if (!n) { + continue; + } + let r = a[l].result; q = b.get(n); m = q.encoder; h = q.tokenize; @@ -1429,20 +1432,21 @@ function Sa(a, c, b, e, d, f) { m !== g && (g = m, k = g.encode(c)); for (let u = 0; u < r.length; u++) { let t = "", w = ba(r[u].doc, p).split(/\s+/); - for (let y = 0, E, A; y < w.length; y++) { + for (let y = 0, E, z; y < w.length; y++) { E = w[y]; - A = g.encode(E).join(" "); + z = m.encode(E); + z = 1 < z.length ? z.join(" ") : z[0]; let x; - if (A && E) { + if (z && E) { for (let C = 0, G; C < k.length; C++) { if (G = k[C], "strict" === h) { - if (A === G) { + if (z === G) { t += (t ? " " : "") + f.replace("$1", E); x = !0; break; } } else { - const D = A.indexOf(G); + const D = z.indexOf(G); if (-1 < D) { t += (t ? " " : "") + E.substring(0, D) + f.replace("$1", E.substring(D, G.length)) + E.substring(D + G.length); x = !0; @@ -1458,24 +1462,16 @@ function Sa(a, c, b, e, d, f) { } return a; } -function Ra(a, c) { - const b = [], e = B(); - for (let d = 0, f, g; d < a.length; d++) { - f = a[d]; - g = f.result; - for (let k = 0, h, l, n; k < g.length; k++) { - if (l = g[k], "object" !== typeof l && (l = {id:l}), h = l.id, n = e[h]) { - n.push(f.field); - } else { - if (b.length === c) { - return b; - } - l.field = e[h] = [f.field]; - b.push(l); - } +function Ra(a) { + const c = [], b = B(); + for (let e = 0, d, f; e < a.length; e++) { + d = a[e]; + f = d.result; + for (let g = 0, k, h, l; g < f.length; g++) { + h = f[g], "object" !== typeof h && (h = {id:h}), k = h.id, (l = b[k]) ? l.push(d.field) : (h.field = b[k] = [d.field], c.push(h)); } } - return b; + return c; } function Qa(a, c, b, e, d) { let f = this.tag.get(a); @@ -1811,12 +1807,12 @@ X.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Wa = {normalize:!1, numeric:!1}; +const Wa = {normalize:!1, numeric:!1, dedupe:!1}; const Xa = {}; const Ya = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); const Za = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), $a = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; const ab = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var bb = {X:Wa, W:Xa, Y:Xa, LatinBalance:{dedupe:!0, mapper:Ya}, LatinAdvanced:{dedupe:!0, mapper:Ya, matcher:Za, replacer:$a}, LatinExtra:{dedupe:!0, mapper:Ya, replacer:$a.concat([/(?!^)[aeo]/g, ""]), matcher:Za}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { +var bb = {Exact:Wa, Default:Xa, Normalize:Xa, LatinBalance:{mapper:Ya}, LatinAdvanced:{mapper:Ya, matcher:Za, replacer:$a}, LatinExtra:{mapper:Ya, replacer:$a.concat([/(?!^)[aeo]/g, ""]), matcher:Za}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; let e = c.charAt(0), d = ab[e]; @@ -1962,7 +1958,7 @@ function fb(a, c, b, e, d) { return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; } ;N.prototype.search = function(a, c, b) { - b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0)); + b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); let e = [], d, f, g, k = 0, h, l, n, m, q; b ? (a = b.query || a, c = b.limit || c, k = b.offset || 0, f = b.context, g = b.suggest, q = (h = !1 !== b.resolve) && b.enrich, n = b.boost, m = b.resolution, l = this.db && b.tag) : h = this.resolve; let p = this.encoder.encode(a); @@ -1976,7 +1972,7 @@ function fb(a, c, b, e, d) { return hb.call(this, p[1], p[0], c, k, h, q, l); } let r = B(), u = 0, t; - 1 < d && f && (t = p[0], u = 1); + f && (t = p[0], u = 1); m || 0 === m || (m = t ? this.U : this.resolution); if (this.db) { if (this.db.search && (a = this.db.search(this, p, c, k, g, h, q, l), !1 !== a)) { diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js index 8d7ead9..85f6293 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -1,95 +1,95 @@ /**! - * FlexSearch.js v0.8.149 (Bundle/Module) + * FlexSearch.js v0.8.151 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var u;function z(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function B(){return Object.create(null)}function F(a){return"string"===typeof a} +var u;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 F(a){return"string"===typeof a} function H(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function I(a,b){if(F(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; -this.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,ca)}catch(d){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:z(c&&new Set(c),null,this.filter);this.dedupe=z(a.dedupe,!1,this.dedupe);this.matcher=z((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=z((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=z((c=a.stemmer)&&new Map(c), -null,this.stemmer);this.replacer=z(a.replacer,null,this.replacer);this.minlength=z(a.minlength,1,this.minlength);this.maxlength=z(a.maxlength,0,this.maxlength);this.rtl=z(a.rtl,!1,this.rtl);if(this.cache=c=z(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.A+= +u.assign=function(a){this.normalize=A(a.normalize,!0,this.normalize);let b=a.include,c=b||a.exclude||a.split,e;if(c||""===c){if("object"===typeof c&&c.constructor!==RegExp){let d="";e=!b;b||(d+="\\p{Z}");c.letter&&(d+="\\p{L}");c.number&&(d+="\\p{N}",e=!!b);c.symbol&&(d+="\\p{S}");c.punctuation&&(d+="\\p{P}");c.control&&(d+="\\p{C}");if(c=c.char)d+="object"===typeof c?c.join(""):c;try{this.split=new RegExp("["+(b?"^":"")+d+"]+","u")}catch(f){this.split=/\s+/}}else this.split=c,e=!1===c||2>"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);c=a.filter;this.filter="function"===typeof c?c:A(c&&new Set(c),null,this.filter);this.dedupe=A(a.dedupe,!0,this.dedupe);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,1024,this.maxlength);this.rtl=A(a.rtl,!1,this.rtl);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};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&&J(this);return this};u.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&J(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&&J(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&&J(this);return this}; u.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(J,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),d!==g&&this.filter&& -g.length>=this.minlength&&("function"===typeof this.filter?!this.filter(g):this.filter.has(g))&&(g=""));if(g&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(g&&this.replacer)for(d=0;g&&dthis.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function J(a){a.H=null;a.B.clear();a.G.clear()};let L,ja;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":ja=a.options||{};(b=a.factory)?(Function("return "+b)()(self),L=new self.FlexSearch.Index(ja),delete self.FlexSearch):L=new M(ja);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=ja.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await ja.import.call(L,e[0]),L.import(e[0],a)):(d=e&&L[b].apply(L,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} +[],e=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,k;fthis.maxlength))if(b)c.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.L)if(this.H){var d=this.G.get(g);if(d||""===d){d&&c.push(d);continue}}else this.H=setTimeout(J,50,this);this.stemmer&&2this.stemmer.get(h)), +d!==g&&this.filter&&g.length>=this.minlength&&("function"===typeof this.filter?!this.filter(g):this.filter.has(g))&&(g=""));if(g&&(this.mapper||this.dedupe&&1this.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&dthis.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function J(a){a.H=null;a.B.clear();a.G.clear()};let L,ja;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":ja=a.options||{};(b=a.factory)?(Function("return "+b)()(self),L=new self.FlexSearch.Index(ja),delete self.FlexSearch):L=new M(ja);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=ja.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await ja.import.call(L,e[0]),L.import(e[0],a)):(d=e&&L[b].apply(L,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);na?pa||(pa=Date.now()-oa>=this.priority*this.priority*3):(na=setTimeout(qa,0),oa=Date.now());if(pa){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let N=0; -function P(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,n=l&&d.h[l];n&&(n(k.msg),delete d.h[l])}this.worker=g;this.h=B();if(this.worker){e?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){d.h[++N]=function(){k(d);1E9=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const h=b.length;if(h&&(d=d.length?d.concat(b):b,c-=h,e&&(a.length-=h),!c))break;b=0}return d} -function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,h,k;g=g.length)b-=g.length;else{b=g[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||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,k,h;gc||e?k.slice(e,c+e):k;else{if(ac||e)k=k.slice(e,c+e)}else{d= -[];for(let m=0,q;me)e-=q.length;else{if(q.length>c||e)q=q.slice(e,c+e),c-=q.length,e&&(e-=q.length);d.push(q);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,e?V.call(this,a):a;let d=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=b);if(!d.length&&h>=b)return e?V.call(this,g):g;d.push(g);b-=h;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ga(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};W.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:h,offset:k,enrich:l,resolve:n,suggest:m}=Ja(this,"and",arguments);return La.call(this,f,g,h,k,l,n,m)}return d?this.resolve(b,c,e):this}; -function La(a,b,c,e,d,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(b=ba(a))return this.result=Fa(a,b,c,e,g,this.h,f),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};W.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,e,d,f,g)}; -function Ma(a,b,c,e,d,f,g){if(b.length){const h=this;return Promise.all(b).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function Na(a,b,c,e,d){const f=[],g=B();let h=0;for(let k=0,l;kc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d= +[];for(let m=0,q;me)e-=q.length;else{if(q.length>c||e)q=q.slice(e,c+e),c-=q.length,e&&(e-=q.length);d.push(q);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=Ga(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};W.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:n,suggest:m}=Ja(this,"and",arguments);return La.call(this,f,g,k,h,l,n,m)}return d?this.resolve(b,c,e):this}; +function La(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,n;la.length)this.result=a[0];else{if(b=ba(a))return this.result=Fa(a,b,c,e,g,this.h,f),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};W.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,e,d,f,g)}; +function Ma(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} +function Na(a,b,c,e,d){const f=[],g=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;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -X.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:!1,numeric:!1};const Xa={};const Ya=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Za=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),$a=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ab={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var bb={X:Wa,W:Xa,Y:Xa,LatinBalance:{dedupe:!0,mapper:Ya},LatinAdvanced:{dedupe:!0,mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{dedupe:!0,mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cd.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else cb(this.map,a),this.depth&&cb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&db(this));this.cache&&this.cache.remove(a);return this}; -function cb(a,b){let c=0;var e="undefined"===typeof b;if(a.constructor===Array)for(let d=0,f,g;dt;f--){g=r.substring(t,f);v=this.rtl?d-1-t:t;var h=this.score?this.score(b,r,p,g,v):fb(q,e,p,d,v); -gb(this,n,g,h,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1), -e,p,h-1,k-1),v=this.bidirectional&&r>f;gb(this,l,v?f:r,t,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&db(this));return this}; -function gb(a,b,c,e,d,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=B()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){b=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[e]=h=b}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} -function fb(a,b,c,e,d){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,e,d,f,g,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=F(a)?a:a.preset;c&&(a=Object.assign({},eb[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=F(a.encoder)?bb[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new ia(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; +X.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:!1,numeric:!1,dedupe:!1};const Xa={};const Ya=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Za=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),$a=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const ab={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var bb={Exact:Wa,Default:Xa,Normalize:Xa,LatinBalance:{mapper:Ya},LatinAdvanced:{mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cd.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else cb(this.map,a),this.depth&&cb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&db(this));this.cache&&this.cache.remove(a);return this}; +function cb(a,b){let c=0;var e="undefined"===typeof b;if(a.constructor===Array)for(let d=0,f,g;dt;f--){g=r.substring(t,f);v=this.rtl?d-1-t:t;var k=this.score?this.score(b,r,p,g,v):fb(q,e,p,d,v); +gb(this,n,g,k,a,c)}break}case "bidirectional":case "reverse":if(1g?0:1), +e,p,k-1,h-1),v=this.bidirectional&&r>f;gb(this,l,v?f:r,t,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&db(this));return this}; +function gb(a,b,c,e,d,f,g){let 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 fb(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};function M(a,b){if(!this||this.constructor!==M)return new M(a);if(a){var c=F(a)?a:a.preset;c&&(a=Object.assign({},eb[c],a))}else a={};c=a.context;const e=!0===c?{depth:1}:c||{},d=F(a.encoder)?bb[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new ia(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.U=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new X(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.T=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}u=M.prototype; u.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};u.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};u.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function db(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};u.append=function(a,b){return this.add(a,b,!0)};u.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};u.update=function(a,b){const c=this,e=this.remove(a);return e&&e.then?e.then(()=>c.add(a,b)):this.add(a,b)}; u.cleanup=function(){if(!this.fastupdate)return this;cb(this.map);this.depth&&cb(this.ctx);return this};u.searchCache=Va;u.export=function(a,b,c=0,e=0){let d,f;switch(e){case 0:d="reg";f=wa(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=sa(this.map,this.reg.size);break;case 3:d="ctx";f=ua(this.ctx,this.reg.size);break;default:return}return ya.call(this,a,b,d,f,c,e)}; u.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=n.length){e-=n.length;continue}const m=c?e+Math.min(n.length-e,c):n.length;for(let q=e;q=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; +u.get=function(a,b,c=0,e=0,d=!0,f=!1){a=this.db.transaction((b?"ctx":"map")+(this.field?":"+this.field:""),"readonly").objectStore((b?"ctx":"map")+(this.field?":"+this.field:"")).get(b?b+":"+a:a);const g=this;return Z(a).then(function(k){let h=[];if(!k||!k.length)return h;if(d){if(!c&&!e&&1===k.length)return k[0];for(let l=0,n;l=n.length){e-=n.length;continue}const m=c?e+Math.min(n.length-e,c):n.length;for(let q=e;q=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; u.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e{a.onsuccess=a.oncomplete=function(){b&&b(this.result);b=null;c(this.result)};a.onerror=a.onblocked=e;a=null})};export default {Index:M,Charset:bb,Encoder:ia,Document:U,Worker:P,Resolver:W,IndexedDB:ob,Language:{}}; export const Index=M;export const Charset=bb;export const Encoder=ia;export const Document=U;export const Worker=P;export const Resolver=W;export const IndexedDB=ob;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.debug.js b/dist/flexsearch.compact.debug.js index 679812e..0101fab 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.149 (Bundle/Debug) + * FlexSearch.js v0.8.151 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -121,13 +121,13 @@ w.assign = function(a) { this.finalize = B(a.finalize, null, this.finalize); b = a.filter; this.filter = "function" === typeof b ? b : B(b && new Set(b), null, this.filter); - this.dedupe = B(a.dedupe, !1, this.dedupe); + this.dedupe = B(a.dedupe, !0, this.dedupe); this.matcher = B((b = a.matcher) && new Map(b), null, this.matcher); this.mapper = B((b = a.mapper) && new Map(b), null, this.mapper); this.stemmer = B((b = a.stemmer) && new Map(b), null, this.stemmer); this.replacer = B(a.replacer, null, this.replacer); this.minlength = B(a.minlength, 1, this.minlength); - this.maxlength = B(a.maxlength, 0, this.maxlength); + this.maxlength = B(a.maxlength, 1024, this.maxlength); this.rtl = B(a.rtl, !1, this.rtl); if (this.cache = b = B(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; @@ -212,7 +212,7 @@ w.encode = function(a) { const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let b = [], e = this.split || "" === this.split ? a.split(this.split) : a; for (let f = 0, g, k; f < e.length; f++) { - if ((g = k = e[f]) && !(g.length < this.minlength)) { + if ((g = k = e[f]) && !(g.length < this.minlength || g.length > this.maxlength)) { if (c) { b.push(g); } else { @@ -289,17 +289,17 @@ async function ha(a) { } } ;function ia(a) { - O.call(a, "add"); - O.call(a, "append"); - O.call(a, "search"); - O.call(a, "update"); - O.call(a, "remove"); + P.call(a, "add"); + P.call(a, "append"); + P.call(a, "search"); + P.call(a, "update"); + P.call(a, "remove"); } let ja, ka, Q; function la() { ja = Q = 0; } -function O(a) { +function P(a) { this[a + "Async"] = function() { const c = arguments; var b = c[c.length - 1]; @@ -579,11 +579,11 @@ function va(a, c, b, e, d, f, g, k) { const f = a.length; let g = [], k, h; k = C(); - for (let l = 0, m, n, u, p; l < c; l++) { + for (let l = 0, m, n, v, p; l < c; l++) { for (let q = 0; q < f; q++) { - if (u = a[q], l < u.length && (m = u[l])) { - for (let t = 0; t < m.length; t++) { - if (n = m[t], (h = k[n]) ? k[n]++ : (h = 0, k[n] = 1), p = g[h] || (g[h] = []), p.push(n), b && h === f - 1 && p.length - e === b) { + if (v = a[q], l < v.length && (m = v[l])) { + for (let u = 0; u < m.length; u++) { + if (n = m[u], (h = k[n]) ? k[n]++ : (h = 0, k[n] = 1), p = g[h] || (g[h] = []), p.push(n), b && h === f - 1 && p.length - e === b) { return e ? p.slice(e) : p; } } @@ -687,30 +687,30 @@ function za(a, c) { let d = [], f = 0, g = 0, k, h, l; for (let m = 0, n; m < b.length; m++) { if (n = b[m]) { - let u; + let v; if (n.constructor === W) { - u = n.result; + v = n.result; } else if (n.constructor === Array) { - u = n; + v = n; } else { if (f = n.limit || 0, g = n.offset || 0, l = n.suggest, h = n.resolve, k = n.enrich && h, n.index) { - n.resolve = !1, n.enrich = !1, u = n.index.search(n).result, n.resolve = h, n.enrich = k; + n.resolve = !1, n.enrich = !1, v = n.index.search(n).result, n.resolve = h, n.enrich = k; } else if (n.and) { - u = a.and(n.and); + v = a.and(n.and); } else if (n.or) { - u = a.or(n.or); + v = a.or(n.or); } else if (n.xor) { - u = a.xor(n.xor); + v = a.xor(n.xor); } else if (n.not) { - u = a.not(n.not); + v = a.not(n.not); } else { continue; } } - if (u.then) { - d.push(u); - } else if (u.length) { - e[m] = u; + if (v.then) { + d.push(v); + } else if (v.length) { + e[m] = v; } else if (!l && ("and" === c || "xor" === c)) { e = []; break; @@ -808,17 +808,17 @@ function Fa(a, c, b, e, d) { k < l.length && (k = l.length); for (let m = 0, n; m < l.length; m++) { if (n = l[m]) { - for (let u = 0, p; u < n.length; u++) { - p = n[u], g[p] = g[p] ? 2 : 1; + for (let v = 0, p; v < n.length; v++) { + p = n[v], g[p] = g[p] ? 2 : 1; } } } } } for (let h = 0, l, m = 0; h < k; h++) { - for (let n = 0, u; n < a.length; n++) { - if (u = a[n]) { - if (l = u[h]) { + for (let n = 0, v; n < a.length; n++) { + if (v = a[n]) { + if (l = v[h]) { for (let p = 0, q; p < l.length; p++) { if (q = l[p], 1 === g[q]) { if (b) { @@ -829,9 +829,9 @@ function Fa(a, c, b, e, d) { return f; } } else { - const t = h + (n ? d : 0); - f[t] || (f[t] = []); - f[t].push(q); + const u = h + (n ? d : 0); + f[u] || (f[u] = []); + f[u].push(q); if (++m === c) { return f; } @@ -951,7 +951,7 @@ U.prototype.search = function(a, c, b, e) { var f = []; let g; let k, h, l; - let m = 0, n = !0, u; + let m = 0, n = !0, v; if (b) { b.constructor === Array && (b = {index:b}); a = b.query || a; @@ -962,54 +962,54 @@ U.prototype.search = function(a, c, b, e) { k = b.suggest; n = !0; this.store && b.enrich && !n && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - u = (g = this.store && b.enrich && n) && b.highlight; + v = (g = this.store && b.enrich && n) && b.highlight; c = b.limit || c; - var t = b.offset || 0; + var u = b.offset || 0; c || (c = 100); if (l) { l.constructor !== Array && (l = [l]); - var r = []; - for (let y = 0, v; y < l.length; y++) { - v = l[y]; - if (D(v)) { + var t = []; + for (let y = 0, r; y < l.length; y++) { + r = l[y]; + if (D(r)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } - if (v.field && v.tag) { - var x = v.tag; + if (r.field && r.tag) { + var x = r.tag; if (x.constructor === Array) { for (var z = 0; z < x.length; z++) { - r.push(v.field, x[z]); + t.push(r.field, x[z]); } } else { - r.push(v.field, x); + t.push(r.field, x); } } else { - x = Object.keys(v); + x = Object.keys(r); for (let E = 0, F, A; E < x.length; E++) { - if (F = x[E], A = v[F], A.constructor === Array) { + if (F = x[E], A = r[F], A.constructor === Array) { for (z = 0; z < A.length; z++) { - r.push(F, A[z]); + t.push(F, A[z]); } } else { - r.push(F, A); + t.push(F, A); } } } } - if (!r.length) { + if (!t.length) { throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); } - l = r; + l = t; if (!a) { f = []; - if (r.length) { - for (p = 0; p < r.length; p += 2) { - q = Ia.call(this, r[p], r[p + 1], c, t, g), d.push({field:r[p], tag:r[p + 1], result:q}); + if (t.length) { + for (p = 0; p < t.length; p += 2) { + q = Ia.call(this, t[p], t[p + 1], c, u, g), d.push({field:t[p], tag:t[p + 1], result:q}); } } return f.length ? Promise.all(f).then(function(y) { - for (let v = 0; v < y.length; v++) { - d[v].result = y[v]; + for (let r = 0; r < y.length; r++) { + d[r].result = y[r]; } return d; }) : d; @@ -1018,60 +1018,60 @@ U.prototype.search = function(a, c, b, e) { h && h.constructor !== Array && (h = [h]); } h || (h = this.field); - r = !e && (this.worker || this.db) && []; - for (let y = 0, v, E, F; y < h.length; y++) { + t = !e && (this.worker || this.db) && []; + for (let y = 0, r, E, F; y < h.length; y++) { E = h[y]; let A; - D(E) || (A = E, E = A.field, a = A.query || a, c = A.limit || c, t = A.offset || t, k = A.suggest || k, g = this.store && (A.enrich || g)); + D(E) || (A = E, E = A.field, a = A.query || a, c = A.limit || c, u = A.offset || u, k = A.suggest || k, g = this.store && (A.enrich || g)); if (e) { - v = e[y]; + r = e[y]; } else { - if (x = A || b, z = this.index.get(E), l && (x.enrich = !1), r) { - r[y] = z.search(a, c, x); + if (x = A || b, z = this.index.get(E), l && (x.enrich = !1), t) { + t[y] = z.search(a, c, x); x && g && (x.enrich = g); continue; } else { - v = z.search(a, c, x), x && g && (x.enrich = g); + r = z.search(a, c, x), x && g && (x.enrich = g); } } - F = v && (n ? v.length : v.result.length); + F = r && (n ? r.length : r.result.length); if (l && F) { x = []; z = 0; - for (let G = 0, P, Ya; G < l.length; G += 2) { - P = this.tag.get(l[G]); - if (!P) { + for (let G = 0, O, Ya; G < l.length; G += 2) { + O = this.tag.get(l[G]); + if (!O) { if (console.warn("Tag '" + l[G] + ":" + l[G + 1] + "' will be skipped because there is no field '" + l[G] + "'."), k) { continue; } else { return n ? d : new W(d); } } - if (Ya = (P = P && P.get(l[G + 1])) && P.length) { - z++, x.push(P); + if (Ya = (O = O && O.get(l[G + 1])) && O.length) { + z++, x.push(O); } else if (!k) { return n ? d : new W(d); } } if (z) { - v = za(v, x); - F = v.length; + r = za(r, x); + F = r.length; if (!F && !k) { - return n ? v : new W(v); + return n ? r : new W(r); } z--; } } if (F) { - f[m] = E, d.push(v), m++; + f[m] = E, d.push(r), m++; } else if (1 === h.length) { return n ? d : new W(d); } } - if (r) { + if (t) { const y = this; - return Promise.all(r).then(function(v) { - return v.length ? y.search(a, c, b, v) : v; + return Promise.all(t).then(function(r) { + return r.length ? y.search(a, c, b, r) : r; }); } if (!m) { @@ -1080,76 +1080,72 @@ U.prototype.search = function(a, c, b, e) { if (p && (!g || !this.store)) { return d[0]; } - r = []; - for (t = 0; t < f.length; t++) { - e = d[t]; + t = []; + for (u = 0; u < f.length; u++) { + e = d[u]; g && e.length && "undefined" === typeof e[0].doc && (e = V.call(this, e)); if (p) { return n ? e : new W(e); } - d[t] = {field:f[t], result:e}; + d[u] = {field:f[u], result:e}; } - return q ? Ja(d, c) : u ? Ka(d, a, this.index, this.field, this.C, u) : d; + return q ? Ja(d) : v ? Ka(d, a, this.index, this.field, this.C, v) : d; }; function Ka(a, c, b, e, d, f) { let g, k, h; - for (let l = 0, m, n, u, p; l < a.length; l++) { - let q = a[l].result; + for (let l = 0, m, n, v, p; l < a.length; l++) { m = a[l].field; - u = b.get(m); - n = u.encoder; - h = u.tokenize; + if (!m) { + continue; + } + let q = a[l].result; + v = b.get(m); + n = v.encoder; + h = v.tokenize; p = d[e.indexOf(m)]; n !== g && (g = n, k = g.encode(c)); - for (let t = 0; t < q.length; t++) { - let r = "", x = I(q[t].doc, p).split(/\s+/); - for (let z = 0, y, v; z < x.length; z++) { + for (let u = 0; u < q.length; u++) { + let t = "", x = I(q[u].doc, p).split(/\s+/); + for (let z = 0, y, r; z < x.length; z++) { y = x[z]; - v = g.encode(y).join(" "); + r = n.encode(y); + r = 1 < r.length ? r.join(" ") : r[0]; let E; - if (v && y) { + if (r && y) { for (let F = 0, A; F < k.length; F++) { if (A = k[F], "strict" === h) { - if (v === A) { - r += (r ? " " : "") + f.replace("$1", y); + if (r === A) { + t += (t ? " " : "") + f.replace("$1", y); E = !0; break; } } else { - const G = v.indexOf(A); + const G = r.indexOf(A); if (-1 < G) { - r += (r ? " " : "") + y.substring(0, G) + f.replace("$1", y.substring(G, A.length)) + y.substring(G + A.length); + t += (t ? " " : "") + y.substring(0, G) + f.replace("$1", y.substring(G, A.length)) + y.substring(G + A.length); E = !0; break; } } } } - E || (r += (r ? " " : "") + x[z]); + E || (t += (t ? " " : "") + x[z]); } - q[t].highlight = r; + q[u].highlight = t; } } return a; } -function Ja(a, c) { - const b = [], e = C(); - for (let d = 0, f, g; d < a.length; d++) { - f = a[d]; - g = f.result; - for (let k = 0, h, l, m; k < g.length; k++) { - if (l = g[k], "object" !== typeof l && (l = {id:l}), h = l.id, m = e[h]) { - m.push(f.field); - } else { - if (b.length === c) { - return b; - } - l.field = e[h] = [f.field]; - b.push(l); - } +function Ja(a) { + const c = [], b = C(); + for (let e = 0, d, f; e < a.length; e++) { + d = a[e]; + f = d.result; + for (let g = 0, k, h, l; g < f.length; g++) { + h = f[g], "object" !== typeof h && (h = {id:h}), k = h.id, (l = b[k]) ? l.push(d.field) : (h.field = b[k] = [d.field], c.push(h)); } } - return b; + return c; } function Ia(a, c, b, e, d) { let f = this.tag.get(a); @@ -1394,12 +1390,12 @@ X.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Na = {normalize:!1, numeric:!1}; +const Na = {normalize:!1, numeric:!1, dedupe:!1}; const Oa = {}; const Pa = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); const Qa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Ra = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; const Sa = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var Ta = {W:Na, V:Oa, X:Oa, LatinBalance:{dedupe:!0, mapper:Pa}, LatinAdvanced:{dedupe:!0, mapper:Pa, matcher:Qa, replacer:Ra}, LatinExtra:{dedupe:!0, mapper:Pa, replacer:Ra.concat([/(?!^)[aeo]/g, ""]), matcher:Qa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { +var Ta = {Exact:Na, Default:Oa, Normalize:Oa, LatinBalance:{mapper:Pa}, LatinAdvanced:{mapper:Pa, matcher:Qa, replacer:Ra}, LatinExtra:{mapper:Pa, replacer:Ra.concat([/(?!^)[aeo]/g, ""]), matcher:Qa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; let e = c.charAt(0), d = Sa[e]; @@ -1465,20 +1461,20 @@ N.prototype.add = function(a, c, b, e) { } c = this.encoder.encode(c); if (e = c.length) { - const l = C(), m = C(), n = this.depth, u = this.resolution; + const l = C(), m = C(), n = this.depth, v = this.resolution; for (let p = 0; p < e; p++) { 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) : Va(u, e, p), g = ""; + var f = this.score ? this.score(c, q, p, null, 0) : Va(v, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { - for (let t = 0, r; t < d; t++) { - for (f = d; f > t; f--) { - g = q.substring(t, f); - r = this.rtl ? d - 1 - t : t; - var k = this.score ? this.score(c, q, p, g, r) : Va(u, e, p, d, r); + for (let u = 0, t; u < d; u++) { + for (f = d; f > u; f--) { + g = q.substring(u, f); + t = this.rtl ? d - 1 - u : u; + var k = this.score ? this.score(c, q, p, g, t) : Va(v, e, p, d, t); Z(this, m, g, k, a, b); } } @@ -1489,7 +1485,7 @@ N.prototype.add = function(a, c, b, e) { if (1 < d) { for (k = d - 1; 0 < k; k--) { g = q[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, q, p, g, k) : Va(u, e, p, d, k); + var h = this.score ? this.score(c, q, p, g, k) : Va(v, e, p, d, k); Z(this, m, g, h, a, b); } g = ""; @@ -1506,8 +1502,8 @@ N.prototype.add = function(a, c, b, e) { for (d = C(), g = this.S, f = q, k = Math.min(n + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { if ((q = c[this.rtl ? e - 1 - p - h : p + h]) && !d[q]) { d[q] = 1; - const t = this.score ? this.score(c, f, p, q, h - 1) : Va(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), r = this.bidirectional && q > f; - Z(this, l, r ? f : q, t, a, b, r ? q : f); + const u = this.score ? this.score(c, f, p, q, h - 1) : Va(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), t = this.bidirectional && q > f; + Z(this, l, t ? f : q, u, a, b, t ? q : f); } } } @@ -1529,7 +1525,7 @@ function Va(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; } ;N.prototype.search = function(a, c, b) { - b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0)); + b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); var e = [], d = 0; if (b) { a = b.query || a; @@ -1554,19 +1550,19 @@ function Va(a, c, b, e, d) { } k = C(); let l = 0; - if (1 < b && f) { + if (f) { var m = a[0]; l = 1; } h || 0 === h || (h = m ? this.S : this.resolution); - for (let q, t; l < b; l++) { - if ((t = a[l]) && !k[t]) { - k[t] = 1; - q = Wa(this, t, m); + for (let q, u; l < b; l++) { + if ((u = a[l]) && !k[u]) { + k[u] = 1; + q = Wa(this, u, m); a: { f = q; - var n = e, u = g, p = h; - let r = []; + var n = e, v = g, p = h; + let t = []; if (f && f.length) { if (f.length <= p) { n.push(f); @@ -1575,22 +1571,22 @@ function Va(a, c, b, e, d) { } for (let x = 0, z; x < p; x++) { if (z = f[x]) { - r[x] = z; + t[x] = z; } } - if (r.length) { - n.push(r); + if (t.length) { + n.push(t); q = void 0; break a; } } - q = u ? void 0 : r; + q = v ? void 0 : t; } if (q) { e = q; break; } - m && (g && q && e.length || (m = t)); + m && (g && q && e.length || (m = u)); } g && m && l === b - 1 && !e.length && (h = this.resolution, m = "", l = -1, k = C()); } diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index 0760219..b1135c9 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.149 (Bundle) + * FlexSearch.js v0.8.151 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -8,15 +8,15 @@ (function(self){'use strict';var w;function B(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function C(){return Object.create(null)}function D(a){return"string"===typeof a} function G(a){return"object"===typeof a}function H(a,c){if(D(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; -this.numeric=B(a.numeric,e)}else{try{this.split=B(this.split,ba)}catch(d){this.split=/\s+/}this.numeric=B(a.numeric,B(this.numeric,!0))}this.prepare=B(a.prepare,null,this.prepare);this.finalize=B(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:B(b&&new Set(b),null,this.filter);this.dedupe=B(a.dedupe,!1,this.dedupe);this.matcher=B((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=B((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=B((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=B(a.replacer,null,this.replacer);this.minlength=B(a.minlength,1,this.minlength);this.maxlength=B(a.maxlength,0,this.maxlength);this.rtl=B(a.rtl,!1,this.rtl);if(this.cache=b=B(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.numeric=B(a.numeric,e)}else{try{this.split=B(this.split,ba)}catch(d){this.split=/\s+/}this.numeric=B(a.numeric,B(this.numeric,!0))}this.prepare=B(a.prepare,null,this.prepare);this.finalize=B(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:B(b&&new Set(b),null,this.filter);this.dedupe=B(a.dedupe,!0,this.dedupe);this.matcher=B((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=B((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=B((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=B(a.replacer,null,this.replacer);this.minlength=B(a.minlength,1,this.minlength);this.maxlength=B(a.maxlength,1024,this.maxlength);this.rtl=B(a.rtl,!1,this.rtl);if(this.cache=b=B(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};w.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&&K(this);return this};w.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&K(this);return this}; w.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&&K(this);return this}; w.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&K(this);return this}; w.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(K,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=fa?a.normalize("NFKD").replace(fa,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),d!==g&&this.filter&& -g.length>=this.minlength&&("function"===typeof this.filter?!this.filter(g):this.filter.has(g))&&(g=""));if(g&&(this.mapper||this.dedupe&&1this.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&dthis.R&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function K(a){a.H=null;a.F.clear();a.G.clear()};let L,M;async function ha(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":M=a.options||{};(c=a.factory)?(Function("return "+c)()(self),L=new self.FlexSearch.Index(M),delete self.FlexSearch):L=new N(M);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=M.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await M.import.call(L,e[0]),L.import(e[0],a)):(d=e&&L[c].apply(L,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ia(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let ja,ka,Q;function la(){ja=Q=0} +[],e=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,k;fthis.maxlength))if(c)b.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.L)if(this.H){var d=this.G.get(g);if(d||""===d){d&&b.push(d);continue}}else this.H=setTimeout(K,50,this);this.stemmer&&2this.stemmer.get(h)), +d!==g&&this.filter&&g.length>=this.minlength&&("function"===typeof this.filter?!this.filter(g):this.filter.has(g))&&(g=""));if(g&&(this.mapper||this.dedupe&&1this.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&dthis.R&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function K(a){a.H=null;a.F.clear();a.G.clear()};let L,M;async function ha(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":M=a.options||{};(c=a.factory)?(Function("return "+c)()(self),L=new self.FlexSearch.Index(M),delete self.FlexSearch):L=new O(M);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=M.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await M.import.call(L,e[0]),L.import(e[0],a)):(d=e&&L[c].apply(L,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ia(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let ja,ka,Q;function la(){ja=Q=0} function P(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]);ja?Q||(Q=Date.now()-ka>=this.priority*this.priority*3):(ja=setTimeout(la,0),ka=Date.now());if(Q){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};let R=0; function S(a={}){function c(g){function k(h){h=h.data||h;const l=h.id,m=l&&d.h[l];m&&(m(h.msg),delete d.h[l])}this.worker=g;this.h=C();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++R]=function(){h(d);1E9b||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} -function ya(a,c,b){const e=[],d=C();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?V.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};W.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; +function va(a,c,b,e,d,f,g,k){if(a=a[g])if(e===c.length-1){if(a.constructor===Array){if(b[e]){for(c=0;cb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} +function ya(a,c,b){const e=[],d=C();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?V.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};W.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; function Da(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(c=aa(a))return this.result=xa(a,c,b,e,g),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};W.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Ba(this,"xor",arguments);return Ea.call(this,a,c,b,e,d,f,g)}; function Ea(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Fa.call(this,a,b,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} -function Fa(a,c,b,e,d){const f=[],g=C();let k=0;for(let h=0,l;hb||e)a=a.slice(e,e+b);d&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -X.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};X.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:!1,numeric:!1};const Oa={};const Pa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Qa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Ra=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Sa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Ta={W:Na,V:Oa,X:Oa,LatinBalance:{dedupe:!0,mapper:Pa},LatinAdvanced:{dedupe:!0,mapper:Pa,matcher:Qa,replacer:Ra},LatinExtra:{dedupe:!0,mapper:Pa,replacer:Ra.concat([/(?!^)[aeo]/g,""]),matcher:Qa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bd.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Y(this.map,a),this.depth&&Y(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Y(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dr;f--){g=q.substring(r,f);t=this.rtl?d-1-r:r;var k=this.score?this.score(c,q,p,g,t):Va(u,e,p,d,t); -Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),e,p, -k-1,h-1),t=this.bidirectional&&q>f;Z(this,l,t?f:q,r,a,b,t?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Va(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function N(a,c){if(!this||this.constructor!==N)return new N(a);if(a){var b=D(a)?a:a.preset;b&&(a=Object.assign({},Ua[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=D(a.encoder)?Ta[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new J(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.S=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new X(b);this.priority=a.priority||4}w=N.prototype;w.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};w.append=function(a,c){return this.add(a,c,!0)};w.contain=function(a){return this.reg.has(a)}; +X.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};X.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:!1,numeric:!1,dedupe:!1};const Oa={};const Pa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Qa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Ra=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Sa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Ta={Exact:Na,Default:Oa,Normalize:Oa,LatinBalance:{mapper:Pa},LatinAdvanced:{mapper:Pa,matcher:Qa,replacer:Ra},LatinExtra:{mapper:Pa,replacer:Ra.concat([/(?!^)[aeo]/g,""]),matcher:Qa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bd.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Y(this.map,a),this.depth&&Y(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Y(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Va(v,e,p,d,u); +Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),e,p, +k-1,h-1),u=this.bidirectional&&q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Va(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function O(a,c){if(!this||this.constructor!==O)return new O(a);if(a){var b=D(a)?a:a.preset;b&&(a=Object.assign({},Ua[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=D(a.encoder)?Ta[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new J(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.S=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new X(b);this.priority=a.priority||4}w=O.prototype;w.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};w.append=function(a,c){return this.add(a,c,!0)};w.contain=function(a){return this.reg.has(a)}; 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)};w.cleanup=function(){if(!this.fastupdate)return this;Y(this.map);this.depth&&Y(this.ctx);return this};w.searchCache=Ma;w.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=ra(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=na(this.map,this.reg.size);break;case 3:d="ctx";f=pa(this.ctx,this.reg.size);break;default:return}return ta.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(),3===a.length&&a.shift(),a=1 this.maxlength)) { if (c) { b.push(g); } else { @@ -288,17 +288,17 @@ async function ha(a) { } } ;function ia(a) { - O.call(a, "add"); - O.call(a, "append"); - O.call(a, "search"); - O.call(a, "update"); - O.call(a, "remove"); + P.call(a, "add"); + P.call(a, "append"); + P.call(a, "search"); + P.call(a, "update"); + P.call(a, "remove"); } let ja, ka, Q; function la() { ja = Q = 0; } -function O(a) { +function P(a) { this[a + "Async"] = function() { const c = arguments; var b = c[c.length - 1]; @@ -578,11 +578,11 @@ function va(a, c, b, e, d, f, g, k) { const f = a.length; let g = [], k, h; k = C(); - for (let l = 0, m, n, u, p; l < c; l++) { + for (let l = 0, m, n, v, p; l < c; l++) { for (let q = 0; q < f; q++) { - if (u = a[q], l < u.length && (m = u[l])) { - for (let t = 0; t < m.length; t++) { - if (n = m[t], (h = k[n]) ? k[n]++ : (h = 0, k[n] = 1), p = g[h] || (g[h] = []), p.push(n), b && h === f - 1 && p.length - e === b) { + if (v = a[q], l < v.length && (m = v[l])) { + for (let u = 0; u < m.length; u++) { + if (n = m[u], (h = k[n]) ? k[n]++ : (h = 0, k[n] = 1), p = g[h] || (g[h] = []), p.push(n), b && h === f - 1 && p.length - e === b) { return e ? p.slice(e) : p; } } @@ -686,30 +686,30 @@ function za(a, c) { let d = [], f = 0, g = 0, k, h, l; for (let m = 0, n; m < b.length; m++) { if (n = b[m]) { - let u; + let v; if (n.constructor === W) { - u = n.result; + v = n.result; } else if (n.constructor === Array) { - u = n; + v = n; } else { if (f = n.limit || 0, g = n.offset || 0, l = n.suggest, h = n.resolve, k = n.enrich && h, n.index) { - n.resolve = !1, n.enrich = !1, u = n.index.search(n).result, n.resolve = h, n.enrich = k; + n.resolve = !1, n.enrich = !1, v = n.index.search(n).result, n.resolve = h, n.enrich = k; } else if (n.and) { - u = a.and(n.and); + v = a.and(n.and); } else if (n.or) { - u = a.or(n.or); + v = a.or(n.or); } else if (n.xor) { - u = a.xor(n.xor); + v = a.xor(n.xor); } else if (n.not) { - u = a.not(n.not); + v = a.not(n.not); } else { continue; } } - if (u.then) { - d.push(u); - } else if (u.length) { - e[m] = u; + if (v.then) { + d.push(v); + } else if (v.length) { + e[m] = v; } else if (!l && ("and" === c || "xor" === c)) { e = []; break; @@ -807,17 +807,17 @@ function Fa(a, c, b, e, d) { k < l.length && (k = l.length); for (let m = 0, n; m < l.length; m++) { if (n = l[m]) { - for (let u = 0, p; u < n.length; u++) { - p = n[u], g[p] = g[p] ? 2 : 1; + for (let v = 0, p; v < n.length; v++) { + p = n[v], g[p] = g[p] ? 2 : 1; } } } } } for (let h = 0, l, m = 0; h < k; h++) { - for (let n = 0, u; n < a.length; n++) { - if (u = a[n]) { - if (l = u[h]) { + for (let n = 0, v; n < a.length; n++) { + if (v = a[n]) { + if (l = v[h]) { for (let p = 0, q; p < l.length; p++) { if (q = l[p], 1 === g[q]) { if (b) { @@ -828,9 +828,9 @@ function Fa(a, c, b, e, d) { return f; } } else { - const t = h + (n ? d : 0); - f[t] || (f[t] = []); - f[t].push(q); + const u = h + (n ? d : 0); + f[u] || (f[u] = []); + f[u].push(q); if (++m === c) { return f; } @@ -950,7 +950,7 @@ U.prototype.search = function(a, c, b, e) { var f = []; let g; let k, h, l; - let m = 0, n = !0, u; + let m = 0, n = !0, v; if (b) { b.constructor === Array && (b = {index:b}); a = b.query || a; @@ -961,54 +961,54 @@ U.prototype.search = function(a, c, b, e) { k = b.suggest; n = !0; this.store && b.enrich && !n && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - u = (g = this.store && b.enrich && n) && b.highlight; + v = (g = this.store && b.enrich && n) && b.highlight; c = b.limit || c; - var t = b.offset || 0; + var u = b.offset || 0; c || (c = 100); if (l) { l.constructor !== Array && (l = [l]); - var r = []; - for (let y = 0, v; y < l.length; y++) { - v = l[y]; - if (D(v)) { + var t = []; + for (let y = 0, r; y < l.length; y++) { + r = l[y]; + if (D(r)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } - if (v.field && v.tag) { - var x = v.tag; + if (r.field && r.tag) { + var x = r.tag; if (x.constructor === Array) { for (var z = 0; z < x.length; z++) { - r.push(v.field, x[z]); + t.push(r.field, x[z]); } } else { - r.push(v.field, x); + t.push(r.field, x); } } else { - x = Object.keys(v); + x = Object.keys(r); for (let E = 0, F, A; E < x.length; E++) { - if (F = x[E], A = v[F], A.constructor === Array) { + if (F = x[E], A = r[F], A.constructor === Array) { for (z = 0; z < A.length; z++) { - r.push(F, A[z]); + t.push(F, A[z]); } } else { - r.push(F, A); + t.push(F, A); } } } } - if (!r.length) { + if (!t.length) { throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); } - l = r; + l = t; if (!a) { f = []; - if (r.length) { - for (p = 0; p < r.length; p += 2) { - q = Ia.call(this, r[p], r[p + 1], c, t, g), d.push({field:r[p], tag:r[p + 1], result:q}); + if (t.length) { + for (p = 0; p < t.length; p += 2) { + q = Ia.call(this, t[p], t[p + 1], c, u, g), d.push({field:t[p], tag:t[p + 1], result:q}); } } return f.length ? Promise.all(f).then(function(y) { - for (let v = 0; v < y.length; v++) { - d[v].result = y[v]; + for (let r = 0; r < y.length; r++) { + d[r].result = y[r]; } return d; }) : d; @@ -1017,60 +1017,60 @@ U.prototype.search = function(a, c, b, e) { h && h.constructor !== Array && (h = [h]); } h || (h = this.field); - r = !e && (this.worker || this.db) && []; - for (let y = 0, v, E, F; y < h.length; y++) { + t = !e && (this.worker || this.db) && []; + for (let y = 0, r, E, F; y < h.length; y++) { E = h[y]; let A; - D(E) || (A = E, E = A.field, a = A.query || a, c = A.limit || c, t = A.offset || t, k = A.suggest || k, g = this.store && (A.enrich || g)); + D(E) || (A = E, E = A.field, a = A.query || a, c = A.limit || c, u = A.offset || u, k = A.suggest || k, g = this.store && (A.enrich || g)); if (e) { - v = e[y]; + r = e[y]; } else { - if (x = A || b, z = this.index.get(E), l && (x.enrich = !1), r) { - r[y] = z.search(a, c, x); + if (x = A || b, z = this.index.get(E), l && (x.enrich = !1), t) { + t[y] = z.search(a, c, x); x && g && (x.enrich = g); continue; } else { - v = z.search(a, c, x), x && g && (x.enrich = g); + r = z.search(a, c, x), x && g && (x.enrich = g); } } - F = v && (n ? v.length : v.result.length); + F = r && (n ? r.length : r.result.length); if (l && F) { x = []; z = 0; - for (let G = 0, P, Va; G < l.length; G += 2) { - P = this.tag.get(l[G]); - if (!P) { + for (let G = 0, O, Va; G < l.length; G += 2) { + O = this.tag.get(l[G]); + if (!O) { if (console.warn("Tag '" + l[G] + ":" + l[G + 1] + "' will be skipped because there is no field '" + l[G] + "'."), k) { continue; } else { return n ? d : new W(d); } } - if (Va = (P = P && P.get(l[G + 1])) && P.length) { - z++, x.push(P); + if (Va = (O = O && O.get(l[G + 1])) && O.length) { + z++, x.push(O); } else if (!k) { return n ? d : new W(d); } } if (z) { - v = za(v, x); - F = v.length; + r = za(r, x); + F = r.length; if (!F && !k) { - return n ? v : new W(v); + return n ? r : new W(r); } z--; } } if (F) { - f[m] = E, d.push(v), m++; + f[m] = E, d.push(r), m++; } else if (1 === h.length) { return n ? d : new W(d); } } - if (r) { + if (t) { const y = this; - return Promise.all(r).then(function(v) { - return v.length ? y.search(a, c, b, v) : v; + return Promise.all(t).then(function(r) { + return r.length ? y.search(a, c, b, r) : r; }); } if (!m) { @@ -1079,76 +1079,72 @@ U.prototype.search = function(a, c, b, e) { if (p && (!g || !this.store)) { return d[0]; } - r = []; - for (t = 0; t < f.length; t++) { - e = d[t]; + t = []; + for (u = 0; u < f.length; u++) { + e = d[u]; g && e.length && "undefined" === typeof e[0].doc && (e = V.call(this, e)); if (p) { return n ? e : new W(e); } - d[t] = {field:f[t], result:e}; + d[u] = {field:f[u], result:e}; } - return q ? Ja(d, c) : u ? Ka(d, a, this.index, this.field, this.C, u) : d; + return q ? Ja(d) : v ? Ka(d, a, this.index, this.field, this.C, v) : d; }; function Ka(a, c, b, e, d, f) { let g, k, h; - for (let l = 0, m, n, u, p; l < a.length; l++) { - let q = a[l].result; + for (let l = 0, m, n, v, p; l < a.length; l++) { m = a[l].field; - u = b.get(m); - n = u.encoder; - h = u.tokenize; + if (!m) { + continue; + } + let q = a[l].result; + v = b.get(m); + n = v.encoder; + h = v.tokenize; p = d[e.indexOf(m)]; n !== g && (g = n, k = g.encode(c)); - for (let t = 0; t < q.length; t++) { - let r = "", x = I(q[t].doc, p).split(/\s+/); - for (let z = 0, y, v; z < x.length; z++) { + for (let u = 0; u < q.length; u++) { + let t = "", x = I(q[u].doc, p).split(/\s+/); + for (let z = 0, y, r; z < x.length; z++) { y = x[z]; - v = g.encode(y).join(" "); + r = n.encode(y); + r = 1 < r.length ? r.join(" ") : r[0]; let E; - if (v && y) { + if (r && y) { for (let F = 0, A; F < k.length; F++) { if (A = k[F], "strict" === h) { - if (v === A) { - r += (r ? " " : "") + f.replace("$1", y); + if (r === A) { + t += (t ? " " : "") + f.replace("$1", y); E = !0; break; } } else { - const G = v.indexOf(A); + const G = r.indexOf(A); if (-1 < G) { - r += (r ? " " : "") + y.substring(0, G) + f.replace("$1", y.substring(G, A.length)) + y.substring(G + A.length); + t += (t ? " " : "") + y.substring(0, G) + f.replace("$1", y.substring(G, A.length)) + y.substring(G + A.length); E = !0; break; } } } } - E || (r += (r ? " " : "") + x[z]); + E || (t += (t ? " " : "") + x[z]); } - q[t].highlight = r; + q[u].highlight = t; } } return a; } -function Ja(a, c) { - const b = [], e = C(); - for (let d = 0, f, g; d < a.length; d++) { - f = a[d]; - g = f.result; - for (let k = 0, h, l, m; k < g.length; k++) { - if (l = g[k], "object" !== typeof l && (l = {id:l}), h = l.id, m = e[h]) { - m.push(f.field); - } else { - if (b.length === c) { - return b; - } - l.field = e[h] = [f.field]; - b.push(l); - } +function Ja(a) { + const c = [], b = C(); + for (let e = 0, d, f; e < a.length; e++) { + d = a[e]; + f = d.result; + for (let g = 0, k, h, l; g < f.length; g++) { + h = f[g], "object" !== typeof h && (h = {id:h}), k = h.id, (l = b[k]) ? l.push(d.field) : (h.field = b[k] = [d.field], c.push(h)); } } - return b; + return c; } function Ia(a, c, b, e, d) { let f = this.tag.get(a); @@ -1393,12 +1389,12 @@ X.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Na = {normalize:!1, numeric:!1}; +const Na = {normalize:!1, numeric:!1, dedupe:!1}; const Oa = {}; const Pa = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); const Qa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Ra = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; const Sa = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var Ta = {W:Na, V:Oa, X:Oa, LatinBalance:{dedupe:!0, mapper:Pa}, LatinAdvanced:{dedupe:!0, mapper:Pa, matcher:Qa, replacer:Ra}, LatinExtra:{dedupe:!0, mapper:Pa, replacer:Ra.concat([/(?!^)[aeo]/g, ""]), matcher:Qa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { +var Ta = {Exact:Na, Default:Oa, Normalize:Oa, LatinBalance:{mapper:Pa}, LatinAdvanced:{mapper:Pa, matcher:Qa, replacer:Ra}, LatinExtra:{mapper:Pa, replacer:Ra.concat([/(?!^)[aeo]/g, ""]), matcher:Qa}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; let e = c.charAt(0), d = Sa[e]; @@ -1464,20 +1460,20 @@ N.prototype.add = function(a, c, b, e) { } c = this.encoder.encode(c); if (e = c.length) { - const l = C(), m = C(), n = this.depth, u = this.resolution; + const l = C(), m = C(), n = this.depth, v = this.resolution; for (let p = 0; p < e; p++) { 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) : Wa(u, e, p), g = ""; + var f = this.score ? this.score(c, q, p, null, 0) : Wa(v, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { - for (let t = 0, r; t < d; t++) { - for (f = d; f > t; f--) { - g = q.substring(t, f); - r = this.rtl ? d - 1 - t : t; - var k = this.score ? this.score(c, q, p, g, r) : Wa(u, e, p, d, r); + for (let u = 0, t; u < d; u++) { + for (f = d; f > u; f--) { + g = q.substring(u, f); + t = this.rtl ? d - 1 - u : u; + var k = this.score ? this.score(c, q, p, g, t) : Wa(v, e, p, d, t); Z(this, m, g, k, a, b); } } @@ -1488,7 +1484,7 @@ N.prototype.add = function(a, c, b, e) { if (1 < d) { for (k = d - 1; 0 < k; k--) { g = q[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, q, p, g, k) : Wa(u, e, p, d, k); + var h = this.score ? this.score(c, q, p, g, k) : Wa(v, e, p, d, k); Z(this, m, g, h, a, b); } g = ""; @@ -1505,8 +1501,8 @@ N.prototype.add = function(a, c, b, e) { for (d = C(), g = this.S, f = q, k = Math.min(n + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { if ((q = c[this.rtl ? e - 1 - p - h : p + h]) && !d[q]) { d[q] = 1; - const t = this.score ? this.score(c, f, p, q, h - 1) : Wa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), r = this.bidirectional && q > f; - Z(this, l, r ? f : q, t, a, b, r ? q : f); + const u = this.score ? this.score(c, f, p, q, h - 1) : Wa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), t = this.bidirectional && q > f; + Z(this, l, t ? f : q, u, a, b, t ? q : f); } } } @@ -1528,7 +1524,7 @@ function Wa(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; } ;N.prototype.search = function(a, c, b) { - b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0)); + b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); var e = [], d = 0; if (b) { a = b.query || a; @@ -1553,19 +1549,19 @@ function Wa(a, c, b, e, d) { } k = C(); let l = 0; - if (1 < b && f) { + if (f) { var m = a[0]; l = 1; } h || 0 === h || (h = m ? this.S : this.resolution); - for (let q, t; l < b; l++) { - if ((t = a[l]) && !k[t]) { - k[t] = 1; - q = Xa(this, t, m); + for (let q, u; l < b; l++) { + if ((u = a[l]) && !k[u]) { + k[u] = 1; + q = Xa(this, u, m); a: { f = q; - var n = e, u = g, p = h; - let r = []; + var n = e, v = g, p = h; + let t = []; if (f && f.length) { if (f.length <= p) { n.push(f); @@ -1574,22 +1570,22 @@ function Wa(a, c, b, e, d) { } for (let x = 0, z; x < p; x++) { if (z = f[x]) { - r[x] = z; + t[x] = z; } } - if (r.length) { - n.push(r); + if (t.length) { + n.push(t); q = void 0; break a; } } - q = u ? void 0 : r; + q = v ? void 0 : t; } if (q) { e = q; break; } - m && (g && q && e.length || (m = t)); + m && (g && q && e.length || (m = u)); } g && m && l === b - 1 && !e.length && (h = this.resolution, m = "", l = -1, k = C()); } diff --git a/dist/flexsearch.compact.module.min.js b/dist/flexsearch.compact.module.min.js index 367ef74..550702e 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.149 (Bundle) + * FlexSearch.js v0.8.151 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -8,15 +8,15 @@ var w;function B(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function C(){return Object.create(null)}function D(a){return"string"===typeof a} function G(a){return"object"===typeof a}function H(a,c){if(D(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; -this.numeric=B(a.numeric,e)}else{try{this.split=B(this.split,ba)}catch(d){this.split=/\s+/}this.numeric=B(a.numeric,B(this.numeric,!0))}this.prepare=B(a.prepare,null,this.prepare);this.finalize=B(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:B(b&&new Set(b),null,this.filter);this.dedupe=B(a.dedupe,!1,this.dedupe);this.matcher=B((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=B((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=B((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=B(a.replacer,null,this.replacer);this.minlength=B(a.minlength,1,this.minlength);this.maxlength=B(a.maxlength,0,this.maxlength);this.rtl=B(a.rtl,!1,this.rtl);if(this.cache=b=B(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.numeric=B(a.numeric,e)}else{try{this.split=B(this.split,ba)}catch(d){this.split=/\s+/}this.numeric=B(a.numeric,B(this.numeric,!0))}this.prepare=B(a.prepare,null,this.prepare);this.finalize=B(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:B(b&&new Set(b),null,this.filter);this.dedupe=B(a.dedupe,!0,this.dedupe);this.matcher=B((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=B((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=B((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=B(a.replacer,null,this.replacer);this.minlength=B(a.minlength,1,this.minlength);this.maxlength=B(a.maxlength,1024,this.maxlength);this.rtl=B(a.rtl,!1,this.rtl);if(this.cache=b=B(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};w.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&&K(this);return this};w.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&K(this);return this}; w.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&&K(this);return this}; w.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&K(this);return this}; w.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(K,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=fa?a.normalize("NFKD").replace(fa,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),d!==g&&this.filter&& -g.length>=this.minlength&&("function"===typeof this.filter?!this.filter(g):this.filter.has(g))&&(g=""));if(g&&(this.mapper||this.dedupe&&1this.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&dthis.R&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function K(a){a.H=null;a.F.clear();a.G.clear()};let L,M;async function ha(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":M=a.options||{};(c=a.factory)?(Function("return "+c)()(self),L=new self.FlexSearch.Index(M),delete self.FlexSearch):L=new N(M);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=M.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await M.import.call(L,e[0]),L.import(e[0],a)):(d=e&&L[c].apply(L,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ia(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let ja,ka,Q;function la(){ja=Q=0} +[],e=this.split||""===this.split?a.split(this.split):a;for(let f=0,g,k;fthis.maxlength))if(c)b.push(g);else if(!this.filter||("function"===typeof this.filter?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.L)if(this.H){var d=this.G.get(g);if(d||""===d){d&&b.push(d);continue}}else this.H=setTimeout(K,50,this);this.stemmer&&2this.stemmer.get(h)), +d!==g&&this.filter&&g.length>=this.minlength&&("function"===typeof this.filter?!this.filter(g):this.filter.has(g))&&(g=""));if(g&&(this.mapper||this.dedupe&&1this.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&dthis.R&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function K(a){a.H=null;a.F.clear();a.G.clear()};let L,M;async function ha(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":M=a.options||{};(c=a.factory)?(Function("return "+c)()(self),L=new self.FlexSearch.Index(M),delete self.FlexSearch):L=new O(M);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=M.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await M.import.call(L,e[0]),L.import(e[0],a)):(d=e&&L[c].apply(L,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ia(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let ja,ka,Q;function la(){ja=Q=0} function P(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]);ja?Q||(Q=Date.now()-ka>=this.priority*this.priority*3):(ja=setTimeout(la,0),ka=Date.now());if(Q){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,c))},0)})}const d=this[a].apply(this,c);b=d.then?d:new Promise(f=>f(d));e&&b.then(e);return b}};let R=0; function S(a={}){function c(g){function k(h){h=h.data||h;const l=h.id,m=l&&d.h[l];m&&(m(h.msg),delete d.h[l])}this.worker=g;this.h=C();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++R]=function(){h(d);1E9b||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} -function ya(a,c,b){const e=[],d=C();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?V.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};W.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; +function va(a,c,b,e,d,f,g,k){if(a=a[g])if(e===c.length-1){if(a.constructor===Array){if(b[e]){for(c=0;cb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} +function ya(a,c,b){const e=[],d=C();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?V.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};W.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; function Da(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(c=aa(a))return this.result=xa(a,c,b,e,g),f?d?V.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};W.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Ba(this,"xor",arguments);return Ea.call(this,a,c,b,e,d,f,g)}; function Ea(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Fa.call(this,a,b,e,f,this.h),f?d?V.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} -function Fa(a,c,b,e,d){const f=[],g=C();let k=0;for(let h=0,l;hb||e)a=a.slice(e,e+b);d&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -X.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};X.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:!1,numeric:!1};const Oa={};const Pa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Qa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Ra=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Sa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Ta={W:Na,V:Oa,X:Oa,LatinBalance:{dedupe:!0,mapper:Pa},LatinAdvanced:{dedupe:!0,mapper:Pa,matcher:Qa,replacer:Ra},LatinExtra:{dedupe:!0,mapper:Pa,replacer:Ra.concat([/(?!^)[aeo]/g,""]),matcher:Qa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bd.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Y(this.map,a),this.depth&&Y(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Y(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dr;f--){g=q.substring(r,f);t=this.rtl?d-1-r:r;var k=this.score?this.score(c,q,p,g,t):Wa(u,e,p,d,t); -Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),e,p, -k-1,h-1),t=this.bidirectional&&q>f;Z(this,l,t?f:q,r,a,b,t?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Wa(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function N(a,c){if(!this||this.constructor!==N)return new N(a);if(a){var b=D(a)?a:a.preset;b&&(a=Object.assign({},Va[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=D(a.encoder)?Ta[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new J(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.S=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new X(b);this.priority=a.priority||4}w=N.prototype;w.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};w.append=function(a,c){return this.add(a,c,!0)};w.contain=function(a){return this.reg.has(a)}; +X.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};X.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};X.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:!1,numeric:!1,dedupe:!1};const Oa={};const Pa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Qa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Ra=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Sa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Ta={Exact:Na,Default:Oa,Normalize:Oa,LatinBalance:{mapper:Pa},LatinAdvanced:{mapper:Pa,matcher:Qa,replacer:Ra},LatinExtra:{mapper:Pa,replacer:Ra.concat([/(?!^)[aeo]/g,""]),matcher:Qa},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bd.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Y(this.map,a),this.depth&&Y(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Y(a,c){let b=0;var e="undefined"===typeof c;if(a.constructor===Array)for(let d=0,f,g;dt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Wa(v,e,p,d,u); +Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),e,p, +k-1,h-1),u=this.bidirectional&&q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Wa(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function O(a,c){if(!this||this.constructor!==O)return new O(a);if(a){var b=D(a)?a:a.preset;b&&(a=Object.assign({},Va[b],a))}else a={};b=a.context;const e=!0===b?{depth:1}:b||{},d=D(a.encoder)?Ta[a.encoder]:a.encode||a.encoder||{};this.encoder=d.encode?d:"object"===typeof d?new J(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&e.depth||0;this.bidirectional=!1!==e.bidirectional;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;b=!1;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.S=e.resolution||3;this.rtl=d.rtl||a.rtl||!1;this.cache=(b=a.cache||null)&&new X(b);this.priority=a.priority||4}w=O.prototype;w.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();return this};w.append=function(a,c){return this.add(a,c,!0)};w.contain=function(a){return this.reg.has(a)}; 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)};w.cleanup=function(){if(!this.fastupdate)return this;Y(this.map);this.depth&&Y(this.ctx);return this};w.searchCache=Ma;w.export=function(a,c,b=0,e=0){let d,f;switch(e){case 0:d="reg";f=ra(this.reg);break;case 1:d="cfg";f=null;break;case 2:d="map";f=na(this.map,this.reg.size);break;case 3:d="ctx";f=pa(this.ctx,this.reg.size);break;default:return}return ta.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(),3===a.length&&a.shift(),a=1 this.maxlength)) { if (c) { d.push(f); } else { @@ -1074,7 +1074,7 @@ u.encode = function(a) { continue; } } else { - this.D = setTimeout(M, 50, this); + this.D = setTimeout(L, 50, this); } } this.stemmer && 2 < f.length && (this.N || (this.N = new RegExp("(?!^)(" + this.A + ")$")), k = f, f = f.replace(this.N, function(q) { @@ -1105,13 +1105,13 @@ u.encode = function(a) { 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 M(a) { +function L(a) { a.D = null; a.B.clear(); a.C.clear(); } -;var Ga, O; -function Ha(a) { +;var Ha, N; +function Ia(a) { var b, c, d, e, g, f; return ta(function(h) { switch(h.h) { @@ -1122,8 +1122,8 @@ function Ha(a) { d = a.args; switch(b) { case "init": - O = a.options || {}; - (e = a.factory) ? (Function("return " + e)()(self), Ga = new self.FlexSearch.Index(O), delete self.FlexSearch) : Ga = new P(O); + N = a.options || {}; + (e = a.factory) ? (Function("return " + e)()(self), Ha = new self.FlexSearch.Index(N), delete self.FlexSearch) : Ha = new O(N); postMessage({id:c}); break; default: @@ -1133,58 +1133,58 @@ function Ha(a) { break; case 2: if ("export" === b) { - if (!O.export || "function" !== typeof O.export) { + if (!N.export || "function" !== typeof N.export) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "export".'); } - d[1] ? (d[0] = O.export, d[2] = 0, d[3] = 1) : d = null; + d[1] ? (d[0] = N.export, d[2] = 0, d[3] = 1) : d = null; } if ("import" === b) { - if (!O.import || "function" !== typeof O.import) { + if (!N.import || "function" !== typeof N.import) { throw Error('Either no extern configuration provided for the Worker-Index or no method was defined on the config property "import".'); } if (!d[0]) { h.h = 5; break; } - return D(h, O.import.call(Ga, d[0]), 9); + return E(h, N.import.call(Ha, d[0]), 9); } - g = d && Ga[b].apply(Ga, d); + g = d && Ha[b].apply(Ha, d); if (!g || !g.then) { h.h = 5; break; } - return D(h, g, 7); + return E(h, g, 7); case 7: g = h.D; h.h = 5; break; case 9: - f = h.D, Ga.import(d[0], f); + f = h.D, Ha.import(d[0], f); case 5: postMessage("search" === b ? {id:c, msg:g} : {id:c}), h.h = 0; } }); } -;function Ia(a) { - Ja.call(a, "add"); - Ja.call(a, "append"); - Ja.call(a, "search"); - Ja.call(a, "update"); - Ja.call(a, "remove"); +;function Ja(a) { + Ka.call(a, "add"); + Ka.call(a, "append"); + Ka.call(a, "search"); + Ka.call(a, "update"); + Ka.call(a, "remove"); } -var Ka, Na, Oa; -function Pa() { - Ka = Oa = 0; +var Na, Oa, Pa; +function Qa() { + Na = Pa = 0; } -function Ja(a) { +function Ka(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]; } - Ka ? Oa || (Oa = Date.now() - Na >= this.priority * this.priority * 3) : (Ka = setTimeout(Pa, 0), Na = Date.now()); - if (Oa) { + Na ? Pa || (Pa = Date.now() - Oa >= this.priority * this.priority * 3) : (Na = setTimeout(Qa, 0), Oa = Date.now()); + if (Pa) { var e = this; return new Promise(function(f) { setTimeout(function() { @@ -1200,8 +1200,8 @@ function Ja(a) { return c; }; } -;var Qa = 0; -function Ra(a) { +;var Ra = 0; +function Sa(a) { function b(f) { function h(k) { k = k.data || k; @@ -1209,16 +1209,16 @@ function Ra(a) { m && (m(k.msg), delete e.h[l]); } this.worker = f; - this.h = I(); + this.h = J(); if (this.worker) { d ? this.worker.on("message", h) : this.worker.onmessage = h; if (a.config) { return new Promise(function(k) { - e.h[++Qa] = function() { + e.h[++Ra] = function() { k(e); - 1e9 < Qa && (Qa = 0); + 1e9 < Ra && (Ra = 0); }; - e.worker.postMessage({id:Qa, task:"init", factory:c, options:a}); + e.worker.postMessage({id:Ra, task:"init", factory:c, options:a}); }); } this.worker.postMessage({task:"init", factory:c, options:a}); @@ -1227,27 +1227,27 @@ function Ra(a) { } } a = void 0 === a ? {} : a; - if (!this || this.constructor !== Ra) { - return new Ra(a); + if (!this || this.constructor !== Sa) { + return new Sa(a); } var c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; c && (c = c.toString()); - var d = "undefined" === typeof window, e = this, g = Sa(c, d, a.worker); + var d = "undefined" === typeof window, e = this, g = Ta(c, d, a.worker); return g.then ? g.then(function(f) { return b.call(e, f); }) : b.call(this, g); } -S("add"); -S("append"); -S("search"); -S("update"); -S("remove"); -S("clear"); -S("export"); -S("import"); -Ia(Ra.prototype); -function S(a) { - Ra.prototype[a] = function() { +P("add"); +P("append"); +P("search"); +P("update"); +P("remove"); +P("clear"); +P("export"); +P("import"); +Ja(Sa.prototype); +function P(a) { + Sa.prototype[a] = function() { var b = this, c = [].slice.call(arguments), d = c[c.length - 1]; if ("function" === typeof d) { var e = d; @@ -1255,69 +1255,69 @@ function S(a) { } d = new Promise(function(g) { "export" === a && "function" === typeof c[0] && (c[0] = null); - b.h[++Qa] = g; - b.worker.postMessage({task:a, id:Qa, args:c}); + b.h[++Ra] = g; + b.worker.postMessage({task:a, id:Ra, args:c}); }); return e ? (d.then(e), this) : d; }; } -function Sa(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=" + Ha.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function Ta(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=" + Ia.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function Ta(a, b) { +;function Ua(a, b) { b = void 0 === b ? 0 : b; var c = [], d = []; b && (b = 250000 / b * 5000 | 0); - a = y(a.entries()); + a = x(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 Ua(a, b) { +function Va(a, b) { b || (b = new Map()); for (var c = 0, d; c < a.length; c++) { d = a[c], b.set(d[0], d[1]); } return b; } -function Va(a, b) { +function Wa(a, b) { b = void 0 === b ? 0 : b; var c = [], d = []; b && (b = 250000 / b * 1000 | 0); - a = y(a.entries()); + a = x(a.entries()); for (var e = a.next(); !e.done; e = a.next()) { - e = e.value, d.push([e[0], Ta(e[1])[0]]), d.length === b && (c.push(d), d = []); + e = e.value, d.push([e[0], Ua(e[1])[0]]), d.length === b && (c.push(d), d = []); } d.length && c.push(d); return c; } -function Wa(a, b) { +function Xa(a, b) { b || (b = new Map()); for (var c = 0, d, e; c < a.length; c++) { - d = a[c], e = b.get(d[0]), b.set(d[0], Ua(d[1], e)); + d = a[c], e = b.get(d[0]), b.set(d[0], Va(d[1], e)); } return b; } -function Xa(a) { +function Ya(a) { var b = [], c = []; - a = y(a.keys()); + a = x(a.keys()); for (var d = a.next(); !d.done; d = a.next()) { c.push(d.value), 250000 === c.length && (b.push(c), c = []); } c.length && b.push(c); return b; } -function Ya(a, b) { +function Za(a, b) { b || (b = new Set()); for (var c = 0; c < a.length; c++) { b.add(a[c]); } return b; } -function Za(a, b, c, d, e, g, f) { +function $a(a, b, c, d, e, g, f) { f = void 0 === f ? 0 : f; var h = d && d.constructor === Array, k = h ? d.shift() : d; if (!k) { @@ -1326,14 +1326,14 @@ function Za(a, b, c, d, e, g, f) { if ((k = a((b ? b + "." : "") + (f + 1) + "." + c, JSON.stringify(k))) && k.then) { var l = this; return k.then(function() { - return Za.call(l, a, b, c, h ? d : null, e, g, f + 1); + return $a.call(l, a, b, c, h ? d : null, e, g, f + 1); }); } - return Za.call(this, a, b, c, h ? d : null, e, g, f + 1); + return $a.call(this, a, b, c, h ? d : null, e, g, f + 1); } -function $a(a, b) { +function ab(a, b) { var c = ""; - a = y(a.entries()); + a = x(a.entries()); for (var d = a.next(); !d.done; d = a.next()) { var e = d.value; d = e[0]; @@ -1351,7 +1351,7 @@ function $a(a, b) { } return c; } -;function ab(a, b, c, d) { +;function bb(a, b, c, d) { for (var e = [], g = 0, f; g < a.index.length; g++) { if (f = a.index[g], b >= f.length) { b -= f.length; @@ -1367,9 +1367,9 @@ function $a(a, b) { } return e; } -function T(a) { - if (!this || this.constructor !== T) { - return new T(a); +function S(a) { + if (!this || this.constructor !== S) { + return new S(a); } this.index = a ? [a] : []; this.length = a ? a.length : 0; @@ -1416,12 +1416,12 @@ function T(a) { } if ("slice" === d) { return function(e, g) { - return ab(b, e || 0, g || b.length, !1); + return bb(b, e || 0, g || b.length, !1); }; } if ("splice" === d) { return function(e, g) { - return ab(b, e || 0, g || b.length, !0); + return bb(b, e || 0, g || b.length, !0); }; } if ("constructor" === d) { @@ -1437,87 +1437,61 @@ function T(a) { return !0; }}); } -T.prototype.clear = function() { +S.prototype.clear = function() { this.index.length = 0; }; -T.prototype.destroy = function() { +S.prototype.destroy = function() { this.proxy = this.index = null; }; -T.prototype.push = function() { +S.prototype.push = function() { +}; +function T(a) { + a = void 0 === a ? 8 : a; + if (!this || this.constructor !== T) { + return new T(a); + } + this.index = J(); + this.h = []; + this.size = 0; + 32 < a ? (this.A = cb, this.B = BigInt(a)) : (this.A = db, this.B = a); +} +T.prototype.get = function(a) { + var b = this.A(a); + return (b = this.index[b]) && b.get(a); +}; +T.prototype.set = function(a, b) { + var c = this.A(a), d = this.index[c]; + d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.h.push(d), this.size++); }; function U(a) { a = void 0 === a ? 8 : a; if (!this || this.constructor !== U) { return new U(a); } - this.index = I(); + this.index = J(); this.h = []; this.size = 0; - 32 < a ? (this.A = bb, this.B = BigInt(a)) : (this.A = cb, this.B = a); + 32 < a ? (this.A = cb, this.B = BigInt(a)) : (this.A = db, this.B = a); } -U.prototype.get = function(a) { - var b = this.A(a); - return (b = this.index[b]) && b.get(a); -}; -U.prototype.set = function(a, b) { - var c = this.A(a), d = this.index[c]; - d ? (c = d.size, d.set(a, b), (c -= d.size) && this.size++) : (this.index[c] = d = new Map([[a, b]]), this.h.push(d), this.size++); -}; -function V(a) { - a = void 0 === a ? 8 : a; - if (!this || this.constructor !== V) { - return new V(a); - } - this.index = I(); - this.h = []; - this.size = 0; - 32 < a ? (this.A = bb, this.B = BigInt(a)) : (this.A = cb, this.B = a); -} -V.prototype.add = function(a) { +U.prototype.add = function(a) { var b = this.A(a), c = this.index[b]; c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c), this.size++); }; -u = U.prototype; -u.has = V.prototype.has = function(a) { +u = T.prototype; +u.has = U.prototype.has = function(a) { var b = this.A(a); return (b = this.index[b]) && b.has(a); }; -u.delete = V.prototype.delete = function(a) { +u.delete = U.prototype.delete = function(a) { var b = this.A(a); (b = this.index[b]) && b.delete(a) && this.size--; }; -u.clear = V.prototype.clear = function() { - this.index = I(); +u.clear = U.prototype.clear = function() { + this.index = J(); this.h = []; this.size = 0; }; -u.values = V.prototype.values = function db() { - var b, c = this, d, e, g; - return ra(db, function(f) { - switch(f.h) { - case 1: - b = 0; - case 2: - if (!(b < c.h.length)) { - f.h = 0; - break; - } - d = y(c.h[b].values()); - e = d.next(); - case 5: - if (e.done) { - b++; - f.h = 2; - break; - } - g = e.value; - return D(f, g, 6); - case 6: - e = d.next(), f.h = 5; - } - }); -}; -u.keys = V.prototype.keys = function eb() { +u.values = U.prototype.values = function eb() { var b, c = this, d, e, g; return ra(eb, function(f) { switch(f.h) { @@ -1528,7 +1502,7 @@ u.keys = V.prototype.keys = function eb() { f.h = 0; break; } - d = y(c.h[b].keys()); + d = x(c.h[b].values()); e = d.next(); case 5: if (e.done) { @@ -1537,13 +1511,13 @@ u.keys = V.prototype.keys = function eb() { break; } g = e.value; - return D(f, g, 6); + return E(f, g, 6); case 6: e = d.next(), f.h = 5; } }); }; -u.entries = V.prototype.entries = function fb() { +u.keys = U.prototype.keys = function fb() { var b, c = this, d, e, g; return ra(fb, function(f) { switch(f.h) { @@ -1554,7 +1528,7 @@ u.entries = V.prototype.entries = function fb() { f.h = 0; break; } - d = y(c.h[b].entries()); + d = x(c.h[b].keys()); e = d.next(); case 5: if (e.done) { @@ -1563,13 +1537,39 @@ u.entries = V.prototype.entries = function fb() { break; } g = e.value; - return D(f, g, 6); + return E(f, g, 6); case 6: e = d.next(), f.h = 5; } }); }; -function cb(a) { +u.entries = U.prototype.entries = function gb() { + var b, c = this, d, e, g; + return ra(gb, function(f) { + switch(f.h) { + case 1: + b = 0; + case 2: + if (!(b < c.h.length)) { + f.h = 0; + break; + } + d = x(c.h[b].entries()); + e = d.next(); + case 5: + if (e.done) { + b++; + f.h = 2; + break; + } + g = e.value; + return E(f, g, 6); + case 6: + e = d.next(), f.h = 5; + } + }); +}; +function db(a) { var b = Math.pow(2, this.B) - 1; if ("number" == typeof a) { return a & b; @@ -1579,11 +1579,11 @@ function cb(a) { } return 32 === this.B ? c + Math.pow(2, 31) : c; } -function bb() { +function cb() { throw Error("The keystore is limited to 32 for EcmaScript5"); } -;W.prototype.add = function(a, b, c) { - K(a) && (b = a, a = ya(b, this.key)); +;V.prototype.add = function(a, b, c) { + xa(a) && (b = a, a = za(b, this.key)); if (b && (a || 0 === a)) { if (!c && this.reg.has(a)) { return this.update(a, b); @@ -1596,7 +1596,7 @@ function bb() { } else { var f = e.R; if (!f || f(b)) { - e.constructor === String ? e = ["" + e] : J(e) && (e = [e]), gb(b, e, this.S, 0, g, a, e[0], c); + e.constructor === String ? e = ["" + e] : K(e) && (e = [e]), hb(b, e, this.S, 0, g, a, e[0], c); } } } @@ -1605,7 +1605,7 @@ function bb() { f = this.L[d]; var h = this.aa[d]; g = this.tag.get(h); - e = I(); + e = J(); if ("function" === typeof f) { if (f = f(b), !f) { continue; @@ -1616,10 +1616,10 @@ function bb() { continue; } f.constructor === String && (f = "" + f); - f = ya(b, f); + f = za(b, f); } if (g && f) { - for (J(f) && (f = [f]), h = 0, k = void 0; h < f.length; h++) { + for (K(f) && (f = [f]), h = 0, k = void 0; h < f.length; h++) { var l = f[h]; if (!e[l]) { e[l] = 1; @@ -1627,9 +1627,9 @@ function bb() { (m = g.get(l)) ? k = m : g.set(l, k = []); if (!c || !k.includes(a)) { if (k.length === Math.pow(2, 31) - 1) { - m = new T(k); + m = new S(k); if (this.fastupdate) { - for (var n = y(this.reg.values()), p = n.next(); !p.done; p = n.next()) { + for (var n = x(this.reg.values()), p = n.next(); !p.done; p = n.next()) { p = p.value, p.includes(k) && (p[p.indexOf(k)] = m); } } @@ -1647,7 +1647,7 @@ function bb() { } if (this.store && (!c || !this.store.has(a))) { if (this.I) { - var q = I(); + var q = J(); for (c = 0; c < this.I.length; c++) { if (d = this.I[c], g = d.R, !g || g(b)) { g = void 0; @@ -1657,11 +1657,11 @@ function bb() { continue; } d = [d.ja]; - } else if (J(d) || d.constructor === String) { + } else if (K(d) || d.constructor === String) { q[d] = b[d]; continue; } - hb(b, q, d, 0, d[0], g); + ib(b, q, d, 0, d[0], g); } } } @@ -1671,21 +1671,21 @@ function bb() { } return this; }; -function hb(a, b, c, d, e, g) { +function ib(a, b, c, d, e, g) { a = a[e]; if (d === c.length - 1) { b[e] = g || a; } else if (a) { if (a.constructor === Array) { for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) { - hb(a, b, c, d, e); + ib(a, b, c, d, e); } } else { - b = b[e] || (b[e] = I()), e = c[++d], hb(a, b, c, d, e); + b = b[e] || (b[e] = J()), e = c[++d], ib(a, b, c, d, e); } } } -function gb(a, b, c, d, e, g, f, h) { +function hb(a, b, c, d, e, g, f, h) { if (a = a[f]) { if (d === b.length - 1) { if (a.constructor === Array) { @@ -1701,30 +1701,30 @@ function gb(a, b, c, d, e, g, f, h) { } else { if (a.constructor === Array) { for (f = 0; f < a.length; f++) { - gb(a, b, c, d, e, g, f, h); + hb(a, b, c, d, e, g, f, h); } } else { - f = b[++d], gb(a, b, c, d, e, g, f, h); + f = b[++d], hb(a, b, c, d, e, g, f, h); } } } else { e.db && e.remove(g); } } -;function ib(a, b, c, d, e, g, f) { +;function jb(a, b, c, d, e, g, f) { var h = a.length, k = []; - var l = I(); + var l = J(); for (var m = 0, n = void 0, p, q; m < b; m++) { - for (var t = 0; t < h; t++) { - var w = a[t]; + for (var r = 0; r < h; r++) { + var w = a[r]; if (m < w.length && (n = w[m])) { - for (var r = 0; r < n.length; r++) { - p = n[r]; + for (var t = 0; t < n.length; t++) { + p = n[t]; (w = l[p]) ? l[p]++ : (w = 0, l[p] = 1); q = k[w] || (k[w] = []); if (!f) { - var z = m + (t || !e ? 0 : g || 0); - q = q[z] || (q[z] = []); + var A = m + (r || !e ? 0 : g || 0); + q = q[A] || (q[A] = []); } q.push(p); if (f && c && w === h - 1 && q.length - d === c) { @@ -1736,7 +1736,7 @@ function gb(a, b, c, d, e, g, f, h) { } if (a = k.length) { if (e) { - k = 1 < k.length ? jb(k, c, d, f, g) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; + k = 1 < k.length ? kb(k, c, d, f, g) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; } else { if (a < h) { return []; @@ -1769,8 +1769,8 @@ function gb(a, b, c, d, e, g, f, h) { } return k; } -function jb(a, b, c, d, e) { - var g = [], f = I(), h = a.length, k; +function kb(a, b, c, d, e) { + var g = [], f = J(), h = a.length, k; if (d) { for (e = h - 1; 0 <= e; e--) { if (k = (d = a[e]) && d.length) { @@ -1793,8 +1793,8 @@ function jb(a, b, c, d, e) { n = a[m]; for (var q = 0; q < n.length; q++) { if (k = (d = n[q]) && d.length) { - for (var t = 0; t < k; t++) { - if (l = d[t], !f[l]) { + for (var r = 0; r < k; r++) { + if (l = d[r], !f[l]) { if (f[l] = 1, c) { c--; } else { @@ -1812,8 +1812,8 @@ function jb(a, b, c, d, e) { } return g; } -function kb(a, b, c) { - for (var d = I(), e = [], g = 0, f; g < b.length; g++) { +function lb(a, b, c) { + for (var d = J(), e = [], g = 0, f; g < b.length; g++) { f = b[g]; for (var h = 0; h < f.length; h++) { d[f[h]] = 1; @@ -1832,12 +1832,12 @@ function kb(a, b, c) { } return e; } -;function lb(a, b, c, d) { +;function mb(a, b, c, d) { 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, d ? X.call(this, a) : a; + return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? W.call(this, a) : a; } for (var e = [], g = 0, f = void 0, h = void 0; g < a.length; g++) { if ((f = a[g]) && (h = f.length)) { @@ -1850,7 +1850,7 @@ function kb(a, b, c) { } h > b && (f = f.slice(0, b), h = b); if (!e.length && h >= b) { - return d ? X.call(this, f) : f; + return d ? W.call(this, f) : f; } e.push(f); b -= h; @@ -1860,9 +1860,9 @@ function kb(a, b, c) { } } e = 1 < e.length ? [].concat.apply([], e) : e[0]; - return d ? X.call(this, e) : e; + return d ? W.call(this, e) : e; } -;function mb(a, b, c) { +;function nb(a, b, c) { var d = c[0]; if (d.then) { return Promise.all(c).then(function(q) { @@ -1876,7 +1876,7 @@ function kb(a, b, c) { for (var e = [], g = 0, f = 0, h, k, l, m = 0, n = void 0; m < c.length; m++) { if (n = c[m]) { var p = void 0; - if (n.constructor === Y) { + if (n.constructor === X) { p = n.result; } else if (n.constructor === Array) { p = n; @@ -1907,11 +1907,11 @@ function kb(a, b, c) { } return {W:d, $:e, limit:g, offset:f, enrich:h, resolve:k, suggest:l}; } -;Y.prototype.or = function() { - var a = mb(this, "or", arguments); - return nb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve); +;X.prototype.or = function() { + var a = nb(this, "or", arguments); + return ob.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve); }; -function nb(a, b, c, d, e, g) { +function ob(a, b, c, d, e, g) { if (b.length) { var f = this; return Promise.all(b).then(function(h) { @@ -1919,13 +1919,13 @@ function nb(a, b, c, d, e, g) { for (var k = 0, l = void 0; k < h.length; k++) { (l = h[k]).length && (a[k] = l); } - return nb.call(f, a, [], c, d, e, g); + return ob.call(f, a, [], c, d, e, g); }); } - 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)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = kb(a, c, d, !1, this.h), d = 0)); return g ? this.resolve(c, d, e) : this; } -;Y.prototype.and = function() { +;X.prototype.and = function() { var a = this.result.length; if (!a) { var b = arguments[0]; @@ -1937,36 +1937,7 @@ function nb(a, b, c, d, e, g) { 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; l < k.length; l++) { - (m = k[l]).length && (a[l] = m); - } - return ob.call(h, a, [], c, d, e, g, f); - }); - } - if (a.length) { - if (this.result.length && a.unshift(this.result), 2 > a.length) { - this.result = a[0]; - } else { - if (b = za(a)) { - return this.result = ib(a, b, c, d, f, this.h, g), g ? e ? X.call(this.index, this.result) : this.result : this; - } - this.result = []; - } - } else { - f || (this.result = a); - } - return g ? this.resolve(c, d, e) : this; -} -;Y.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); + return a ? (a = nb(this, "and", arguments), pb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest)) : c ? this.resolve(d, e, g) : this; }; function pb(a, b, c, d, e, g, f) { if (b.length) { @@ -1983,15 +1954,44 @@ function pb(a, b, c, d, e, g, f) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - return this.result = qb.call(this, a, c, d, g, this.h), g ? e ? X.call(this.index, this.result) : this.result : this; + if (b = Aa(a)) { + return this.result = jb(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; } -function qb(a, b, c, d, e) { - for (var g = [], f = I(), h = 0, k = 0, l; k < a.length; k++) { +;X.prototype.xor = function() { + var a = nb(this, "xor", arguments); + return qb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); +}; +function qb(a, b, c, d, e, g, f) { + if (b.length) { + var h = this; + return Promise.all(b).then(function(k) { + a = []; + for (var l = 0, m = void 0; l < k.length; l++) { + (m = k[l]).length && (a[l] = m); + } + return qb.call(h, a, [], c, 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 = rb.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 rb(a, b, c, d, e) { + for (var g = [], f = J(), h = 0, k = 0, l; k < a.length; k++) { if (l = a[k]) { h < l.length && (h = l.length); for (var m = 0, n; m < l.length; m++) { @@ -2017,9 +2017,9 @@ function qb(a, b, c, d, e) { return g; } } else { - var t = k + (m ? e : 0); - g[t] || (g[t] = []); - g[t].push(q); + var r = k + (m ? e : 0); + g[r] || (g[r] = []); + g[r].push(q); if (++l === b) { return g; } @@ -2033,11 +2033,11 @@ function qb(a, b, c, d, e) { } return g; } -;Y.prototype.not = function() { - var a = mb(this, "not", arguments); - return rb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); +;X.prototype.not = function() { + var a = nb(this, "not", arguments); + return sb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); }; -function rb(a, b, c, d, e, g, f) { +function sb(a, b, c, d, e, g, f) { if (b.length) { var h = this; return Promise.all(b).then(function(k) { @@ -2045,17 +2045,17 @@ function rb(a, b, c, d, e, g, f) { for (var l = 0, m = void 0; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return rb.call(h, a, [], c, d, e, g, f); + return sb.call(h, a, [], c, d, e, g, f); }); } if (a.length && this.result.length) { - this.result = sb.call(this, a, c, d, g); + this.result = tb.call(this, a, c, d, g); } else if (g) { return this.resolve(c, d, e); } - return g ? e ? X.call(this.index, this.result) : this.result : this; + return g ? e ? W.call(this.index, this.result) : this.result : this; } -function sb(a, b, c, d) { +function tb(a, b, c, d) { var e = []; a = new Set(a.flat().flat()); for (var g = 0, f, h = 0; g < this.result.length; g++) { @@ -2081,9 +2081,9 @@ function sb(a, b, c, d) { } return e; } -;function Y(a) { - if (!this || this.constructor !== Y) { - return new Y(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; @@ -2092,7 +2092,7 @@ function sb(a, b, c, d) { this.result = a || []; this.h = 0; } -Y.prototype.limit = function(a) { +X.prototype.limit = function(a) { if (this.result.length) { for (var b = [], c = 0, d; c < this.result.length; c++) { if (d = this.result[c]) { @@ -2110,7 +2110,7 @@ Y.prototype.limit = function(a) { } return this; }; -Y.prototype.offset = function(a) { +X.prototype.offset = function(a) { if (this.result.length) { for (var b = [], c = 0, d; c < this.result.length; c++) { if (d = this.result[c]) { @@ -2121,18 +2121,18 @@ Y.prototype.offset = function(a) { } return this; }; -Y.prototype.boost = function(a) { +X.prototype.boost = function(a) { this.h += a; return this; }; -Y.prototype.resolve = function(a, b, c) { +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), lb.call(e, d, a || 100, b, c)) : d; + return d.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), mb.call(e, d, a || 100, b, c)) : d; }; -I(); -W.prototype.search = function(a, b, c, d) { - c || (!b && K(a) ? (c = a, a = "") : K(b) && (c = b, b = 0)); +J(); +V.prototype.search = function(a, b, c, d) { + c || (!b && xa(a) ? (c = a, a = "") : xa(b) && (c = b, b = 0)); var e = [], g = [], f, h = 0, k = !0; if (c) { c.constructor === Array && (c = {index:c}); @@ -2145,67 +2145,67 @@ W.prototype.search = function(a, b, c, d) { k = !1 !== c.resolve; if (!k && !l) { if (n = n || this.field) { - J(n) ? l = n : (n.constructor === Array && 1 === n.length && (n = n[0]), l = n.field || n.index); + K(n) ? l = n : (n.constructor === Array && 1 === n.length && (n = n[0]), l = n.field || n.index); } if (!l) { throw Error("Apply resolver on document search requires either the option 'pluck' to be set or just select a single field name in your query."); } } this.store && c.enrich && !k && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - var t = (f = this.store && c.enrich && k) && c.highlight; + var r = (f = this.store && c.enrich && k) && c.highlight; b = c.limit || b; var w = c.offset || 0; b || (b = 100); if (p && (!this.db || !d)) { p.constructor !== Array && (p = [p]); - for (var r = [], z = 0, A = void 0; z < p.length; z++) { - A = p[z]; - if (J(A)) { + for (var t = [], A = 0, z = void 0; A < p.length; A++) { + z = p[A]; + if (K(z)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } - if (A.field && A.tag) { - var v = A.tag; + if (z.field && z.tag) { + var v = z.tag; if (v.constructor === Array) { - for (var x = 0; x < v.length; x++) { - r.push(A.field, v[x]); + for (var y = 0; y < v.length; y++) { + t.push(z.field, v[y]); } } else { - r.push(A.field, v); + t.push(z.field, v); } } else { - v = Object.keys(A); - x = 0; - for (var E = void 0, N = void 0; x < v.length; x++) { - if (E = v[x], N = A[E], N.constructor === Array) { - for (var H = 0; H < N.length; H++) { - r.push(E, N[H]); + v = Object.keys(z); + y = 0; + for (var D = void 0, H = void 0; y < v.length; y++) { + if (D = v[y], H = z[D], H.constructor === Array) { + for (var I = 0; I < H.length; I++) { + t.push(D, H[I]); } } else { - r.push(E, N); + t.push(D, H); } } } } - if (!r.length) { + if (!t.length) { throw Error("Your tag definition within the search options is probably wrong. No valid tags found."); } - p = r; + p = t; if (!a) { k = []; - if (r.length) { - for (g = 0; g < r.length; g += 2) { + if (t.length) { + for (g = 0; g < t.length; g += 2) { l = void 0; if (this.db) { - l = this.index.get(r[g]); + l = this.index.get(t[g]); if (!l) { - console.warn("Tag '" + r[g] + ":" + r[g + 1] + "' will be skipped because there is no field '" + r[g] + "'."); + console.warn("Tag '" + t[g] + ":" + t[g + 1] + "' will be skipped because there is no field '" + t[g] + "'."); continue; } - k.push(l = l.db.tag(r[g + 1], b, w, f)); + k.push(l = l.db.tag(t[g + 1], b, w, f)); } else { - l = tb.call(this, r[g], r[g + 1], b, w, f); + l = ub.call(this, t[g], t[g + 1], b, w, f); } - e.push({field:r[g], tag:r[g + 1], result:l}); + e.push({field:t[g], tag:t[g + 1], result:l}); } } return k.length ? Promise.all(k).then(function(Q) { @@ -2219,83 +2219,83 @@ W.prototype.search = function(a, b, c, d) { n && n.constructor !== Array && (n = [n]); } n || (n = this.field); - r = !d && (this.worker || this.db) && []; - z = 0; - for (x = A = v = void 0; z < n.length; z++) { - if (A = n[z], !this.db || !this.tag || this.J[z]) { + t = !d && (this.worker || this.db) && []; + A = 0; + for (y = z = v = void 0; A < n.length; A++) { + if (z = n[A], !this.db || !this.tag || this.J[A]) { v = void 0; - J(A) || (v = A, A = v.field, a = v.query || a, b = v.limit || b, w = v.offset || w, q = v.suggest || q, f = this.store && (v.enrich || f)); + K(z) || (v = z, z = v.field, a = v.query || a, b = v.limit || b, w = v.offset || w, q = v.suggest || q, f = this.store && (v.enrich || f)); if (d) { - v = d[z]; + v = d[A]; } else { - x = v || c; - v = this.index.get(A); + y = v || c; + v = this.index.get(z); if (p) { if (this.db) { - x.tag = p; + y.tag = p; var La = v.db.support_tag_search; - x.field = n; + y.field = n; } - La || (x.enrich = !1); + La || (y.enrich = !1); } - if (r) { - r[z] = v.search(a, b, x); - x && f && (x.enrich = f); + if (t) { + t[A] = v.search(a, b, y); + y && f && (y.enrich = f); continue; } else { - v = v.search(a, b, x), x && f && (x.enrich = f); + v = v.search(a, b, y), y && f && (y.enrich = f); } } - x = v && (k ? v.length : v.result.length); - if (p && x) { - E = []; - N = 0; + y = v && (k ? v.length : v.result.length); + if (p && y) { + D = []; + H = 0; if (this.db && d) { if (!La) { - for (H = n.length; H < d.length; H++) { - var L = d[H]; - if (L && L.length) { - N++, E.push(L); + for (I = n.length; I < d.length; I++) { + var M = d[I]; + if (M && M.length) { + H++, D.push(M); } else if (!q) { - return k ? e : new Y(e); + return k ? e : new X(e); } } } } else { - H = 0; - for (var Xb = L = void 0; H < p.length; H += 2) { - L = this.tag.get(p[H]); - if (!L) { - if (console.warn("Tag '" + p[H] + ":" + p[H + 1] + "' will be skipped because there is no field '" + p[H] + "'."), q) { + I = 0; + for (var Xb = M = void 0; I < p.length; I += 2) { + M = this.tag.get(p[I]); + if (!M) { + if (console.warn("Tag '" + p[I] + ":" + p[I + 1] + "' will be skipped because there is no field '" + p[I] + "'."), q) { continue; } else { - return k ? e : new Y(e); + return k ? e : new X(e); } } - if (Xb = (L = L && L.get(p[H + 1])) && L.length) { - N++, E.push(L); + if (Xb = (M = M && M.get(p[I + 1])) && M.length) { + H++, D.push(M); } else if (!q) { - return k ? e : new Y(e); + return k ? e : new X(e); } } } - if (N) { - v = kb(v, E, k); - x = v.length; - if (!x && !q) { - return k ? v : new Y(v); + if (H) { + v = lb(v, D, k); + y = v.length; + if (!y && !q) { + return k ? v : new X(v); } - N--; + H--; } } - if (x) { - g[h] = A, e.push(v), h++; + if (y) { + g[h] = z, e.push(v), h++; } else if (1 === n.length) { - return k ? e : new Y(e); + return k ? e : new X(e); } } } - if (r) { + if (t) { if (this.db && p && p.length && !La) { for (f = 0; f < p.length; f += 2) { g = this.index.get(p[f]); @@ -2303,101 +2303,95 @@ W.prototype.search = function(a, b, c, d) { if (console.warn("Tag '" + p[f] + ":" + p[f + 1] + "' was not found because there is no field '" + p[f] + "'."), q) { continue; } else { - return k ? e : new Y(e); + return k ? e : new X(e); } } - r.push(g.db.tag(p[f + 1], b, w, !1)); + t.push(g.db.tag(p[f + 1], b, w, !1)); } } var Yb = this; - return Promise.all(r).then(function(Q) { + return Promise.all(t).then(function(Q) { return Q.length ? Yb.search(a, b, c, Q) : Q; }); } if (!h) { - return k ? e : new Y(e); + return k ? e : new X(e); } if (l && (!f || !this.store)) { return e[0]; } - r = []; + t = []; for (w = 0; w < g.length; w++) { q = e[w]; - f && q.length && "undefined" === typeof q[0].doc && (this.db ? r.push(q = this.index.get(this.field[0]).db.enrich(q)) : q = X.call(this, q)); + f && q.length && "undefined" === typeof q[0].doc && (this.db ? t.push(q = this.index.get(this.field[0]).db.enrich(q)) : q = W.call(this, q)); if (l) { - return k ? q : new Y(q); + return k ? q : new X(q); } e[w] = {field:g[w], result:q}; } - if (f && this.db && r.length) { + if (f && this.db && t.length) { var Ma = this; - return Promise.all(r).then(function(Q) { + return Promise.all(t).then(function(Q) { for (var R = 0; R < Q.length; R++) { e[R].result = Q[R]; } - return m ? ub(e, b) : t ? vb(e, a, Ma.index, Ma.field, Ma.J, t) : e; + return m ? vb(e) : r ? wb(e, a, Ma.index, Ma.field, Ma.J, r) : e; }); } - return m ? ub(e, b) : t ? vb(e, a, this.index, this.field, this.J, t) : e; + return m ? vb(e) : r ? wb(e, a, this.index, this.field, this.J, r) : e; }; -function vb(a, b, c, d, e, g) { +function wb(a, b, c, d, e, g) { for (var f, h, k, l = 0, m, n; l < a.length; l++) { - var p = a[l].result; - m = a[l].field; - k = c.get(m); - n = k.encoder; - k = k.tokenize; - m = e[d.indexOf(m)]; - n !== f && (f = n, h = f.encode(b)); - for (n = 0; n < p.length; n++) { - for (var q = "", t = ya(p[n].doc, m).split(/\s+/), w = 0, r, z; w < t.length; w++) { - r = t[w]; - z = f.encode(r).join(" "); - var A = void 0; - if (z && r) { - for (var v = 0, x; v < h.length; v++) { - if (x = h[v], "strict" === k) { - if (z === x) { - q += (q ? " " : "") + g.replace("$1", r); - A = !0; - break; - } - } else { - var E = z.indexOf(x); - if (-1 < E) { - q += (q ? " " : "") + r.substring(0, E) + g.replace("$1", r.substring(E, x.length)) + r.substring(E + x.length); - A = !0; - break; + if (m = a[l].field) { + var p = a[l].result; + k = c.get(m); + n = k.encoder; + k = k.tokenize; + m = e[d.indexOf(m)]; + n !== f && (f = n, h = f.encode(b)); + for (var q = 0; q < p.length; q++) { + for (var r = "", w = za(p[q].doc, m).split(/\s+/), t = 0, A, z; t < w.length; t++) { + A = w[t]; + z = n.encode(A); + z = 1 < z.length ? z.join(" ") : z[0]; + var v = void 0; + if (z && A) { + for (var y = 0, D; y < h.length; y++) { + if (D = h[y], "strict" === k) { + if (z === D) { + r += (r ? " " : "") + g.replace("$1", A); + v = !0; + break; + } + } else { + var H = z.indexOf(D); + if (-1 < H) { + r += (r ? " " : "") + A.substring(0, H) + g.replace("$1", A.substring(H, D.length)) + A.substring(H + D.length); + v = !0; + break; + } } } } + v || (r += (r ? " " : "") + w[t]); } - A || (q += (q ? " " : "") + t[w]); + p[q].highlight = r; } - p[n].highlight = q; } } return a; } -function ub(a, b) { - for (var c = [], d = I(), e = 0, g, f; e < a.length; e++) { - g = a[e]; - f = g.result; - for (var h = 0, k, l, m; h < f.length; h++) { - if (l = f[h], "object" !== typeof l && (l = {id:l}), k = l.id, m = d[k]) { - m.push(g.field); - } else { - if (c.length === b) { - return c; - } - l.field = d[k] = [g.field]; - c.push(l); - } +function vb(a) { + for (var b = [], c = J(), d = 0, e, g; d < a.length; d++) { + e = a[d]; + g = e.result; + for (var f = 0, h, k, l; f < g.length; f++) { + k = g[f], "object" !== typeof k && (k = {id:k}), h = k.id, (l = c[h]) ? l.push(e.field) : (k.field = c[h] = [e.field], b.push(k)); } } - return c; + return b; } -function tb(a, b, c, d, e) { +function ub(a, b, c, d, e) { var g = this.tag.get(a); if (!g) { return console.warn("Tag '" + a + "' was not found"), []; @@ -2406,11 +2400,11 @@ function tb(a, b, c, d, e) { if (a > c || d) { g = g.slice(d, d + c); } - e && (g = X.call(this, g)); + e && (g = W.call(this, g)); return g; } } -function X(a) { +function W(a) { if (!this || !this.store) { return a; } @@ -2419,21 +2413,21 @@ function X(a) { } return b; } -;function W(a) { - if (!this || this.constructor !== W) { - return new W(a); +;function V(a) { + if (!this || this.constructor !== V) { + return new V(a); } var b = a.document || a.doc || a, c, d; this.J = []; this.field = []; this.S = []; - this.key = (c = b.key || b.id) && wb(c, this.S) || "id"; + this.key = (c = b.key || b.id) && xb(c, this.S) || "id"; (d = a.keystore || 0) && (this.keystore = d); this.fastupdate = !!a.fastupdate; - this.reg = !this.fastupdate || a.worker || a.db ? d ? new V(d) : new Set() : d ? new U(d) : new Map(); + this.reg = !this.fastupdate || a.worker || a.db ? d ? new U(d) : new Set() : d ? new T(d) : new Map(); this.I = (c = b.store || null) && c && !0 !== c && []; - this.store = c && (d ? new U(d) : new Map()); - this.cache = (c = a.cache || null) && new xb(c); + this.store = c && (d ? new T(d) : new Map()); + this.cache = (c = a.cache || null) && new Y(c); a.cache = !1; this.worker = a.worker; this.priority = a.priority || 4; @@ -2451,7 +2445,7 @@ function X(a) { if (!e) { throw Error("The tag field from the document descriptor is undefined."); } - 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)); + d.custom ? this.L[b] = d.custom : (this.L[b] = xb(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()); } @@ -2460,14 +2454,14 @@ function X(a) { if (this.worker) { this.fastupdate = !1; a = []; - c = y(this.index.values()); + c = x(this.index.values()); for (b = c.next(); !b.done; b = c.next()) { b = b.value, b.then && a.push(b); } if (a.length) { var g = this; return Promise.all(a).then(function(f) { - for (var h = 0, k = y(g.index.entries()), l = k.next(); !l.done; l = k.next()) { + for (var h = 0, k = x(g.index.entries()), l = k.next(); !l.done; l = k.next()) { l = l.value; var m = l[0]; l[1].then && g.index.set(m, f[h++]); @@ -2479,7 +2473,7 @@ function X(a) { a.db && (this.fastupdate = !1, this.mount(a.db)); } } -u = W.prototype; +u = V.prototype; u.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); @@ -2489,7 +2483,7 @@ u.mount = function(a) { for (var c = 0, d; c < this.aa.length; c++) { d = this.aa[c]; var e; - this.index.set(d, e = new P({}, this.reg)); + this.index.set(d, e = new O({}, this.reg)); b === this.field && (b = b.slice(0)); b.push(d); e.tag = this.tag.get(d); @@ -2515,45 +2509,45 @@ u.commit = function(a, b) { return ta(function(h) { if (1 == h.h) { d = []; - e = y(c.index.values()); + e = x(c.index.values()); for (g = e.next(); !g.done; g = e.next()) { f = g.value, d.push(f.commit(a, b)); } - return D(h, Promise.all(d), 2); + return E(h, Promise.all(d), 2); } c.reg.clear(); h.h = 0; }); }; u.destroy = function() { - for (var a = [], b = y(this.index.values()), c = b.next(); !c.done; c = b.next()) { + for (var a = [], b = x(this.index.values()), c = b.next(); !c.done; c = b.next()) { a.push(c.value.destroy()); } return Promise.all(a); }; function yb(a, b) { var c = new Map(), d = b.index || b.field || b; - J(d) && (d = [d]); + K(d) && (d = [d]); for (var e = 0, g, f = void 0; e < d.length; e++) { g = d[e]; - J(g) || (f = g, g = g.field); - f = K(f) ? Object.assign({}, a, f) : a; + K(g) || (f = g, g = g.field); + f = xa(f) ? Object.assign({}, a, f) : a; if (this.worker) { - var h = new Ra(f); + var h = new Sa(f); c.set(g, h); } - this.worker || c.set(g, new P(f, this.reg)); - f.custom ? this.J[e] = f.custom : (this.J[e] = wb(g, this.S), f.filter && ("string" === typeof this.J[e] && (this.J[e] = new String(this.J[e])), this.J[e].R = f.filter)); + this.worker || c.set(g, new O(f, this.reg)); + f.custom ? this.J[e] = f.custom : (this.J[e] = xb(g, this.S), f.filter && ("string" === typeof this.J[e] && (this.J[e] = new String(this.J[e])), this.J[e].R = f.filter)); this.field[e] = g; } if (this.I) { - for (a = b.store, J(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] = 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)); + 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] = xb(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 wb(a, b) { +function xb(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); } @@ -2567,15 +2561,15 @@ u.update = function(a, b) { return this.remove(a).add(a, b); }; u.remove = function(a) { - K(a) && (a = ya(a, this.key)); - for (var b = y(this.index.values()), c = b.next(); !c.done; c = b.next()) { + xa(a) && (a = za(a, this.key)); + for (var b = x(this.index.values()), c = b.next(); !c.done; c = b.next()) { c.value.remove(a, !0); } if (this.reg.has(a)) { if (this.tag && !this.fastupdate) { - for (b = y(this.tag.values()), c = b.next(); !c.done; c = b.next()) { + for (b = x(this.tag.values()), c = b.next(); !c.done; c = b.next()) { c = c.value; - for (var d = y(c), e = d.next(); !e.done; e = d.next()) { + for (var d = x(c), e = d.next(); !e.done; e = d.next()) { var g = e.value; e = g[0]; g = g[1]; @@ -2591,11 +2585,11 @@ u.remove = function(a) { return this; }; u.clear = function() { - for (var a = [], b = y(this.index.values()), c = b.next(); !c.done; c = b.next()) { + for (var a = [], b = x(this.index.values()), c = b.next(); !c.done; c = b.next()) { c = c.value.clear(), c.then && a.push(c); } if (this.tag) { - for (b = y(this.tag.values()), c = b.next(); !c.done; c = b.next()) { + for (b = x(this.tag.values()), c = b.next(); !c.done; c = b.next()) { c.value.clear(); } } @@ -2607,7 +2601,7 @@ u.contain = function(a) { return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a); }; u.cleanup = function() { - for (var a = y(this.index.values()), b = a.next(); !b.done; b = a.next()) { + for (var a = x(this.index.values()), b = a.next(); !b.done; b = a.next()) { b.value.cleanup(); } return this; @@ -2618,7 +2612,7 @@ u.get = function(a) { }) : this.store.get(a) || null; }; u.set = function(a, b) { - "object" === typeof a && (b = a, a = ya(b, this.key)); + "object" === typeof a && (b = a, a = za(b, this.key)); this.store.set(a, b); return this; }; @@ -2639,23 +2633,23 @@ u.export = function(a, b, c, d) { switch(d) { case 0: var f = "reg"; - var h = Xa(this.reg); + var h = Ya(this.reg); b = null; break; case 1: f = "tag"; - h = this.tag && Va(this.tag, this.reg.size); + h = this.tag && Wa(this.tag, this.reg.size); b = null; break; case 2: f = "doc"; - h = this.store && Ta(this.store); + h = this.store && Ua(this.store); b = null; break; default: return; } - return Za.call(this, a, b, f, h, c, d); + return $a.call(this, a, b, f, h, c, d); }; u.import = function(a, b) { var c = a.split("."); @@ -2673,13 +2667,13 @@ u.import = function(a, b) { switch(c) { case "reg": this.fastupdate = !1; - this.reg = Ya(b, this.reg); + this.reg = Za(b, this.reg); for (b = 0; b < this.field.length; b++) { d = this.index.get(this.field[b]), d.fastupdate = !1, d.reg = this.reg; } if (this.worker) { b = []; - d = y(this.index.values()); + d = x(this.index.values()); for (c = d.next(); !c.done; c = d.next()) { b.push(c.value.import(a)); } @@ -2687,17 +2681,17 @@ u.import = function(a, b) { } break; case "tag": - this.tag = Wa(b, this.tag); + this.tag = Xa(b, this.tag); break; case "doc": - this.store = Ua(b, this.store); + this.store = Va(b, this.store); } } }; -Ia(W.prototype); +Ja(V.prototype); function zb(a, b, c) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new xb()); + this.cache || (this.cache = new Y()); var d = this.cache.get(a); if (!d) { d = this.search(a, b, c); @@ -2712,44 +2706,44 @@ function zb(a, b, c) { } return d; } -function xb(a) { +function Y(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -xb.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); }; -xb.prototype.get = function(a) { +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; }; -xb.prototype.remove = function(a) { - for (var b = y(this.cache), c = b.next(); !c.done; c = b.next()) { +Y.prototype.remove = function(a) { + for (var b = x(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); } }; -xb.prototype.clear = function() { +Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -var Ab = {normalize:!1, numeric:!1}; +var Ab = {normalize:!1, numeric:!1, dedupe:!1}; var Bb = {}; var Cb = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); var Db = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Eb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; var Fb = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -var Gb = {na:Ab, ma:Bb, oa:Bb, LatinBalance:{dedupe:!0, mapper:Cb}, LatinAdvanced:{dedupe:!0, mapper:Cb, matcher:Db, replacer:Eb}, LatinExtra:{dedupe:!0, mapper:Cb, replacer:Eb.concat([/(?!^)[aeo]/g, ""]), matcher:Db}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { +var Gb = {Exact:Ab, Default:Bb, Normalize:Bb, LatinBalance:{mapper:Cb}, LatinAdvanced:{mapper:Cb, matcher:Db, replacer:Eb}, LatinExtra:{mapper:Cb, replacer:Eb.concat([/(?!^)[aeo]/g, ""]), matcher:Db}, LatinSoundex:{dedupe:!1, include:{letter:!0}, finalize:function(a) { for (var b = 0; b < a.length; b++) { for (var c = a[b], d = c.charAt(0), e = Fb[d], g = 1, f; g < c.length && (f = c.charAt(g), "h" === f || "w" === f || !(f = Fb[f]) || f === e || (d += f, e = f, 4 !== d.length)); g++) { } a[b] = d; } }}, LatinExact:Ab, LatinDefault:Bb, LatinSimple:Bb}; -P.prototype.remove = function(a, b) { +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) { @@ -2790,21 +2784,21 @@ function Hb(a, b) { } } } else { - for (d = y(a.entries()), e = d.next(); !e.done; e = d.next()) { + for (d = x(a.entries()), e = d.next(); !e.done; e = d.next()) { g = e.value, e = g[0], (g = Hb(g[1], b)) ? c += g : a.delete(e); } } return c; } ;var Jb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -P.prototype.add = function(a, b, c, d) { +O.prototype.add = function(a, b, c, d) { if (b && (a || 0 === a)) { if (!d && !c && this.reg.has(a)) { return this.update(a, b); } b = this.encoder.encode(b); if (d = b.length) { - for (var e = I(), g = I(), f = this.depth, h = this.resolution, k = 0; k < d; k++) { + for (var e = J(), g = J(), f = this.depth, h = this.resolution, k = 0; k < d; k++) { var l = b[this.rtl ? d - 1 - k : k], m = l.length; if (m && (f || !g[l])) { var n = this.score ? this.score(b, l, k, null, 0) : Kb(h, d, k), p = ""; @@ -2813,8 +2807,8 @@ P.prototype.add = function(a, b, c, d) { if (2 < m) { n = 0; for (var q; n < m; n++) { - for (var t = m; t > n; t--) { - p = l.substring(n, t), q = this.rtl ? m - 1 - n : n, q = this.score ? this.score(b, l, k, p, q) : Kb(h, d, k, m, q), Lb(this, g, p, q, a, c); + for (var r = m; r > n; r--) { + p = l.substring(n, r), q = this.rtl ? m - 1 - n : n, q = this.score ? this.score(b, l, k, p, q) : Kb(h, d, k, m, q), Lb(this, g, p, q, a, c); } } break; @@ -2822,25 +2816,25 @@ P.prototype.add = function(a, b, c, d) { case "bidirectional": case "reverse": if (1 < m) { - for (t = m - 1; 0 < t; t--) { - p = l[this.rtl ? m - 1 - t : t] + p, q = this.score ? this.score(b, l, k, p, t) : Kb(h, d, k, m, t), Lb(this, g, p, q, a, c); + for (r = m - 1; 0 < r; r--) { + p = l[this.rtl ? m - 1 - r : r] + p, q = this.score ? this.score(b, l, k, p, r) : Kb(h, d, k, m, r), Lb(this, g, p, q, a, c); } p = ""; } case "forward": if (1 < m) { - for (t = 0; t < m; t++) { - p += l[this.rtl ? m - 1 - t : t], Lb(this, g, p, n, a, c); + for (r = 0; r < m; r++) { + p += l[this.rtl ? m - 1 - r : r], Lb(this, g, p, n, a, c); } break; } default: if (Lb(this, g, l, n, a, c), f && 1 < d && k < d - 1) { - for (m = I(), p = this.da, n = l, t = Math.min(f + 1, this.rtl ? k + 1 : d - k), q = m[n] = 1; q < t; q++) { + for (m = J(), p = this.da, n = l, r = Math.min(f + 1, this.rtl ? k + 1 : d - k), q = m[n] = 1; q < r; q++) { if ((l = b[this.rtl ? d - 1 - k - q : k + q]) && !m[l]) { m[l] = 1; - var w = this.score ? this.score(b, n, k, l, q - 1) : Kb(p + (d / 2 > p ? 0 : 1), d, k, t - 1, q - 1), r = this.bidirectional && l > n; - Lb(this, e, r ? n : l, w, a, c, r ? l : n); + var w = this.score ? this.score(b, n, k, l, q - 1) : Kb(p + (d / 2 > p ? 0 : 1), d, k, r - 1, q - 1), t = this.bidirectional && l > n; + Lb(this, e, t ? n : l, w, a, c, t ? l : n); } } } @@ -2858,11 +2852,11 @@ P.prototype.add = function(a, b, c, d) { function Lb(a, b, c, d, e, g, f) { var h = f ? a.ctx : a.map, k; if (!b[c] || f && !(k = b[c])[f]) { - if (f ? (b = k || (b[c] = I()), b[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : b[c] = 1, (k = h.get(c)) ? h = k : h.set(c, h = k = []), h = h[d] || (h[d] = []), !g || !h.includes(e)) { + if (f ? (b = k || (b[c] = J()), 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 T(h); + b = new S(h); if (a.fastupdate) { - for (c = y(a.reg.values()), g = c.next(); !g.done; g = c.next()) { + for (c = x(a.reg.values()), g = c.next(); !g.done; g = c.next()) { g = g.value, g.includes(h) && (g[g.indexOf(h)] = b); } } @@ -2876,8 +2870,8 @@ function Lb(a, b, c, d, e, g, f) { function Kb(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; } -;P.prototype.search = function(a, b, c) { - c || (!b && K(a) ? (c = a, a = "") : K(b) && (c = b, b = 0)); +;O.prototype.search = function(a, b, c) { + c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = "")); var d = [], e = 0, g; if (c) { a = c.query || a; @@ -2902,82 +2896,82 @@ function Kb(a, b, c, d, e) { if (2 === q && f && !h) { return Mb.call(this, p[1], p[0], b, e, g, k, n); } - var t = I(), w = 0; - if (1 < q && f) { - var r = p[0]; + var r = J(), w = 0; + if (f) { + var t = p[0]; w = 1; } - m || 0 === m || (m = r ? this.da : this.resolution); + m || 0 === m || (m = t ? this.da : this.resolution); if (this.db) { if (this.db.search && (a = this.db.search(this, p, b, e, h, g, k, n), !1 !== a)) { return a; } - var z = this; + var A = this; return function() { - var A, v; - return ta(function(x) { - switch(x.h) { + var z, v; + return ta(function(y) { + switch(y.h) { case 1: - v = A = void 0; + v = z = void 0; case 2: if (!(w < q)) { - x.h = 4; + y.h = 4; break; } v = p[w]; - if (!v || t[v]) { - x.h = 5; + if (!v || r[v]) { + y.h = 5; break; } - t[v] = 1; - return D(x, Nb(z, v, r, 0, 0, !1, !1), 6); + r[v] = 1; + return E(y, Nb(A, v, t, 0, 0, !1, !1), 6); case 6: - A = x.D; - if (A = Ob(A, d, h, m)) { - d = A; - x.h = 4; + z = y.D; + if (z = Ob(z, d, h, m)) { + d = z; + y.h = 4; break; } - r && (h && A && d.length || (r = v)); + t && (h && z && d.length || (t = v)); case 5: - h && r && w === q - 1 && !d.length && (m = z.resolution, r = "", w = -1, t = I()); + h && t && w === q - 1 && !d.length && (m = A.resolution, t = "", w = -1, r = J()); w++; - x.h = 2; + y.h = 2; break; case 4: - return x.return(Pb(d, m, b, e, h, l, g)); + return y.return(Pb(d, m, b, e, h, l, g)); } }); }(); } for (c = a = void 0; w < q; w++) { - if ((c = p[w]) && !t[c]) { - t[c] = 1; - a = Nb(this, c, r, 0, 0, !1, !1); + if ((c = p[w]) && !r[c]) { + r[c] = 1; + a = Nb(this, c, t, 0, 0, !1, !1); if (a = Ob(a, d, h, m)) { d = a; break; } - r && (h && a && d.length || (r = c)); + t && (h && a && d.length || (t = c)); } - h && r && w === q - 1 && !d.length && (m = this.resolution, r = "", w = -1, t = I()); + h && t && w === q - 1 && !d.length && (m = this.resolution, t = "", w = -1, r = J()); } return Pb(d, m, b, e, h, l, g); }; function Pb(a, b, c, d, e, g, f) { var h = a.length, k = a; if (1 < h) { - k = ib(a, b, c, d, e, g, f); + k = jb(a, b, c, d, e, g, f); } else if (1 === h) { - return f ? lb.call(null, a[0], c, d) : new Y(a[0]); + return f ? mb.call(null, a[0], c, d) : new X(a[0]); } - return f ? k : new Y(k); + return f ? k : new X(k); } function Mb(a, b, c, d, e, g, f) { a = Nb(this, a, b, c, d, e, g, f); return this.db ? a.then(function(h) { - return e ? h || [] : new Y(h); - }) : a && a.length ? e ? lb.call(this, a, c, d) : new Y(a) : e ? [] : new Y(); + return e ? h || [] : new X(h); + }) : a && a.length ? e ? mb.call(this, a, c, d) : new X(a) : e ? [] : new X(); } function Ob(a, b, c, d) { var e = []; @@ -3009,19 +3003,19 @@ function Nb(a, b, c, d, e, g, f, h) { a = c ? (a = a.ctx.get(c)) && a.get(b) : a.map.get(b); return a; } -;function P(a, b) { - if (!this || this.constructor !== P) { - return new P(a); +;function O(a, b) { + if (!this || this.constructor !== O) { + return new O(a); } if (a) { - var c = J(a) ? a : a.preset; + var c = K(a) ? a : a.preset; c && (Jb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Jb[c], a)); } else { a = {}; } c = a.context; - var d = !0 === c ? {depth:1} : c || {}, e = J(a.encoder) ? Gb[a.encoder] : a.encode || a.encoder || {}; - this.encoder = e.encode ? e : "object" === typeof e ? new Fa(e) : {encode:e}; + var d = !0 === c ? {depth:1} : c || {}, e = K(a.encoder) ? Gb[a.encoder] : a.encode || a.encoder || {}; + this.encoder = e.encode ? e : "object" === typeof e ? new Ga(e) : {encode:e}; this.resolution = a.resolution || 9; this.tokenize = c = (c = a.tokenize) && "default" !== c && "exact" !== c && c || "strict"; this.depth = "strict" === c && d.depth || 0; @@ -3030,12 +3024,12 @@ function Nb(a, b, c, d, e, g, f, h) { this.score = a.score || null; d && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); (c = a.keystore || 0) && (this.keystore = c); - this.map = c ? new U(c) : new Map(); - this.ctx = c ? new U(c) : new Map(); - this.reg = b || (this.fastupdate ? c ? new U(c) : new Map() : c ? new V(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.da = d.resolution || 3; this.rtl = e.rtl || a.rtl || !1; - this.cache = (c = a.cache || null) && new xb(c); + this.cache = (c = a.cache || null) && new Y(c); this.resolve = !1 !== a.resolve; if (c = a.db) { this.db = this.mount(c); @@ -3045,7 +3039,7 @@ function Nb(a, b, c, d, e, g, f, h) { this.commit_timer = null; this.priority = a.priority || 4; } -u = P.prototype; +u = O.prototype; u.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); @@ -3099,7 +3093,7 @@ u.export = function(a, b, c, d) { switch(d) { case 0: var e = "reg"; - var g = Xa(this.reg); + var g = Ya(this.reg); break; case 1: e = "cfg"; @@ -3107,29 +3101,29 @@ u.export = function(a, b, c, d) { break; case 2: e = "map"; - g = Ta(this.map, this.reg.size); + g = Ua(this.map, this.reg.size); break; case 3: e = "ctx"; - g = Va(this.ctx, this.reg.size); + g = Wa(this.ctx, this.reg.size); break; default: return; } - return Za.call(this, a, b, e, g, c, d); + return $a.call(this, a, b, e, g, c, d); }; u.import = function(a, b) { if (b) { switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = Ya(b, this.reg); + this.reg = Za(b, this.reg); break; case "map": - this.map = Ua(b, this.map); + this.map = Va(b, this.map); break; case "ctx": - this.ctx = Wa(b, this.ctx); + this.ctx = Xa(b, this.ctx); } } }; @@ -3138,18 +3132,18 @@ u.serialize = function(a) { var b = "", c = "", d = ""; if (this.reg.size) { var e; - c = y(this.reg.keys()); + c = x(this.reg.keys()); for (var g = c.next(); !g.done; g = c.next()) { g = g.value, e || (e = typeof g), b += (b ? "," : "") + ("string" === e ? '"' + g + '"' : g); } b = "index.reg=new Set([" + b + "]);"; - c = $a(this.map, e); + c = ab(this.map, e); c = "index.map=new Map([" + c + "]);"; - g = y(this.ctx.entries()); + g = x(this.ctx.entries()); for (var f = g.next(); !f.done; f = g.next()) { var h = f.value; f = h[0]; - h = $a(h[1], e); + h = ab(h[1], e); h = "new Map([" + h + "])"; h = '["' + f + '",' + h + "]"; d += (d ? "," : "") + h; @@ -3158,8 +3152,8 @@ u.serialize = function(a) { } return a ? "function inject(index){" + b + c + d + "}" : b + c + d; }; -Ia(P.prototype); -var Qb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Rb = ["map", "ctx", "tag", "reg", "cfg"], Sb = I(); +Ja(O.prototype); +var Qb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Rb = ["map", "ctx", "tag", "reg", "cfg"], Sb = J(); function Tb(a, b) { b = void 0 === b ? {} : b; if (!this) { @@ -3322,7 +3316,7 @@ u.commit = function(a, b, c) { switch(h.h) { case 1: if (b) { - return D(h, d.clear(), 12); + return E(h, d.clear(), 12); } e = a.commit_task; a.commit_task = []; @@ -3339,7 +3333,7 @@ u.commit = function(a, b, c) { h.h = 5; break; } - return D(h, d.clear(), 8); + return E(h, d.clear(), 8); case 8: b = !0; h.h = 6; @@ -3353,12 +3347,12 @@ u.commit = function(a, b, c) { h.h = 3; break; } - c || (e = e.concat(xa(a.reg))); + c || (e = e.concat(ya(a.reg))); if (!e.length) { h.h = 10; break; } - return D(h, d.remove(e), 11); + return E(h, d.remove(e), 11); case 11: case 10: h.h = 3; @@ -3366,59 +3360,59 @@ u.commit = function(a, b, c) { case 12: a.commit_task = []; case 3: - return a.reg.size ? D(h, d.transaction("map", "readwrite", function(k) { - for (var l = y(a.map), m = l.next(), n = {}; !m.done; n = {O:void 0, Y:void 0}, m = l.next()) { + return a.reg.size ? E(h, d.transaction("map", "readwrite", function(k) { + for (var l = x(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) { return function() { - var q = this.result, t; + var q = this.result, r; if (q && q.length) { - for (var w = Math.max(q.length, p.O.length), r = 0, z; r < w; r++) { - if ((z = p.O[r]) && z.length) { - if ((t = q[r]) && t.length) { - for (var A = 0; A < z.length; A++) { - t.push(z[A]); + for (var w = Math.max(q.length, p.O.length), t = 0, A; t < w; t++) { + if ((A = p.O[t]) && A.length) { + if ((r = q[t]) && r.length) { + for (var z = 0; z < A.length; z++) { + r.push(A[z]); } } else { - q[r] = z; + q[t] = A; } - t = 1; + r = 1; } } } else { - q = p.O, t = 1; + q = p.O, r = 1; } - t && k.put(q, p.Y); + r && k.put(q, p.Y); }; }(n)); } }), 13) : h.return(); case 13: - return D(h, d.transaction("ctx", "readwrite", function(k) { - for (var l = y(a.ctx), m = l.next(), n = {}; !m.done; n = {V:void 0}, m = l.next()) { + return E(h, d.transaction("ctx", "readwrite", function(k) { + for (var l = x(a.ctx), m = l.next(), n = {}; !m.done; n = {V:void 0}, m = l.next()) { m = m.value; n.V = m[0]; - m = y(m[1]); + m = x(m[1]); for (var p = m.next(), q = {}; !p.done; q = {P:void 0, Z:void 0}, p = m.next()) { - p = p.value, q.Z = p[0], q.P = p[1], q.P.length && (b ? k.put(q.P, n.V + ":" + q.Z) : k.get(n.V + ":" + q.Z).onsuccess = function(t, w) { + p = p.value, q.Z = p[0], q.P = p[1], q.P.length && (b ? k.put(q.P, n.V + ":" + q.Z) : k.get(n.V + ":" + q.Z).onsuccess = function(r, w) { return function() { - var r = this.result, z; - if (r && r.length) { - for (var A = Math.max(r.length, t.P.length), v = 0, x; v < A; v++) { - if ((x = t.P[v]) && x.length) { - if ((z = r[v]) && z.length) { - for (var E = 0; E < x.length; E++) { - z.push(x[E]); + var t = this.result, A; + if (t && t.length) { + for (var z = Math.max(t.length, r.P.length), v = 0, y; v < z; v++) { + if ((y = r.P[v]) && y.length) { + if ((A = t[v]) && A.length) { + for (var D = 0; D < y.length; D++) { + A.push(y[D]); } } else { - r[v] = x; + t[v] = y; } - z = 1; + A = 1; } } } else { - r = t.P, z = 1; + t = r.P, A = 1; } - z && k.put(r, w.V + ":" + t.Z); + A && k.put(t, w.V + ":" + r.Z); }; }(q, n)); } @@ -3426,8 +3420,8 @@ u.commit = function(a, b, c) { }), 14); case 14: if (a.store) { - return D(h, d.transaction("reg", "readwrite", function(k) { - for (var l = y(a.store), m = l.next(); !m.done; m = l.next()) { + return E(h, d.transaction("reg", "readwrite", function(k) { + for (var l = x(a.store), m = l.next(); !m.done; m = l.next()) { var n = m.value; m = n[0]; n = n[1]; @@ -3439,8 +3433,8 @@ u.commit = function(a, b, c) { h.h = 16; break; } - return D(h, d.transaction("reg", "readwrite", function(k) { - for (var l = y(a.reg.keys()), m = l.next(); !m.done; m = l.next()) { + return E(h, d.transaction("reg", "readwrite", function(k) { + for (var l = x(a.reg.keys()), m = l.next(); !m.done; m = l.next()) { k.put(1, m.value); } }), 16); @@ -3449,8 +3443,8 @@ u.commit = function(a, b, c) { h.h = 20; break; } - return D(h, d.transaction("tag", "readwrite", function(k) { - for (var l = y(a.tag), m = l.next(), n = {}; !m.done; n = {X:void 0, ba:void 0}, m = l.next()) { + return E(h, d.transaction("tag", "readwrite", function(k) { + for (var l = x(a.tag), m = l.next(), n = {}; !m.done; n = {X:void 0, ba:void 0}, m = l.next()) { m = m.value, n.ba = m[0], n.X = m[1], n.X.length && (k.get(n.ba).onsuccess = function(p) { return function() { var q = this.result; @@ -3521,7 +3515,7 @@ function Z(a, b) { a = null; }); } -;var Vb = {Index:P, Charset:Gb, Encoder:Fa, Document:W, Worker:Ra, Resolver:Y, IndexedDB:Tb, Language:{}}, Wb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self, Zb; +;var Vb = {Index:O, Charset:Gb, Encoder:Ga, Document:V, Worker:Sa, Resolver:X, IndexedDB:Tb, Language:{}}, Wb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self, Zb; (Zb = Wb.define) && Zb.amd ? Zb([], function() { return Vb; }) : "object" === typeof Wb.exports ? Wb.exports = Vb : Wb.FlexSearch = Vb; diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js index 2a502b4..13800c7 100644 --- a/dist/flexsearch.es5.min.js +++ b/dist/flexsearch.es5.min.js @@ -1,14 +1,14 @@ /**! - * FlexSearch.js v0.8.149 (ES5) + * FlexSearch.js v0.8.151 (ES5) * 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 u;function aa(a){var b=0;return function(){return bc&&(c=Math.max(c+e,0));c"a1a".split(c).length; -this.numeric=G(a.numeric,e)}else{try{this.split=G(this.split,Aa)}catch(g){this.split=/\s+/}this.numeric=G(a.numeric,G(this.numeric,!0))}this.prepare=G(a.prepare,null,this.prepare);this.finalize=G(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:G(c&&new Set(c),null,this.filter);this.dedupe=G(a.dedupe,!1,this.dedupe);this.matcher=G((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=G((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=G((c=a.stemmer)&&new Map(c), -null,this.stemmer);this.replacer=G(a.replacer,null,this.replacer);this.minlength=G(a.minlength,1,this.minlength);this.maxlength=G(a.maxlength,0,this.maxlength);this.rtl=G(a.rtl,!1,this.rtl);if(this.cache=c=G(a.cache,!0,this.cache))this.D=null,this.T="number"===typeof c?c:2E5,this.B=new Map,this.C=new Map,this.H=this.G=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(a=y(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.h+=(this.h?"|":"")+b.value;if(this.stemmer)for(a=y(this.stemmer.keys()), -b=a.next();!b.done;b=a.next())this.A+=(this.A?"|":"")+b.value;return this};u.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&M(this);return this};u.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&M(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&&M(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&&M(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(M,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=Ea?a.normalize("NFKD").replace(Ea,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3=this.minlength&&("function"===typeof this.filter?!this.filter(f):this.filter.has(f))&&(f=""));if(f&&(this.mapper||this.dedupe&&1this.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 M(a){a.D=null;a.B.clear();a.C.clear()};var Ga,Ha; -function Ia(a){var b,c,d,e,g,f;return ta(function(h){switch(h.h){case 1:a=a.data;b=a.task;c=a.id;d=a.args;switch(b){case "init":Ha=a.options||{};(e=a.factory)?(Function("return "+e)()(self),Ga=new self.FlexSearch.Index(Ha),delete self.FlexSearch):Ga=new O(Ha);postMessage({id:c});break;default:h.h=2;return}h.h=0;break;case 2:"export"===b&&(d[1]?(d[0]=Ha.export,d[2]=0,d[3]=1):d=null);if("import"===b){if(!d[0]){h.h=5;break}return D(h,Ha.import.call(Ga,d[0]),9)}g=d&&Ga[b].apply(Ga,d);if(!g||!g.then){h.h= -5;break}return D(h,g,7);case 7:g=h.D;h.h=5;break;case 9:f=h.D,Ga.import(d[0],f);case 5:postMessage("search"===b?{id:c,msg:g}:{id:c}),h.h=0}})};function Ja(a){Ka.call(a,"add");Ka.call(a,"append");Ka.call(a,"search");Ka.call(a,"update");Ka.call(a,"remove")}var Na,Oa,Pa;function Qa(){Na=Pa=0} -function Ka(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if("function"===typeof c){var d=c;delete b[b.length-1]}Na?Pa||(Pa=Date.now()-Oa>=this.priority*this.priority*3):(Na=setTimeout(Qa,0),Oa=Date.now());if(Pa){var e=this;return new Promise(function(f){setTimeout(function(){f(e[a+"Async"].apply(e,b))},0)})}var g=this[a].apply(this,b);c=g.then?g:new Promise(function(f){return f(g)});d&&c.then(d);return c}};var Ra=0; -function Sa(a){function b(f){function h(k){k=k.data||k;var l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=f;this.h=I();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++Ra]=function(){k(e);1E9=f.length)b-=f.length;else{b=f[d?"splice":"slice"](b,c);if(f=b.length)if(e=e.length?e.concat(b):b,c-=f,d&&(a.length-=f),!c)break;b=0}return e} -function S(a){if(!this||this.constructor!==S)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+ +this.numeric=G(a.numeric,e)}else{try{this.split=G(this.split,Ba)}catch(g){this.split=/\s+/}this.numeric=G(a.numeric,G(this.numeric,!0))}this.prepare=G(a.prepare,null,this.prepare);this.finalize=G(a.finalize,null,this.finalize);c=a.filter;this.filter="function"===typeof c?c:G(c&&new Set(c),null,this.filter);this.dedupe=G(a.dedupe,!0,this.dedupe);this.matcher=G((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=G((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer=G((c=a.stemmer)&&new Map(c), +null,this.stemmer);this.replacer=G(a.replacer,null,this.replacer);this.minlength=G(a.minlength,1,this.minlength);this.maxlength=G(a.maxlength,1024,this.maxlength);this.rtl=G(a.rtl,!1,this.rtl);if(this.cache=c=G(a.cache,!0,this.cache))this.D=null,this.T="number"===typeof c?c:2E5,this.B=new Map,this.C=new Map,this.H=this.G=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(a=x(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.h+=(this.h?"|":"")+b.value;if(this.stemmer)for(a=x(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&&L(this);return this};u.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&L(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&&L(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&&L(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(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=Fa?a.normalize("NFKD").replace(Fa,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.maxlength))if(c)d.push(f);else if(!this.filter||("function"===typeof this.filter?this.filter(f):!this.filter.has(f))){if(this.cache&&f.length<=this.H)if(this.D){var k=this.C.get(f);if(k||""===k){k&&d.push(k);continue}}else this.D=setTimeout(L,50,this);this.stemmer&&2=this.minlength&&("function"===typeof this.filter?!this.filter(f):this.filter.has(f))&&(f=""));if(f&&(this.mapper||this.dedupe&&1this.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 L(a){a.D=null;a.B.clear();a.C.clear()};var Ha,Ia; +function Ja(a){var b,c,d,e,g,f;return ta(function(h){switch(h.h){case 1:a=a.data;b=a.task;c=a.id;d=a.args;switch(b){case "init":Ia=a.options||{};(e=a.factory)?(Function("return "+e)()(self),Ha=new self.FlexSearch.Index(Ia),delete self.FlexSearch):Ha=new N(Ia);postMessage({id:c});break;default:h.h=2;return}h.h=0;break;case 2:"export"===b&&(d[1]?(d[0]=Ia.export,d[2]=0,d[3]=1):d=null);if("import"===b){if(!d[0]){h.h=5;break}return E(h,Ia.import.call(Ha,d[0]),9)}g=d&&Ha[b].apply(Ha,d);if(!g||!g.then){h.h= +5;break}return E(h,g,7);case 7:g=h.D;h.h=5;break;case 9:f=h.D,Ha.import(d[0],f);case 5:postMessage("search"===b?{id:c,msg:g}:{id:c}),h.h=0}})};function Ka(a){Na.call(a,"add");Na.call(a,"append");Na.call(a,"search");Na.call(a,"update");Na.call(a,"remove")}var Oa,Pa,Qa;function Ra(){Oa=Qa=0} +function Na(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]}Oa?Qa||(Qa=Date.now()-Pa>=this.priority*this.priority*3):(Oa=setTimeout(Ra,0),Pa=Date.now());if(Qa){var e=this;return new Promise(function(f){setTimeout(function(){f(e[a+"Async"].apply(e,b))},0)})}var g=this[a].apply(this,b);c=g.then?g:new Promise(function(f){return f(g)});d&&c.then(d);return c}};var Sa=0; +function Ta(a){function b(f){function h(k){k=k.data||k;var l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=f;this.h=J();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++Sa]=function(){k(e);1E9=f.length)b-=f.length;else{b=f[d?"splice":"slice"](b,c);if(f=b.length)if(e=e.length?e.concat(b):b,c-=f,d&&(a.length-=f),!c)break;b=0}return e} +function R(a){if(!this||this.constructor!==R)return new R(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var g=0,f=0,h,k;fc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+ d)}else{e=[];for(g=0;gd)d-=f.length;else{if(f.length>c||d)f=f.slice(d,c+d),c-=f.length,d&&(d-=f.length);e.push(f);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,d?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=kb(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=nb(this,"and",arguments),pb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)):c?this.resolve(d,e,g):this}; -function pb(a,b,c,d,e,g,f){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else{if(b=za(a))return this.result=jb(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=nb(this,"xor",arguments);return qb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)}; -function qb(a,b,c,d,e,g,f){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else return this.result=rb.call(this,a,c,d,g,this.h),g?e?W.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(c,d,e):this} -function rb(a,b,c,d,e){for(var g=[],f=I(),h=0,k=0,l;kc||d)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=y(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};var Ab={normalize:!1,numeric:!1};var Bb={};var Cb=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);var Db=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Eb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];var Fb={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Gb={na:Ab,ma:Bb,oa:Bb,LatinBalance:{dedupe:!0,mapper:Cb},LatinAdvanced:{dedupe:!0,mapper:Cb,matcher:Db,replacer:Eb},LatinExtra:{dedupe:!0,mapper:Cb,replacer:Eb.concat([/(?!^)[aeo]/g,""]),matcher:Db},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;be.length)e.pop();else{var g=e.indexOf(a);g===c.length-1?e.pop():e.splice(g,1)}}else Hb(this.map,a),this.depth&&Hb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Ib(this));this.cache&&this.cache.remove(a);return this}; -function Hb(a,b){var c=0,d="undefined"===typeof b;if(a.constructor===Array)for(var e=0,g=void 0,f;en;t--)p=l.substring(n,t),q=this.rtl?m-1-n:n,q=this.score?this.score(b,l,k,p,q):Kb(h,d,k,m,q),Lb(this,g,p, -q,a,c);break}case "bidirectional":case "reverse":if(1p?0:1),d,k,t-1,q-1),r=this.bidirectional&& -l>n;Lb(this,e,r?n:l,w,a,c,r?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.ca&&Ib(this));return this}; -function Lb(a,b,c,d,e,g,f){var h=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])if(f?(b=k||(b[c]=I()),b[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!g||!h.includes(e)){if(h.length===Math.pow(2,31)-1){b=new S(h);if(a.fastupdate)for(c=y(a.reg.values()),g=c.next();!g.done;g=c.next())g=g.value,g.includes(h)&&(g[g.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} -function Kb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,g,f,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function O(a,b){if(!this||this.constructor!==O)return new O(a);if(a){var c=J(a)?a:a.preset;c&&(a=Object.assign({},Jb[c],a))}else a={};c=a.context;var d=!0===c?{depth:1}:c||{},e=J(a.encoder)?Gb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new Fa(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; -this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new 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.da=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new Y(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.ca=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}u=O.prototype; -u.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};u.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};u.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function Ib(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} +function lb(a,b,c,d,e){var g=[],f=J(),h=a.length,k;if(d)for(e=h-1;0<=e;e--){if(k=(d=a[e])&&d.length)for(h=0;hb?b?a.slice(c,c+b):a.slice(c):a,d?V.call(this,a):a;for(var e=[],g=0,f=void 0,h=void 0;g=h){c-=h;continue}cb&&(f=f.slice(0,b),h=b);if(!e.length&&h>=b)return d?V.call(this,f):f;e.push(f);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=lb(a,c,d,!1,this.h),d=0));return g?this.resolve(c,d,e):this};W.prototype.and=function(){var a=this.result.length;if(!a){var b=arguments[0];if(b){a=!!b.suggest;var c=b.resolve;var d=b.limit;var e=b.offset;var g=b.enrich&&c}}return a?(a=ob(this,"and",arguments),qb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)):c?this.resolve(d,e,g):this}; +function qb(a,b,c,d,e,g,f){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else{if(b=Aa(a))return this.result=kb(a,b,c,d,f,this.h,g),g?e?V.call(this.index,this.result):this.result:this;this.result=[]}else f||(this.result=a);return g?this.resolve(c,d,e):this};W.prototype.xor=function(){var a=ob(this,"xor",arguments);return rb.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)}; +function rb(a,b,c,d,e,g,f){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=sb.call(this,a,c,d,g,this.h),g?e?V.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(c,d,e):this} +function sb(a,b,c,d,e){for(var g=[],f=J(),h=0,k=0,l;kc||d)a=a.slice(d,d+c);e&&(a=V.call(this,a));return a}}function V(a){if(!this||!this.store)return a;for(var b=Array(a.length),c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +X.prototype.get=function(a){var b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};X.prototype.remove=function(a){for(var b=x(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};X.prototype.clear=function(){this.cache.clear();this.h=""};var Bb={normalize:!1,numeric:!1,dedupe:!1};var Cb={};var Db=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 Eb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Fb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];var Gb={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 Hb={Exact:Bb,Default:Cb,Normalize:Cb,LatinBalance:{mapper:Db},LatinAdvanced:{mapper:Db,matcher:Eb,replacer:Fb},LatinExtra:{mapper:Db,replacer:Fb.concat([/(?!^)[aeo]/g,""]),matcher:Eb},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;be.length)e.pop();else{var g=e.indexOf(a);g===c.length-1?e.pop():e.splice(g,1)}}else Ib(this.map,a),this.depth&&Ib(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Jb(this));this.cache&&this.cache.remove(a);return this}; +function Ib(a,b){var c=0,d="undefined"===typeof b;if(a.constructor===Array)for(var e=0,g=void 0,f;en;r--)p=l.substring(n,r),q=this.rtl?m-1-n:n,q=this.score?this.score(b,l,k,p,q):Lb(h,d,k,m,q),Mb(this,g,p, +q,a,c);break}case "bidirectional":case "reverse":if(1p?0:1),d,k,r-1,q-1),t=this.bidirectional&& +l>n;Mb(this,e,t?n:l,w,a,c,t?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.ca&&Jb(this));return this}; +function Mb(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]=J()),b[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!g||!h.includes(e)){if(h.length===Math.pow(2,31)-1){b=new R(h);if(a.fastupdate)for(c=x(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 Lb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,g,f,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};function N(a,b){if(!this||this.constructor!==N)return new N(a);if(a){var c=K(a)?a:a.preset;c&&(a=Object.assign({},Kb[c],a))}else a={};c=a.context;var d=!0===c?{depth:1}:c||{},e=K(a.encoder)?Hb[a.encoder]:a.encode||a.encoder||{};this.encoder=e.encode?e:"object"===typeof e?new Ga(e):{encode:e};this.resolution=a.resolution||9;this.tokenize=c=(c=a.tokenize)&&"default"!==c&&"exact"!==c&&c||"strict";this.depth="strict"===c&&d.depth||0;this.bidirectional=!1!==d.bidirectional;this.fastupdate=!!a.fastupdate; +this.score=a.score||null;(c=a.keystore||0)&&(this.keystore=c);this.map=c?new S(c):new Map;this.ctx=c?new S(c):new Map;this.reg=b||(this.fastupdate?c?new S(c):new Map:c?new T(c):new Set);this.da=d.resolution||3;this.rtl=e.rtl||a.rtl||!1;this.cache=(c=a.cache||null)&&new X(c);this.resolve=!1!==a.resolve;if(c=a.db)this.db=this.mount(c);this.ca=!1!==a.commit;this.commit_task=[];this.commit_timer=null;this.priority=a.priority||4}u=N.prototype; +u.mount=function(a){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return a.mount(this)};u.commit=function(a,b){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.commit(this,a,b)};u.destroy=function(){this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null);return this.db.destroy()};function Jb(a){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null;a.db.commit(a,void 0,void 0)},1))} u.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();this.cache&&this.cache.clear();this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]);return this};u.append=function(a,b){return this.add(a,b,!0)};u.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)};u.update=function(a,b){var c=this,d=this.remove(a);return d&&d.then?d.then(function(){return c.add(a,b)}):this.add(a,b)}; -u.cleanup=function(){if(!this.fastupdate)return this;Hb(this.map);this.depth&&Hb(this.ctx);return this};u.searchCache=zb;u.export=function(a,b,c,d){c=void 0===c?0:c;d=void 0===d?0:d;switch(d){case 0:var e="reg";var g=Ya(this.reg);break;case 1:e="cfg";g=null;break;case 2:e="map";g=Ua(this.map,this.reg.size);break;case 3:e="ctx";g=Wa(this.ctx,this.reg.size);break;default:return}return $a.call(this,a,b,e,g,c,d)}; -u.import=function(a,b){if(b)switch("string"===typeof b&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),3===a.length&&a.shift(),a=1=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length, 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;d this.maxlength)) { if (d) { b.push(e); } else { @@ -410,7 +410,7 @@ function L(a, d, b, f, c) { } h = w(); var n = 0; - if (1 < b && g) { + if (g) { var m = a[0]; n = 1; } diff --git a/dist/flexsearch.light.min.js b/dist/flexsearch.light.min.js index db03d27..0c6455f 100644 --- a/dist/flexsearch.light.min.js +++ b/dist/flexsearch.light.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.149 (Light) + * FlexSearch.js v0.8.151 (Light) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -7,20 +7,20 @@ */ (function(self){'use strict';var r;function u(a,d,b){const f=typeof b,c=typeof a;if("undefined"!==f){if("undefined"!==c){if(b){if("function"===c&&f===c)return function(h){return a(b(h))};d=a.constructor;if(d===b.constructor){if(d===Array)return b.concat(a);if(d===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(d===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===c?d:a}function w(){return Object.create(null)};const z=/[^\p{L}\p{N}]+/u,A=/(\d{3})/g,B=/(\D)(\d{3})/g,C=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; -this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,z)}catch(c){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!1,this.dedupe);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,0,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const c of this.matcher.keys())this.g+=(this.g?"|":"")+c;if(this.stemmer)for(const c of this.stemmer.keys())this.h+= +this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,z)}catch(c){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!0,this.dedupe);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,1024,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const c of this.matcher.keys())this.g+=(this.g?"|":"")+c;if(this.stemmer)for(const c of this.stemmer.keys())this.h+= (this.h?"|":"")+c;return this};r.addStemmer=function(a,d){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,d);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; r.addMapper=function(a,d){if("object"===typeof a)return this.addReplacer(a,d);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,d);this.matcher||(this.matcher=new Map);this.matcher.set(a,d);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this}; r.addReplacer=function(a,d){if("string"===typeof a)return this.addMatcher(a,d);this.replacer||(this.replacer=[]);this.replacer.push(a,d);this.cache&&G(this);return this}; r.encode=function(a){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),c!==e&&this.filter&& -e.length>=this.minlength&&("function"===typeof this.filter?!this.filter(e):this.filter.has(e))&&(e=""));if(e&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(e&&this.replacer)for(c=0;e&&cthis.A&&(this.j.clear(),this.o=this.o/1.1|0));e&&b.push(e)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.m&&(this.i.set(a,b),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return b};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,d,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>d?d?a.slice(b,b+d):a.slice(b):a;let f=[];for(let c=0,g,e;c=e){b-=e;continue}bd&&(g=g.slice(0,d),e=d);if(!f.length&&e>=d)return g;f.push(g);d-=e;if(!d)break}return f=1c.length)c.pop();else{const g=c.indexOf(a);g===b.length-1?c.pop():c.splice(g,1)}}else J(this.map,a),this.depth&&J(this.ctx,a);d||this.reg.delete(a)}return this}; +this.split||""===this.split?a.split(this.split):a;for(let g=0,e,h;gthis.maxlength))if(d)b.push(e);else if(!this.filter||("function"===typeof this.filter?this.filter(e):!this.filter.has(e))){if(this.cache&&e.length<=this.o)if(this.l){var c=this.j.get(e);if(c||""===c){c&&b.push(c);continue}}else this.l=setTimeout(G,50,this);this.stemmer&&2this.stemmer.get(k)), +c!==e&&this.filter&&e.length>=this.minlength&&("function"===typeof this.filter?!this.filter(e):this.filter.has(e))&&(e=""));if(e&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(e&&this.replacer)for(c=0;e&&cthis.A&&(this.j.clear(),this.o=this.o/1.1|0));e&&b.push(e)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.m&&(this.i.set(a,b),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return b};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,d,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>d?d?a.slice(b,b+d):a.slice(b):a;let f=[];for(let c=0,g,e;c=e){b-=e;continue}bd&&(g=g.slice(0,d),e=d);if(!f.length&&e>=d)return g;f.push(g);d-=e;if(!d)break}return f=1c.length)c.pop();else{const g=c.indexOf(a);g===b.length-1?c.pop():c.splice(g,1)}}else J(this.map,a),this.depth&&J(this.ctx,a);d||this.reg.delete(a)}return this}; function J(a,d){let b=0;var f="undefined"===typeof d;if(a.constructor===Array)for(let c=0,g,e;cq;g--){e=l.substring(q,g);t=this.rtl?c-1-q:q;var h=this.score?this.score(d,l,p,e,t):L(D,f,p,c,t);M(this, m,e,h,a,b)}break}case "bidirectional":case "reverse":if(1e?0:1),f,p,h-1,k-1), -t=this.bidirectional&&l>g;M(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,d,b,f,c,g,e){let h=e?a.ctx:a.map,k;if(!d[b]||e&&!(k=d[b])[e])e?(d=k||(d[b]=w()),d[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):d[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(c)||(h.push(c),a.fastupdate&&((d=a.reg.get(c))?d.push(h):a.reg.set(c,[h])))}function L(a,d,b,f,c){return b&&1d||c?e.slice(c,d+c):e;e=a}else{if(ad||c)e=e.slice(c,d+c)}m=e}else if(1===f){d=H.call(null, -a[0],d,c);break a}d=m}return d};function N(a,d,b){let f;b&&(f=a.bidirectional&&d>b)&&(f=b,b=d,d=f);a=b?(a=a.ctx.get(b))&&a.get(d):a.map.get(d);return a};function I(a,d){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},c=a.encode||a.encoder||{};this.encoder=c.encode?c:"object"===typeof c?new F(c):{encode:c};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= +t=this.bidirectional&&l>g;M(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,d,b,f,c,g,e){let h=e?a.ctx:a.map,k;if(!d[b]||e&&!(k=d[b])[e])e?(d=k||(d[b]=w()),d[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):d[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(c)||(h.push(c),a.fastupdate&&((d=a.reg.get(c))?d.push(h):a.reg.set(c,[h])))}function L(a,d,b,f,c){return b&&1d||c?e.slice(c,d+c):e;e=a}else{if(ad||c)e=e.slice(c,d+c)}m=e}else if(1===f){d=H.call(null,a[0], +d,c);break a}d=m}return d};function N(a,d,b){let f;b&&(f=a.bidirectional&&d>b)&&(f=b,b=d,d=f);a=b?(a=a.ctx.get(b))&&a.get(d):a.map.get(d);return a};function I(a,d){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},c=a.encode||a.encoder||{};this.encoder=c.encode?c:"object"===typeof c?new F(c):{encode:c};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= a.score||null;this.map=new Map;this.ctx=new Map;this.reg=d||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=c.rtl||a.rtl||!1}r=I.prototype;r.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};r.append=function(a,d){return this.add(a,d,!0)};r.contain=function(a){return this.reg.has(a)};r.update=function(a,d){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,d)):this.add(a,d)}; r.cleanup=function(){if(!this.fastupdate)return this;J(this.map);this.depth&&J(this.ctx);return this};w();const O={Index:I,Charset:null,Encoder:F,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}},P="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let Q;(Q=P.define)&&Q.amd?Q([],function(){return O}):"object"===typeof P.exports?P.exports=O:P.FlexSearch=O;}(this||self)); diff --git a/dist/flexsearch.light.module.debug.js b/dist/flexsearch.light.module.debug.js index 8edd1eb..5121bed 100644 --- a/dist/flexsearch.light.module.debug.js +++ b/dist/flexsearch.light.module.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.149 (Bundle/Debug) + * FlexSearch.js v0.8.151 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -97,13 +97,13 @@ r.assign = function(a) { this.finalize = u(a.finalize, null, this.finalize); b = a.filter; this.filter = "function" === typeof b ? b : u(b && new Set(b), null, this.filter); - this.dedupe = u(a.dedupe, !1, this.dedupe); + this.dedupe = u(a.dedupe, !0, this.dedupe); this.matcher = u((b = a.matcher) && new Map(b), null, this.matcher); this.mapper = u((b = a.mapper) && new Map(b), null, this.mapper); this.stemmer = u((b = a.stemmer) && new Map(b), null, this.stemmer); this.replacer = u(a.replacer, null, this.replacer); this.minlength = u(a.minlength, 1, this.minlength); - this.maxlength = u(a.maxlength, 0, this.maxlength); + this.maxlength = u(a.maxlength, 1024, this.maxlength); this.rtl = u(a.rtl, !1, this.rtl); if (this.cache = b = u(a.cache, !0, this.cache)) { this.l = null, this.A = "number" === typeof b ? b : 2e5, this.i = new Map(), this.j = new Map(), this.o = this.m = 128; @@ -188,7 +188,7 @@ r.encode = function(a) { const d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let b = [], f = this.split || "" === this.split ? a.split(this.split) : a; for (let g = 0, e, h; g < f.length; g++) { - if ((e = h = f[g]) && !(e.length < this.minlength)) { + if ((e = h = f[g]) && !(e.length < this.minlength || e.length > this.maxlength)) { if (d) { b.push(e); } else { @@ -409,7 +409,7 @@ function L(a, d, b, f, c) { } h = w(); var n = 0; - if (1 < b && g) { + if (g) { var m = a[0]; n = 1; } diff --git a/dist/flexsearch.light.module.min.js b/dist/flexsearch.light.module.min.js index 0f08b6c..1002354 100644 --- a/dist/flexsearch.light.module.min.js +++ b/dist/flexsearch.light.module.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.149 (Bundle) + * FlexSearch.js v0.8.151 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -7,21 +7,21 @@ */ var r;function u(a,d,b){const f=typeof b,c=typeof a;if("undefined"!==f){if("undefined"!==c){if(b){if("function"===c&&f===c)return function(h){return a(b(h))};d=a.constructor;if(d===b.constructor){if(d===Array)return b.concat(a);if(d===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(d===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===c?d:a}function w(){return Object.create(null)};const z=/[^\p{L}\p{N}]+/u,A=/(\d{3})/g,B=/(\D)(\d{3})/g,C=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; -this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,z)}catch(c){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!1,this.dedupe);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,0,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const c of this.matcher.keys())this.g+=(this.g?"|":"")+c;if(this.stemmer)for(const c of this.stemmer.keys())this.h+= +this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,z)}catch(c){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);b=a.filter;this.filter="function"===typeof b?b:u(b&&new Set(b),null,this.filter);this.dedupe=u(a.dedupe,!0,this.dedupe);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,1024,this.maxlength);this.rtl=u(a.rtl,!1,this.rtl);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const c of this.matcher.keys())this.g+=(this.g?"|":"")+c;if(this.stemmer)for(const c of this.stemmer.keys())this.h+= (this.h?"|":"")+c;return this};r.addStemmer=function(a,d){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,d);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; r.addMapper=function(a,d){if("object"===typeof a)return this.addReplacer(a,d);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,d);this.matcher||(this.matcher=new Map);this.matcher.set(a,d);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this}; r.addReplacer=function(a,d){if("string"===typeof a)return this.addMatcher(a,d);this.replacer||(this.replacer=[]);this.replacer.push(a,d);this.cache&&G(this);return this}; r.encode=function(a){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),c!==e&&this.filter&& -e.length>=this.minlength&&("function"===typeof this.filter?!this.filter(e):this.filter.has(e))&&(e=""));if(e&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(e&&this.replacer)for(c=0;e&&cthis.A&&(this.j.clear(),this.o=this.o/1.1|0));e&&b.push(e)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.m&&(this.i.set(a,b),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return b};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,d,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>d?d?a.slice(b,b+d):a.slice(b):a;let f=[];for(let c=0,g,e;c=e){b-=e;continue}bd&&(g=g.slice(0,d),e=d);if(!f.length&&e>=d)return g;f.push(g);d-=e;if(!d)break}return f=1c.length)c.pop();else{const g=c.indexOf(a);g===b.length-1?c.pop():c.splice(g,1)}}else J(this.map,a),this.depth&&J(this.ctx,a);d||this.reg.delete(a)}return this}; +this.split||""===this.split?a.split(this.split):a;for(let g=0,e,h;gthis.maxlength))if(d)b.push(e);else if(!this.filter||("function"===typeof this.filter?this.filter(e):!this.filter.has(e))){if(this.cache&&e.length<=this.o)if(this.l){var c=this.j.get(e);if(c||""===c){c&&b.push(c);continue}}else this.l=setTimeout(G,50,this);this.stemmer&&2this.stemmer.get(k)), +c!==e&&this.filter&&e.length>=this.minlength&&("function"===typeof this.filter?!this.filter(e):this.filter.has(e))&&(e=""));if(e&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(e&&this.replacer)for(c=0;e&&cthis.A&&(this.j.clear(),this.o=this.o/1.1|0));e&&b.push(e)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.m&&(this.i.set(a,b),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return b};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,d,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>d?d?a.slice(b,b+d):a.slice(b):a;let f=[];for(let c=0,g,e;c=e){b-=e;continue}bd&&(g=g.slice(0,d),e=d);if(!f.length&&e>=d)return g;f.push(g);d-=e;if(!d)break}return f=1c.length)c.pop();else{const g=c.indexOf(a);g===b.length-1?c.pop():c.splice(g,1)}}else J(this.map,a),this.depth&&J(this.ctx,a);d||this.reg.delete(a)}return this}; function J(a,d){let b=0;var f="undefined"===typeof d;if(a.constructor===Array)for(let c=0,g,e;cq;g--){e=l.substring(q,g);t=this.rtl?c-1-q:q;var h=this.score?this.score(d,l,p,e,t):L(D,f,p,c,t);M(this, m,e,h,a,b)}break}case "bidirectional":case "reverse":if(1e?0:1),f,p,h-1,k-1), -t=this.bidirectional&&l>g;M(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,d,b,f,c,g,e){let h=e?a.ctx:a.map,k;if(!d[b]||e&&!(k=d[b])[e])e?(d=k||(d[b]=w()),d[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):d[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(c)||(h.push(c),a.fastupdate&&((d=a.reg.get(c))?d.push(h):a.reg.set(c,[h])))}function L(a,d,b,f,c){return b&&1d||c?e.slice(c,d+c):e;e=a}else{if(ad||c)e=e.slice(c,d+c)}m=e}else if(1===f){d=H.call(null, -a[0],d,c);break a}d=m}return d};function N(a,d,b){let f;b&&(f=a.bidirectional&&d>b)&&(f=b,b=d,d=f);a=b?(a=a.ctx.get(b))&&a.get(d):a.map.get(d);return a};function I(a,d){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},c=a.encode||a.encoder||{};this.encoder=c.encode?c:"object"===typeof c?new F(c):{encode:c};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= +t=this.bidirectional&&l>g;M(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function M(a,d,b,f,c,g,e){let h=e?a.ctx:a.map,k;if(!d[b]||e&&!(k=d[b])[e])e?(d=k||(d[b]=w()),d[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):d[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(c)||(h.push(c),a.fastupdate&&((d=a.reg.get(c))?d.push(h):a.reg.set(c,[h])))}function L(a,d,b,f,c){return b&&1d||c?e.slice(c,d+c):e;e=a}else{if(ad||c)e=e.slice(c,d+c)}m=e}else if(1===f){d=H.call(null,a[0], +d,c);break a}d=m}return d};function N(a,d,b){let f;b&&(f=a.bidirectional&&d>b)&&(f=b,b=d,d=f);a=b?(a=a.ctx.get(b))&&a.get(d):a.map.get(d);return a};function I(a,d){if(!this||this.constructor!==I)return new I(a);if(a){var b="string"===typeof a?a:a.preset;b&&(a=Object.assign({},K[b],a))}else a={};b=a.context;const f=!0===b?{depth:1}:b||{},c=a.encode||a.encoder||{};this.encoder=c.encode?c:"object"===typeof c?new F(c):{encode:c};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&"default"!==b&&"exact"!==b&&b||"strict";this.depth="strict"===b&&f.depth||0;this.bidirectional=!1!==f.bidirectional;this.fastupdate=!!a.fastupdate;this.score= a.score||null;this.map=new Map;this.ctx=new Map;this.reg=d||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=c.rtl||a.rtl||!1}r=I.prototype;r.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};r.append=function(a,d){return this.add(a,d,!0)};r.contain=function(a){return this.reg.has(a)};r.update=function(a,d){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,d)):this.add(a,d)}; r.cleanup=function(){if(!this.fastupdate)return this;J(this.map);this.depth&&J(this.ctx);return this};w();export default {Index:I,Charset:null,Encoder:F,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}}; export const Index=I;export const Charset=null;export const Encoder=F;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file diff --git a/dist/module-debug/bundle.js b/dist/module-debug/bundle.js index 19a3757..6ec120b 100644 --- a/dist/module-debug/bundle.js +++ b/dist/module-debug/bundle.js @@ -116,16 +116,19 @@ import { KeystoreMap, KeystoreArray, KeystoreSet } from "./keystore.js"; /** @export */KeystoreMap.size; /** @export */KeystoreSet.size; -/** @export */Charset.LatinExact; -/** @export */Charset.LatinDefault; -/** @export */Charset.LatinSimple; +/** @export */Charset.Exact; +/** @export */Charset.Default; +/** @export */Charset.Normalize; /** @export */Charset.LatinBalance; /** @export */Charset.LatinAdvanced; /** @export */Charset.LatinExtra; /** @export */Charset.LatinSoundex; -/** @export */Charset.ArabicDefault; -/** @export */Charset.CjkDefault; -/** @export */Charset.CyrillicDefault; +/** @export @deprecated */Charset.LatinExact; +/** @export @deprecated */Charset.LatinDefault; +/** @export @deprecated */Charset.LatinSimple; +/** @export @deprecated */Charset.ArabicDefault; +/** @export @deprecated */Charset.CjkDefault; +/** @export @deprecated */Charset.CyrillicDefault; /** @export */IndexOptions.preset; /** @export */IndexOptions.context; diff --git a/dist/module-debug/charset.js b/dist/module-debug/charset.js index 3f4c1ec..812089f 100644 --- a/dist/module-debug/charset.js +++ b/dist/module-debug/charset.js @@ -1,36 +1,36 @@ -import charset_latin_exact from "./charset/latin/exact.js"; -import charset_latin_normalize from "./charset/latin/normalize.js"; +import charset_exact from "./charset/exact.js"; +import charset_normalize from "./charset/normalize.js"; import charset_latin_balance from "./charset/latin/balance.js"; import charset_latin_advanced from "./charset/latin/advanced.js"; import charset_latin_extra from "./charset/latin/extra.js"; import charset_latin_soundex from "./charset/latin/soundex.js"; // universal charset -export const Exact = charset_latin_exact; -export const Default = charset_latin_normalize; -export const Normalize = charset_latin_normalize; +export const Exact = charset_exact; +export const Default = charset_normalize; +export const Normalize = charset_normalize; // latin charset export const LatinBalance = charset_latin_balance; export const LatinAdvanced = charset_latin_advanced; export const LatinExtra = charset_latin_extra; export const LatinSoundex = charset_latin_soundex; // deprecated -export const LatinExact = charset_latin_exact; -export const LatinDefault = charset_latin_normalize; -export const LatinSimple = charset_latin_normalize; +export const LatinExact = charset_exact; +export const LatinDefault = charset_normalize; +export const LatinSimple = charset_normalize; export default { // universal charset - Exact: charset_latin_exact, - Default: charset_latin_normalize, - Normalize: charset_latin_normalize, + Exact: charset_exact, + Default: charset_normalize, + Normalize: charset_normalize, // latin charset LatinBalance: charset_latin_balance, LatinAdvanced: charset_latin_advanced, LatinExtra: charset_latin_extra, LatinSoundex: charset_latin_soundex, // deprecated - LatinExact: charset_latin_exact, - LatinDefault: charset_latin_normalize, - LatinSimple: charset_latin_normalize + LatinExact: charset_exact, + LatinDefault: charset_normalize, + LatinSimple: charset_normalize }; \ No newline at end of file diff --git a/dist/module/charset/latin/exact.js b/dist/module-debug/charset/exact.js similarity index 66% rename from dist/module/charset/latin/exact.js rename to dist/module-debug/charset/exact.js index e51f713..29c26bb 100644 --- a/dist/module/charset/latin/exact.js +++ b/dist/module-debug/charset/exact.js @@ -1,9 +1,10 @@ -import { EncoderOptions } from "../../type.js"; +import { EncoderOptions } from "../type.js"; /** @type EncoderOptions */ const options = { normalize: !1, - numeric: !1 + numeric: !1, + dedupe: !1 //split: /\s+/ //normalize: false, //dedupe: false diff --git a/dist/module-debug/charset/latin/advanced.js b/dist/module-debug/charset/latin/advanced.js index 5d4003c..e20e3d9 100644 --- a/dist/module-debug/charset/latin/advanced.js +++ b/dist/module-debug/charset/latin/advanced.js @@ -18,7 +18,7 @@ export const replacer = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /** @type EncoderOptions */ const options = { //normalize: true, - dedupe: !0, + //dedupe: true, mapper: soundex, matcher: matcher, replacer: replacer diff --git a/dist/module-debug/charset/latin/balance.js b/dist/module-debug/charset/latin/balance.js index bae3dea..6eb1be8 100644 --- a/dist/module-debug/charset/latin/balance.js +++ b/dist/module-debug/charset/latin/balance.js @@ -31,7 +31,7 @@ export const soundex = new Map([["b", "p"], /** @type EncoderOptions */ const options = { //normalize: true, - dedupe: !0, + //dedupe: true, mapper: soundex }; export default options; \ No newline at end of file diff --git a/dist/module-debug/charset/latin/extra.js b/dist/module-debug/charset/latin/extra.js index 10a41b9..4498453 100644 --- a/dist/module-debug/charset/latin/extra.js +++ b/dist/module-debug/charset/latin/extra.js @@ -8,7 +8,7 @@ export const compact = [/(?!^)[aeo]/g, "" // before soundex: aeoy, old: aioy /** @type EncoderOptions */ const options = { //normalize: true, - dedupe: !0, + //dedupe: true, mapper: soundex, replacer: replacer.concat(compact), matcher: matcher diff --git a/dist/module/charset/latin/normalize.js b/dist/module-debug/charset/normalize.js similarity index 80% rename from dist/module/charset/latin/normalize.js rename to dist/module-debug/charset/normalize.js index e9557b2..1c971e5 100644 --- a/dist/module/charset/latin/normalize.js +++ b/dist/module-debug/charset/normalize.js @@ -1,4 +1,4 @@ -import { EncoderOptions } from "../../type.js"; +import { EncoderOptions } from "../type.js"; /** @type EncoderOptions */ const options = { diff --git a/dist/module-debug/document/search.js b/dist/module-debug/document/search.js index 9a923fc..8f2a8cc 100644 --- a/dist/module-debug/document/search.js +++ b/dist/module-debug/document/search.js @@ -47,6 +47,7 @@ Document.prototype.search = function (query, limit, options, _promises) { /** @type { * DocumentSearchResults| * EnrichedDocumentSearchResults| + * MergedDocumentSearchResults| * SearchResults| * IntermediateSearchResults| * EnrichedSearchResults @@ -382,7 +383,8 @@ Document.prototype.search = function (query, limit, options, _promises) { return resolve ? result : new Resolver(result); } if (pluck && (!enrich || !this.store)) { - return result[0]; + return (/** @type {SearchResults} */result[0] + ); } promises = []; @@ -399,18 +401,19 @@ Document.prototype.search = function (query, limit, options, _promises) { res = apply_enrich.call(this, res); // } } else { + // todo // the documents are stored on the first field promises.push(res = this.index.get(this.field[0]).db.enrich(res)); } } if (pluck) { - return resolve ? res : new Resolver(res); + return resolve ? /** @type {SearchResults|EnrichedSearchResults} */res : new Resolver( /** @type {IntermediateSearchResults} */res); } result[i] = { field: result_field[i], - result: res + result: /** @type {SearchResults|EnrichedSearchResults} */res }; } @@ -420,61 +423,75 @@ Document.prototype.search = function (query, limit, options, _promises) { for (let j = 0; j < promises.length; j++) { result[j].result = promises[j]; } - return merge ? merge_fields(result, /** @type {number} */limit, offset) : highlight ? highlight_fields(result, query, self.index, self.field, self.tree, highlight, limit, offset) : result; + return merge ? merge_fields(result) : highlight ? highlight_fields(result, /** @type {string} */query, self.index, self.field, self.tree, highlight) : /** @type {DocumentSearchResults} */result; }); } - return merge ? merge_fields(result, limit, offset) : highlight ? highlight_fields(result, query, this.index, this.field, this.tree, highlight, limit, offset) : result; + return merge ? merge_fields(result) : highlight ? highlight_fields(result, /** @type {string} */query, this.index, this.field, this.tree, highlight) : /** @type {DocumentSearchResults} */result; }; -/* - - karmen or clown or not found -[Carmen]cita - Le [clown] et ses chiens - +/** + * @param {EnrichedDocumentSearchResults} result + * @param {string} query + * @param {Map} index + * @param {string} field + * @param {Array} tree + * @param {string} template + * @return {EnrichedDocumentSearchResults} */ - function highlight_fields(result, query, index, field, tree, template) { + // The biggest issue is dealing with custom encoders, for this reason + // a regular expression can't apply + // Todo: when one of the basic encoders was used, provide + // combined regex + // // if(typeof template === "string"){ // template = new RegExp(template, "g"); // } - //console.log("template", template) + let encoder, query_enc, tokenize; - for (let i = 0, res_field, enc, idx, path, res; i < result.length; i++) { - - /** @type {SearchResults|EnrichedSearchResults} */ - res = result[i].result; + // for every field + for (let i = 0, res_field, enc, idx, path; i < result.length; i++) { res_field = result[i].field; + // skip when not a field entry (e.g. tags) + if (!res_field) continue; + + /** @type {EnrichedSearchResults} */ + let res = result[i].result; idx = index.get(res_field); enc = idx.encoder; tokenize = idx.tokenize; path = tree[field.indexOf(res_field)]; + // re-encode query when encoder has changed if (enc !== encoder) { encoder = enc; query_enc = encoder.encode(query); } + // for every doc in results for (let j = 0; j < res.length; j++) { let str = "", content = parse_simple(res[j].doc, path), doc_org = content.split(/\s+/); //let doc_enc = encoder.encode(content); + // loop terms of encoded doc content for (let k = 0, doc_org_cur, doc_enc_cur; k < doc_org.length; k++) { doc_org_cur = doc_org[k]; //doc_enc_cur = doc_enc[k]; - doc_enc_cur = encoder.encode(doc_org_cur).join(" "); + doc_enc_cur = enc.encode(doc_org_cur); + doc_enc_cur = 1 < doc_enc_cur.length ? doc_enc_cur.join(" ") : doc_enc_cur[0]; let found; if (doc_enc_cur && doc_org_cur) { + // loop terms of encoded query content for (let l = 0, query_enc_cur; l < query_enc.length; l++) { query_enc_cur = query_enc[l]; // todo tokenize could be custom also when "strict" was used @@ -523,12 +540,10 @@ function highlight_fields(result, query, index, field, tree, template) { /** * @param {DocumentSearchResults} fields - * @param {number=} limit - * @param {number=} offset * @return {MergedDocumentSearchResults} */ -function merge_fields(fields, limit) { - /** @type {Array} */ +function merge_fields(fields) { + /** @type {MergedDocumentSearchResults} */ const final = [], set = create_object(); @@ -539,23 +554,11 @@ function merge_fields(fields, limit) { entry = res[j]; // upgrade flat results if ("object" != typeof entry) { - entry = { - id: entry - }; + entry = { id: entry }; } id = entry.id; tmp = set[id]; if (!tmp) { - // offset was already applied on field indexes - // if(offset){ - // offset--; - // continue; - // } - // apply limit from last round, because just fields could - // be pushed without adding new results - if (final.length === limit) { - return final; - } entry.field = set[id] = [field.field]; final.push( /** @type {MergedDocumentSearchEntry} */entry); } else { diff --git a/dist/module-debug/encoder.js b/dist/module-debug/encoder.js index b08389b..6eb4124 100644 --- a/dist/module-debug/encoder.js +++ b/dist/module-debug/encoder.js @@ -188,13 +188,13 @@ Encoder.prototype.assign = function (options) { tmp = options.filter; this.filter = "function" == typeof tmp ? tmp : merge_option(tmp && new Set(tmp), null, this.filter); - this.dedupe = merge_option(options.dedupe, !1, this.dedupe); + this.dedupe = merge_option(options.dedupe, !0, this.dedupe); this.matcher = merge_option((tmp = options.matcher) && new Map(tmp), null, this.matcher); this.mapper = merge_option((tmp = options.mapper) && new Map(tmp), null, this.mapper); this.stemmer = merge_option((tmp = options.stemmer) && new Map(tmp), null, this.stemmer); this.replacer = merge_option(options.replacer, null, this.replacer); this.minlength = merge_option(options.minlength, 1, this.minlength); - this.maxlength = merge_option(options.maxlength, 0, this.maxlength); + this.maxlength = merge_option(options.maxlength, 1024, this.maxlength); this.rtl = merge_option(options.rtl, !1, this.rtl); // auto-balanced cache @@ -396,7 +396,7 @@ Encoder.prototype.encode = function (str) { if (!(word = base = words[i])) { continue; } - if (word.length < this.minlength) { + if (word.length < this.minlength || word.length > this.maxlength) { continue; } if (skip) { diff --git a/dist/module-debug/index/search.js b/dist/module-debug/index/search.js index e6ba8b8..695f0d4 100644 --- a/dist/module-debug/index/search.js +++ b/dist/module-debug/index/search.js @@ -26,10 +26,10 @@ import resolve_default from "../resolve/default.js"; Index.prototype.search = function (query, limit, options) { if (!options) { - if (!limit && is_object(query)) { + if (!limit && "object" == typeof query) { options = /** @type {!SearchOptions} */query; query = ""; - } else if (is_object(limit)) { + } else if ("object" == typeof limit) { options = /** @type {!SearchOptions} */limit; limit = 0; } @@ -188,21 +188,21 @@ Index.prototype.search = function (query, limit, options) { keyword; - if (1 < length) { - if (context) { - // start with context right away - keyword = query_terms[0]; - index = 1; - } - // todo - // else if(maxlength > 9 && (maxlength / minlength) > 3){ - // // sorting terms will break the context chain - // // bigger terms has less occurrence - // // this might also reduce the intersection task - // // todo check intersection order - // query_terms.sort(sort_by_length_down); - // } + //if(length > 1){ + if (context) { + // start with context right away + keyword = query_terms[0]; + index = 1; } + // todo + // else if(maxlength > 9 && (maxlength / minlength) > 3){ + // // sorting terms will break the context chain + // // bigger terms has less occurrence + // // this might also reduce the intersection task + // // todo check intersection order + // query_terms.sort(sort_by_length_down); + // } + //} if (!resolution && 0 !== resolution) { resolution = keyword ? this.resolution_ctx : this.resolution; diff --git a/dist/module-debug/type.js b/dist/module-debug/type.js index 0bc2652..768bbc8 100644 --- a/dist/module-debug/type.js +++ b/dist/module-debug/type.js @@ -1,5 +1,6 @@ // When you are looking for type definitions which fully describes the usage take a look into the index.d.ts file. // Some of the types here aren't supposed to be used as public, they might be defined just for internal state. + import Index from "./index.js"; import Encoder from "./encoder.js"; import StorageInterface from "./db/interface.js"; @@ -141,7 +142,7 @@ export let SearchOptions = {}; * index: (Array|Array|DocumentSearchOptions|string|undefined), * pluck: (string|DocumentSearchOptions|undefined), * merge: (boolean|undefined), - * highlight: (string|undefined), + * highlight: (string|undefined) * }} */ export let DocumentSearchOptions = {}; @@ -153,7 +154,7 @@ export let DocumentSearchOptions = {}; export let SearchResults = []; /** - * @typedef Array> + * @typedef Array * @global */ export let IntermediateSearchResults = []; @@ -161,7 +162,8 @@ export let IntermediateSearchResults = []; /** * @typedef Array<{ * id: (number|string), - * doc: (Object|null) + * doc: (Object|null), + * highlight: (string|undefined) * }> */ export let EnrichedSearchResults = []; @@ -179,8 +181,7 @@ export let DocumentSearchResults = []; * @typedef Array<{ * field: (string|undefined), * tag: (string|undefined), - * highlight: (string|undefined), - * result: {EnrichedSearchResults} + * result: EnrichedSearchResults * }> */ export let EnrichedDocumentSearchResults = []; diff --git a/dist/module-min/bundle.js b/dist/module-min/bundle.js index 0d916b2..b087aef 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";import{KeystoreMap,KeystoreArray,KeystoreSet}from"./keystore.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.encoder,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,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,KeystoreArray.length,KeystoreMap.size,KeystoreSet.size,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,IndexOptions.export,IndexOptions.import,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,DocumentOptions.export,DocumentOptions.import,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,DocumentDescriptor.id,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,ResolverOptions.pluck,ResolverOptions.field;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{const a="undefined"==typeof self?"undefined"==typeof global?self:global: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";import{KeystoreMap,KeystoreArray,KeystoreSet}from"./keystore.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.encoder,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,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,KeystoreArray.length,KeystoreMap.size,KeystoreSet.size,Charset.Exact,Charset.Default,Charset.Normalize,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,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,IndexOptions.export,IndexOptions.import,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,DocumentOptions.export,DocumentOptions.import,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,DocumentDescriptor.id,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,ResolverOptions.pluck,ResolverOptions.field;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{const a="undefined"==typeof self?"undefined"==typeof global?self:global: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.js b/dist/module-min/charset.js index 3d423d8..4993ae6 100644 --- a/dist/module-min/charset.js +++ b/dist/module-min/charset.js @@ -1 +1 @@ -import charset_latin_exact from"./charset/latin/exact.js";import charset_latin_normalize from"./charset/latin/normalize.js";import charset_latin_balance from"./charset/latin/balance.js";import charset_latin_advanced from"./charset/latin/advanced.js";import charset_latin_extra from"./charset/latin/extra.js";import charset_latin_soundex from"./charset/latin/soundex.js";export const Exact=charset_latin_exact;export const Default=charset_latin_normalize;export const Normalize=charset_latin_normalize;export const LatinBalance=charset_latin_balance;export const LatinAdvanced=charset_latin_advanced;export const LatinExtra=charset_latin_extra;export const LatinSoundex=charset_latin_soundex;export const LatinExact=charset_latin_exact;export const LatinDefault=charset_latin_normalize;export const LatinSimple=charset_latin_normalize;export default{Exact:charset_latin_exact,Default:charset_latin_normalize,Normalize:charset_latin_normalize,LatinBalance:charset_latin_balance,LatinAdvanced:charset_latin_advanced,LatinExtra:charset_latin_extra,LatinSoundex:charset_latin_soundex,LatinExact:charset_latin_exact,LatinDefault:charset_latin_normalize,LatinSimple:charset_latin_normalize}; \ No newline at end of file +import charset_exact from"./charset/exact.js";import charset_normalize from"./charset/normalize.js";import charset_latin_balance from"./charset/latin/balance.js";import charset_latin_advanced from"./charset/latin/advanced.js";import charset_latin_extra from"./charset/latin/extra.js";import charset_latin_soundex from"./charset/latin/soundex.js";export const Exact=charset_exact;export const Default=charset_normalize;export const Normalize=charset_normalize;export const LatinBalance=charset_latin_balance;export const LatinAdvanced=charset_latin_advanced;export const LatinExtra=charset_latin_extra;export const LatinSoundex=charset_latin_soundex;export const LatinExact=charset_exact;export const LatinDefault=charset_normalize;export const LatinSimple=charset_normalize;export default{Exact:charset_exact,Default:charset_normalize,Normalize:charset_normalize,LatinBalance:charset_latin_balance,LatinAdvanced:charset_latin_advanced,LatinExtra:charset_latin_extra,LatinSoundex:charset_latin_soundex,LatinExact:charset_exact,LatinDefault:charset_normalize,LatinSimple:charset_normalize}; \ No newline at end of file diff --git a/dist/module-min/charset/exact.js b/dist/module-min/charset/exact.js new file mode 100644 index 0000000..6150229 --- /dev/null +++ b/dist/module-min/charset/exact.js @@ -0,0 +1 @@ +import{EncoderOptions}from"../type.js";const options={normalize:!1,numeric:!1,dedupe:!1};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/latin/advanced.js b/dist/module-min/charset/latin/advanced.js index 0296417..7f41438 100644 --- a/dist/module-min/charset/latin/advanced.js +++ b/dist/module-min/charset/latin/advanced.js @@ -1 +1 @@ -import{EncoderOptions}from"../../type.js";import{soundex}from"./balance.js";export const matcher=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]);export const replacer=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const options={dedupe:!0,mapper:soundex,matcher:matcher,replacer:replacer};export default options; \ No newline at end of file +import{EncoderOptions}from"../../type.js";import{soundex}from"./balance.js";export const matcher=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]);export const replacer=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const options={mapper:soundex,matcher:matcher,replacer:replacer};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/latin/balance.js b/dist/module-min/charset/latin/balance.js index ad5d1db..8ffd818 100644 --- a/dist/module-min/charset/latin/balance.js +++ b/dist/module-min/charset/latin/balance.js @@ -1 +1 @@ -import{EncoderOptions}from"../../type.js";export const soundex=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 options={dedupe:!0,mapper:soundex};export default options; \ No newline at end of file +import{EncoderOptions}from"../../type.js";export const soundex=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 options={mapper:soundex};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/latin/exact.js b/dist/module-min/charset/latin/exact.js deleted file mode 100644 index 46a2217..0000000 --- a/dist/module-min/charset/latin/exact.js +++ /dev/null @@ -1 +0,0 @@ -import{EncoderOptions}from"../../type.js";const options={normalize:!1,numeric:!1};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/latin/extra.js b/dist/module-min/charset/latin/extra.js index 8c3b3fe..b3616eb 100644 --- a/dist/module-min/charset/latin/extra.js +++ b/dist/module-min/charset/latin/extra.js @@ -1 +1 @@ -import{EncoderOptions}from"../../type.js";import{soundex}from"./balance.js";import{matcher,replacer}from"./advanced.js";export const compact=[/(?!^)[aeo]/g,""];const options={dedupe:!0,mapper:soundex,replacer:replacer.concat(compact),matcher:matcher};export default options; \ No newline at end of file +import{EncoderOptions}from"../../type.js";import{soundex}from"./balance.js";import{matcher,replacer}from"./advanced.js";export const compact=[/(?!^)[aeo]/g,""];const options={mapper:soundex,replacer:replacer.concat(compact),matcher:matcher};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/latin/normalize.js b/dist/module-min/charset/latin/normalize.js deleted file mode 100644 index 07081f7..0000000 --- a/dist/module-min/charset/latin/normalize.js +++ /dev/null @@ -1 +0,0 @@ -import{EncoderOptions}from"../../type.js";const options={};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/normalize.js b/dist/module-min/charset/normalize.js new file mode 100644 index 0000000..e2d6c5b --- /dev/null +++ b/dist/module-min/charset/normalize.js @@ -0,0 +1 @@ +import{EncoderOptions}from"../type.js";const options={};export default options; \ No newline at end of file diff --git a/dist/module-min/document/search.js b/dist/module-min/document/search.js index 45e0478..52442a0 100644 --- a/dist/module-min/document/search.js +++ b/dist/module-min/document/search.js @@ -1 +1 @@ -import{DocumentSearchOptions,DocumentSearchResults,EnrichedDocumentSearchResults,MergedDocumentSearchResults,MergedDocumentSearchEntry,EnrichedSearchResults,SearchResults,IntermediateSearchResults}from"../type.js";import{create_object,is_array,is_object,is_string,parse_simple}from"../common.js";import{intersect_union}from"../intersect.js";import Document from"../document.js";import Index from"../index.js";import Resolver from"../resolver.js";import tick from"../profiler.js";Document.prototype.search=function(a,b,c,d){!1,c||(!b&&is_object(a)?(c=a,a=""):is_object(b)&&(c=b,b=0));let e,f,g,h,j,k,l,m,n=[],o=[],p=0,q=!0;if(c){if(is_array(c)&&(c={index:c}),a=c.query||a,e=c.pluck,g=c.merge,j=e||c.field||(j=c.index)&&(j.index?null:j),k=this.tag&&c.tag,h=c.suggest,q=!1!==c.resolve,(q||e||(j=j||this.field,j&&(is_string(j)?e=j:(is_array(j)&&1===j.length&&(j=j[0]),e=j.field||j.index))),!1,f=this.store&&c.enrich&&q,m=f&&c.highlight,b=c.limit||b,l=c.offset||0,b||(b=100),k&&(!this.db||!d))){!1,k.constructor!==Array&&(k=[k]);let c=[];for(let a,b=0;b"a1a".split(d).length;this.numeric=merge_option(a.numeric,b)}else{try{this.split=merge_option(this.split,whitespace)}catch(a){!1,this.split=/\s+/}this.numeric=merge_option(a.numeric,merge_option(this.numeric,!0))}if(this.prepare=merge_option(a.prepare,null,this.prepare),this.finalize=merge_option(a.finalize,null,this.finalize),d=a.filter,this.filter="function"==typeof d?d:merge_option(d&&new Set(d),null,this.filter),this.dedupe=merge_option(a.dedupe,!1,this.dedupe),this.matcher=merge_option((d=a.matcher)&&new Map(d),null,this.matcher),this.mapper=merge_option((d=a.mapper)&&new Map(d),null,this.mapper),this.stemmer=merge_option((d=a.stemmer)&&new Map(d),null,this.stemmer),this.replacer=merge_option(a.replacer,null,this.replacer),this.minlength=merge_option(a.minlength,1,this.minlength),this.maxlength=merge_option(a.maxlength,0,this.maxlength),this.rtl=merge_option(a.rtl,!1,this.rtl),this.cache=d=merge_option(a.cache,!0,this.cache),d&&(this.timer=null,this.cache_size="number"==typeof d?d:2e5,this.cache_enc=new Map,this.cache_term=new Map,this.cache_enc_length=128,this.cache_term_length=128),this.matcher_str="",this.matcher_test=null,this.stemmer_str="",this.stemmer_test=null,this.matcher)for(const a of this.matcher.keys())this.matcher_str+=(this.matcher_str?"|":"")+a;if(this.stemmer)for(const a of this.stemmer.keys())this.stemmer_str+=(this.stemmer_str?"|":"")+a;return this},Encoder.prototype.addStemmer=function(a,b){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(a,b),this.stemmer_str+=(this.stemmer_str?"|":"")+a,this.stemmer_test=null,this.cache&&clear(this),this},Encoder.prototype.addFilter=function(a){return"function"==typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a)),this.cache&&clear(this),this},Encoder.prototype.addMapper=function(a,b){return"object"==typeof a?this.addReplacer(a,b):1a.length&&(this.dedupe||this.mapper)?this.addMapper(a,b):(this.matcher||(this.matcher=new Map),this.matcher.set(a,b),this.matcher_str+=(this.matcher_str?"|":"")+a,this.matcher_test=null,this.cache&&clear(this),this)},Encoder.prototype.addReplacer=function(a,b){return"string"==typeof a?this.addMatcher(a,b):(this.replacer||(this.replacer=[]),this.replacer.push(a,b),this.cache&&clear(this),this)},Encoder.prototype.encode=function(a){if(this.cache&&a.length<=this.cache_enc_length)if(!this.timer)this.timer=setTimeout(clear,50,this);else if(this.cache_enc.has(a))return this.cache_enc.get(a);this.normalize&&("function"==typeof this.normalize?a=this.normalize(a):normalize?a=a.normalize("NFKD").replace(normalize,"").toLowerCase():a=a.toLowerCase()),this.prepare&&(a=this.prepare(a)),this.numeric&&3this.stemmer.get(a)),a!==e&&this.filter&&e.length>=this.minlength&&("function"==typeof this.filter?!this.filter(e):this.filter.has(e))&&(e="")}if(e&&(this.mapper||this.dedupe&&1this.matcher.get(a))),e&&this.replacer)for(let a=0;e&&athis.cache_size&&(this.cache_term.clear(),this.cache_term_length=0|this.cache_term_length/1.1)),e&&c.push(e)}}return this.finalize&&(c=this.finalize(c)||c),this.cache&&a.length<=this.cache_enc_length&&(this.cache_enc.set(a,c),this.cache_enc.size>this.cache_size&&(this.cache_enc.clear(),this.cache_enc_length=0|this.cache_enc_length/1.1)),c};export function fallback_encoder(a){return a.normalize("NFKD").replace(normalize,"").toLowerCase().trim().split(/\s+/)}function clear(a){a.timer=null,a.cache_enc.clear(),a.cache_term.clear()} \ No newline at end of file +import{merge_option}from"./common.js";import normalize_polyfill from"./charset/polyfill.js";import{EncoderOptions}from"./type.js";const whitespace=/[^\p{L}\p{N}]+/u,numeric_split_length=/(\d{3})/g,numeric_split_prev_char=/(\D)(\d{3})/g,numeric_split_next_char=/(\d{3})(\D)/g,normalize=/[\u0300-\u036f]/g;export default function Encoder(a={}){if(!this||this.constructor!==Encoder)return new Encoder(...arguments);if(arguments.length)for(let a=0;a"a1a".split(d).length;this.numeric=merge_option(a.numeric,b)}else{try{this.split=merge_option(this.split,whitespace)}catch(a){!1,this.split=/\s+/}this.numeric=merge_option(a.numeric,merge_option(this.numeric,!0))}if(this.prepare=merge_option(a.prepare,null,this.prepare),this.finalize=merge_option(a.finalize,null,this.finalize),d=a.filter,this.filter="function"==typeof d?d:merge_option(d&&new Set(d),null,this.filter),this.dedupe=merge_option(a.dedupe,!0,this.dedupe),this.matcher=merge_option((d=a.matcher)&&new Map(d),null,this.matcher),this.mapper=merge_option((d=a.mapper)&&new Map(d),null,this.mapper),this.stemmer=merge_option((d=a.stemmer)&&new Map(d),null,this.stemmer),this.replacer=merge_option(a.replacer,null,this.replacer),this.minlength=merge_option(a.minlength,1,this.minlength),this.maxlength=merge_option(a.maxlength,1024,this.maxlength),this.rtl=merge_option(a.rtl,!1,this.rtl),this.cache=d=merge_option(a.cache,!0,this.cache),d&&(this.timer=null,this.cache_size="number"==typeof d?d:2e5,this.cache_enc=new Map,this.cache_term=new Map,this.cache_enc_length=128,this.cache_term_length=128),this.matcher_str="",this.matcher_test=null,this.stemmer_str="",this.stemmer_test=null,this.matcher)for(const a of this.matcher.keys())this.matcher_str+=(this.matcher_str?"|":"")+a;if(this.stemmer)for(const a of this.stemmer.keys())this.stemmer_str+=(this.stemmer_str?"|":"")+a;return this},Encoder.prototype.addStemmer=function(a,b){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(a,b),this.stemmer_str+=(this.stemmer_str?"|":"")+a,this.stemmer_test=null,this.cache&&clear(this),this},Encoder.prototype.addFilter=function(a){return"function"==typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a)),this.cache&&clear(this),this},Encoder.prototype.addMapper=function(a,b){return"object"==typeof a?this.addReplacer(a,b):1a.length&&(this.dedupe||this.mapper)?this.addMapper(a,b):(this.matcher||(this.matcher=new Map),this.matcher.set(a,b),this.matcher_str+=(this.matcher_str?"|":"")+a,this.matcher_test=null,this.cache&&clear(this),this)},Encoder.prototype.addReplacer=function(a,b){return"string"==typeof a?this.addMatcher(a,b):(this.replacer||(this.replacer=[]),this.replacer.push(a,b),this.cache&&clear(this),this)},Encoder.prototype.encode=function(a){if(this.cache&&a.length<=this.cache_enc_length)if(!this.timer)this.timer=setTimeout(clear,50,this);else if(this.cache_enc.has(a))return this.cache_enc.get(a);this.normalize&&("function"==typeof this.normalize?a=this.normalize(a):normalize?a=a.normalize("NFKD").replace(normalize,"").toLowerCase():a=a.toLowerCase()),this.prepare&&(a=this.prepare(a)),this.numeric&&3this.maxlength)){if(b){c.push(e);continue}if(!(this.filter&&("function"==typeof this.filter?!this.filter(e):this.filter.has(e)))){if(this.cache&&e.length<=this.cache_term_length)if(this.timer){const a=this.cache_term.get(e);if(a||""===a){a&&c.push(a);continue}}else this.timer=setTimeout(clear,50,this);if(this.stemmer&&2this.stemmer.get(a)),a!==e&&this.filter&&e.length>=this.minlength&&("function"==typeof this.filter?!this.filter(e):this.filter.has(e))&&(e="")}if(e&&(this.mapper||this.dedupe&&1this.matcher.get(a))),e&&this.replacer)for(let a=0;e&&athis.cache_size&&(this.cache_term.clear(),this.cache_term_length=0|this.cache_term_length/1.1)),e&&c.push(e)}}return this.finalize&&(c=this.finalize(c)||c),this.cache&&a.length<=this.cache_enc_length&&(this.cache_enc.set(a,c),this.cache_enc.size>this.cache_size&&(this.cache_enc.clear(),this.cache_enc_length=0|this.cache_enc_length/1.1)),c};export function fallback_encoder(a){return a.normalize("NFKD").replace(normalize,"").toLowerCase().trim().split(/\s+/)}function clear(a){a.timer=null,a.cache_enc.clear(),a.cache_term.clear()} \ No newline at end of file diff --git a/dist/module-min/index/search.js b/dist/module-min/index/search.js index 9304865..6ac44d4 100644 --- a/dist/module-min/index/search.js +++ b/dist/module-min/index/search.js @@ -1 +1 @@ -import{SearchOptions,SearchResults,EnrichedSearchResults,IntermediateSearchResults}from"../type.js";import{create_object,is_object,sort_by_length_down}from"../common.js";import Index from"../index.js";import default_compress from"../compress.js";import Resolver from"../resolver.js";import{intersect}from"../intersect.js";import resolve_default from"../resolve/default.js";Index.prototype.search=function(a,b,c){c||(!b&&is_object(a)?(c=a,a=""):is_object(b)&&(c=b,b=0));let d,e,f,g,h,i,j,k,l=[],m=0;c?(a=c.query||a,b=c.limit||b,m=c.offset||0,e=c.context,f=c.suggest,g=!1!==c.resolve,k=g&&c.enrich,i=c.boost,j=c.resolution,h=this.db&&c.tag):g=this.resolve;let n=this.encoder.encode(a);if(d=n.length,b=b||(g?100:0),1===d)return single_term_query.call(this,n[0],"",b,m,g,k,h);if(e=this.depth&&!1!==e,2===d&&e&&!f)return single_term_query.call(this,n[1],n[0],b,m,g,k,h);let o,p=create_object(),q=0;if(1b,i&&(i=b,b=a,a=i)),this.compress&&(a=default_compress(a),b&&(b=default_compress(b))),this.db)?this.db.get(a,b,c,d,e,f,g):(b?(h=this.ctx.get(b),h=h&&h.get(a)):h=this.map.get(a),h)}; \ No newline at end of file +import{SearchOptions,SearchResults,EnrichedSearchResults,IntermediateSearchResults}from"../type.js";import{create_object,is_object,sort_by_length_down}from"../common.js";import Index from"../index.js";import default_compress from"../compress.js";import Resolver from"../resolver.js";import{intersect}from"../intersect.js";import resolve_default from"../resolve/default.js";Index.prototype.search=function(a,b,c){c||(b||"object"!=typeof a?"object"==typeof b&&(c=b,b=0):(c=a,a=""));let d,e,f,g,h,i,j,k,l=[],m=0;c?(a=c.query||a,b=c.limit||b,m=c.offset||0,e=c.context,f=c.suggest,g=!1!==c.resolve,k=g&&c.enrich,i=c.boost,j=c.resolution,h=this.db&&c.tag):g=this.resolve;let n=this.encoder.encode(a);if(d=n.length,b=b||(g?100:0),1===d)return single_term_query.call(this,n[0],"",b,m,g,k,h);if(e=this.depth&&!1!==e,2===d&&e&&!f)return single_term_query.call(this,n[1],n[0],b,m,g,k,h);let o,p=create_object(),q=0;if(e&&(o=n[0],q=1),j||0===j||(j=o?this.resolution_ctx:this.resolution),this.db){if(this.db.search){const a=this.db.search(this,n,b,m,f,g,k,h);if(!1!==a)return a}const a=this;return async function(){for(let b,c;qb,i&&(i=b,b=a,a=i)),this.compress&&(a=default_compress(a),b&&(b=default_compress(b))),this.db)?this.db.get(a,b,c,d,e,f,g):(b?(h=this.ctx.get(b),h=h&&h.get(a)):h=this.map.get(a),h)}; \ No newline at end of file diff --git a/dist/module/bundle.js b/dist/module/bundle.js index 19a3757..6ec120b 100644 --- a/dist/module/bundle.js +++ b/dist/module/bundle.js @@ -116,16 +116,19 @@ import { KeystoreMap, KeystoreArray, KeystoreSet } from "./keystore.js"; /** @export */KeystoreMap.size; /** @export */KeystoreSet.size; -/** @export */Charset.LatinExact; -/** @export */Charset.LatinDefault; -/** @export */Charset.LatinSimple; +/** @export */Charset.Exact; +/** @export */Charset.Default; +/** @export */Charset.Normalize; /** @export */Charset.LatinBalance; /** @export */Charset.LatinAdvanced; /** @export */Charset.LatinExtra; /** @export */Charset.LatinSoundex; -/** @export */Charset.ArabicDefault; -/** @export */Charset.CjkDefault; -/** @export */Charset.CyrillicDefault; +/** @export @deprecated */Charset.LatinExact; +/** @export @deprecated */Charset.LatinDefault; +/** @export @deprecated */Charset.LatinSimple; +/** @export @deprecated */Charset.ArabicDefault; +/** @export @deprecated */Charset.CjkDefault; +/** @export @deprecated */Charset.CyrillicDefault; /** @export */IndexOptions.preset; /** @export */IndexOptions.context; diff --git a/dist/module/charset.js b/dist/module/charset.js index 3f4c1ec..812089f 100644 --- a/dist/module/charset.js +++ b/dist/module/charset.js @@ -1,36 +1,36 @@ -import charset_latin_exact from "./charset/latin/exact.js"; -import charset_latin_normalize from "./charset/latin/normalize.js"; +import charset_exact from "./charset/exact.js"; +import charset_normalize from "./charset/normalize.js"; import charset_latin_balance from "./charset/latin/balance.js"; import charset_latin_advanced from "./charset/latin/advanced.js"; import charset_latin_extra from "./charset/latin/extra.js"; import charset_latin_soundex from "./charset/latin/soundex.js"; // universal charset -export const Exact = charset_latin_exact; -export const Default = charset_latin_normalize; -export const Normalize = charset_latin_normalize; +export const Exact = charset_exact; +export const Default = charset_normalize; +export const Normalize = charset_normalize; // latin charset export const LatinBalance = charset_latin_balance; export const LatinAdvanced = charset_latin_advanced; export const LatinExtra = charset_latin_extra; export const LatinSoundex = charset_latin_soundex; // deprecated -export const LatinExact = charset_latin_exact; -export const LatinDefault = charset_latin_normalize; -export const LatinSimple = charset_latin_normalize; +export const LatinExact = charset_exact; +export const LatinDefault = charset_normalize; +export const LatinSimple = charset_normalize; export default { // universal charset - Exact: charset_latin_exact, - Default: charset_latin_normalize, - Normalize: charset_latin_normalize, + Exact: charset_exact, + Default: charset_normalize, + Normalize: charset_normalize, // latin charset LatinBalance: charset_latin_balance, LatinAdvanced: charset_latin_advanced, LatinExtra: charset_latin_extra, LatinSoundex: charset_latin_soundex, // deprecated - LatinExact: charset_latin_exact, - LatinDefault: charset_latin_normalize, - LatinSimple: charset_latin_normalize + LatinExact: charset_exact, + LatinDefault: charset_normalize, + LatinSimple: charset_normalize }; \ No newline at end of file diff --git a/dist/module-debug/charset/latin/exact.js b/dist/module/charset/exact.js similarity index 66% rename from dist/module-debug/charset/latin/exact.js rename to dist/module/charset/exact.js index e51f713..29c26bb 100644 --- a/dist/module-debug/charset/latin/exact.js +++ b/dist/module/charset/exact.js @@ -1,9 +1,10 @@ -import { EncoderOptions } from "../../type.js"; +import { EncoderOptions } from "../type.js"; /** @type EncoderOptions */ const options = { normalize: !1, - numeric: !1 + numeric: !1, + dedupe: !1 //split: /\s+/ //normalize: false, //dedupe: false diff --git a/dist/module/charset/latin/advanced.js b/dist/module/charset/latin/advanced.js index 5d4003c..e20e3d9 100644 --- a/dist/module/charset/latin/advanced.js +++ b/dist/module/charset/latin/advanced.js @@ -18,7 +18,7 @@ export const replacer = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /** @type EncoderOptions */ const options = { //normalize: true, - dedupe: !0, + //dedupe: true, mapper: soundex, matcher: matcher, replacer: replacer diff --git a/dist/module/charset/latin/balance.js b/dist/module/charset/latin/balance.js index bae3dea..6eb1be8 100644 --- a/dist/module/charset/latin/balance.js +++ b/dist/module/charset/latin/balance.js @@ -31,7 +31,7 @@ export const soundex = new Map([["b", "p"], /** @type EncoderOptions */ const options = { //normalize: true, - dedupe: !0, + //dedupe: true, mapper: soundex }; export default options; \ No newline at end of file diff --git a/dist/module/charset/latin/extra.js b/dist/module/charset/latin/extra.js index 10a41b9..4498453 100644 --- a/dist/module/charset/latin/extra.js +++ b/dist/module/charset/latin/extra.js @@ -8,7 +8,7 @@ export const compact = [/(?!^)[aeo]/g, "" // before soundex: aeoy, old: aioy /** @type EncoderOptions */ const options = { //normalize: true, - dedupe: !0, + //dedupe: true, mapper: soundex, replacer: replacer.concat(compact), matcher: matcher diff --git a/dist/module-debug/charset/latin/normalize.js b/dist/module/charset/normalize.js similarity index 80% rename from dist/module-debug/charset/latin/normalize.js rename to dist/module/charset/normalize.js index e9557b2..1c971e5 100644 --- a/dist/module-debug/charset/latin/normalize.js +++ b/dist/module/charset/normalize.js @@ -1,4 +1,4 @@ -import { EncoderOptions } from "../../type.js"; +import { EncoderOptions } from "../type.js"; /** @type EncoderOptions */ const options = { diff --git a/dist/module/document/search.js b/dist/module/document/search.js index 9dc606e..fba07da 100644 --- a/dist/module/document/search.js +++ b/dist/module/document/search.js @@ -47,6 +47,7 @@ Document.prototype.search = function (query, limit, options, _promises) { /** @type { * DocumentSearchResults| * EnrichedDocumentSearchResults| + * MergedDocumentSearchResults| * SearchResults| * IntermediateSearchResults| * EnrichedSearchResults @@ -362,7 +363,8 @@ Document.prototype.search = function (query, limit, options, _promises) { return resolve ? result : new Resolver(result); } if (pluck && (!enrich || !this.store)) { - return result[0]; + return (/** @type {SearchResults} */result[0] + ); } promises = []; @@ -379,18 +381,19 @@ Document.prototype.search = function (query, limit, options, _promises) { res = apply_enrich.call(this, res); // } } else { + // todo // the documents are stored on the first field promises.push(res = this.index.get(this.field[0]).db.enrich(res)); } } if (pluck) { - return resolve ? res : new Resolver(res); + return resolve ? /** @type {SearchResults|EnrichedSearchResults} */res : new Resolver( /** @type {IntermediateSearchResults} */res); } result[i] = { field: result_field[i], - result: res + result: /** @type {SearchResults|EnrichedSearchResults} */res }; } @@ -400,61 +403,75 @@ Document.prototype.search = function (query, limit, options, _promises) { for (let j = 0; j < promises.length; j++) { result[j].result = promises[j]; } - return merge ? merge_fields(result, /** @type {number} */limit, offset) : highlight ? highlight_fields(result, query, self.index, self.field, self.tree, highlight, limit, offset) : result; + return merge ? merge_fields(result) : highlight ? highlight_fields(result, /** @type {string} */query, self.index, self.field, self.tree, highlight) : /** @type {DocumentSearchResults} */result; }); } - return merge ? merge_fields(result, limit, offset) : highlight ? highlight_fields(result, query, this.index, this.field, this.tree, highlight, limit, offset) : result; + return merge ? merge_fields(result) : highlight ? highlight_fields(result, /** @type {string} */query, this.index, this.field, this.tree, highlight) : /** @type {DocumentSearchResults} */result; }; -/* - - karmen or clown or not found -[Carmen]cita - Le [clown] et ses chiens - +/** + * @param {EnrichedDocumentSearchResults} result + * @param {string} query + * @param {Map} index + * @param {string} field + * @param {Array} tree + * @param {string} template + * @return {EnrichedDocumentSearchResults} */ - function highlight_fields(result, query, index, field, tree, template) { + // The biggest issue is dealing with custom encoders, for this reason + // a regular expression can't apply + // Todo: when one of the basic encoders was used, provide + // combined regex + // // if(typeof template === "string"){ // template = new RegExp(template, "g"); // } - //console.log("template", template) + let encoder, query_enc, tokenize; - for (let i = 0, res_field, enc, idx, path, res; i < result.length; i++) { - - /** @type {SearchResults|EnrichedSearchResults} */ - res = result[i].result; + // for every field + for (let i = 0, res_field, enc, idx, path; i < result.length; i++) { res_field = result[i].field; + // skip when not a field entry (e.g. tags) + if (!res_field) continue; + + /** @type {EnrichedSearchResults} */ + let res = result[i].result; idx = index.get(res_field); enc = idx.encoder; tokenize = idx.tokenize; path = tree[field.indexOf(res_field)]; + // re-encode query when encoder has changed if (enc !== encoder) { encoder = enc; query_enc = encoder.encode(query); } + // for every doc in results for (let j = 0; j < res.length; j++) { let str = "", content = parse_simple(res[j].doc, path), doc_org = content.split(/\s+/); //let doc_enc = encoder.encode(content); + // loop terms of encoded doc content for (let k = 0, doc_org_cur, doc_enc_cur; k < doc_org.length; k++) { doc_org_cur = doc_org[k]; //doc_enc_cur = doc_enc[k]; - doc_enc_cur = encoder.encode(doc_org_cur).join(" "); + doc_enc_cur = enc.encode(doc_org_cur); + doc_enc_cur = 1 < doc_enc_cur.length ? doc_enc_cur.join(" ") : doc_enc_cur[0]; let found; if (doc_enc_cur && doc_org_cur) { + // loop terms of encoded query content for (let l = 0, query_enc_cur; l < query_enc.length; l++) { query_enc_cur = query_enc[l]; // todo tokenize could be custom also when "strict" was used @@ -503,12 +520,10 @@ function highlight_fields(result, query, index, field, tree, template) { /** * @param {DocumentSearchResults} fields - * @param {number=} limit - * @param {number=} offset * @return {MergedDocumentSearchResults} */ -function merge_fields(fields, limit) { - /** @type {Array} */ +function merge_fields(fields) { + /** @type {MergedDocumentSearchResults} */ const final = [], set = create_object(); @@ -519,23 +534,11 @@ function merge_fields(fields, limit) { entry = res[j]; // upgrade flat results if ("object" != typeof entry) { - entry = { - id: entry - }; + entry = { id: entry }; } id = entry.id; tmp = set[id]; if (!tmp) { - // offset was already applied on field indexes - // if(offset){ - // offset--; - // continue; - // } - // apply limit from last round, because just fields could - // be pushed without adding new results - if (final.length === limit) { - return final; - } entry.field = set[id] = [field.field]; final.push( /** @type {MergedDocumentSearchEntry} */entry); } else { diff --git a/dist/module/encoder.js b/dist/module/encoder.js index ec7c94c..35d5272 100644 --- a/dist/module/encoder.js +++ b/dist/module/encoder.js @@ -186,13 +186,13 @@ Encoder.prototype.assign = function (options) { tmp = options.filter; this.filter = "function" == typeof tmp ? tmp : merge_option(tmp && new Set(tmp), null, this.filter); - this.dedupe = merge_option(options.dedupe, !1, this.dedupe); + this.dedupe = merge_option(options.dedupe, !0, this.dedupe); this.matcher = merge_option((tmp = options.matcher) && new Map(tmp), null, this.matcher); this.mapper = merge_option((tmp = options.mapper) && new Map(tmp), null, this.mapper); this.stemmer = merge_option((tmp = options.stemmer) && new Map(tmp), null, this.stemmer); this.replacer = merge_option(options.replacer, null, this.replacer); this.minlength = merge_option(options.minlength, 1, this.minlength); - this.maxlength = merge_option(options.maxlength, 0, this.maxlength); + this.maxlength = merge_option(options.maxlength, 1024, this.maxlength); this.rtl = merge_option(options.rtl, !1, this.rtl); // auto-balanced cache @@ -394,7 +394,7 @@ Encoder.prototype.encode = function (str) { if (!(word = base = words[i])) { continue; } - if (word.length < this.minlength) { + if (word.length < this.minlength || word.length > this.maxlength) { continue; } if (skip) { diff --git a/dist/module/index/search.js b/dist/module/index/search.js index e6ba8b8..695f0d4 100644 --- a/dist/module/index/search.js +++ b/dist/module/index/search.js @@ -26,10 +26,10 @@ import resolve_default from "../resolve/default.js"; Index.prototype.search = function (query, limit, options) { if (!options) { - if (!limit && is_object(query)) { + if (!limit && "object" == typeof query) { options = /** @type {!SearchOptions} */query; query = ""; - } else if (is_object(limit)) { + } else if ("object" == typeof limit) { options = /** @type {!SearchOptions} */limit; limit = 0; } @@ -188,21 +188,21 @@ Index.prototype.search = function (query, limit, options) { keyword; - if (1 < length) { - if (context) { - // start with context right away - keyword = query_terms[0]; - index = 1; - } - // todo - // else if(maxlength > 9 && (maxlength / minlength) > 3){ - // // sorting terms will break the context chain - // // bigger terms has less occurrence - // // this might also reduce the intersection task - // // todo check intersection order - // query_terms.sort(sort_by_length_down); - // } + //if(length > 1){ + if (context) { + // start with context right away + keyword = query_terms[0]; + index = 1; } + // todo + // else if(maxlength > 9 && (maxlength / minlength) > 3){ + // // sorting terms will break the context chain + // // bigger terms has less occurrence + // // this might also reduce the intersection task + // // todo check intersection order + // query_terms.sort(sort_by_length_down); + // } + //} if (!resolution && 0 !== resolution) { resolution = keyword ? this.resolution_ctx : this.resolution; diff --git a/dist/module/type.js b/dist/module/type.js index 0bc2652..768bbc8 100644 --- a/dist/module/type.js +++ b/dist/module/type.js @@ -1,5 +1,6 @@ // When you are looking for type definitions which fully describes the usage take a look into the index.d.ts file. // Some of the types here aren't supposed to be used as public, they might be defined just for internal state. + import Index from "./index.js"; import Encoder from "./encoder.js"; import StorageInterface from "./db/interface.js"; @@ -141,7 +142,7 @@ export let SearchOptions = {}; * index: (Array|Array|DocumentSearchOptions|string|undefined), * pluck: (string|DocumentSearchOptions|undefined), * merge: (boolean|undefined), - * highlight: (string|undefined), + * highlight: (string|undefined) * }} */ export let DocumentSearchOptions = {}; @@ -153,7 +154,7 @@ export let DocumentSearchOptions = {}; export let SearchResults = []; /** - * @typedef Array> + * @typedef Array * @global */ export let IntermediateSearchResults = []; @@ -161,7 +162,8 @@ export let IntermediateSearchResults = []; /** * @typedef Array<{ * id: (number|string), - * doc: (Object|null) + * doc: (Object|null), + * highlight: (string|undefined) * }> */ export let EnrichedSearchResults = []; @@ -179,8 +181,7 @@ export let DocumentSearchResults = []; * @typedef Array<{ * field: (string|undefined), * tag: (string|undefined), - * highlight: (string|undefined), - * result: {EnrichedSearchResults} + * result: EnrichedSearchResults * }> */ export let EnrichedDocumentSearchResults = []; diff --git a/doc/encoder.md b/doc/encoder.md index 37ed804..0209032 100644 --- a/doc/encoder.md +++ b/doc/encoder.md @@ -271,7 +271,7 @@ const index = new Index({ Encoder Split Options - Deduplicate following letters, e.g. "missing" to "mising" + Define which of the string contents should be included (inclusion properties defaults to false) { letter: true, number: true } @@ -280,7 +280,7 @@ const index = new Index({ Encoder Split Options - Deduplicate following letters, e.g. "missing" to "mising" + Define which of the string contents should be excluded (exclusion properties defaults to true) false @@ -323,7 +323,7 @@ const index = new Index({ Number - Set the minimum term length which should be added to the index. This limit does not apply to the `forward` tokenizer. You still get results when just typing "f" on a term "flexsearch" when e.g. `minlength: 4` was used. + Set the minimum term length which should be added to the index. This limit does not apply to the forward tokenizer. You still get results when just typing "f" on a term "flexsearch" when e.g. minlength: 4 was used. 1 diff --git a/package-lock.json b/package-lock.json index 1ac8321..c4c1c71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "flexsearch", - "version": "0.8.149", + "version": "0.8.151", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "flexsearch", - "version": "0.8.149", + "version": "0.8.151", "funding": [ { "type": "github", diff --git a/package.json b/package.json index 341d6b8..39d673c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "public": true, "preferGlobal": false, "name": "flexsearch", - "version": "0.8.149", + "version": "0.8.151", "description": "Next-Generation full-text search library for Browser and Node.js", "homepage": "https://github.com/nextapps-de/flexsearch/", "author": "Thomas Wilkerling", diff --git a/src/bundle.js b/src/bundle.js index 54d22d0..585580b 100644 --- a/src/bundle.js +++ b/src/bundle.js @@ -147,16 +147,19 @@ if(SUPPORT_SERIALIZE){ /** @export */ KeystoreMap.size; /** @export */ KeystoreSet.size; -/** @export */ Charset.LatinExact; -/** @export */ Charset.LatinDefault; -/** @export */ Charset.LatinSimple; +/** @export */ Charset.Exact; +/** @export */ Charset.Default; +/** @export */ Charset.Normalize; /** @export */ Charset.LatinBalance; /** @export */ Charset.LatinAdvanced; /** @export */ Charset.LatinExtra; /** @export */ Charset.LatinSoundex; -/** @export */ Charset.ArabicDefault; -/** @export */ Charset.CjkDefault; -/** @export */ Charset.CyrillicDefault; +/** @export @deprecated */ Charset.LatinExact; +/** @export @deprecated */ Charset.LatinDefault; +/** @export @deprecated */ Charset.LatinSimple; +/** @export @deprecated */ Charset.ArabicDefault; +/** @export @deprecated */ Charset.CjkDefault; +/** @export @deprecated */ Charset.CyrillicDefault; /** @export */ IndexOptions.preset; /** @export */ IndexOptions.context; diff --git a/src/charset.js b/src/charset.js index e036fa8..ac8e30a 100644 --- a/src/charset.js +++ b/src/charset.js @@ -1,36 +1,36 @@ -import charset_latin_exact from "./charset/latin/exact.js"; -import charset_latin_normalize from "./charset/latin/normalize.js"; +import charset_exact from "./charset/exact.js"; +import charset_normalize from "./charset/normalize.js"; import charset_latin_balance from "./charset/latin/balance.js"; import charset_latin_advanced from "./charset/latin/advanced.js"; import charset_latin_extra from "./charset/latin/extra.js"; import charset_latin_soundex from "./charset/latin/soundex.js"; // universal charset -export const Exact = charset_latin_exact; -export const Default = charset_latin_normalize; -export const Normalize = charset_latin_normalize; +export const Exact = charset_exact; +export const Default = charset_normalize; +export const Normalize = charset_normalize; // latin charset export const LatinBalance = charset_latin_balance; export const LatinAdvanced = charset_latin_advanced; export const LatinExtra = charset_latin_extra; export const LatinSoundex = charset_latin_soundex; // deprecated -export const LatinExact = charset_latin_exact; -export const LatinDefault = charset_latin_normalize; -export const LatinSimple = charset_latin_normalize; +export const LatinExact = charset_exact; +export const LatinDefault = charset_normalize; +export const LatinSimple = charset_normalize; export default { // universal charset - Exact: charset_latin_exact, - Default: charset_latin_normalize, - Normalize: charset_latin_normalize, + Exact: charset_exact, + Default: charset_normalize, + Normalize: charset_normalize, // latin charset LatinBalance: charset_latin_balance, LatinAdvanced: charset_latin_advanced, LatinExtra: charset_latin_extra, LatinSoundex: charset_latin_soundex, // deprecated - LatinExact: charset_latin_exact, - LatinDefault: charset_latin_normalize, - LatinSimple: charset_latin_normalize + LatinExact: charset_exact, + LatinDefault: charset_normalize, + LatinSimple: charset_normalize }; diff --git a/src/charset/latin/exact.js b/src/charset/exact.js similarity index 65% rename from src/charset/latin/exact.js rename to src/charset/exact.js index d9fa4fc..2d1f506 100644 --- a/src/charset/latin/exact.js +++ b/src/charset/exact.js @@ -1,9 +1,10 @@ -import { EncoderOptions } from "../../type.js"; +import { EncoderOptions } from "../type.js"; /** @type EncoderOptions */ const options = { normalize: false, - numeric: false + numeric: false, + dedupe: false //split: /\s+/ //normalize: false, //dedupe: false diff --git a/src/charset/latin/advanced.js b/src/charset/latin/advanced.js index 9abb73b..77dcb75 100644 --- a/src/charset/latin/advanced.js +++ b/src/charset/latin/advanced.js @@ -26,7 +26,7 @@ export const replacer = [ /** @type EncoderOptions */ const options = { //normalize: true, - dedupe: true, + //dedupe: true, mapper: soundex, matcher: matcher, replacer: replacer diff --git a/src/charset/latin/balance.js b/src/charset/latin/balance.js index 7d42731..1320ac0 100644 --- a/src/charset/latin/balance.js +++ b/src/charset/latin/balance.js @@ -41,7 +41,7 @@ export const soundex = new Map([ /** @type EncoderOptions */ const options = { //normalize: true, - dedupe: true, + //dedupe: true, mapper: soundex }; export default options; diff --git a/src/charset/latin/extra.js b/src/charset/latin/extra.js index 31512c9..5257f8d 100644 --- a/src/charset/latin/extra.js +++ b/src/charset/latin/extra.js @@ -9,7 +9,7 @@ export const compact = [ /** @type EncoderOptions */ const options = { //normalize: true, - dedupe: true, + //dedupe: true, mapper: soundex, replacer: replacer.concat(compact), matcher: matcher diff --git a/src/charset/latin/normalize.js b/src/charset/normalize.js similarity index 80% rename from src/charset/latin/normalize.js rename to src/charset/normalize.js index ea36514..956f17c 100644 --- a/src/charset/latin/normalize.js +++ b/src/charset/normalize.js @@ -1,4 +1,4 @@ -import { EncoderOptions } from "../../type.js"; +import { EncoderOptions } from "../type.js"; /** @type EncoderOptions */ const options = { diff --git a/src/document/search.js b/src/document/search.js index f78e078..b8e91ba 100644 --- a/src/document/search.js +++ b/src/document/search.js @@ -69,6 +69,7 @@ Document.prototype.search = function(query, limit, options, _promises){ /** @type { * DocumentSearchResults| * EnrichedDocumentSearchResults| + * MergedDocumentSearchResults| * SearchResults| * IntermediateSearchResults| * EnrichedSearchResults @@ -432,7 +433,7 @@ Document.prototype.search = function(query, limit, options, _promises){ : new Resolver(result); } if(pluck && (!enrich || !this.store)){ - return result[0]; + return /** @type {SearchResults} */ (result[0]); } promises = []; @@ -450,6 +451,7 @@ Document.prototype.search = function(query, limit, options, _promises){ } else{ PROFILER && tick("Document.search:doc:get"); + // todo // the documents are stored on the first field promises.push(res = this.index.get(this.field[0]).db.enrich(res)); } @@ -457,13 +459,13 @@ Document.prototype.search = function(query, limit, options, _promises){ if(pluck){ return resolve - ? res - : new Resolver(res); + ? /** @type {SearchResults|EnrichedSearchResults} */ (res) + : new Resolver(/** @type {IntermediateSearchResults} */ (res)); } result[i] = { "field": result_field[i], - "result": res + "result": /** @type {SearchResults|EnrichedSearchResults} */ (res) }; } @@ -474,40 +476,34 @@ Document.prototype.search = function(query, limit, options, _promises){ result[j]["result"] = promises[j]; } return merge - ? merge_fields(result, /** @type {number} */ (limit), offset) + ? merge_fields(result) : highlight - ? highlight_fields(result, query, self.index, self.field, self.tree, highlight, limit, offset) - : result; + ? highlight_fields(result, /** @type {string} */ (query), self.index, self.field, self.tree, highlight) + : /** @type {DocumentSearchResults} */ ( + result + ); }); } return merge - ? merge_fields(result, limit, offset) + ? merge_fields(result) : highlight - ? highlight_fields(result, query, this.index, this.field, this.tree, highlight, limit, offset) - : result; + ? highlight_fields(result, /** @type {string} */ (query), this.index, this.field, this.tree, highlight) + : /** @type {DocumentSearchResults} */ ( + result + ); } -/* - - karmen or clown or not found -[Carmen]cita - Le [clown] et ses chiens - - */ - /** * @param {EnrichedDocumentSearchResults} result - * @param query - * @param index - * @param field - * @param tree - * @param template - * @param limit - * @param offset - * @return {*} + * @param {string} query + * @param {Map} index + * @param {string} field + * @param {Array} tree + * @param {string} template + * @return {EnrichedDocumentSearchResults} */ -function highlight_fields(result, query, index, field, tree, template, limit, offset){ +function highlight_fields(result, query, index, field, tree, template){ // The biggest issue is dealing with custom encoders, for this reason // a regular expression can't apply @@ -525,9 +521,12 @@ function highlight_fields(result, query, index, field, tree, template, limit, of // for every field for(let i = 0, res_field, enc, idx, path; i < result.length; i++){ + res_field = result[i].field; + // skip when not a field entry (e.g. tags) + if(!res_field) continue; + /** @type {EnrichedSearchResults} */ let res = result[i].result; - res_field = result[i].field; idx = index.get(res_field); enc = idx.encoder; tokenize = idx.tokenize; @@ -609,12 +608,10 @@ function highlight_fields(result, query, index, field, tree, template, limit, of /** * @param {DocumentSearchResults} fields - * @param {number=} limit - * @param {number=} offset * @return {MergedDocumentSearchResults} */ -function merge_fields(fields, limit, offset){ - /** @type {Array} */ +function merge_fields(fields){ + /** @type {MergedDocumentSearchResults} */ const final = []; const set = create_object(); for(let i = 0, field, res; i < fields.length; i++){ @@ -624,23 +621,11 @@ function merge_fields(fields, limit, offset){ entry = res[j]; // upgrade flat results if(typeof entry !== "object"){ - entry = { - "id": entry - }; + entry = { "id": entry }; } id = entry["id"]; tmp = set[id]; if(!tmp){ - // offset was already applied on field indexes - // if(offset){ - // offset--; - // continue; - // } - // apply limit from last round, because just fields could - // be pushed without adding new results - if(final.length === limit){ - return final; - } entry.field = set[id] = [field.field]; final.push(/** @type {MergedDocumentSearchEntry} */ (entry)); } diff --git a/src/encoder.js b/src/encoder.js index 1242470..59e0327 100644 --- a/src/encoder.js +++ b/src/encoder.js @@ -211,7 +211,7 @@ Encoder.prototype.assign = function(options){ tmp = options.filter; this.filter = typeof tmp === "function" ? tmp : merge_option(tmp && new Set(tmp), null, this.filter); - this.dedupe = merge_option(options.dedupe, false, this.dedupe); + this.dedupe = merge_option(options.dedupe, true, this.dedupe); this.matcher = merge_option((tmp = options.matcher) && new Map(tmp), null, this.matcher); this.mapper = merge_option((tmp = options.mapper) && new Map(tmp), null, this.mapper); this.stemmer = merge_option((tmp = options.stemmer) && new Map(tmp), null, this.stemmer); diff --git a/src/index/search.js b/src/index/search.js index d340839..509b915 100644 --- a/src/index/search.js +++ b/src/index/search.js @@ -36,11 +36,11 @@ import resolve_default from "../resolve/default.js"; Index.prototype.search = function(query, limit, options){ if(!options){ - if(!limit && is_object(query)){ + if(!limit && typeof query === "object"){ options = /** @type {!SearchOptions} */ (query); query = ""; } - else if(is_object(limit)){ + else if(typeof limit === "object"){ options = /** @type {!SearchOptions} */ (limit); limit = 0; } @@ -208,7 +208,7 @@ Index.prototype.search = function(query, limit, options){ let dupes = create_object(); let index = 0, keyword; - if(length > 1){ + //if(length > 1){ if(context){ // start with context right away keyword = query_terms[0]; @@ -222,7 +222,7 @@ Index.prototype.search = function(query, limit, options){ // // todo check intersection order // query_terms.sort(sort_by_length_down); // } - } + //} if(!resolution && resolution !== 0){ resolution = keyword diff --git a/src/type.js b/src/type.js index 2418de8..eb4e0e6 100644 --- a/src/type.js +++ b/src/type.js @@ -1,5 +1,6 @@ // When you are looking for type definitions which fully describes the usage take a look into the index.d.ts file. // Some of the types here aren't supposed to be used as public, they might be defined just for internal state. + import Index from "./index.js"; import Encoder from "./encoder.js"; import StorageInterface from "./db/interface.js"; @@ -153,7 +154,7 @@ export let DocumentSearchOptions = {}; export let SearchResults = []; /** - * @typedef Array> + * @typedef Array * @global */ export let IntermediateSearchResults = []; @@ -189,7 +190,6 @@ export let EnrichedDocumentSearchResults = []; * @typedef {{ * id: (number|string), * doc: (Object|null), - * highlight: (string|undefined), * field: (Array|undefined), * tag: (Array|undefined) * }} diff --git a/test/basic.js b/test/basic.js index fabf8a9..84acd09 100644 --- a/test/basic.js +++ b/test/basic.js @@ -64,10 +64,10 @@ describe("Initialize", function(){ index.encoder.normalize = encoder.normalize; expect(index.encoder).to.eql(encoder); expect(index.encoder.minlength).to.equal(1); - expect(index.encoder.maxlength).to.equal(0); + expect(index.encoder.maxlength).to.equal(1024); expect(index.encoder.rtl).to.equal(false); expect(index.encoder.numeric).to.equal(true); - expect(index.encoder.dedupe).to.equal(false); + expect(index.encoder.dedupe).to.equal(true); }); }); @@ -82,8 +82,8 @@ describe("Add", function(){ index.add(1, "FooBar"); index.add(3, "Some 'short' content."); - expect(index.reg.keys()).to.have.members([0, 1, 2, 3]); - expect(index.map.keys()).to.have.members(["foo", "bar", "foobar", "some", "short", "content"]); + expect(Array.from(index.reg.keys())).to.have.members([0, 1, 2, 3]); + expect(Array.from(index.map.keys())).to.have.members(["fo", "bar", "fobar", "some", "short", "content"]); expect(index.ctx.size).to.equal(0); expect(index.reg.size).to.equal(4); }); @@ -97,12 +97,12 @@ describe("Add", function(){ index.add(2, "T10030T10030"); index.add(3, "1443-AB14345-1778"); - expect(index.reg.keys()).to.have.members([0, 1, 2, 3]); - expect(index.map.keys()).to.have.members([ + expect(Array.from(index.reg.keys())).to.have.members([0, 1, 2, 3]); + expect(Array.from(index.map.keys())).to.have.members([ "test", "123", "456", "789", - "t", "100", "30", + "t", "10", "30", // id 2 was already completely added, split: "t", "100", "30", "t", "100", "30" - "144", "3", "ab", "143", "45", "177", "8" + "14", "3", "ab", "143", "45", "17", "8" ]); expect(index.ctx.size).to.equal(0); expect(index.reg.size).to.equal(4); diff --git a/test/cache.js b/test/cache.js index ad25392..8405298 100644 --- a/test/cache.js +++ b/test/cache.js @@ -10,7 +10,7 @@ const build_compact = env && env.includes(".compact"); const build_esm = !env || env.startsWith("module"); const Charset = _Charset || (await import("../src/charset.js")).default; -describe("Caching", function(){ +if(!build_light) describe("Caching", function(){ it("Should have been cached and sorted by popularity/latest", function(){ diff --git a/test/context.js b/test/context.js index 97764c4..e4dee3a 100644 --- a/test/context.js +++ b/test/context.js @@ -120,10 +120,10 @@ describe("Context", function(){ index = new Index({ context: true }); index.add(1, "1 A B C D 2 E F G H I 3 J K L"); index.add(2, "A B C D E F G H I J 1 2 3 K L"); - result = result = index.search("1 2 3"); + result = index.search("1 2 3"); expect(result[0]).to.equal(2); - index.search("1 2 3", { context: false }); + result = index.search("1 2 3", { context: false }); expect(result[0]).to.equal(1); }); }); diff --git a/test/encoder.js b/test/encoder.js index 694aa00..7e9135d 100644 --- a/test/encoder.js +++ b/test/encoder.js @@ -31,9 +31,14 @@ describe("Encoder: Charset", function(){ it("Should have been encoded properly: Default", function(){ - const index = new Index({ encoder: Charset.Default }); + let index = new Index({ encoder: Charset.Default }); expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql( - ["bjorn", "phillipp", "mayer"] + ["bjorn", "philip", "mayer"] + ); + + index = new Index(); + expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql( + ["bjorn", "philip", "mayer"] ); }); @@ -51,7 +56,7 @@ describe("Encoder: Charset", function(){ const index = new Index({ encoder: Charset.Normalize }); expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql( - index.encoder.encode("bjorn/phillipp mayer") + index.encoder.encode("bjorn/philip mayer") ); }); diff --git a/test/keystore.js b/test/keystore.js index b85ead8..a9ef278 100644 --- a/test/keystore.js +++ b/test/keystore.js @@ -26,8 +26,8 @@ if(!build_light && !build_compact) describe("Keystore", function(){ } expect(index.map.size).to.equal(2); - expect(index.map.get("foo")[0].length).to.equal(100); - expect(index.ctx.get("foo").get("bar")[0].length).to.equal(100); + expect(index.map.get("fo")[0].length).to.equal(100); + expect(index.ctx.get("fo").get("bar")[0].length).to.equal(100); expect(index.reg.size).to.equal(100); for(let i = 0; i < 100; i++){ @@ -38,9 +38,9 @@ if(!build_light && !build_compact) describe("Keystore", function(){ index.cleanup(); expect(index.map.size).to.equal(1); - expect(index.map.get("foo")).to.be.undefined; - expect(index.map.get("foobar")[0].length).to.equal(100); - expect(index.ctx.get("foo")).to.be.undefined; + expect(index.map.get("fo")).to.be.undefined; + expect(index.map.get("fobar")[0].length).to.equal(100); + expect(index.ctx.get("fo")).to.be.undefined; expect(index.reg.size).to.equal(100); for(let i = 0; i < 50; i++){ @@ -48,7 +48,7 @@ if(!build_light && !build_compact) describe("Keystore", function(){ } expect(index.map.size).to.equal(1); - expect(index.map.get("foobar")[0].length).to.equal(50); + expect(index.map.get("fobar")[0].length).to.equal(50); expect(index.reg.size).to.equal(50); index.clear(); @@ -76,8 +76,8 @@ if(!build_light && !build_compact) describe("Keystore", function(){ index.add(1, "foo bar"); index.add(2, "foo bar"); - let foo = index.map.get("foo"); - let bar = index.ctx.get("foo").get("bar"); + let foo = index.map.get("fo"); + let bar = index.ctx.get("fo").get("bar"); foo[0].length = 2**31 - 10; bar[0].length = 2**31 - 10; @@ -85,10 +85,10 @@ if(!build_light && !build_compact) describe("Keystore", function(){ index.add(i, "foo bar"); } - expect(index.map.get("foo")[0].length).to.equal(2**31 + 10); - expect(index.ctx.get("foo").get("bar")[0].length).to.equal(2**31 + 10); + expect(index.map.get("fo")[0].length).to.equal(2**31 + 10); + expect(index.ctx.get("fo").get("bar")[0].length).to.equal(2**31 + 10); //expect(index.reg.size).to.equal(2**31 + 1); - expect(index.search("foo bar", 3)).to.eql([0, 1, 2]); + expect(index.search("fo bar", 3)).to.eql([0, 1, 2]); index.clear(); diff --git a/test/serialize.js b/test/serialize.js index 230121f..c602d16 100644 --- a/test/serialize.js +++ b/test/serialize.js @@ -24,7 +24,7 @@ if(!build_light) describe("Export / Import", function(){ index.add(2, "foobar foo bar"); expect(index.reg.size).to.equal(3); - expect(index.map.size).to.equal(9); + expect(index.map.size).to.equal(8); expect(index.search("foobar")).to.eql([2, 0, 1]); const payload = new Map(); @@ -34,7 +34,7 @@ if(!build_light) describe("Export / Import", function(){ expect(payload).to.eql(new Map([ ['1.reg', '[0,1,2]'], - ['1.map', '[["f",[[0,2],[1]]],["fo",[[0,2],[1]]],["foo",[[0,2],[1]]],["b",[[1],[0],[2]]],["ba",[[1],[0],[2]]],["bar",[[1],[0],[2]]],["foob",[[2],null,[0,1]]],["fooba",[[2],null,[0,1]]],["foobar",[[2],null,[0,1]]]]'] + ['1.map', '[["f",[[0,2],[1]]],["fo",[[0,2],[1]]],["b",[[1],[0],[2]]],["ba",[[1],[0],[2]]],["bar",[[1],[0],[2]]],["fob",[[2],null,[0,1]]],["foba",[[2],null,[0,1]]],["fobar",[[2],null,[0,1]]]]'] ])); index = new Index({ @@ -46,7 +46,7 @@ if(!build_light) describe("Export / Import", function(){ } expect(index.reg.size).to.equal(3); - expect(index.map.size).to.equal(9); + expect(index.map.size).to.equal(8); expect(index.search("foobar")).to.eql([2, 0, 1]); }); @@ -72,8 +72,8 @@ if(!build_light) describe("Export / Import", function(){ expect(payload).to.eql(new Map([ ['1.reg', '[0,1,2]'], - ['1.map', '[["foo",[[0],[1,2]]],["bar",[[1],[0],[2]]],["foobar",[[2],null,[0,1]]]]'], - ['1.ctx', '[["foo",[["bar",[[0,1],[2]]]]],["foobar",[["bar",[null,[0]]],["foo",[[2],[1]]]]]]'] + ['1.map', '[["fo",[[0],[1,2]]],["bar",[[1],[0],[2]]],["fobar",[[2],null,[0,1]]]]'], + ['1.ctx', '[["fo",[["bar",[[0,1],[2]]]]],["fobar",[["bar",[null,[0]]],["fo",[[2],[1]]]]]]'] ])); index = new Index({