diff --git a/CHANGELOG.md b/CHANGELOG.md index e113d07..da59120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### Current Version + +- Use multi-language charset normalization as the default `Encoder` +- Simplified charset support for CJK, Arabic, Cyrillic, Hindi, ... no extra charset definition required, the default encoder can handle them all +- Charset renamed `LatinExact` => `Exact`, `LatinDefault` => `Default` and `LatinSimple` => `Normalize`, these are universal charset presets for any languages +- Charset `CjkDefault`, `ArabicDefault` and `CyrillicDefault` was removed, they are fully covered by the default universal charset presets + ### v0.8.1 - Resolver Support for Documents diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js index 6e9a4bd..a488bc3 100644 --- a/dist/flexsearch.bundle.debug.js +++ b/dist/flexsearch.bundle.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.142 (Bundle/Debug) + * FlexSearch.js v0.8.143 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -77,18 +77,10 @@ function ca(a) { } return c; } -;var da = [["\u00aa", "a"], ["\u00b2", "2"], ["\u00b3", "3"], ["\u00b9", "1"], ["\u00ba", "o"], ["\u00bc", "1\u20444"], ["\u00bd", "1\u20442"], ["\u00be", "3\u20444"], ["\u00e0", "a"], ["\u00e1", "a"], ["\u00e2", "a"], ["\u00e3", "a"], ["\u00e4", "a"], ["\u00e5", "a"], ["\u00e7", "c"], ["\u00e8", "e"], ["\u00e9", "e"], ["\u00ea", "e"], ["\u00eb", "e"], ["\u00ec", "i"], ["\u00ed", "i"], ["\u00ee", "i"], ["\u00ef", "i"], ["\u00f1", "n"], ["\u00f2", "o"], ["\u00f3", "o"], ["\u00f4", "o"], ["\u00f5", -"o"], ["\u00f6", "o"], ["\u00f9", "u"], ["\u00fa", "u"], ["\u00fb", "u"], ["\u00fc", "u"], ["\u00fd", "y"], ["\u00ff", "y"], ["\u0101", "a"], ["\u0103", "a"], ["\u0105", "a"], ["\u0107", "c"], ["\u0109", "c"], ["\u010b", "c"], ["\u010d", "c"], ["\u010f", "d"], ["\u0113", "e"], ["\u0115", "e"], ["\u0117", "e"], ["\u0119", "e"], ["\u011b", "e"], ["\u011d", "g"], ["\u011f", "g"], ["\u0121", "g"], ["\u0123", "g"], ["\u0125", "h"], ["\u0129", "i"], ["\u012b", "i"], ["\u012d", "i"], ["\u012f", "i"], ["\u0133", -"ij"], ["\u0135", "j"], ["\u0137", "k"], ["\u013a", "l"], ["\u013c", "l"], ["\u013e", "l"], ["\u0140", "l"], ["\u0144", "n"], ["\u0146", "n"], ["\u0148", "n"], ["\u0149", "n"], ["\u014d", "o"], ["\u014f", "o"], ["\u0151", "o"], ["\u0155", "r"], ["\u0157", "r"], ["\u0159", "r"], ["\u015b", "s"], ["\u015d", "s"], ["\u015f", "s"], ["\u0161", "s"], ["\u0163", "t"], ["\u0165", "t"], ["\u0169", "u"], ["\u016b", "u"], ["\u016d", "u"], ["\u016f", "u"], ["\u0171", "u"], ["\u0173", "u"], ["\u0175", "w"], ["\u0177", -"y"], ["\u017a", "z"], ["\u017c", "z"], ["\u017e", "z"], ["\u017f", "s"], ["\u01a1", "o"], ["\u01b0", "u"], ["\u01c6", "dz"], ["\u01c9", "lj"], ["\u01cc", "nj"], ["\u01ce", "a"], ["\u01d0", "i"], ["\u01d2", "o"], ["\u01d4", "u"], ["\u01d6", "u"], ["\u01d8", "u"], ["\u01da", "u"], ["\u01dc", "u"], ["\u01df", "a"], ["\u01e1", "a"], ["\u01e3", "ae"], ["\u00e6", "ae"], ["\u01fd", "ae"], ["\u01e7", "g"], ["\u01e9", "k"], ["\u01eb", "o"], ["\u01ed", "o"], ["\u01ef", "\u0292"], ["\u01f0", "j"], ["\u01f3", -"dz"], ["\u01f5", "g"], ["\u01f9", "n"], ["\u01fb", "a"], ["\u01ff", "\u00f8"], ["\u0201", "a"], ["\u0203", "a"], ["\u0205", "e"], ["\u0207", "e"], ["\u0209", "i"], ["\u020b", "i"], ["\u020d", "o"], ["\u020f", "o"], ["\u0211", "r"], ["\u0213", "r"], ["\u0215", "u"], ["\u0217", "u"], ["\u0219", "s"], ["\u021b", "t"], ["\u021f", "h"], ["\u0227", "a"], ["\u0229", "e"], ["\u022b", "o"], ["\u022d", "o"], ["\u022f", "o"], ["\u0231", "o"], ["\u0233", "y"], ["\u02b0", "h"], ["\u02b1", "h"], ["\u0266", "h"], -["\u02b2", "j"], ["\u02b3", "r"], ["\u02b4", "\u0279"], ["\u02b5", "\u027b"], ["\u02b6", "\u0281"], ["\u02b7", "w"], ["\u02b8", "y"], ["\u02e0", "\u0263"], ["\u02e1", "l"], ["\u02e2", "s"], ["\u02e3", "x"], ["\u02e4", "\u0295"], ["\u0390", "\u03b9"], ["\u03ac", "\u03b1"], ["\u03ad", "\u03b5"], ["\u03ae", "\u03b7"], ["\u03af", "\u03b9"], ["\u03b0", "\u03c5"], ["\u03ca", "\u03b9"], ["\u03cb", "\u03c5"], ["\u03cc", "\u03bf"], ["\u03cd", "\u03c5"], ["\u03ce", "\u03c9"], ["\u03d0", "\u03b2"], ["\u03d1", -"\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db", -"\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]]; -const ea = /[^\p{L}\p{N}]+/u, fa = /(\d{3})/g, ha = /(\D)(\d{3})/g, ia = /(\d{3})(\D)/g, ja = "".normalize && /[\u0300-\u036f]/g; -function ka(a = {}) { - if (!this || this.constructor !== ka) { - return new ka(...arguments); +;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++) { @@ -98,7 +90,7 @@ function ka(a = {}) { this.assign(a); } } -t = ka.prototype; +t = ja.prototype; t.assign = function(a) { this.normalize = z(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, e; @@ -126,7 +118,7 @@ t.assign = function(a) { this.numeric = z(a.numeric, e); } else { try { - this.split = z(this.split, ea); + 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+/; } @@ -134,7 +126,6 @@ t.assign = function(a) { } this.prepare = z(a.prepare, null, this.prepare); this.finalize = z(a.finalize, null, this.finalize); - ja || (this.mapper = new Map(da)); 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); @@ -222,9 +213,9 @@ t.encode = function(a) { this.H = setTimeout(J, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ja ? a.normalize("NFKD").replace(ja, "").toLowerCase() : a.toLowerCase()); + 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(ha, "$1 $2").replace(ia, "$1 $2").replace(fa, "$1 ")); + 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++) { @@ -274,7 +265,7 @@ function J(a) { a.G.clear(); } ;let K, M; -async function la(a) { +async function ka(a) { a = a.data; var c = a.task; const b = a.id; @@ -304,25 +295,25 @@ async function la(a) { postMessage("search" === c ? {id:b, msg:d} : {id:b}); } } -;function ma(a) { - na.call(a, "add"); - na.call(a, "append"); - na.call(a, "search"); - na.call(a, "update"); - na.call(a, "remove"); +;function la(a) { + ma.call(a, "add"); + ma.call(a, "append"); + ma.call(a, "search"); + ma.call(a, "update"); + ma.call(a, "remove"); } -let oa, pa, qa; -function ra() { - oa = qa = 0; +let na, oa, pa; +function qa() { + na = pa = 0; } -function na(a) { +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]); - oa ? qa || (qa = Date.now() - pa >= this.priority * this.priority * 3) : (oa = setTimeout(ra, 0), pa = Date.now()); - if (qa) { + 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() { @@ -367,7 +358,7 @@ function 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 = sa(b, e, a.worker); + 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); @@ -380,7 +371,7 @@ Q("remove"); Q("clear"); Q("export"); Q("import"); -ma(P.prototype); +la(P.prototype); function Q(a) { P.prototype[a] = function() { const c = this, b = [].slice.call(arguments); @@ -395,11 +386,11 @@ function Q(a) { return d ? (e.then(d), this) : e; }; } -function sa(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=" + la.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function ra(a, 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 ta(a, c = 0) { +;function sa(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { @@ -408,30 +399,30 @@ function sa(a, c, b) { e.length && b.push(e); return b; } -function ua(a, c) { +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 va(a, c = 0) { +function ua(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], ta(d[1])[0]]), e.length === c && (b.push(e), e = []); + e.push([d[0], sa(d[1])[0]]), e.length === c && (b.push(e), e = []); } e.length && b.push(e); return b; } -function wa(a, c) { +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], ua(e[1], d)); + e = a[b], d = c.get(e[0]), c.set(e[0], ta(e[1], d)); } return c; } -function xa(a) { +function wa(a) { let c = [], b = []; for (const e of a.keys()) { b.push(e), 250000 === b.length && (c.push(b), b = []); @@ -439,14 +430,14 @@ function xa(a) { b.length && c.push(b); return c; } -function ya(a, c) { +function xa(a, c) { c || (c = new Set()); for (let b = 0; b < a.length; b++) { c.add(a[b]); } return c; } -function za(a, c, b, e, d, f, g = 0) { +function ya(a, c, b, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { @@ -455,12 +446,12 @@ function za(a, c, b, e, d, f, g = 0) { if ((h = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(h))) && h.then) { const l = this; return h.then(function() { - return za.call(l, a, c, b, k ? e : null, d, f, g + 1); + return ya.call(l, a, c, b, k ? e : null, d, f, g + 1); }); } - return za.call(this, 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 Aa(a, c) { +function za(a, c) { let b = ""; for (const e of a.entries()) { a = e[0]; @@ -480,7 +471,7 @@ function Aa(a, c) { } return b; } -;function Ba(a, c, b, e) { +;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) { @@ -546,12 +537,12 @@ function R(a) { } if ("slice" === e) { return function(d, f) { - return Ba(c, d || 0, f || c.length, !1); + return Aa(c, d || 0, f || c.length, !1); }; } if ("splice" === e) { return function(d, f) { - return Ba(c, d || 0, f || c.length, !0); + return Aa(c, d || 0, f || c.length, !0); }; } if ("constructor" === e) { @@ -582,7 +573,7 @@ function S(a = 8) { this.index = B(); this.h = []; this.size = 0; - 32 < a ? (this.B = Ca, this.A = BigInt(a)) : (this.B = Da, this.A = a); + 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)]; @@ -600,7 +591,7 @@ function T(a = 8) { this.index = B(); this.h = []; this.size = 0; - 32 < a ? (this.B = Ca, this.A = BigInt(a)) : (this.B = Da, this.A = a); + 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); @@ -642,7 +633,7 @@ t.entries = T.prototype.entries = function*() { } } }; -function Da(a) { +function Ca(a) { let c = 2 ** this.A - 1; if ("number" == typeof a) { return a & c; @@ -653,7 +644,7 @@ function Da(a) { } return 32 === this.A ? b + 2 ** 31 : b; } -function Ca(a) { +function Ba(a) { let c = BigInt(2) ** this.A - BigInt(1); var b = typeof a; if ("bigint" === b) { @@ -683,7 +674,7 @@ function Ca(a) { d && e.add(a, d, !1, !0); } else { if (d = h.I, !d || d(c)) { - h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Ea(c, h, this.J, 0, e, a, h[0], b); + h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Da(c, h, this.J, 0, e, a, h[0], b); } } } @@ -746,7 +737,7 @@ function Ca(a) { k[l] = c[l]; continue; } - Fa(c, k, l, 0, l[0], n); + Ea(c, k, l, 0, l[0], n); } } this.store.set(a, k || c); @@ -755,21 +746,21 @@ function Ca(a) { } return this; }; -function Fa(a, c, b, e, d, f) { +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++) { - Fa(a, c, b, e, d); + Ea(a, c, b, e, d); } } else { - c = c[d] || (c[d] = B()), d = b[++e], Fa(a, c, b, e, d); + c = c[d] || (c[d] = B()), d = b[++e], Ea(a, c, b, e, d); } } } -function Ea(a, c, b, e, d, f, g, k) { +function Da(a, c, b, e, d, f, g, k) { if (a = a[g]) { if (e === c.length - 1) { if (a.constructor === Array) { @@ -785,17 +776,17 @@ function Ea(a, c, b, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Ea(a, c, b, e, d, f, g, k); + Da(a, c, b, e, d, f, g, k); } } else { - g = c[++e], Ea(a, c, b, e, d, f, g, k); + g = c[++e], Da(a, c, b, e, d, f, g, k); } } } else { d.db && d.remove(f); } } -;function Ga(a, c, b, e, d, f, g) { +;function Fa(a, c, b, e, d, f, g) { const k = a.length; let h = [], l, n; l = B(); @@ -820,7 +811,7 @@ function Ea(a, c, b, e, d, f, g, k) { } if (a = h.length) { if (d) { - h = 1 < h.length ? Ha(h, b, e, g, f) : (h = h[0]).length > b || e ? h.slice(e, b + e) : h; + 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 []; @@ -853,7 +844,7 @@ function Ea(a, c, b, e, d, f, g, k) { } return h; } -function Ha(a, c, b, e, d) { +function Ga(a, c, b, e, d) { const f = [], g = B(); let k; var h = a.length; @@ -898,7 +889,7 @@ function Ha(a, c, b, e, d) { } return f; } -function Ia(a, c, b) { +function Ha(a, c, b) { const e = B(), d = []; for (let f = 0, g; f < c.length; f++) { g = c[f]; @@ -919,7 +910,7 @@ function Ia(a, c, b) { } return d; } -;function Ja(a, c, b, e) { +;function Ia(a, c, b, e) { if (!a.length) { return a; } @@ -950,7 +941,7 @@ function Ia(a, c, b) { d = 1 < d.length ? [].concat.apply([], d) : d[0]; return e ? V.call(this, d) : d; } -;function Ka(a, c, b) { +;function Ja(a, c, b) { var e = b[0]; if (e.then) { return Promise.all(b).then(function(n) { @@ -997,10 +988,10 @@ function Ia(a, c, b) { 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} = Ka(this, "or", arguments); - return La.call(this, a, c, b, e, d, f); + 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 La(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) { @@ -1008,10 +999,10 @@ function La(a, c, b, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return La.call(g, a, [], b, e, d, f); + 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 = Ha(a, b, e, !1, this.h), e = 0)); + 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() { @@ -1021,11 +1012,40 @@ function La(a, c, b, e, d, f) { 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} = Ka(this, "and", arguments); - return Ma.call(this, f, g, k, h, l, n, m); + 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; @@ -1041,43 +1061,14 @@ function Ma(a, c, b, e, d, f, g) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (c = ca(a)) { - return this.result = Ga(a, c, b, e, g, this.h, f), f ? d ? V.call(this.index, this.result) : this.result : this; - } - this.result = []; + 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; } -;W.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ka(this, "xor", arguments); - return Na.call(this, a, c, b, e, d, f, g); -}; -function Na(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 Na.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 = Oa.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 Oa(a, c, b, e, d) { +function Na(a, c, b, e, d) { const f = [], g = B(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -1123,10 +1114,10 @@ function Oa(a, c, b, e, d) { return f; } ;W.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ka(this, "not", arguments); - return Pa.call(this, a, c, b, e, d, f, g); + 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 Pa(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) { @@ -1134,17 +1125,17 @@ function Pa(a, c, b, e, d, f, g) { for (let l = 0, n; l < h.length; l++) { (n = h[l]).length && (a[l] = n); } - return Pa.call(k, a, [], b, e, d, f, g); + return Oa.call(k, a, [], b, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Qa.call(this, a, b, e, f); + 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 Qa(a, c, b, e) { +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++) { @@ -1219,7 +1210,7 @@ W.prototype.boost = function(a) { 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), Ja.call(d, e, a || 100, c, b)) : e; + 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) { @@ -1299,7 +1290,7 @@ U.prototype.search = function(a, c, b, e) { } m.push(p = p.db.tag(v[f + 1], c, u, g)); } else { - p = Ra.call(this, v[f], v[f + 1], c, u, g); + p = Qa.call(this, v[f], v[f + 1], c, u, g); } d.push({field:v[f], tag:v[f + 1], result:p}); } @@ -1351,7 +1342,7 @@ U.prototype.search = function(a, c, b, e) { } } } else { - for (let G = 0, L, sb; G < l.length; G += 2) { + for (let G = 0, L, tb; G < l.length; G += 2) { L = this.tag.get(l[G]); if (!L) { if (console.warn("Tag '" + l[G] + ":" + l[G + 1] + "' will be skipped because there is no field '" + l[G] + "'."), r) { @@ -1360,7 +1351,7 @@ U.prototype.search = function(a, c, b, e) { return m ? d : new W(d); } } - if (sb = (L = L && L.get(l[G + 1])) && L.length) { + if (tb = (L = L && L.get(l[G + 1])) && L.length) { y++, w.push(L); } else if (!r) { return m ? d : new W(d); @@ -1368,7 +1359,7 @@ U.prototype.search = function(a, c, b, e) { } } if (y) { - x = Ia(x, w, m); + x = Ha(x, w, m); H = x.length; if (!H && !r) { return m ? x : new W(x); @@ -1422,12 +1413,12 @@ U.prototype.search = function(a, c, b, e) { for (let D = 0; D < x.length; D++) { d[D].result = x[D]; } - return k ? Sa(d, c) : q ? Ta(d, a, A.index, A.field, A.D, q) : d; + return k ? Ra(d, c) : q ? Sa(d, a, A.index, A.field, A.D, q) : d; }); } - return k ? Sa(d, c) : q ? Ta(d, a, this.index, this.field, this.D, q) : d; + return k ? Ra(d, c) : q ? Sa(d, a, this.index, this.field, this.D, q) : d; }; -function Ta(a, c, b, e, d, f) { +function Sa(a, c, b, e, d, f) { let g, k, h; for (let n = 0, m, q, p, r; n < a.length; n++) { let u = a[n].result; @@ -1472,7 +1463,7 @@ function Ta(a, c, b, e, d, f) { } return a; } -function Sa(a, c) { +function Ra(a, c) { const b = [], e = B(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1491,7 +1482,7 @@ function Sa(a, c) { } return b; } -function Ra(a, c, b, e, d) { +function Qa(a, c, b, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1523,7 +1514,7 @@ function V(a) { this.D = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && Ua(b, this.J) || "id"; + 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(); @@ -1533,7 +1524,7 @@ function V(a) { a.cache = !1; this.worker = a.worker; this.priority = a.priority || 4; - this.index = Va.call(this, a, c); + this.index = Ua.call(this, a, c); this.tag = null; if (b = c.tag) { if ("string" === typeof b && (b = [b]), b.length) { @@ -1546,7 +1537,7 @@ function V(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.F[d] = f.custom : (this.F[d] = Ua(g, this.J), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = f.filter)); + f.custom ? this.F[d] = f.custom : (this.F[d] = 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()); } @@ -1618,7 +1609,7 @@ t.destroy = function() { } return Promise.all(a); }; -function Va(a, c) { +function Ua(a, c) { const b = new Map(); let e = c.index || c.field || c; E(e) && (e = [e]); @@ -1631,19 +1622,19 @@ function Va(a, c) { b.set(f, k); } this.worker || b.set(f, new N(g, this.reg)); - g.custom ? this.D[d] = g.custom : (this.D[d] = Ua(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); + 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; E(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = Ua(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = 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 Ua(a, c) { +function Ta(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { @@ -1712,7 +1703,7 @@ t.set = function(a, c) { this.store.set(a, c); return this; }; -t.searchCache = Wa; +t.searchCache = Va; t.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1728,23 +1719,23 @@ t.export = function(a, c, b = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = xa(this.reg); + f = wa(this.reg); c = null; break; case 1: d = "tag"; - f = this.tag && va(this.tag, this.reg.size); + f = this.tag && ua(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = this.store && ta(this.store); + f = this.store && sa(this.store); c = null; break; default: return; } - return za.call(this, a, c, d, f, b, e); + return ya.call(this, a, c, d, f, b, e); }; t.import = function(a, c) { var b = a.split("."); @@ -1762,7 +1753,7 @@ t.import = function(a, c) { switch(b) { case "reg": this.fastupdate = !1; - this.reg = ya(c, this.reg); + 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; } @@ -1775,15 +1766,15 @@ t.import = function(a, c) { } break; case "tag": - this.tag = wa(c, this.tag); + this.tag = va(c, this.tag); break; case "doc": - this.store = ua(c, this.store); + this.store = ta(c, this.store); } } }; -ma(U.prototype); -function Wa(a, c, b) { +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); @@ -1824,31 +1815,22 @@ X.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Xa = {normalize:function(a) { - return a.toLowerCase(); -}}; -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}; -const bb = /[\x00-\x7F]+/g; -const cb = /[\x00-\x7F]+/g; -const db = /[\x00-\x7F]+/g; -var eb = {LatinExact:{split:/\s+/, normalize:!1}, LatinDefault:Xa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ya}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ya, matcher:Za, replacer:$a}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ya, replacer:$a.concat([/(?!^)[aeo]/g, ""]), matcher:Za}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +const Wa = {normalize:!1, numeric:!1, split:/\s+/}; +const Xa = {normalize:!0}; +const Ya = {normalize:!0, dedupe:!0}; +const Za = 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 $a = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), ab = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const bb = {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 cb = {X:Wa, W:Xa, Y:Ya, LatinBalance:{normalize:!0, dedupe:!0, mapper:Za}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Za, matcher:$a, replacer:ab}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Za, replacer:ab.concat([/(?!^)[aeo]/g, ""]), matcher:$a}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; - let e = c.charAt(0), d = 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++) { + let e = c.charAt(0), d = bb[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = bb[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } -}}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(bb, " "); -}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(cb, ""); -}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(db, " "); -}}}; -const fb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +}}, LatinExact:Wa, LatinDefault:Xa, LatinSimple:Ya}; +const db = {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)) { @@ -1861,7 +1843,7 @@ N.prototype.add = function(a, c, b, e) { 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) : gb(q, e, p), g = ""; + var f = this.score ? this.score(c, r, p, null, 0) : eb(q, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { @@ -1869,35 +1851,36 @@ N.prototype.add = function(a, c, b, e) { for (f = d; f > u; f--) { g = r.substring(u, f); v = this.rtl ? d - 1 - u : u; - var k = this.score ? this.score(c, r, p, g, v) : gb(q, e, p, d, v); - hb(this, n, g, k, a, b); + var k = this.score ? this.score(c, r, p, g, v) : eb(q, e, p, d, v); + fb(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) : gb(q, e, p, d, k); - hb(this, n, g, h, a, b); + var h = this.score ? this.score(c, r, p, g, k) : eb(q, e, p, d, k); + fb(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], hb(this, n, g, f, a, b); + g += r[this.rtl ? d - 1 - k : k], fb(this, n, g, f, a, b); } break; } default: - if (hb(this, n, r, f, a, b), m && 1 < e && p < e - 1) { + if (fb(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) : gb(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), v = this.bidirectional && r > f; - hb(this, l, v ? f : r, u, a, b, v ? r : f); + const u = this.score ? this.score(c, f, p, r, h - 1) : eb(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), v = this.bidirectional && r > f; + fb(this, l, v ? f : r, u, a, b, v ? r : f); } } } @@ -1909,10 +1892,10 @@ N.prototype.add = function(a, c, b, e) { c = ""; } } - this.db && (c || this.commit_task.push({del:a}), this.T && ib(this)); + this.db && (c || this.commit_task.push({del:a}), this.T && gb(this)); return this; }; -function hb(a, c, b, e, d, f, g) { +function fb(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)) { @@ -1930,7 +1913,7 @@ function hb(a, c, b, e, d, f, g) { } } } -function gb(a, c, b, e, d) { +function eb(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) { @@ -1941,11 +1924,11 @@ function gb(a, c, b, e, d) { d = p.length; c = c || (h ? 100 : 0); if (1 === d) { - return jb.call(this, p[0], "", c, k, h, q, l); + return hb.call(this, p[0], "", c, k, h, q, l); } f = this.depth && !1 !== f; if (2 === d && f && !g) { - return jb.call(this, p[0], p[1], c, k, h, q, l); + return hb.call(this, p[0], p[1], c, k, h, q, l); } let r = B(), u = 0, v; 1 < d && f && (v = p[0], u = 1); @@ -1959,8 +1942,8 @@ function gb(a, c, b, e, d) { for (let y, F; u < d; u++) { if ((F = p[u]) && !r[F]) { r[F] = 1; - y = await kb(w, F, v, 0, 0, !1, !1); - if (y = lb(y, e, g, m)) { + y = await ib(w, F, v, 0, 0, !1, !1); + if (y = jb(y, e, g, m)) { e = y; break; } @@ -1968,14 +1951,14 @@ function gb(a, c, b, e, d) { } g && v && u === d - 1 && !e.length && (m = w.resolution, v = "", u = -1, r = B()); } - return mb(e, m, c, k, g, n, h); + 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 = kb(this, y, v, 0, 0, !1, !1); - if (w = lb(w, e, g, m)) { + w = ib(this, y, v, 0, 0, !1, !1); + if (w = jb(w, e, g, m)) { e = w; break; } @@ -1983,24 +1966,24 @@ function gb(a, c, b, e, d) { } g && v && u === d - 1 && !e.length && (m = this.resolution, v = "", u = -1, r = B()); } - return mb(e, m, c, k, g, n, h); + return kb(e, m, c, k, g, n, h); }; -function mb(a, c, b, e, d, f, g) { +function kb(a, c, b, e, d, f, g) { let k = a.length, h = a; if (1 < k) { - h = Ga(a, c, b, e, d, f, g); + h = Fa(a, c, b, e, d, f, g); } else if (1 === k) { - return g ? Ja.call(null, a[0], b, e) : new W(a[0]); + return g ? Ia.call(null, a[0], b, e) : new W(a[0]); } return g ? h : new W(h); } -function jb(a, c, b, e, d, f, g) { - a = kb(this, a, c, b, e, d, f, g); +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 ? Ja.call(this, a, b, e) : new W(a) : d ? [] : new W(); + }) : a && a.length ? d ? Ia.call(this, a, b, e) : new W(a) : d ? [] : new W(); } -function lb(a, c, b, e) { +function jb(a, c, b, e) { let d = []; if (a && a.length) { if (a.length <= e) { @@ -2021,7 +2004,7 @@ function lb(a, c, b, e) { return d; } } -function kb(a, c, b, e, d, f, g, k) { +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) { @@ -2045,15 +2028,15 @@ function kb(a, c, b, e, d, f, g, k) { } } } else { - nb(this.map, a), this.depth && nb(this.ctx, a); + lb(this.map, a), this.depth && lb(this.ctx, a); } c || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.T && ib(this)); + this.db && (this.commit_task.push({del:a}), this.T && gb(this)); this.cache && this.cache.remove(a); return this; }; -function nb(a, c) { +function lb(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -2068,7 +2051,7 @@ function nb(a, c) { } } else { for (let e of a.entries()) { - const d = e[0], f = nb(e[1], c); + const d = e[0], f = lb(e[1], c); f ? b += f : a.delete(d); } } @@ -2080,15 +2063,15 @@ function nb(a, c) { } if (a) { var b = E(a) ? a : a.preset; - b && (fb[b] || console.warn("Preset not found: " + b), a = Object.assign({}, fb[b], a)); + b && (db[b] || console.warn("Preset not found: " + b), a = Object.assign({}, db[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = E(a.encoder) ? eb[a.encoder] : a.encode || a.encoder || Xa; - this.encoder = d.encode ? d : "object" === typeof d ? new ka(d) : {encode:d}; + const e = !0 === b ? {depth:1} : b || {}, d = E(a.encoder) ? cb[a.encoder] : a.encode || a.encoder || Xa; + 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 && b || "strict"; + 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; @@ -2123,7 +2106,7 @@ t.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function ib(a) { +function gb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); @@ -2147,7 +2130,7 @@ t.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; -function ob(a) { +function mb(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -2155,7 +2138,7 @@ function ob(a) { } } else { for (const b of a.entries()) { - const e = b[0], d = ob(b[1]); + const e = b[0], d = mb(b[1]); d ? c += d : a.delete(e); } } @@ -2165,17 +2148,17 @@ t.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - ob(this.map); - this.depth && ob(this.ctx); + mb(this.map); + this.depth && mb(this.ctx); return this; }; -t.searchCache = Wa; +t.searchCache = Va; t.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = xa(this.reg); + f = wa(this.reg); break; case 1: d = "cfg"; @@ -2183,29 +2166,29 @@ t.export = function(a, c, b = 0, e = 0) { break; case 2: d = "map"; - f = ta(this.map, this.reg.size); + f = sa(this.map, this.reg.size); break; case 3: d = "ctx"; - f = va(this.ctx, this.reg.size); + f = ua(this.ctx, this.reg.size); break; default: return; } - return za.call(this, a, c, d, f, b, e); + return ya.call(this, a, c, d, f, b, e); }; t.import = function(a, c) { if (c) { switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = ya(c, this.reg); + this.reg = xa(c, this.reg); break; case "map": - this.map = ua(c, this.map); + this.map = ta(c, this.map); break; case "ctx": - this.ctx = wa(c, this.ctx); + this.ctx = va(c, this.ctx); } } }; @@ -2217,11 +2200,11 @@ t.serialize = function(a = !0) { f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); } c = "index.reg=new Set([" + c + "]);"; - b = Aa(this.map, f); + b = za(this.map, f); b = "index.map=new Map([" + b + "]);"; for (const g of this.ctx.entries()) { d = g[0]; - let k = Aa(g[1], f); + let k = za(g[1], f); k = "new Map([" + k + "])"; k = '["' + d + '",' + k + "]"; e += (e ? "," : "") + k; @@ -2230,11 +2213,11 @@ t.serialize = function(a = !0) { } return a ? "function inject(index){" + c + b + e + "}" : c + b + e; }; -ma(N.prototype); -const pb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), qb = ["map", "ctx", "tag", "reg", "cfg"], Y = B(); -function rb(a, c = {}) { +la(N.prototype); +const nb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), ob = ["map", "ctx", "tag", "reg", "cfg"], Y = B(); +function pb(a, c = {}) { if (!this) { - return new rb(a, c); + return new pb(a, c); } "object" === typeof a && (c = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -2245,7 +2228,7 @@ function rb(a, c = {}) { this.db = null; this.h = {}; } -t = rb.prototype; +t = pb.prototype; t.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -2261,11 +2244,11 @@ t.open = function() { navigator.storage && navigator.storage.persist(); Y[a.id] || (Y[a.id] = []); Y[a.id].push(a.field); - const c = pb.open(a.id, 1); + const c = nb.open(a.id, 1); c.onupgradeneeded = function() { const b = a.db = this.result; - for (let e = 0, d; e < qb.length; e++) { - d = qb[e]; + for (let e = 0, d; e < ob.length; e++) { + d = ob[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 : "" : "")); } @@ -2283,13 +2266,13 @@ t.close = function() { this.db = null; }; t.destroy = function() { - const a = pb.deleteDatabase(this.id); + const a = nb.deleteDatabase(this.id); return Z(a); }; t.clear = function() { const a = []; - for (let b = 0, e; b < qb.length; b++) { - e = qb[b]; + for (let b = 0, e; b < ob.length; b++) { + e = ob[b]; for (let d = 0, f; d < Y[this.id].length; d++) { f = Y[this.id][d], a.push(e + ("reg" !== e ? f ? ":" + f : "" : "")); } @@ -2476,7 +2459,7 @@ t.commit = async function(a, c, b) { } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function tb(a, c, b) { +function qb(a, c, b) { const e = a.value; let d, f = 0; for (let g = 0, k; g < e.length; g++) { @@ -2505,17 +2488,17 @@ t.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(c) { c.openCursor().onsuccess = function() { const b = this.result; - b && tb(b, a); + b && qb(b, a); }; }), this.transaction("ctx", "readwrite", function(c) { c.openCursor().onsuccess = function() { const b = this.result; - b && tb(b, a); + b && qb(b, a); }; }), this.transaction("tag", "readwrite", function(c) { c.openCursor().onsuccess = function() { const b = this.result; - b && tb(b, a, !0); + b && qb(b, a, !0); }; }), this.transaction("reg", "readwrite", function(c) { for (let b = 0; b < a.length; b++) { @@ -2534,9 +2517,9 @@ function Z(a, c) { a = null; }); } -;const ub = {Index:N, Charset:eb, Encoder:ka, Document:U, Worker:P, Resolver:W, IndexedDB:rb, Language:{}}, vb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; -let wb; -(wb = vb.define) && wb.amd ? wb([], function() { - return ub; -}) : "object" === typeof vb.exports ? vb.exports = ub : vb.FlexSearch = ub; +;const rb = {Index:N, Charset:cb, Encoder:ja, Document:U, Worker:P, Resolver:W, IndexedDB:pb, Language:{}}, sb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; +let ub; +(ub = sb.define) && ub.amd ? ub([], function() { + return rb; +}) : "object" === typeof sb.exports ? sb.exports = rb : sb.FlexSearch = rb; }(this||self)); diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index 82ab6d1..c2f500d 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -1,95 +1,89 @@ /**! - * FlexSearch.js v0.8.142 (Bundle) + * FlexSearch.js v0.8.143 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ (function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var t;function z(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var 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 E(a){return"string"===typeof a} -function I(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(E(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; -this.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,ea)}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);ja||(this.mapper=new Map(da));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.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,da)}catch(d){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);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};t.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&&K(this);return this};t.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&K(this);return this}; t.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&K(this);return this}; t.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&K(this);return this}; -t.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(K,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ja?a.normalize("NFKD").replace(ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(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&&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 K(a){a.H=null;a.B.clear();a.G.clear()};let M,ka;async function la(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":ka=a.options||{};(c=a.factory)?(Function("return "+c)()(self),M=new self.FlexSearch.Index(ka),delete self.FlexSearch):M=new N(ka);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=ka.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await ka.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[c].apply(M,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ma(a){na.call(a,"add");na.call(a,"append");na.call(a,"search");na.call(a,"update");na.call(a,"remove")}let oa,pa,qa;function ra(){oa=qa=0} -function na(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]);oa?qa||(qa=Date.now()-pa>=this.priority*this.priority*3):(oa=setTimeout(ra,0),pa=Date.now());if(qa){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; +this.replacer[d+1]);this.cache&&h.length<=this.L&&(this.G.set(h,g),this.G.size>this.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.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 K(a){a.H=null;a.B.clear();a.G.clear()};let M,ja;async function ka(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":ja=a.options||{};(c=a.factory)?(Function("return "+c)()(self),M=new self.FlexSearch.Index(ja),delete self.FlexSearch):M=new N(ja);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=ja.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await ja.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[c].apply(M,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 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[++O]=function(){k(d);1E9=g.length)c-=g.length;else{c=g[e?"splice":"slice"](c,b);const h=c.length;if(h&&(d=d.length?d.concat(c):c,b-=h,e&&(a.length-=h),!b))break;c=0}return d} +function ra(a,c,b){return c?"undefined"!==typeof module?new(require("worker_threads")["Worker"])(__dirname+"/node/node.js"):import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)("import.meta.dirname")+"/node/node.mjs")}):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ka.toString()],{type:"text/javascript"}))):new window.Worker("string"===typeof b?b:(0,eval)("import.meta.url").replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", +"module/worker/worker.js"),{type:"module"})};function sa(a,c=0){let b=[],e=[];c&&(c=25E4/c*5E3|0);for(const d of a.entries())e.push(d),e.length===c&&(b.push(e),e=[]);e.length&&b.push(e);return b}function ta(a,c){c||(c=new Map);for(let b=0,e;b=g.length)c-=g.length;else{c=g[e?"splice":"slice"](c,b);const h=c.length;if(h&&(d=d.length?d.concat(c):c,b-=h,e&&(a.length-=h),!b))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,h,k;gb||e?k.slice(e,b+e):k;else{if(ab||e)k=k.slice(e,b+e)}else{d=[];for(let m= +this.C[k];if((b=l.I)&&!b(c))continue;let n;if("function"===typeof l){n=l(c);if(!n)continue;l=[l.V]}else if(E(l)||l.constructor===String){h[l]=c[l];continue}Ea(c,h,l,0,l[0],n)}}this.store.set(a,h||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;db||e?k.slice(e,b+e):k;else{if(ab||e)k=k.slice(e,b+e)}else{d=[];for(let m= 0,q;me)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}k=1c?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,h;f=h){b-=h;continue}bc&&(g=g.slice(0,c),h=c);if(!d.length&&h>=c)return e?V.call(this,g):g;d.push(g);c-=h;if(!c)break}d=1a.length?this.result=a[0]:(this.result=Ha(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:h,offset:k,enrich:l,resolve:n,suggest:m}=Ka(this,"and",arguments);return Ma.call(this,f,g,h,k,l,n,m)}return d?this.resolve(c,b,e):this}; -function Ma(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(c=ca(a))return this.result=Ga(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}=Ka(this,"xor",arguments);return Na.call(this,a,c,b,e,d,f,g)}; -function Na(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Oa.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 Oa(a,c,b,e,d){const f=[],g=B();let h=0;for(let k=0,l;kc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,h;f=h){b-=h;continue}bc&&(g=g.slice(0,c),h=c);if(!d.length&&h>=c)return e?V.call(this,g):g;d.push(g);c-=h;if(!c)break}d=1a.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: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(c,b,e):this}; +function La(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.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 h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=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 h=0;for(let k=0,l;kb||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;bb||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 Xa={normalize:function(a){return a.toLowerCase()}};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};const bb=/[\x00-\x7F]+/g;const cb=/[\x00-\x7F]+/g;const db=/[\x00-\x7F]+/g;var eb={LatinExact:{split:/\s+/,normalize:!1},LatinDefault:Xa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ya},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bu;f--){g=r.substring(u,f);v=this.rtl?d-1-u:u;var h=this.score?this.score(c,r,p,g,v):gb(q,e,p,d,v); -hb(this,n,g,h,a,b)}break}case "reverse":if(1g?0:1),e,p,h-1,k-1),v=this.bidirectional&& -r>f;hb(this,l,v?f:r,u,a,b,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else c=""}this.db&&(c||this.commit_task.push({del:a}),this.T&&ib(this));return this}; -function hb(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])if(g?(c=k||(c[b]=B()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){c=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=c);k[e]=h=c}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} -function gb(a,c,b,e,d){return b&&1b)&&(k=b,b=c,c=k);if(a.db)return a.db.get(c,b,e,d,f,g,h);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};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;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else nb(this.map,a),this.depth&&nb(this.ctx,a);c||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&ib(this));this.cache&&this.cache.remove(a);return this}; -function nb(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;ethis.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,split:/\s+/};const Xa={normalize:!0};const Ya={normalize:!0,dedupe:!0};const Za=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 $a=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),ab=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const bb={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 cb={X:Wa,W:Xa,Y:Ya,LatinBalance:{normalize:!0,dedupe:!0,mapper:Za},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Za,matcher:$a,replacer:ab},LatinExtra:{normalize:!0,dedupe:!0,mapper:Za,replacer:ab.concat([/(?!^)[aeo]/g,""]),matcher:$a},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bu;f--){g=r.substring(u,f);v=this.rtl?d-1-u:u;var h=this.score?this.score(c,r,p,g,v):eb(q,e,p,d,v); +fb(this,n,g,h,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1), +e,p,h-1,k-1),v=this.bidirectional&&r>f;fb(this,l,v?f:r,u,a,b,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else c=""}this.db&&(c||this.commit_task.push({del:a}),this.T&&gb(this));return this}; +function fb(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])if(g?(c=k||(c[b]=B()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){c=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=c);k[e]=h=c}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} +function eb(a,c,b,e,d){return b&&1b)&&(k=b,b=c,c=k);if(a.db)return a.db.get(c,b,e,d,f,g,h);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};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;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else lb(this.map,a),this.depth&&lb(this.ctx,a);c||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&gb(this));this.cache&&this.cache.remove(a);return this}; +function lb(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)}; -function ob(a){let c=0;if(a.constructor===Array)for(let b=0,e;b=n.length){e-=n.length;continue}const m=b?e+Math.min(n.length-e,b):n.length;for(let q=e;q=f.length)return[];if(!c&&!b)return f;f=f.slice(b,b+c);return e?d.enrich(f):f})}; t.enrich=function(a){"object"!==typeof a&&(a=[a]);const c=this.db.transaction("reg","readonly").objectStore("reg"),b=[];for(let e=0;e{a.onsuccess=a.oncomplete=function(){c&&c(this.result);c=null;b(this.result)};a.onerror=a.onblocked=e;a=null})};const ub={Index:N,Charset:eb,Encoder:J,Document:U,Worker:P,Resolver:W,IndexedDB:sb,Language:{}},vb="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let wb;(wb=vb.define)&&wb.amd?wb([],function(){return ub}):"object"===typeof vb.exports?vb.exports=ub:vb.FlexSearch=ub;}(this||self)); +h=h&&h.length?h.concat(g):g;e.put(h,f)})}}),a.map.clear(),a.ctx.clear(),a.tag&&a.tag.clear(),a.store&&a.store.clear(),a.document||a.reg.clear())};function qb(a,c,b){const e=a.value;let d,f=0;for(let g=0,h;g{a.onsuccess=a.oncomplete=function(){c&&c(this.result);c=null;b(this.result)};a.onerror=a.onblocked=e;a=null})};const rb={Index:N,Charset:cb,Encoder:J,Document:U,Worker:P,Resolver:W,IndexedDB:pb,Language:{}},tb="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let ub;(ub=tb.define)&&ub.amd?ub([],function(){return rb}):"object"===typeof tb.exports?tb.exports=rb:tb.FlexSearch=rb;}(this||self)); diff --git a/dist/flexsearch.bundle.module.debug.js b/dist/flexsearch.bundle.module.debug.js index 763e6be..6aa96e8 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.142 (Bundle/Module/Debug) + * FlexSearch.js v0.8.143 (Bundle/Module/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -76,18 +76,10 @@ function ca(a) { } return c; } -;var da = [["\u00aa", "a"], ["\u00b2", "2"], ["\u00b3", "3"], ["\u00b9", "1"], ["\u00ba", "o"], ["\u00bc", "1\u20444"], ["\u00bd", "1\u20442"], ["\u00be", "3\u20444"], ["\u00e0", "a"], ["\u00e1", "a"], ["\u00e2", "a"], ["\u00e3", "a"], ["\u00e4", "a"], ["\u00e5", "a"], ["\u00e7", "c"], ["\u00e8", "e"], ["\u00e9", "e"], ["\u00ea", "e"], ["\u00eb", "e"], ["\u00ec", "i"], ["\u00ed", "i"], ["\u00ee", "i"], ["\u00ef", "i"], ["\u00f1", "n"], ["\u00f2", "o"], ["\u00f3", "o"], ["\u00f4", "o"], ["\u00f5", -"o"], ["\u00f6", "o"], ["\u00f9", "u"], ["\u00fa", "u"], ["\u00fb", "u"], ["\u00fc", "u"], ["\u00fd", "y"], ["\u00ff", "y"], ["\u0101", "a"], ["\u0103", "a"], ["\u0105", "a"], ["\u0107", "c"], ["\u0109", "c"], ["\u010b", "c"], ["\u010d", "c"], ["\u010f", "d"], ["\u0113", "e"], ["\u0115", "e"], ["\u0117", "e"], ["\u0119", "e"], ["\u011b", "e"], ["\u011d", "g"], ["\u011f", "g"], ["\u0121", "g"], ["\u0123", "g"], ["\u0125", "h"], ["\u0129", "i"], ["\u012b", "i"], ["\u012d", "i"], ["\u012f", "i"], ["\u0133", -"ij"], ["\u0135", "j"], ["\u0137", "k"], ["\u013a", "l"], ["\u013c", "l"], ["\u013e", "l"], ["\u0140", "l"], ["\u0144", "n"], ["\u0146", "n"], ["\u0148", "n"], ["\u0149", "n"], ["\u014d", "o"], ["\u014f", "o"], ["\u0151", "o"], ["\u0155", "r"], ["\u0157", "r"], ["\u0159", "r"], ["\u015b", "s"], ["\u015d", "s"], ["\u015f", "s"], ["\u0161", "s"], ["\u0163", "t"], ["\u0165", "t"], ["\u0169", "u"], ["\u016b", "u"], ["\u016d", "u"], ["\u016f", "u"], ["\u0171", "u"], ["\u0173", "u"], ["\u0175", "w"], ["\u0177", -"y"], ["\u017a", "z"], ["\u017c", "z"], ["\u017e", "z"], ["\u017f", "s"], ["\u01a1", "o"], ["\u01b0", "u"], ["\u01c6", "dz"], ["\u01c9", "lj"], ["\u01cc", "nj"], ["\u01ce", "a"], ["\u01d0", "i"], ["\u01d2", "o"], ["\u01d4", "u"], ["\u01d6", "u"], ["\u01d8", "u"], ["\u01da", "u"], ["\u01dc", "u"], ["\u01df", "a"], ["\u01e1", "a"], ["\u01e3", "ae"], ["\u00e6", "ae"], ["\u01fd", "ae"], ["\u01e7", "g"], ["\u01e9", "k"], ["\u01eb", "o"], ["\u01ed", "o"], ["\u01ef", "\u0292"], ["\u01f0", "j"], ["\u01f3", -"dz"], ["\u01f5", "g"], ["\u01f9", "n"], ["\u01fb", "a"], ["\u01ff", "\u00f8"], ["\u0201", "a"], ["\u0203", "a"], ["\u0205", "e"], ["\u0207", "e"], ["\u0209", "i"], ["\u020b", "i"], ["\u020d", "o"], ["\u020f", "o"], ["\u0211", "r"], ["\u0213", "r"], ["\u0215", "u"], ["\u0217", "u"], ["\u0219", "s"], ["\u021b", "t"], ["\u021f", "h"], ["\u0227", "a"], ["\u0229", "e"], ["\u022b", "o"], ["\u022d", "o"], ["\u022f", "o"], ["\u0231", "o"], ["\u0233", "y"], ["\u02b0", "h"], ["\u02b1", "h"], ["\u0266", "h"], -["\u02b2", "j"], ["\u02b3", "r"], ["\u02b4", "\u0279"], ["\u02b5", "\u027b"], ["\u02b6", "\u0281"], ["\u02b7", "w"], ["\u02b8", "y"], ["\u02e0", "\u0263"], ["\u02e1", "l"], ["\u02e2", "s"], ["\u02e3", "x"], ["\u02e4", "\u0295"], ["\u0390", "\u03b9"], ["\u03ac", "\u03b1"], ["\u03ad", "\u03b5"], ["\u03ae", "\u03b7"], ["\u03af", "\u03b9"], ["\u03b0", "\u03c5"], ["\u03ca", "\u03b9"], ["\u03cb", "\u03c5"], ["\u03cc", "\u03bf"], ["\u03cd", "\u03c5"], ["\u03ce", "\u03c9"], ["\u03d0", "\u03b2"], ["\u03d1", -"\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db", -"\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]]; -const ea = /[^\p{L}\p{N}]+/u, fa = /(\d{3})/g, ha = /(\D)(\d{3})/g, ia = /(\d{3})(\D)/g, ja = "".normalize && /[\u0300-\u036f]/g; -function ka(a = {}) { - if (!this || this.constructor !== ka) { - return new ka(...arguments); +;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++) { @@ -97,7 +89,7 @@ function ka(a = {}) { this.assign(a); } } -t = ka.prototype; +t = ja.prototype; t.assign = function(a) { this.normalize = z(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, e; @@ -125,7 +117,7 @@ t.assign = function(a) { this.numeric = z(a.numeric, e); } else { try { - this.split = z(this.split, ea); + 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+/; } @@ -133,7 +125,6 @@ t.assign = function(a) { } this.prepare = z(a.prepare, null, this.prepare); this.finalize = z(a.finalize, null, this.finalize); - ja || (this.mapper = new Map(da)); 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); @@ -221,9 +212,9 @@ t.encode = function(a) { this.H = setTimeout(J, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ja ? a.normalize("NFKD").replace(ja, "").toLowerCase() : a.toLowerCase()); + 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(ha, "$1 $2").replace(ia, "$1 $2").replace(fa, "$1 ")); + 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++) { @@ -273,7 +264,7 @@ function J(a) { a.G.clear(); } ;let K, M; -async function la(a) { +async function ka(a) { a = a.data; var c = a.task; const b = a.id; @@ -303,25 +294,25 @@ async function la(a) { postMessage("search" === c ? {id:b, msg:d} : {id:b}); } } -;function ma(a) { - na.call(a, "add"); - na.call(a, "append"); - na.call(a, "search"); - na.call(a, "update"); - na.call(a, "remove"); +;function la(a) { + ma.call(a, "add"); + ma.call(a, "append"); + ma.call(a, "search"); + ma.call(a, "update"); + ma.call(a, "remove"); } -let oa, pa, qa; -function ra() { - oa = qa = 0; +let na, oa, pa; +function qa() { + na = pa = 0; } -function na(a) { +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]); - oa ? qa || (qa = Date.now() - pa >= this.priority * this.priority * 3) : (oa = setTimeout(ra, 0), pa = Date.now()); - if (qa) { + 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() { @@ -366,7 +357,7 @@ function 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 = sa(b, e, a.worker); + 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); @@ -379,7 +370,7 @@ Q("remove"); Q("clear"); Q("export"); Q("import"); -ma(P.prototype); +la(P.prototype); function Q(a) { P.prototype[a] = function() { const c = this, b = [].slice.call(arguments); @@ -394,11 +385,11 @@ function Q(a) { return d ? (e.then(d), this) : e; }; } -function sa(a, c, b) { - return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + la.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function ra(a, c, b) { + return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function ta(a, c = 0) { +;function sa(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { @@ -407,30 +398,30 @@ function sa(a, c, b) { e.length && b.push(e); return b; } -function ua(a, c) { +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 va(a, c = 0) { +function ua(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], ta(d[1])[0]]), e.length === c && (b.push(e), e = []); + e.push([d[0], sa(d[1])[0]]), e.length === c && (b.push(e), e = []); } e.length && b.push(e); return b; } -function wa(a, c) { +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], ua(e[1], d)); + e = a[b], d = c.get(e[0]), c.set(e[0], ta(e[1], d)); } return c; } -function xa(a) { +function wa(a) { let c = [], b = []; for (const e of a.keys()) { b.push(e), 250000 === b.length && (c.push(b), b = []); @@ -438,14 +429,14 @@ function xa(a) { b.length && c.push(b); return c; } -function ya(a, c) { +function xa(a, c) { c || (c = new Set()); for (let b = 0; b < a.length; b++) { c.add(a[b]); } return c; } -function za(a, c, b, e, d, f, g = 0) { +function ya(a, c, b, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { @@ -454,12 +445,12 @@ function za(a, c, b, e, d, f, g = 0) { if ((h = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(h))) && h.then) { const l = this; return h.then(function() { - return za.call(l, a, c, b, k ? e : null, d, f, g + 1); + return ya.call(l, a, c, b, k ? e : null, d, f, g + 1); }); } - return za.call(this, 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 Aa(a, c) { +function za(a, c) { let b = ""; for (const e of a.entries()) { a = e[0]; @@ -479,7 +470,7 @@ function Aa(a, c) { } return b; } -;function Ba(a, c, b, e) { +;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) { @@ -545,12 +536,12 @@ function R(a) { } if ("slice" === e) { return function(d, f) { - return Ba(c, d || 0, f || c.length, !1); + return Aa(c, d || 0, f || c.length, !1); }; } if ("splice" === e) { return function(d, f) { - return Ba(c, d || 0, f || c.length, !0); + return Aa(c, d || 0, f || c.length, !0); }; } if ("constructor" === e) { @@ -581,7 +572,7 @@ function S(a = 8) { this.index = B(); this.h = []; this.size = 0; - 32 < a ? (this.B = Ca, this.A = BigInt(a)) : (this.B = Da, this.A = a); + 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)]; @@ -599,7 +590,7 @@ function T(a = 8) { this.index = B(); this.h = []; this.size = 0; - 32 < a ? (this.B = Ca, this.A = BigInt(a)) : (this.B = Da, this.A = a); + 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); @@ -641,7 +632,7 @@ t.entries = T.prototype.entries = function*() { } } }; -function Da(a) { +function Ca(a) { let c = 2 ** this.A - 1; if ("number" == typeof a) { return a & c; @@ -652,7 +643,7 @@ function Da(a) { } return 32 === this.A ? b + 2 ** 31 : b; } -function Ca(a) { +function Ba(a) { let c = BigInt(2) ** this.A - BigInt(1); var b = typeof a; if ("bigint" === b) { @@ -682,7 +673,7 @@ function Ca(a) { d && e.add(a, d, !1, !0); } else { if (d = h.I, !d || d(c)) { - h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Ea(c, h, this.J, 0, e, a, h[0], b); + h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Da(c, h, this.J, 0, e, a, h[0], b); } } } @@ -745,7 +736,7 @@ function Ca(a) { k[l] = c[l]; continue; } - Fa(c, k, l, 0, l[0], n); + Ea(c, k, l, 0, l[0], n); } } this.store.set(a, k || c); @@ -754,21 +745,21 @@ function Ca(a) { } return this; }; -function Fa(a, c, b, e, d, f) { +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++) { - Fa(a, c, b, e, d); + Ea(a, c, b, e, d); } } else { - c = c[d] || (c[d] = B()), d = b[++e], Fa(a, c, b, e, d); + c = c[d] || (c[d] = B()), d = b[++e], Ea(a, c, b, e, d); } } } -function Ea(a, c, b, e, d, f, g, k) { +function Da(a, c, b, e, d, f, g, k) { if (a = a[g]) { if (e === c.length - 1) { if (a.constructor === Array) { @@ -784,17 +775,17 @@ function Ea(a, c, b, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Ea(a, c, b, e, d, f, g, k); + Da(a, c, b, e, d, f, g, k); } } else { - g = c[++e], Ea(a, c, b, e, d, f, g, k); + g = c[++e], Da(a, c, b, e, d, f, g, k); } } } else { d.db && d.remove(f); } } -;function Ga(a, c, b, e, d, f, g) { +;function Fa(a, c, b, e, d, f, g) { const k = a.length; let h = [], l, n; l = B(); @@ -819,7 +810,7 @@ function Ea(a, c, b, e, d, f, g, k) { } if (a = h.length) { if (d) { - h = 1 < h.length ? Ha(h, b, e, g, f) : (h = h[0]).length > b || e ? h.slice(e, b + e) : h; + 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 []; @@ -852,7 +843,7 @@ function Ea(a, c, b, e, d, f, g, k) { } return h; } -function Ha(a, c, b, e, d) { +function Ga(a, c, b, e, d) { const f = [], g = B(); let k; var h = a.length; @@ -897,7 +888,7 @@ function Ha(a, c, b, e, d) { } return f; } -function Ia(a, c, b) { +function Ha(a, c, b) { const e = B(), d = []; for (let f = 0, g; f < c.length; f++) { g = c[f]; @@ -918,7 +909,7 @@ function Ia(a, c, b) { } return d; } -;function Ja(a, c, b, e) { +;function Ia(a, c, b, e) { if (!a.length) { return a; } @@ -949,7 +940,7 @@ function Ia(a, c, b) { d = 1 < d.length ? [].concat.apply([], d) : d[0]; return e ? V.call(this, d) : d; } -;function Ka(a, c, b) { +;function Ja(a, c, b) { var e = b[0]; if (e.then) { return Promise.all(b).then(function(n) { @@ -996,10 +987,10 @@ function Ia(a, c, b) { 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} = Ka(this, "or", arguments); - return La.call(this, a, c, b, e, d, f); + 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 La(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) { @@ -1007,10 +998,10 @@ function La(a, c, b, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return La.call(g, a, [], b, e, d, f); + 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 = Ha(a, b, e, !1, this.h), e = 0)); + 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() { @@ -1020,11 +1011,40 @@ function La(a, c, b, e, d, f) { 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} = Ka(this, "and", arguments); - return Ma.call(this, f, g, k, h, l, n, m); + 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; @@ -1040,43 +1060,14 @@ function Ma(a, c, b, e, d, f, g) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (c = ca(a)) { - return this.result = Ga(a, c, b, e, g, this.h, f), f ? d ? V.call(this.index, this.result) : this.result : this; - } - this.result = []; + 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; } -;W.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ka(this, "xor", arguments); - return Na.call(this, a, c, b, e, d, f, g); -}; -function Na(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 Na.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 = Oa.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 Oa(a, c, b, e, d) { +function Na(a, c, b, e, d) { const f = [], g = B(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -1122,10 +1113,10 @@ function Oa(a, c, b, e, d) { return f; } ;W.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ka(this, "not", arguments); - return Pa.call(this, a, c, b, e, d, f, g); + 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 Pa(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) { @@ -1133,17 +1124,17 @@ function Pa(a, c, b, e, d, f, g) { for (let l = 0, n; l < h.length; l++) { (n = h[l]).length && (a[l] = n); } - return Pa.call(k, a, [], b, e, d, f, g); + return Oa.call(k, a, [], b, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Qa.call(this, a, b, e, f); + 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 Qa(a, c, b, e) { +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++) { @@ -1218,7 +1209,7 @@ W.prototype.boost = function(a) { 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), Ja.call(d, e, a || 100, c, b)) : e; + 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) { @@ -1298,7 +1289,7 @@ U.prototype.search = function(a, c, b, e) { } m.push(p = p.db.tag(v[f + 1], c, u, g)); } else { - p = Ra.call(this, v[f], v[f + 1], c, u, g); + p = Qa.call(this, v[f], v[f + 1], c, u, g); } d.push({field:v[f], tag:v[f + 1], result:p}); } @@ -1350,7 +1341,7 @@ U.prototype.search = function(a, c, b, e) { } } } else { - for (let G = 0, L, pb; G < l.length; G += 2) { + for (let G = 0, L, qb; G < l.length; G += 2) { L = this.tag.get(l[G]); if (!L) { if (console.warn("Tag '" + l[G] + ":" + l[G + 1] + "' will be skipped because there is no field '" + l[G] + "'."), r) { @@ -1359,7 +1350,7 @@ U.prototype.search = function(a, c, b, e) { return m ? d : new W(d); } } - if (pb = (L = L && L.get(l[G + 1])) && L.length) { + if (qb = (L = L && L.get(l[G + 1])) && L.length) { y++, w.push(L); } else if (!r) { return m ? d : new W(d); @@ -1367,7 +1358,7 @@ U.prototype.search = function(a, c, b, e) { } } if (y) { - x = Ia(x, w, m); + x = Ha(x, w, m); H = x.length; if (!H && !r) { return m ? x : new W(x); @@ -1421,12 +1412,12 @@ U.prototype.search = function(a, c, b, e) { for (let D = 0; D < x.length; D++) { d[D].result = x[D]; } - return k ? Sa(d, c) : q ? Ta(d, a, A.index, A.field, A.D, q) : d; + return k ? Ra(d, c) : q ? Sa(d, a, A.index, A.field, A.D, q) : d; }); } - return k ? Sa(d, c) : q ? Ta(d, a, this.index, this.field, this.D, q) : d; + return k ? Ra(d, c) : q ? Sa(d, a, this.index, this.field, this.D, q) : d; }; -function Ta(a, c, b, e, d, f) { +function Sa(a, c, b, e, d, f) { let g, k, h; for (let n = 0, m, q, p, r; n < a.length; n++) { let u = a[n].result; @@ -1471,7 +1462,7 @@ function Ta(a, c, b, e, d, f) { } return a; } -function Sa(a, c) { +function Ra(a, c) { const b = [], e = B(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1490,7 +1481,7 @@ function Sa(a, c) { } return b; } -function Ra(a, c, b, e, d) { +function Qa(a, c, b, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1522,7 +1513,7 @@ function V(a) { this.D = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && Ua(b, this.J) || "id"; + 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(); @@ -1532,7 +1523,7 @@ function V(a) { a.cache = !1; this.worker = a.worker; this.priority = a.priority || 4; - this.index = Va.call(this, a, c); + this.index = Ua.call(this, a, c); this.tag = null; if (b = c.tag) { if ("string" === typeof b && (b = [b]), b.length) { @@ -1545,7 +1536,7 @@ function V(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.F[d] = f.custom : (this.F[d] = Ua(g, this.J), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = f.filter)); + f.custom ? this.F[d] = f.custom : (this.F[d] = 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()); } @@ -1617,7 +1608,7 @@ t.destroy = function() { } return Promise.all(a); }; -function Va(a, c) { +function Ua(a, c) { const b = new Map(); let e = c.index || c.field || c; E(e) && (e = [e]); @@ -1630,19 +1621,19 @@ function Va(a, c) { b.set(f, k); } this.worker || b.set(f, new N(g, this.reg)); - g.custom ? this.D[d] = g.custom : (this.D[d] = Ua(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); + 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; E(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = Ua(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = 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 Ua(a, c) { +function Ta(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { @@ -1711,7 +1702,7 @@ t.set = function(a, c) { this.store.set(a, c); return this; }; -t.searchCache = Wa; +t.searchCache = Va; t.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1727,23 +1718,23 @@ t.export = function(a, c, b = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = xa(this.reg); + f = wa(this.reg); c = null; break; case 1: d = "tag"; - f = this.tag && va(this.tag, this.reg.size); + f = this.tag && ua(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = this.store && ta(this.store); + f = this.store && sa(this.store); c = null; break; default: return; } - return za.call(this, a, c, d, f, b, e); + return ya.call(this, a, c, d, f, b, e); }; t.import = function(a, c) { var b = a.split("."); @@ -1761,7 +1752,7 @@ t.import = function(a, c) { switch(b) { case "reg": this.fastupdate = !1; - this.reg = ya(c, this.reg); + 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; } @@ -1774,15 +1765,15 @@ t.import = function(a, c) { } break; case "tag": - this.tag = wa(c, this.tag); + this.tag = va(c, this.tag); break; case "doc": - this.store = ua(c, this.store); + this.store = ta(c, this.store); } } }; -ma(U.prototype); -function Wa(a, c, b) { +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); @@ -1823,31 +1814,22 @@ X.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Xa = {normalize:function(a) { - return a.toLowerCase(); -}}; -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}; -const bb = /[\x00-\x7F]+/g; -const cb = /[\x00-\x7F]+/g; -const db = /[\x00-\x7F]+/g; -var eb = {LatinExact:{split:/\s+/, normalize:!1}, LatinDefault:Xa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ya}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ya, matcher:Za, replacer:$a}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ya, replacer:$a.concat([/(?!^)[aeo]/g, ""]), matcher:Za}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +const Wa = {normalize:!1, numeric:!1, split:/\s+/}; +const Xa = {normalize:!0}; +const Ya = {normalize:!0, dedupe:!0}; +const Za = 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 $a = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), ab = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const bb = {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 cb = {X:Wa, W:Xa, Y:Ya, LatinBalance:{normalize:!0, dedupe:!0, mapper:Za}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Za, matcher:$a, replacer:ab}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Za, replacer:ab.concat([/(?!^)[aeo]/g, ""]), matcher:$a}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; - let e = c.charAt(0), d = 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++) { + let e = c.charAt(0), d = bb[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = bb[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } -}}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(bb, " "); -}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(cb, ""); -}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(db, " "); -}}}; -const fb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +}}, LatinExact:Wa, LatinDefault:Xa, LatinSimple:Ya}; +const db = {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)) { @@ -1860,7 +1842,7 @@ N.prototype.add = function(a, c, b, e) { 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) : gb(q, e, p), g = ""; + var f = this.score ? this.score(c, r, p, null, 0) : eb(q, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { @@ -1868,35 +1850,36 @@ N.prototype.add = function(a, c, b, e) { for (f = d; f > u; f--) { g = r.substring(u, f); v = this.rtl ? d - 1 - u : u; - var k = this.score ? this.score(c, r, p, g, v) : gb(q, e, p, d, v); - hb(this, n, g, k, a, b); + var k = this.score ? this.score(c, r, p, g, v) : eb(q, e, p, d, v); + fb(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) : gb(q, e, p, d, k); - hb(this, n, g, h, a, b); + var h = this.score ? this.score(c, r, p, g, k) : eb(q, e, p, d, k); + fb(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], hb(this, n, g, f, a, b); + g += r[this.rtl ? d - 1 - k : k], fb(this, n, g, f, a, b); } break; } default: - if (hb(this, n, r, f, a, b), m && 1 < e && p < e - 1) { + if (fb(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) : gb(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), v = this.bidirectional && r > f; - hb(this, l, v ? f : r, u, a, b, v ? r : f); + const u = this.score ? this.score(c, f, p, r, h - 1) : eb(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), v = this.bidirectional && r > f; + fb(this, l, v ? f : r, u, a, b, v ? r : f); } } } @@ -1908,10 +1891,10 @@ N.prototype.add = function(a, c, b, e) { c = ""; } } - this.db && (c || this.commit_task.push({del:a}), this.T && ib(this)); + this.db && (c || this.commit_task.push({del:a}), this.T && gb(this)); return this; }; -function hb(a, c, b, e, d, f, g) { +function fb(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)) { @@ -1929,7 +1912,7 @@ function hb(a, c, b, e, d, f, g) { } } } -function gb(a, c, b, e, d) { +function eb(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) { @@ -1940,11 +1923,11 @@ function gb(a, c, b, e, d) { d = p.length; c = c || (h ? 100 : 0); if (1 === d) { - return jb.call(this, p[0], "", c, k, h, q, l); + return hb.call(this, p[0], "", c, k, h, q, l); } f = this.depth && !1 !== f; if (2 === d && f && !g) { - return jb.call(this, p[0], p[1], c, k, h, q, l); + return hb.call(this, p[0], p[1], c, k, h, q, l); } let r = B(), u = 0, v; 1 < d && f && (v = p[0], u = 1); @@ -1958,8 +1941,8 @@ function gb(a, c, b, e, d) { for (let y, F; u < d; u++) { if ((F = p[u]) && !r[F]) { r[F] = 1; - y = await kb(w, F, v, 0, 0, !1, !1); - if (y = lb(y, e, g, m)) { + y = await ib(w, F, v, 0, 0, !1, !1); + if (y = jb(y, e, g, m)) { e = y; break; } @@ -1967,14 +1950,14 @@ function gb(a, c, b, e, d) { } g && v && u === d - 1 && !e.length && (m = w.resolution, v = "", u = -1, r = B()); } - return mb(e, m, c, k, g, n, h); + 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 = kb(this, y, v, 0, 0, !1, !1); - if (w = lb(w, e, g, m)) { + w = ib(this, y, v, 0, 0, !1, !1); + if (w = jb(w, e, g, m)) { e = w; break; } @@ -1982,24 +1965,24 @@ function gb(a, c, b, e, d) { } g && v && u === d - 1 && !e.length && (m = this.resolution, v = "", u = -1, r = B()); } - return mb(e, m, c, k, g, n, h); + return kb(e, m, c, k, g, n, h); }; -function mb(a, c, b, e, d, f, g) { +function kb(a, c, b, e, d, f, g) { let k = a.length, h = a; if (1 < k) { - h = Ga(a, c, b, e, d, f, g); + h = Fa(a, c, b, e, d, f, g); } else if (1 === k) { - return g ? Ja.call(null, a[0], b, e) : new W(a[0]); + return g ? Ia.call(null, a[0], b, e) : new W(a[0]); } return g ? h : new W(h); } -function jb(a, c, b, e, d, f, g) { - a = kb(this, a, c, b, e, d, f, g); +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 ? Ja.call(this, a, b, e) : new W(a) : d ? [] : new W(); + }) : a && a.length ? d ? Ia.call(this, a, b, e) : new W(a) : d ? [] : new W(); } -function lb(a, c, b, e) { +function jb(a, c, b, e) { let d = []; if (a && a.length) { if (a.length <= e) { @@ -2020,7 +2003,7 @@ function lb(a, c, b, e) { return d; } } -function kb(a, c, b, e, d, f, g, k) { +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) { @@ -2044,15 +2027,15 @@ function kb(a, c, b, e, d, f, g, k) { } } } else { - nb(this.map, a), this.depth && nb(this.ctx, a); + lb(this.map, a), this.depth && lb(this.ctx, a); } c || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.T && ib(this)); + this.db && (this.commit_task.push({del:a}), this.T && gb(this)); this.cache && this.cache.remove(a); return this; }; -function nb(a, c) { +function lb(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -2067,7 +2050,7 @@ function nb(a, c) { } } else { for (let e of a.entries()) { - const d = e[0], f = nb(e[1], c); + const d = e[0], f = lb(e[1], c); f ? b += f : a.delete(d); } } @@ -2079,15 +2062,15 @@ function nb(a, c) { } if (a) { var b = E(a) ? a : a.preset; - b && (fb[b] || console.warn("Preset not found: " + b), a = Object.assign({}, fb[b], a)); + b && (db[b] || console.warn("Preset not found: " + b), a = Object.assign({}, db[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = E(a.encoder) ? eb[a.encoder] : a.encode || a.encoder || Xa; - this.encoder = d.encode ? d : "object" === typeof d ? new ka(d) : {encode:d}; + const e = !0 === b ? {depth:1} : b || {}, d = E(a.encoder) ? cb[a.encoder] : a.encode || a.encoder || Xa; + 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 && b || "strict"; + 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; @@ -2122,7 +2105,7 @@ t.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function ib(a) { +function gb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); @@ -2146,7 +2129,7 @@ t.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; -function ob(a) { +function mb(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -2154,7 +2137,7 @@ function ob(a) { } } else { for (const b of a.entries()) { - const e = b[0], d = ob(b[1]); + const e = b[0], d = mb(b[1]); d ? c += d : a.delete(e); } } @@ -2164,17 +2147,17 @@ t.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - ob(this.map); - this.depth && ob(this.ctx); + mb(this.map); + this.depth && mb(this.ctx); return this; }; -t.searchCache = Wa; +t.searchCache = Va; t.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = xa(this.reg); + f = wa(this.reg); break; case 1: d = "cfg"; @@ -2182,29 +2165,29 @@ t.export = function(a, c, b = 0, e = 0) { break; case 2: d = "map"; - f = ta(this.map, this.reg.size); + f = sa(this.map, this.reg.size); break; case 3: d = "ctx"; - f = va(this.ctx, this.reg.size); + f = ua(this.ctx, this.reg.size); break; default: return; } - return za.call(this, a, c, d, f, b, e); + return ya.call(this, a, c, d, f, b, e); }; t.import = function(a, c) { if (c) { switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = ya(c, this.reg); + this.reg = xa(c, this.reg); break; case "map": - this.map = ua(c, this.map); + this.map = ta(c, this.map); break; case "ctx": - this.ctx = wa(c, this.ctx); + this.ctx = va(c, this.ctx); } } }; @@ -2216,11 +2199,11 @@ t.serialize = function(a = !0) { f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); } c = "index.reg=new Set([" + c + "]);"; - b = Aa(this.map, f); + b = za(this.map, f); b = "index.map=new Map([" + b + "]);"; for (const g of this.ctx.entries()) { d = g[0]; - let k = Aa(g[1], f); + let k = za(g[1], f); k = "new Map([" + k + "])"; k = '["' + d + '",' + k + "]"; e += (e ? "," : "") + k; @@ -2229,11 +2212,11 @@ t.serialize = function(a = !0) { } return a ? "function inject(index){" + c + b + e + "}" : c + b + e; }; -ma(N.prototype); -const qb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), rb = ["map", "ctx", "tag", "reg", "cfg"], Y = B(); -function sb(a, c = {}) { +la(N.prototype); +const nb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), ob = ["map", "ctx", "tag", "reg", "cfg"], Y = B(); +function pb(a, c = {}) { if (!this) { - return new sb(a, c); + return new pb(a, c); } "object" === typeof a && (c = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -2244,7 +2227,7 @@ function sb(a, c = {}) { this.db = null; this.h = {}; } -t = sb.prototype; +t = pb.prototype; t.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -2260,11 +2243,11 @@ t.open = function() { navigator.storage && navigator.storage.persist(); Y[a.id] || (Y[a.id] = []); Y[a.id].push(a.field); - const c = qb.open(a.id, 1); + const c = nb.open(a.id, 1); c.onupgradeneeded = function() { const b = a.db = this.result; - for (let e = 0, d; e < rb.length; e++) { - d = rb[e]; + for (let e = 0, d; e < ob.length; e++) { + d = ob[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 : "" : "")); } @@ -2282,13 +2265,13 @@ t.close = function() { this.db = null; }; t.destroy = function() { - const a = qb.deleteDatabase(this.id); + const a = nb.deleteDatabase(this.id); return Z(a); }; t.clear = function() { const a = []; - for (let b = 0, e; b < rb.length; b++) { - e = rb[b]; + for (let b = 0, e; b < ob.length; b++) { + e = ob[b]; for (let d = 0, f; d < Y[this.id].length; d++) { f = Y[this.id][d], a.push(e + ("reg" !== e ? f ? ":" + f : "" : "")); } @@ -2475,7 +2458,7 @@ t.commit = async function(a, c, b) { } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function tb(a, c, b) { +function rb(a, c, b) { const e = a.value; let d, f = 0; for (let g = 0, k; g < e.length; g++) { @@ -2504,17 +2487,17 @@ t.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(c) { c.openCursor().onsuccess = function() { const b = this.result; - b && tb(b, a); + b && rb(b, a); }; }), this.transaction("ctx", "readwrite", function(c) { c.openCursor().onsuccess = function() { const b = this.result; - b && tb(b, a); + b && rb(b, a); }; }), this.transaction("tag", "readwrite", function(c) { c.openCursor().onsuccess = function() { const b = this.result; - b && tb(b, a, !0); + b && rb(b, a, !0); }; }), this.transaction("reg", "readwrite", function(c) { for (let b = 0; b < a.length; b++) { @@ -2533,6 +2516,6 @@ function Z(a, c) { a = null; }); } -;export default {Index:N, Charset:eb, Encoder:ka, Document:U, Worker:P, Resolver:W, IndexedDB:sb, Language:{}}; +;export default {Index:N, Charset:cb, Encoder:ja, Document:U, Worker:P, Resolver:W, IndexedDB:pb, Language:{}}; -export const Index=N;export const Charset=eb;export const Encoder=ka;export const Document=U;export const Worker=P;export const Resolver=W;export const IndexedDB=sb;export const Language={}; \ No newline at end of file +export const Index=N;export const Charset=cb;export const Encoder=ja;export const Document=U;export const Worker=P;export const Resolver=W;export const IndexedDB=pb;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js index 763c377..6b2f473 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -1,95 +1,89 @@ /**! - * FlexSearch.js v0.8.142 (Bundle/Module) + * FlexSearch.js v0.8.143 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ var t;function z(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var 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 E(a){return"string"===typeof a} -function I(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(E(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; -this.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,ea)}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);ja||(this.mapper=new Map(da));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.numeric=z(a.numeric,e)}else{try{this.split=z(this.split,da)}catch(d){this.split=/\s+/}this.numeric=z(a.numeric,z(this.numeric,!0))}this.prepare=z(a.prepare,null,this.prepare);this.finalize=z(a.finalize,null,this.finalize);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};t.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&&K(this);return this};t.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&K(this);return this}; t.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&K(this);return this}; t.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&K(this);return this}; -t.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(K,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ja?a.normalize("NFKD").replace(ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(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&&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 K(a){a.H=null;a.B.clear();a.G.clear()};let M,ka;async function la(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":ka=a.options||{};(c=a.factory)?(Function("return "+c)()(self),M=new self.FlexSearch.Index(ka),delete self.FlexSearch):M=new N(ka);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=ka.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await ka.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[c].apply(M,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ma(a){na.call(a,"add");na.call(a,"append");na.call(a,"search");na.call(a,"update");na.call(a,"remove")}let oa,pa,qa;function ra(){oa=qa=0} -function na(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]);oa?qa||(qa=Date.now()-pa>=this.priority*this.priority*3):(oa=setTimeout(ra,0),pa=Date.now());if(qa){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; +this.replacer[d+1]);this.cache&&h.length<=this.L&&(this.G.set(h,g),this.G.size>this.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.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 K(a){a.H=null;a.B.clear();a.G.clear()};let M,ja;async function ka(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":ja=a.options||{};(c=a.factory)?(Function("return "+c)()(self),M=new self.FlexSearch.Index(ja),delete self.FlexSearch):M=new N(ja);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=ja.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await ja.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[c].apply(M,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 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[++O]=function(){k(d);1E9=g.length)c-=g.length;else{c=g[e?"splice":"slice"](c,b);const h=c.length;if(h&&(d=d.length?d.concat(c):c,b-=h,e&&(a.length-=h),!b))break;c=0}return d} +function ra(a,c,b){return c?"undefined"!==typeof module?new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js"):import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ka.toString()],{type:"text/javascript"}))):new window.Worker("string"===typeof b?b:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", +"module/worker/worker.js"),{type:"module"})};function sa(a,c=0){let b=[],e=[];c&&(c=25E4/c*5E3|0);for(const d of a.entries())e.push(d),e.length===c&&(b.push(e),e=[]);e.length&&b.push(e);return b}function ta(a,c){c||(c=new Map);for(let b=0,e;b=g.length)c-=g.length;else{c=g[e?"splice":"slice"](c,b);const h=c.length;if(h&&(d=d.length?d.concat(c):c,b-=h,e&&(a.length-=h),!b))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,h,k;gb||e?k.slice(e,b+e):k;else{if(ab||e)k=k.slice(e,b+e)}else{d=[];for(let m= +this.C[k];if((b=l.I)&&!b(c))continue;let n;if("function"===typeof l){n=l(c);if(!n)continue;l=[l.V]}else if(E(l)||l.constructor===String){h[l]=c[l];continue}Ea(c,h,l,0,l[0],n)}}this.store.set(a,h||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;db||e?k.slice(e,b+e):k;else{if(ab||e)k=k.slice(e,b+e)}else{d=[];for(let m= 0,q;me)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}k=1c?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,h;f=h){b-=h;continue}bc&&(g=g.slice(0,c),h=c);if(!d.length&&h>=c)return e?V.call(this,g):g;d.push(g);c-=h;if(!c)break}d=1a.length?this.result=a[0]:(this.result=Ha(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:h,offset:k,enrich:l,resolve:n,suggest:m}=Ka(this,"and",arguments);return Ma.call(this,f,g,h,k,l,n,m)}return d?this.resolve(c,b,e):this}; -function Ma(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(c=ca(a))return this.result=Ga(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}=Ka(this,"xor",arguments);return Na.call(this,a,c,b,e,d,f,g)}; -function Na(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Oa.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 Oa(a,c,b,e,d){const f=[],g=B();let h=0;for(let k=0,l;kc?c?a.slice(b,b+c):a.slice(b):a,e?V.call(this,a):a;let d=[];for(let f=0,g,h;f=h){b-=h;continue}bc&&(g=g.slice(0,c),h=c);if(!d.length&&h>=c)return e?V.call(this,g):g;d.push(g);c-=h;if(!c)break}d=1a.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: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(c,b,e):this}; +function La(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.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 h=this;return Promise.all(c).then(function(k){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=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 h=0;for(let k=0,l;kb||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;bb||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 Xa={normalize:function(a){return a.toLowerCase()}};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};const bb=/[\x00-\x7F]+/g;const cb=/[\x00-\x7F]+/g;const db=/[\x00-\x7F]+/g;var eb={LatinExact:{split:/\s+/,normalize:!1},LatinDefault:Xa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ya},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ya,matcher:Za,replacer:$a},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ya,replacer:$a.concat([/(?!^)[aeo]/g,""]),matcher:Za},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bu;f--){g=r.substring(u,f);v=this.rtl?d-1-u:u;var h=this.score?this.score(c,r,p,g,v):gb(q,e,p,d,v); -hb(this,n,g,h,a,b)}break}case "reverse":if(1g?0:1),e,p,h-1,k-1),v=this.bidirectional&& -r>f;hb(this,l,v?f:r,u,a,b,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else c=""}this.db&&(c||this.commit_task.push({del:a}),this.T&&ib(this));return this}; -function hb(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])if(g?(c=k||(c[b]=B()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){c=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=c);k[e]=h=c}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} -function gb(a,c,b,e,d){return b&&1b)&&(k=b,b=c,c=k);if(a.db)return a.db.get(c,b,e,d,f,g,h);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};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;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else nb(this.map,a),this.depth&&nb(this.ctx,a);c||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&ib(this));this.cache&&this.cache.remove(a);return this}; -function nb(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;ethis.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,split:/\s+/};const Xa={normalize:!0};const Ya={normalize:!0,dedupe:!0};const Za=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 $a=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),ab=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const bb={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 cb={X:Wa,W:Xa,Y:Ya,LatinBalance:{normalize:!0,dedupe:!0,mapper:Za},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Za,matcher:$a,replacer:ab},LatinExtra:{normalize:!0,dedupe:!0,mapper:Za,replacer:ab.concat([/(?!^)[aeo]/g,""]),matcher:$a},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bu;f--){g=r.substring(u,f);v=this.rtl?d-1-u:u;var h=this.score?this.score(c,r,p,g,v):eb(q,e,p,d,v); +fb(this,n,g,h,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1), +e,p,h-1,k-1),v=this.bidirectional&&r>f;fb(this,l,v?f:r,u,a,b,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else c=""}this.db&&(c||this.commit_task.push({del:a}),this.T&&gb(this));return this}; +function fb(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])if(g?(c=k||(c[b]=B()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=k=[]),h=h[e]||(h[e]=[]),!f||!h.includes(d)){if(h.length===2**31-1){c=new R(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=c);k[e]=h=c}h.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(h):a.reg.set(d,[h]))}} +function eb(a,c,b,e,d){return b&&1b)&&(k=b,b=c,c=k);if(a.db)return a.db.get(c,b,e,d,f,g,h);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};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;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else lb(this.map,a),this.depth&&lb(this.ctx,a);c||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&gb(this));this.cache&&this.cache.remove(a);return this}; +function lb(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)}; -function pb(a){let c=0;if(a.constructor===Array)for(let b=0,e;b=n.length){e-=n.length;continue}const m=b?e+Math.min(n.length-e,b):n.length;for(let q=e;q=f.length)return[];if(!c&&!b)return f;f=f.slice(b,b+c);return e?d.enrich(f):f})}; t.enrich=function(a){"object"!==typeof a&&(a=[a]);const c=this.db.transaction("reg","readonly").objectStore("reg"),b=[];for(let e=0;e{a.onsuccess=a.oncomplete=function(){c&&c(this.result);c=null;b(this.result)};a.onerror=a.onblocked=e;a=null})};export default {Index:N,Charset:eb,Encoder:J,Document:U,Worker:P,Resolver:W,IndexedDB:sb,Language:{}}; -export const Index=N;export const Charset=eb;export const Encoder=J;export const Document=U;export const Worker=P;export const Resolver=W;export const IndexedDB=sb;export const Language={}; \ No newline at end of file +h=h&&h.length?h.concat(g):g;e.put(h,f)})}}),a.map.clear(),a.ctx.clear(),a.tag&&a.tag.clear(),a.store&&a.store.clear(),a.document||a.reg.clear())};function rb(a,c,b){const e=a.value;let d,f=0;for(let g=0,h;g{a.onsuccess=a.oncomplete=function(){c&&c(this.result);c=null;b(this.result)};a.onerror=a.onblocked=e;a=null})};export default {Index:N,Charset:cb,Encoder:J,Document:U,Worker:P,Resolver:W,IndexedDB:qb,Language:{}}; +export const Index=N;export const Charset=cb;export const Encoder=J;export const Document=U;export const Worker=P;export const Resolver=W;export const IndexedDB=qb;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.debug.js b/dist/flexsearch.compact.debug.js index 6d82e68..68ac6e1 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.142 (Bundle/Debug) + * FlexSearch.js v0.8.143 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -70,15 +70,7 @@ function aa(a) { } return c; } -;var ba = [["\u00aa", "a"], ["\u00b2", "2"], ["\u00b3", "3"], ["\u00b9", "1"], ["\u00ba", "o"], ["\u00bc", "1\u20444"], ["\u00bd", "1\u20442"], ["\u00be", "3\u20444"], ["\u00e0", "a"], ["\u00e1", "a"], ["\u00e2", "a"], ["\u00e3", "a"], ["\u00e4", "a"], ["\u00e5", "a"], ["\u00e7", "c"], ["\u00e8", "e"], ["\u00e9", "e"], ["\u00ea", "e"], ["\u00eb", "e"], ["\u00ec", "i"], ["\u00ed", "i"], ["\u00ee", "i"], ["\u00ef", "i"], ["\u00f1", "n"], ["\u00f2", "o"], ["\u00f3", "o"], ["\u00f4", "o"], ["\u00f5", -"o"], ["\u00f6", "o"], ["\u00f9", "u"], ["\u00fa", "u"], ["\u00fb", "u"], ["\u00fc", "u"], ["\u00fd", "y"], ["\u00ff", "y"], ["\u0101", "a"], ["\u0103", "a"], ["\u0105", "a"], ["\u0107", "c"], ["\u0109", "c"], ["\u010b", "c"], ["\u010d", "c"], ["\u010f", "d"], ["\u0113", "e"], ["\u0115", "e"], ["\u0117", "e"], ["\u0119", "e"], ["\u011b", "e"], ["\u011d", "g"], ["\u011f", "g"], ["\u0121", "g"], ["\u0123", "g"], ["\u0125", "h"], ["\u0129", "i"], ["\u012b", "i"], ["\u012d", "i"], ["\u012f", "i"], ["\u0133", -"ij"], ["\u0135", "j"], ["\u0137", "k"], ["\u013a", "l"], ["\u013c", "l"], ["\u013e", "l"], ["\u0140", "l"], ["\u0144", "n"], ["\u0146", "n"], ["\u0148", "n"], ["\u0149", "n"], ["\u014d", "o"], ["\u014f", "o"], ["\u0151", "o"], ["\u0155", "r"], ["\u0157", "r"], ["\u0159", "r"], ["\u015b", "s"], ["\u015d", "s"], ["\u015f", "s"], ["\u0161", "s"], ["\u0163", "t"], ["\u0165", "t"], ["\u0169", "u"], ["\u016b", "u"], ["\u016d", "u"], ["\u016f", "u"], ["\u0171", "u"], ["\u0173", "u"], ["\u0175", "w"], ["\u0177", -"y"], ["\u017a", "z"], ["\u017c", "z"], ["\u017e", "z"], ["\u017f", "s"], ["\u01a1", "o"], ["\u01b0", "u"], ["\u01c6", "dz"], ["\u01c9", "lj"], ["\u01cc", "nj"], ["\u01ce", "a"], ["\u01d0", "i"], ["\u01d2", "o"], ["\u01d4", "u"], ["\u01d6", "u"], ["\u01d8", "u"], ["\u01da", "u"], ["\u01dc", "u"], ["\u01df", "a"], ["\u01e1", "a"], ["\u01e3", "ae"], ["\u00e6", "ae"], ["\u01fd", "ae"], ["\u01e7", "g"], ["\u01e9", "k"], ["\u01eb", "o"], ["\u01ed", "o"], ["\u01ef", "\u0292"], ["\u01f0", "j"], ["\u01f3", -"dz"], ["\u01f5", "g"], ["\u01f9", "n"], ["\u01fb", "a"], ["\u01ff", "\u00f8"], ["\u0201", "a"], ["\u0203", "a"], ["\u0205", "e"], ["\u0207", "e"], ["\u0209", "i"], ["\u020b", "i"], ["\u020d", "o"], ["\u020f", "o"], ["\u0211", "r"], ["\u0213", "r"], ["\u0215", "u"], ["\u0217", "u"], ["\u0219", "s"], ["\u021b", "t"], ["\u021f", "h"], ["\u0227", "a"], ["\u0229", "e"], ["\u022b", "o"], ["\u022d", "o"], ["\u022f", "o"], ["\u0231", "o"], ["\u0233", "y"], ["\u02b0", "h"], ["\u02b1", "h"], ["\u0266", "h"], -["\u02b2", "j"], ["\u02b3", "r"], ["\u02b4", "\u0279"], ["\u02b5", "\u027b"], ["\u02b6", "\u0281"], ["\u02b7", "w"], ["\u02b8", "y"], ["\u02e0", "\u0263"], ["\u02e1", "l"], ["\u02e2", "s"], ["\u02e3", "x"], ["\u02e4", "\u0295"], ["\u0390", "\u03b9"], ["\u03ac", "\u03b1"], ["\u03ad", "\u03b5"], ["\u03ae", "\u03b7"], ["\u03af", "\u03b9"], ["\u03b0", "\u03c5"], ["\u03ca", "\u03b9"], ["\u03cb", "\u03c5"], ["\u03cc", "\u03bf"], ["\u03cd", "\u03c5"], ["\u03ce", "\u03c9"], ["\u03d0", "\u03b2"], ["\u03d1", -"\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db", -"\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]]; -const ca = /[^\p{L}\p{N}]+/u, da = /(\d{3})/g, ea = /(\D)(\d{3})/g, fa = /(\d{3})(\D)/g, ha = "".normalize && /[\u0300-\u036f]/g; +;const ba = /[^\p{L}\p{N}]+/u, ca = /(\d{3})/g, da = /(\D)(\d{3})/g, ea = /(\d{3})(\D)/g, fa = /[\u0300-\u036f]/g; function K(a = {}) { if (!this || this.constructor !== K) { return new K(...arguments); @@ -119,7 +111,7 @@ x.assign = function(a) { this.numeric = B(a.numeric, e); } else { try { - this.split = B(this.split, ca); + this.split = B(this.split, ba); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } @@ -127,7 +119,6 @@ x.assign = function(a) { } this.prepare = B(a.prepare, null, this.prepare); this.finalize = B(a.finalize, null, this.finalize); - ha || (this.mapper = new Map(ba)); 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); @@ -215,9 +206,9 @@ x.encode = function(a) { this.H = setTimeout(L, 50, this); } } - this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = ha ? a.normalize("NFKD").replace(ha, "").toLowerCase() : a.toLowerCase()); + this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = fa ? a.normalize("NFKD").replace(fa, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(ea, "$1 $2").replace(fa, "$1 $2").replace(da, "$1 ")); + this.numeric && 3 < a.length && (a = a.replace(da, "$1 $2").replace(ea, "$1 $2").replace(ca, "$1 ")); const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let b = [], e = this.split || "" === this.split ? a.split(this.split) : a; for (let f = 0, g, k; f < e.length; f++) { @@ -267,7 +258,7 @@ function L(a) { a.G.clear(); } ;let M, N; -async function ia(a) { +async function ha(a) { a = a.data; var c = a.task; const b = a.id; @@ -297,16 +288,16 @@ async function ia(a) { postMessage("search" === c ? {id:b, msg:d} : {id:b}); } } -;function ja(a) { +;function ia(a) { P.call(a, "add"); P.call(a, "append"); P.call(a, "search"); P.call(a, "update"); P.call(a, "remove"); } -let ka, la, Q; -function ma() { - ka = Q = 0; +let ja, ka, Q; +function la() { + ja = Q = 0; } function P(a) { this[a + "Async"] = function() { @@ -314,7 +305,7 @@ function P(a) { var b = c[c.length - 1]; let e; "function" === typeof b && (e = b, delete c[c.length - 1]); - ka ? Q || (Q = Date.now() - la >= this.priority * this.priority * 3) : (ka = setTimeout(ma, 0), la = Date.now()); + 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 => { @@ -360,7 +351,7 @@ function S(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 = na(b, e, a.worker); + const e = "undefined" === typeof window, d = this, f = ma(b, e, a.worker); return f.then ? f.then(function(g) { return c.call(d, g); }) : c.call(this, f); @@ -373,7 +364,7 @@ T("remove"); T("clear"); T("export"); T("import"); -ja(S.prototype); +ia(S.prototype); function T(a) { S.prototype[a] = function() { const c = this, b = [].slice.call(arguments); @@ -388,11 +379,11 @@ function T(a) { return d ? (e.then(d), this) : e; }; } -function na(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=" + ia.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function ma(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=" + ha.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 oa(a, c = 0) { +;function na(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { @@ -401,30 +392,30 @@ function na(a, c, b) { e.length && b.push(e); return b; } -function pa(a, c) { +function oa(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 qa(a, c = 0) { +function pa(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], oa(d[1])[0]]), e.length === c && (b.push(e), e = []); + e.push([d[0], na(d[1])[0]]), e.length === c && (b.push(e), e = []); } e.length && b.push(e); return b; } -function ra(a, c) { +function qa(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], pa(e[1], d)); + e = a[b], d = c.get(e[0]), c.set(e[0], oa(e[1], d)); } return c; } -function sa(a) { +function ra(a) { let c = [], b = []; for (const e of a.keys()) { b.push(e), 250000 === b.length && (c.push(b), b = []); @@ -432,7 +423,7 @@ function sa(a) { b.length && c.push(b); return c; } -function ta(a, c) { +function sa(a, c) { c || (c = new Set()); for (let b = 0; b < a.length; b++) { c.add(a[b]); @@ -453,7 +444,7 @@ function U(a, c, b, e, d, f, g = 0) { } return U.call(this, a, c, b, k ? e : null, d, f, g + 1); } -function ua(a, c) { +function ta(a, c) { let b = ""; for (const e of a.entries()) { a = e[0]; @@ -487,7 +478,7 @@ function ua(a, c) { d && e.add(a, d, !1, !0); } else { if (d = h.I, !d || d(c)) { - h.constructor === String ? h = ["" + h] : D(h) && (h = [h]), va(c, h, this.J, 0, e, a, h[0], b); + h.constructor === String ? h = ["" + h] : D(h) && (h = [h]), ua(c, h, this.J, 0, e, a, h[0], b); } } } @@ -538,7 +529,7 @@ function ua(a, c) { k[l] = c[l]; continue; } - wa(c, k, l, 0, l[0], m); + va(c, k, l, 0, l[0], m); } } this.store.set(a, k || c); @@ -546,21 +537,21 @@ function ua(a, c) { } return this; }; -function wa(a, c, b, e, d, f) { +function va(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++) { - wa(a, c, b, e, d); + va(a, c, b, e, d); } } else { - c = c[d] || (c[d] = C()), d = b[++e], wa(a, c, b, e, d); + c = c[d] || (c[d] = C()), d = b[++e], va(a, c, b, e, d); } } } -function va(a, c, b, e, d, f, g, k) { +function ua(a, c, b, e, d, f, g, k) { if (a = a[g]) { if (e === c.length - 1) { if (a.constructor === Array) { @@ -576,15 +567,15 @@ function va(a, c, b, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - va(a, c, b, e, d, f, g, k); + ua(a, c, b, e, d, f, g, k); } } else { - g = c[++e], va(a, c, b, e, d, f, g, k); + g = c[++e], ua(a, c, b, e, d, f, g, k); } } } } -;function xa(a, c, b, e, d) { +;function wa(a, c, b, e, d) { const f = a.length; let g = [], k, h; k = C(); @@ -601,7 +592,7 @@ function va(a, c, b, e, d, f, g, k) { } if (a = g.length) { if (d) { - g = 1 < g.length ? ya(g, b, e) : (g = g[0]).length > b || e ? g.slice(e, b + e) : g; + g = 1 < g.length ? xa(g, b, e) : (g = g[0]).length > b || e ? g.slice(e, b + e) : g; } else { if (a < f) { return []; @@ -616,7 +607,7 @@ function va(a, c, b, e, d, f, g, k) { } return g; } -function ya(a, c, b) { +function xa(a, c, b) { const e = [], d = C(); let f; var g = a.length; @@ -638,7 +629,7 @@ function ya(a, c, b) { } return e; } -function za(a, c) { +function ya(a, c) { const b = C(), e = []; for (let d = 0, f; d < c.length; d++) { f = c[d]; @@ -651,7 +642,7 @@ function za(a, c) { } return e; } -;function Aa(a, c, b, e) { +;function za(a, c, b, e) { if (!a.length) { return a; } @@ -682,7 +673,7 @@ function za(a, c) { d = 1 < d.length ? [].concat.apply([], d) : d[0]; return e ? W.call(this, d) : d; } -;function Ba(a, c, b) { +;function Aa(a, c, b) { var e = b[0]; if (e.then) { return Promise.all(b).then(function(m) { @@ -729,10 +720,10 @@ function za(a, c) { return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; } ;X.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Ba(this, "or", arguments); - return Ca.call(this, a, c, b, e, d, f); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Aa(this, "or", arguments); + return Ba.call(this, a, c, b, e, d, f); }; -function Ca(a, c, b, e, d, f) { +function Ba(a, c, b, e, d, f) { if (c.length) { const g = this; return Promise.all(c).then(function(k) { @@ -740,10 +731,10 @@ function Ca(a, c, b, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return Ca.call(g, a, [], b, e, d, f); + return Ba.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 = ya(a, b, e), e = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = xa(a, b, e), e = 0)); return f ? this.resolve(b, e, d) : this; } ;X.prototype.and = function() { @@ -753,11 +744,40 @@ function Ca(a, c, b, e, d, f) { 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); + const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:n} = Aa(this, "and", arguments); + return Ca.call(this, f, g, k, h, l, m, n); } return d ? this.resolve(c, b, e) : this; }; +function Ca(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; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); + } + return Ca.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 = aa(a)) { + return this.result = wa(a, c, b, e, g), f ? d ? W.call(this.index, this.result) : this.result : this; + } + this.result = []; + } + } else { + g || (this.result = a); + } + return f ? this.resolve(b, e, d) : this; +} +;X.prototype.xor = function() { + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Aa(this, "xor", arguments); + return Da.call(this, a, c, b, e, d, f, g); +}; function Da(a, c, b, e, d, f, g) { if (c.length) { const k = this; @@ -773,43 +793,14 @@ function Da(a, c, b, e, d, f, g) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (c = aa(a)) { - return this.result = xa(a, c, b, e, g), f ? d ? W.call(this.index, this.result) : this.result : this; - } - this.result = []; + return this.result = Ea.call(this, a, b, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(b, e, d) : this; } -;X.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; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); - } - return Ea.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 = Fa.call(this, a, b, e, f, this.h), f ? d ? W.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) { +function Ea(a, c, b, e, d) { const f = [], g = C(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -855,10 +846,10 @@ function Fa(a, c, b, e, d) { return f; } ;X.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ba(this, "not", arguments); - return Ga.call(this, a, c, b, e, d, f, g); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Aa(this, "not", arguments); + return Fa.call(this, a, c, b, e, d, f, g); }; -function Ga(a, c, b, e, d, f, g) { +function Fa(a, c, b, e, d, f, g) { if (c.length) { const k = this; return Promise.all(c).then(function(h) { @@ -866,17 +857,17 @@ function Ga(a, c, b, e, d, f, g) { for (let l = 0, m; l < h.length; l++) { (m = h[l]).length && (a[l] = m); } - return Ga.call(k, a, [], b, e, d, f, g); + return Fa.call(k, a, [], b, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Ha.call(this, a, b, e, f); + this.result = Ga.call(this, a, b, e, f); } else if (f) { return this.resolve(b, e, d); } return f ? d ? W.call(this.index, this.result) : this.result : this; } -function Ha(a, c, b, e) { +function Ga(a, c, b, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, k = 0; f < this.result.length; f++) { @@ -951,7 +942,7 @@ X.prototype.boost = function(a) { X.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), Aa.call(d, e, a || 100, c, b)) : e; + return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), za.call(d, e, a || 100, c, b)) : e; }; C(); V.prototype.search = function(a, c, b, e) { @@ -1013,7 +1004,7 @@ V.prototype.search = function(a, c, b, e) { f = []; if (u.length) { for (p = 0; p < u.length; p += 2) { - q = Ia.call(this, u[p], u[p + 1], c, t, g), d.push({field:u[p], tag:u[p + 1], result:q}); + q = Ha.call(this, u[p], u[p + 1], c, t, g), d.push({field:u[p], tag:u[p + 1], result:q}); } } return f.length ? Promise.all(f).then(function(y) { @@ -1047,7 +1038,7 @@ V.prototype.search = function(a, c, b, e) { if (l && F) { w = []; z = 0; - for (let G = 0, H, Za; G < l.length; G += 2) { + for (let G = 0, H, $a; G < l.length; G += 2) { H = this.tag.get(l[G]); if (!H) { if (console.warn("Tag '" + l[G] + ":" + l[G + 1] + "' will be skipped because there is no field '" + l[G] + "'."), k) { @@ -1056,14 +1047,14 @@ V.prototype.search = function(a, c, b, e) { return n ? d : new X(d); } } - if (Za = (H = H && H.get(l[G + 1])) && H.length) { + if ($a = (H = H && H.get(l[G + 1])) && H.length) { z++, w.push(H); } else if (!k) { return n ? d : new X(d); } } if (z) { - v = za(v, w); + v = ya(v, w); F = v.length; if (!F && !k) { return n ? v : new X(v); @@ -1098,9 +1089,9 @@ V.prototype.search = function(a, c, b, e) { } d[t] = {field:f[t], result:e}; } - return q ? Ja(d, c) : r ? Ka(d, a, this.index, this.field, this.C, r) : d; + return q ? Ia(d, c) : r ? Ja(d, a, this.index, this.field, this.C, r) : d; }; -function Ka(a, c, b, e, d, f) { +function Ja(a, c, b, e, d, f) { let g, k, h; for (let m = 0, n, r, p, q; m < a.length; m++) { let t = a[m].result; @@ -1145,7 +1136,7 @@ function Ka(a, c, b, e, d, f) { } return a; } -function Ja(a, c) { +function Ia(a, c) { const b = [], e = C(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1164,7 +1155,7 @@ function Ja(a, c) { } return b; } -function Ia(a, c, b, e, d) { +function Ha(a, c, b, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1196,7 +1187,7 @@ function W(a) { this.C = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && La(b, this.J) || "id"; + this.key = (b = c.key || c.id) && Ka(b, this.J) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); this.A = (b = c.store || null) && b && !0 !== b && []; this.store = b && new Map(); @@ -1207,13 +1198,13 @@ function W(a) { let e = c.index || c.field || c; D(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], D(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new O(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = La(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; + f = e[d], D(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new O(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Ka(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; } if (this.A) { a = c.store; D(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = La(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = Ka(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); } } this.index = b; @@ -1229,14 +1220,14 @@ function W(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.B[d] = f.custom : (this.B[d] = La(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); + f.custom ? this.B[d] = f.custom : (this.B[d] = Ka(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); this.T[d] = g; this.tag.set(g, new Map()); } } } } -function La(a, c) { +function Ka(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { @@ -1304,7 +1295,7 @@ x.set = function(a, c) { this.store.set(a, c); return this; }; -x.searchCache = Ma; +x.searchCache = La; x.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1320,17 +1311,17 @@ x.export = function(a, c, b = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = sa(this.reg); + f = ra(this.reg); c = null; break; case 1: d = "tag"; - f = this.tag && qa(this.tag, this.reg.size); + f = this.tag && pa(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = this.store && oa(this.store); + f = this.store && na(this.store); c = null; break; default: @@ -1351,21 +1342,21 @@ x.import = function(a, c) { switch(b) { case "reg": this.fastupdate = !1; - this.reg = ta(c, this.reg); + this.reg = sa(c, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; case "tag": - this.tag = ra(c, this.tag); + this.tag = qa(c, this.tag); break; case "doc": - this.store = pa(c, this.store); + this.store = oa(c, this.store); } } }; -ja(V.prototype); -function Ma(a, c, b) { +ia(V.prototype); +function La(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Y()); let e = this.cache.get(a); @@ -1406,31 +1397,22 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Na = {normalize:function(a) { - return a.toLowerCase(); -}}; -const Oa = 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 Pa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Qa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const Ra = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -const Sa = /[\x00-\x7F]+/g; -const Ta = /[\x00-\x7F]+/g; -const Ua = /[\x00-\x7F]+/g; -var Va = {LatinExact:{split:/\s+/, normalize:!1}, LatinDefault:Na, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Oa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Oa, matcher:Pa, replacer:Qa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Oa, replacer:Qa.concat([/(?!^)[aeo]/g, ""]), matcher:Pa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +const Ma = {normalize:!1, numeric:!1, split:/\s+/}; +const Na = {normalize:!0}; +const Oa = {normalize:!0, dedupe:!0}; +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:Ma, V:Na, X:Oa, LatinBalance:{normalize:!0, dedupe:!0, mapper:Pa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Pa, matcher:Qa, replacer:Ra}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Pa, replacer:Ra.concat([/(?!^)[aeo]/g, ""]), matcher:Qa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; - let e = c.charAt(0), d = Ra[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Ra[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = Sa[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Sa[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } -}}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Sa, " "); -}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Ta, ""); -}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ua, " "); -}}}; -const Wa = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +}}, LatinExact:Ma, LatinDefault:Na, LatinSimple:Oa}; +const Ua = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; O.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { @@ -1443,7 +1425,7 @@ O.prototype.add = function(a, c, b, e) { let q = c[this.rtl ? e - 1 - p : p]; var d = q.length; if (d && (n || !m[q])) { - var f = this.score ? this.score(c, q, p, null, 0) : Xa(r, e, p), g = ""; + var f = this.score ? this.score(c, q, p, null, 0) : Va(r, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { @@ -1451,17 +1433,18 @@ O.prototype.add = function(a, c, b, e) { for (f = d; f > t; f--) { g = q.substring(t, f); u = this.rtl ? d - 1 - t : t; - var k = this.score ? this.score(c, q, p, g, u) : Xa(r, e, p, d, u); + var k = this.score ? this.score(c, q, p, g, u) : Va(r, e, p, d, u); Z(this, m, g, k, a, b); } } break; } + case "bidirectional": case "reverse": if (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) : Xa(r, e, p, d, k); + var h = this.score ? this.score(c, q, p, g, k) : Va(r, e, p, d, k); Z(this, m, g, h, a, b); } g = ""; @@ -1478,7 +1461,7 @@ O.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) : Xa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; + const t = this.score ? this.score(c, f, p, q, h - 1) : Va(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; Z(this, l, u ? f : q, t, a, b, u ? q : f); } } @@ -1497,7 +1480,7 @@ function Z(a, c, b, e, d, f, 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 Xa(a, c, b, e, d) { +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; } ;O.prototype.search = function(a, c, b) { @@ -1518,11 +1501,11 @@ function Xa(a, c, b, e, d) { b = a.length; c = c || (k ? 100 : 0); if (1 === b) { - return g = c, (c = Ya(this, a[0], "")) && c.length ? Aa.call(this, c, g, d) : []; + return g = c, (c = Wa(this, a[0], "")) && c.length ? za.call(this, c, g, d) : []; } f = this.depth && !1 !== f; if (2 === b && f && !g) { - return g = c, (c = Ya(this, a[0], a[1])) && c.length ? Aa.call(this, c, g, d) : []; + return g = c, (c = Wa(this, a[0], a[1])) && c.length ? za.call(this, c, g, d) : []; } k = C(); let l = 0; @@ -1534,7 +1517,7 @@ function Xa(a, c, b, e, d) { for (let q, t; l < b; l++) { if ((t = a[l]) && !k[t]) { k[t] = 1; - q = Ya(this, t, m); + q = Wa(this, t, m); a: { f = q; var n = e, r = g, p = h; @@ -1571,16 +1554,16 @@ function Xa(a, c, b, e, d) { e = a.length; m = a; if (1 < e) { - m = xa(a, h, c, d, g); + m = wa(a, h, c, d, g); } else if (1 === e) { - g = Aa.call(null, a[0], c, d); + g = za.call(null, a[0], c, d); break a; } g = m; } return g; }; -function Ya(a, c, b) { +function Wa(a, c, b) { let e; b && (e = a.bidirectional && c > b) && (e = b, b = c, c = e); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); @@ -1601,14 +1584,14 @@ function Ya(a, c, b) { } } } else { - $a(this.map, a), this.depth && $a(this.ctx, a); + Xa(this.map, a), this.depth && Xa(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function $a(a, c) { +function Xa(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1623,7 +1606,7 @@ function $a(a, c) { } } else { for (let e of a.entries()) { - const d = e[0], f = $a(e[1], c); + const d = e[0], f = Xa(e[1], c); f ? b += f : a.delete(d); } } @@ -1635,15 +1618,15 @@ function $a(a, c) { } if (a) { var b = D(a) ? a : a.preset; - b && (Wa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Wa[b], a)); + b && (Ua[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Ua[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? Va[a.encoder] : a.encode || a.encoder || Na; + const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? Ta[a.encoder] : a.encode || a.encoder || Na; this.encoder = d.encode ? d : "object" === typeof d ? new K(d) : {encode:d}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && b || "strict"; + 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; @@ -1676,7 +1659,7 @@ x.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; -function ab(a) { +function Ya(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1684,7 +1667,7 @@ function ab(a) { } } else { for (const b of a.entries()) { - const e = b[0], d = ab(b[1]); + const e = b[0], d = Ya(b[1]); d ? c += d : a.delete(e); } } @@ -1694,17 +1677,17 @@ x.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - ab(this.map); - this.depth && ab(this.ctx); + Ya(this.map); + this.depth && Ya(this.ctx); return this; }; -x.searchCache = Ma; +x.searchCache = La; x.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = sa(this.reg); + f = ra(this.reg); break; case 1: d = "cfg"; @@ -1712,11 +1695,11 @@ x.export = function(a, c, b = 0, e = 0) { break; case 2: d = "map"; - f = oa(this.map, this.reg.size); + f = na(this.map, this.reg.size); break; case 3: d = "ctx"; - f = qa(this.ctx, this.reg.size); + f = pa(this.ctx, this.reg.size); break; default: return; @@ -1728,13 +1711,13 @@ x.import = function(a, 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 = ta(c, this.reg); + this.reg = sa(c, this.reg); break; case "map": - this.map = pa(c, this.map); + this.map = oa(c, this.map); break; case "ctx": - this.ctx = ra(c, this.ctx); + this.ctx = qa(c, this.ctx); } } }; @@ -1746,11 +1729,11 @@ x.serialize = function(a = !0) { f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); } c = "index.reg=new Set([" + c + "]);"; - b = ua(this.map, f); + b = ta(this.map, f); b = "index.map=new Map([" + b + "]);"; for (const g of this.ctx.entries()) { d = g[0]; - let k = ua(g[1], f); + let k = ta(g[1], f); k = "new Map([" + k + "])"; k = '["' + d + '",' + k + "]"; e += (e ? "," : "") + k; @@ -1759,11 +1742,11 @@ x.serialize = function(a = !0) { } return a ? "function inject(index){" + c + b + e + "}" : c + b + e; }; -ja(O.prototype); +ia(O.prototype); C(); -const bb = {Index:O, Charset:Va, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, cb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; -let db; -(db = cb.define) && db.amd ? db([], function() { - return bb; -}) : "object" === typeof cb.exports ? cb.exports = bb : cb.FlexSearch = bb; +const Za = {Index:O, Charset:Ta, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, ab = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; +let bb; +(bb = ab.define) && bb.amd ? bb([], function() { + return Za; +}) : "object" === typeof ab.exports ? ab.exports = Za : ab.FlexSearch = Za; }(this||self)); diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index 5a34495..78b156e 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -1,70 +1,64 @@ /**! - * FlexSearch.js v0.8.142 (Bundle) + * FlexSearch.js v0.8.143 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ (function(self){'use strict';var x;function 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 H(a){return"object"===typeof a}function I(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,ca)}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);ha||(this.mapper=new Map(ba));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,!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.D?"|":"")+d;return this};x.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.D+=(this.D?"|":"")+a;this.N=null;this.cache&&L(this);return this};x.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}; x.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this}; x.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&L(this);return this}; -x.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(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 L(a){a.H=null;a.F.clear();a.G.clear()};let M,N;async function ia(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":N=a.options||{};(c=a.factory)?(Function("return "+c)()(self),M=new self.FlexSearch.Index(N),delete self.FlexSearch):M=new O(N);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=N.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await N.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[c].apply(M,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ja(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let ka,la,Q;function ma(){ka=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]);ka?Q||(Q=Date.now()-la>=this.priority*this.priority*3):(ka=setTimeout(ma,0),la=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; +this.replacer[d+1]);this.cache&&k.length<=this.L&&(this.G.set(k,g),this.G.size>this.R&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function L(a){a.H=null;a.F.clear();a.G.clear()};let M,N;async function ha(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":N=a.options||{};(c=a.factory)?(Function("return "+c)()(self),M=new self.FlexSearch.Index(N),delete self.FlexSearch):M=new O(N);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=N.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await N.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[c].apply(M,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?W.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?W.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};X.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?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};X.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?W.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=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} +function xa(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?W.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?W.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=xa(a,b,e),e=0));return f?this.resolve(b,e,d):this};X.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}=Aa(this,"and",arguments);return Ca.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; +function Ca(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=wa(a,c,b,e,g),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};X.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Aa(this,"xor",arguments);return Da.call(this,a,c,b,e,d,f,g)}; +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 return this.result=Ea.call(this,a,b,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} +function Ea(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=W.call(this,a));return a}}function W(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)}; -Y.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};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:function(a){return a.toLowerCase()}};const Oa=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 Pa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Qa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Ra={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const Sa=/[\x00-\x7F]+/g;const Ta=/[\x00-\x7F]+/g;const Ua=/[\x00-\x7F]+/g;var Va={LatinExact:{split:/\s+/,normalize:!1},LatinDefault:Na,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Oa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Oa,matcher:Pa,replacer:Qa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Oa,replacer:Qa.concat([/(?!^)[aeo]/g,""]),matcher:Pa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Xa(r,e,p,d,u); -Z(this,m,g,k,a,b)}break}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 Xa(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};O.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else $a(this.map,a),this.depth&&$a(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function $a(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};function ab(a){let c=0;if(a.constructor===Array)for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.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};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Ma={normalize:!1,numeric:!1,split:/\s+/};const Na={normalize:!0};const Oa={normalize:!0,dedupe:!0};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:Ma,V:Na,X:Oa,LatinBalance:{normalize:!0,dedupe:!0,mapper:Pa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Pa,matcher:Qa,replacer:Ra},LatinExtra:{normalize:!0,dedupe:!0,mapper:Pa,replacer:Ra.concat([/(?!^)[aeo]/g,""]),matcher:Qa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Va(r,e,p,d,u); +Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),e,p, +k-1,h-1),u=this.bidirectional&&q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=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};O.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Xa(this.map,a),this.depth&&Xa(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Xa(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};function Ya(a){let c=0;if(a.constructor===Array)for(let b=0,e;b= this.priority * this.priority * 3) : (ka = setTimeout(ma, 0), la = Date.now()); + 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 => { @@ -359,7 +350,7 @@ function S(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 = na(b, e, a.worker); + const e = "undefined" === typeof window, d = this, f = ma(b, e, a.worker); return f.then ? f.then(function(g) { return c.call(d, g); }) : c.call(this, f); @@ -372,7 +363,7 @@ T("remove"); T("clear"); T("export"); T("import"); -ja(S.prototype); +ia(S.prototype); function T(a) { S.prototype[a] = function() { const c = this, b = [].slice.call(arguments); @@ -387,11 +378,11 @@ function T(a) { return d ? (e.then(d), this) : e; }; } -function na(a, c, b) { - return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ia.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", +function ma(a, c, b) { + return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ha.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function oa(a, c = 0) { +;function na(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 5000 | 0); for (const d of a.entries()) { @@ -400,30 +391,30 @@ function na(a, c, b) { e.length && b.push(e); return b; } -function pa(a, c) { +function oa(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 qa(a, c = 0) { +function pa(a, c = 0) { let b = [], e = []; c && (c = 250000 / c * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], oa(d[1])[0]]), e.length === c && (b.push(e), e = []); + e.push([d[0], na(d[1])[0]]), e.length === c && (b.push(e), e = []); } e.length && b.push(e); return b; } -function ra(a, c) { +function qa(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], pa(e[1], d)); + e = a[b], d = c.get(e[0]), c.set(e[0], oa(e[1], d)); } return c; } -function sa(a) { +function ra(a) { let c = [], b = []; for (const e of a.keys()) { b.push(e), 250000 === b.length && (c.push(b), b = []); @@ -431,7 +422,7 @@ function sa(a) { b.length && c.push(b); return c; } -function ta(a, c) { +function sa(a, c) { c || (c = new Set()); for (let b = 0; b < a.length; b++) { c.add(a[b]); @@ -452,7 +443,7 @@ function U(a, c, b, e, d, f, g = 0) { } return U.call(this, a, c, b, k ? e : null, d, f, g + 1); } -function ua(a, c) { +function ta(a, c) { let b = ""; for (const e of a.entries()) { a = e[0]; @@ -486,7 +477,7 @@ function ua(a, c) { d && e.add(a, d, !1, !0); } else { if (d = h.I, !d || d(c)) { - h.constructor === String ? h = ["" + h] : D(h) && (h = [h]), va(c, h, this.J, 0, e, a, h[0], b); + h.constructor === String ? h = ["" + h] : D(h) && (h = [h]), ua(c, h, this.J, 0, e, a, h[0], b); } } } @@ -537,7 +528,7 @@ function ua(a, c) { k[l] = c[l]; continue; } - wa(c, k, l, 0, l[0], m); + va(c, k, l, 0, l[0], m); } } this.store.set(a, k || c); @@ -545,21 +536,21 @@ function ua(a, c) { } return this; }; -function wa(a, c, b, e, d, f) { +function va(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++) { - wa(a, c, b, e, d); + va(a, c, b, e, d); } } else { - c = c[d] || (c[d] = C()), d = b[++e], wa(a, c, b, e, d); + c = c[d] || (c[d] = C()), d = b[++e], va(a, c, b, e, d); } } } -function va(a, c, b, e, d, f, g, k) { +function ua(a, c, b, e, d, f, g, k) { if (a = a[g]) { if (e === c.length - 1) { if (a.constructor === Array) { @@ -575,15 +566,15 @@ function va(a, c, b, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - va(a, c, b, e, d, f, g, k); + ua(a, c, b, e, d, f, g, k); } } else { - g = c[++e], va(a, c, b, e, d, f, g, k); + g = c[++e], ua(a, c, b, e, d, f, g, k); } } } } -;function xa(a, c, b, e, d) { +;function wa(a, c, b, e, d) { const f = a.length; let g = [], k, h; k = C(); @@ -600,7 +591,7 @@ function va(a, c, b, e, d, f, g, k) { } if (a = g.length) { if (d) { - g = 1 < g.length ? ya(g, b, e) : (g = g[0]).length > b || e ? g.slice(e, b + e) : g; + g = 1 < g.length ? xa(g, b, e) : (g = g[0]).length > b || e ? g.slice(e, b + e) : g; } else { if (a < f) { return []; @@ -615,7 +606,7 @@ function va(a, c, b, e, d, f, g, k) { } return g; } -function ya(a, c, b) { +function xa(a, c, b) { const e = [], d = C(); let f; var g = a.length; @@ -637,7 +628,7 @@ function ya(a, c, b) { } return e; } -function za(a, c) { +function ya(a, c) { const b = C(), e = []; for (let d = 0, f; d < c.length; d++) { f = c[d]; @@ -650,7 +641,7 @@ function za(a, c) { } return e; } -;function Aa(a, c, b, e) { +;function za(a, c, b, e) { if (!a.length) { return a; } @@ -681,7 +672,7 @@ function za(a, c) { d = 1 < d.length ? [].concat.apply([], d) : d[0]; return e ? W.call(this, d) : d; } -;function Ba(a, c, b) { +;function Aa(a, c, b) { var e = b[0]; if (e.then) { return Promise.all(b).then(function(m) { @@ -728,10 +719,10 @@ function za(a, c) { return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; } ;X.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Ba(this, "or", arguments); - return Ca.call(this, a, c, b, e, d, f); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Aa(this, "or", arguments); + return Ba.call(this, a, c, b, e, d, f); }; -function Ca(a, c, b, e, d, f) { +function Ba(a, c, b, e, d, f) { if (c.length) { const g = this; return Promise.all(c).then(function(k) { @@ -739,10 +730,10 @@ function Ca(a, c, b, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return Ca.call(g, a, [], b, e, d, f); + return Ba.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 = ya(a, b, e), e = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = xa(a, b, e), e = 0)); return f ? this.resolve(b, e, d) : this; } ;X.prototype.and = function() { @@ -752,11 +743,40 @@ function Ca(a, c, b, e, d, f) { 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); + const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:n} = Aa(this, "and", arguments); + return Ca.call(this, f, g, k, h, l, m, n); } return d ? this.resolve(c, b, e) : this; }; +function Ca(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; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); + } + return Ca.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 = aa(a)) { + return this.result = wa(a, c, b, e, g), f ? d ? W.call(this.index, this.result) : this.result : this; + } + this.result = []; + } + } else { + g || (this.result = a); + } + return f ? this.resolve(b, e, d) : this; +} +;X.prototype.xor = function() { + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Aa(this, "xor", arguments); + return Da.call(this, a, c, b, e, d, f, g); +}; function Da(a, c, b, e, d, f, g) { if (c.length) { const k = this; @@ -772,43 +792,14 @@ function Da(a, c, b, e, d, f, g) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (c = aa(a)) { - return this.result = xa(a, c, b, e, g), f ? d ? W.call(this.index, this.result) : this.result : this; - } - this.result = []; + return this.result = Ea.call(this, a, b, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(b, e, d) : this; } -;X.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; l < h.length; l++) { - (m = h[l]).length && (a[l] = m); - } - return Ea.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 = Fa.call(this, a, b, e, f, this.h), f ? d ? W.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) { +function Ea(a, c, b, e, d) { const f = [], g = C(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -854,10 +845,10 @@ function Fa(a, c, b, e, d) { return f; } ;X.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ba(this, "not", arguments); - return Ga.call(this, a, c, b, e, d, f, g); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Aa(this, "not", arguments); + return Fa.call(this, a, c, b, e, d, f, g); }; -function Ga(a, c, b, e, d, f, g) { +function Fa(a, c, b, e, d, f, g) { if (c.length) { const k = this; return Promise.all(c).then(function(h) { @@ -865,17 +856,17 @@ function Ga(a, c, b, e, d, f, g) { for (let l = 0, m; l < h.length; l++) { (m = h[l]).length && (a[l] = m); } - return Ga.call(k, a, [], b, e, d, f, g); + return Fa.call(k, a, [], b, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Ha.call(this, a, b, e, f); + this.result = Ga.call(this, a, b, e, f); } else if (f) { return this.resolve(b, e, d); } return f ? d ? W.call(this.index, this.result) : this.result : this; } -function Ha(a, c, b, e) { +function Ga(a, c, b, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, k = 0; f < this.result.length; f++) { @@ -950,7 +941,7 @@ X.prototype.boost = function(a) { X.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), Aa.call(d, e, a || 100, c, b)) : e; + return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), za.call(d, e, a || 100, c, b)) : e; }; C(); V.prototype.search = function(a, c, b, e) { @@ -1012,7 +1003,7 @@ V.prototype.search = function(a, c, b, e) { f = []; if (u.length) { for (p = 0; p < u.length; p += 2) { - q = Ia.call(this, u[p], u[p + 1], c, t, g), d.push({field:u[p], tag:u[p + 1], result:q}); + q = Ha.call(this, u[p], u[p + 1], c, t, g), d.push({field:u[p], tag:u[p + 1], result:q}); } } return f.length ? Promise.all(f).then(function(y) { @@ -1046,7 +1037,7 @@ V.prototype.search = function(a, c, b, e) { if (l && F) { w = []; z = 0; - for (let G = 0, H, Wa; G < l.length; G += 2) { + for (let G = 0, H, Xa; G < l.length; G += 2) { H = this.tag.get(l[G]); if (!H) { if (console.warn("Tag '" + l[G] + ":" + l[G + 1] + "' will be skipped because there is no field '" + l[G] + "'."), k) { @@ -1055,14 +1046,14 @@ V.prototype.search = function(a, c, b, e) { return n ? d : new X(d); } } - if (Wa = (H = H && H.get(l[G + 1])) && H.length) { + if (Xa = (H = H && H.get(l[G + 1])) && H.length) { z++, w.push(H); } else if (!k) { return n ? d : new X(d); } } if (z) { - v = za(v, w); + v = ya(v, w); F = v.length; if (!F && !k) { return n ? v : new X(v); @@ -1097,9 +1088,9 @@ V.prototype.search = function(a, c, b, e) { } d[t] = {field:f[t], result:e}; } - return q ? Ja(d, c) : r ? Ka(d, a, this.index, this.field, this.C, r) : d; + return q ? Ia(d, c) : r ? Ja(d, a, this.index, this.field, this.C, r) : d; }; -function Ka(a, c, b, e, d, f) { +function Ja(a, c, b, e, d, f) { let g, k, h; for (let m = 0, n, r, p, q; m < a.length; m++) { let t = a[m].result; @@ -1144,7 +1135,7 @@ function Ka(a, c, b, e, d, f) { } return a; } -function Ja(a, c) { +function Ia(a, c) { const b = [], e = C(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1163,7 +1154,7 @@ function Ja(a, c) { } return b; } -function Ia(a, c, b, e, d) { +function Ha(a, c, b, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1195,7 +1186,7 @@ function W(a) { this.C = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && La(b, this.J) || "id"; + this.key = (b = c.key || c.id) && Ka(b, this.J) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); this.A = (b = c.store || null) && b && !0 !== b && []; this.store = b && new Map(); @@ -1206,13 +1197,13 @@ function W(a) { let e = c.index || c.field || c; D(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], D(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new O(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = La(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; + f = e[d], D(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new O(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Ka(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; } if (this.A) { a = c.store; D(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = La(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = Ka(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); } } this.index = b; @@ -1228,14 +1219,14 @@ function W(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.B[d] = f.custom : (this.B[d] = La(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); + f.custom ? this.B[d] = f.custom : (this.B[d] = Ka(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); this.T[d] = g; this.tag.set(g, new Map()); } } } } -function La(a, c) { +function Ka(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { @@ -1303,7 +1294,7 @@ x.set = function(a, c) { this.store.set(a, c); return this; }; -x.searchCache = Ma; +x.searchCache = La; x.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1319,17 +1310,17 @@ x.export = function(a, c, b = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = sa(this.reg); + f = ra(this.reg); c = null; break; case 1: d = "tag"; - f = this.tag && qa(this.tag, this.reg.size); + f = this.tag && pa(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = this.store && oa(this.store); + f = this.store && na(this.store); c = null; break; default: @@ -1350,21 +1341,21 @@ x.import = function(a, c) { switch(b) { case "reg": this.fastupdate = !1; - this.reg = ta(c, this.reg); + this.reg = sa(c, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; case "tag": - this.tag = ra(c, this.tag); + this.tag = qa(c, this.tag); break; case "doc": - this.store = pa(c, this.store); + this.store = oa(c, this.store); } } }; -ja(V.prototype); -function Ma(a, c, b) { +ia(V.prototype); +function La(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Y()); let e = this.cache.get(a); @@ -1405,31 +1396,22 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Na = {normalize:function(a) { - return a.toLowerCase(); -}}; -const Oa = 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 Pa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Qa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const Ra = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -const Sa = /[\x00-\x7F]+/g; -const Ta = /[\x00-\x7F]+/g; -const Ua = /[\x00-\x7F]+/g; -var Va = {LatinExact:{split:/\s+/, normalize:!1}, LatinDefault:Na, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Oa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Oa, matcher:Pa, replacer:Qa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Oa, replacer:Qa.concat([/(?!^)[aeo]/g, ""]), matcher:Pa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +const Ma = {normalize:!1, numeric:!1, split:/\s+/}; +const Na = {normalize:!0}; +const Oa = {normalize:!0, dedupe:!0}; +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:Ma, V:Na, X:Oa, LatinBalance:{normalize:!0, dedupe:!0, mapper:Pa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Pa, matcher:Qa, replacer:Ra}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Pa, replacer:Ra.concat([/(?!^)[aeo]/g, ""]), matcher:Qa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; - let e = c.charAt(0), d = Ra[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Ra[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = Sa[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Sa[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } -}}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Sa, " "); -}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Ta, ""); -}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ua, " "); -}}}; -const Xa = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +}}, LatinExact:Ma, LatinDefault:Na, LatinSimple:Oa}; +const Ua = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; O.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { @@ -1442,7 +1424,7 @@ O.prototype.add = function(a, c, b, e) { let q = c[this.rtl ? e - 1 - p : p]; var d = q.length; if (d && (n || !m[q])) { - var f = this.score ? this.score(c, q, p, null, 0) : Ya(r, e, p), g = ""; + var f = this.score ? this.score(c, q, p, null, 0) : Va(r, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { @@ -1450,17 +1432,18 @@ O.prototype.add = function(a, c, b, e) { for (f = d; f > t; f--) { g = q.substring(t, f); u = this.rtl ? d - 1 - t : t; - var k = this.score ? this.score(c, q, p, g, u) : Ya(r, e, p, d, u); + var k = this.score ? this.score(c, q, p, g, u) : Va(r, e, p, d, u); Z(this, m, g, k, a, b); } } break; } + case "bidirectional": case "reverse": if (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) : Ya(r, e, p, d, k); + var h = this.score ? this.score(c, q, p, g, k) : Va(r, e, p, d, k); Z(this, m, g, h, a, b); } g = ""; @@ -1477,7 +1460,7 @@ O.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) : Ya(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; + const t = this.score ? this.score(c, f, p, q, h - 1) : Va(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; Z(this, l, u ? f : q, t, a, b, u ? q : f); } } @@ -1496,7 +1479,7 @@ function Z(a, c, b, e, d, f, 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 Ya(a, c, b, e, d) { +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; } ;O.prototype.search = function(a, c, b) { @@ -1517,11 +1500,11 @@ function Ya(a, c, b, e, d) { b = a.length; c = c || (k ? 100 : 0); if (1 === b) { - return g = c, (c = Za(this, a[0], "")) && c.length ? Aa.call(this, c, g, d) : []; + return g = c, (c = Wa(this, a[0], "")) && c.length ? za.call(this, c, g, d) : []; } f = this.depth && !1 !== f; if (2 === b && f && !g) { - return g = c, (c = Za(this, a[0], a[1])) && c.length ? Aa.call(this, c, g, d) : []; + return g = c, (c = Wa(this, a[0], a[1])) && c.length ? za.call(this, c, g, d) : []; } k = C(); let l = 0; @@ -1533,7 +1516,7 @@ function Ya(a, c, b, e, d) { for (let q, t; l < b; l++) { if ((t = a[l]) && !k[t]) { k[t] = 1; - q = Za(this, t, m); + q = Wa(this, t, m); a: { f = q; var n = e, r = g, p = h; @@ -1570,16 +1553,16 @@ function Ya(a, c, b, e, d) { e = a.length; m = a; if (1 < e) { - m = xa(a, h, c, d, g); + m = wa(a, h, c, d, g); } else if (1 === e) { - g = Aa.call(null, a[0], c, d); + g = za.call(null, a[0], c, d); break a; } g = m; } return g; }; -function Za(a, c, b) { +function Wa(a, c, b) { let e; b && (e = a.bidirectional && c > b) && (e = b, b = c, c = e); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); @@ -1600,14 +1583,14 @@ function Za(a, c, b) { } } } else { - $a(this.map, a), this.depth && $a(this.ctx, a); + Ya(this.map, a), this.depth && Ya(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function $a(a, c) { +function Ya(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1622,7 +1605,7 @@ function $a(a, c) { } } else { for (let e of a.entries()) { - const d = e[0], f = $a(e[1], c); + const d = e[0], f = Ya(e[1], c); f ? b += f : a.delete(d); } } @@ -1634,15 +1617,15 @@ function $a(a, c) { } if (a) { var b = D(a) ? a : a.preset; - b && (Xa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Xa[b], a)); + b && (Ua[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Ua[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? Va[a.encoder] : a.encode || a.encoder || Na; + const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? Ta[a.encoder] : a.encode || a.encoder || Na; this.encoder = d.encode ? d : "object" === typeof d ? new K(d) : {encode:d}; this.resolution = a.resolution || 9; - this.tokenize = b = (b = a.tokenize) && "default" !== b && b || "strict"; + 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; @@ -1675,7 +1658,7 @@ x.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; -function ab(a) { +function Za(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1683,7 +1666,7 @@ function ab(a) { } } else { for (const b of a.entries()) { - const e = b[0], d = ab(b[1]); + const e = b[0], d = Za(b[1]); d ? c += d : a.delete(e); } } @@ -1693,17 +1676,17 @@ x.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - ab(this.map); - this.depth && ab(this.ctx); + Za(this.map); + this.depth && Za(this.ctx); return this; }; -x.searchCache = Ma; +x.searchCache = La; x.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = sa(this.reg); + f = ra(this.reg); break; case 1: d = "cfg"; @@ -1711,11 +1694,11 @@ x.export = function(a, c, b = 0, e = 0) { break; case 2: d = "map"; - f = oa(this.map, this.reg.size); + f = na(this.map, this.reg.size); break; case 3: d = "ctx"; - f = qa(this.ctx, this.reg.size); + f = pa(this.ctx, this.reg.size); break; default: return; @@ -1727,13 +1710,13 @@ x.import = function(a, 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 = ta(c, this.reg); + this.reg = sa(c, this.reg); break; case "map": - this.map = pa(c, this.map); + this.map = oa(c, this.map); break; case "ctx": - this.ctx = ra(c, this.ctx); + this.ctx = qa(c, this.ctx); } } }; @@ -1745,11 +1728,11 @@ x.serialize = function(a = !0) { f || (f = typeof d), c += (c ? "," : "") + ("string" === f ? '"' + d + '"' : d); } c = "index.reg=new Set([" + c + "]);"; - b = ua(this.map, f); + b = ta(this.map, f); b = "index.map=new Map([" + b + "]);"; for (const g of this.ctx.entries()) { d = g[0]; - let k = ua(g[1], f); + let k = ta(g[1], f); k = "new Map([" + k + "])"; k = '["' + d + '",' + k + "]"; e += (e ? "," : "") + k; @@ -1758,8 +1741,8 @@ x.serialize = function(a = !0) { } return a ? "function inject(index){" + c + b + e + "}" : c + b + e; }; -ja(O.prototype); +ia(O.prototype); C(); -export default {Index:O, Charset:Va, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; +export default {Index:O, Charset:Ta, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; -export const Index=O;export const Charset=Va;export const Encoder=K;export const Document=V;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file +export const Index=O;export const Charset=Ta;export const Encoder=K;export const Document=V;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.module.min.js b/dist/flexsearch.compact.module.min.js index e2137c0..6a02807 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -1,71 +1,65 @@ /**! - * FlexSearch.js v0.8.142 (Bundle) + * FlexSearch.js v0.8.143 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ var x;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 H(a){return"object"===typeof a}function I(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,ca)}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);ha||(this.mapper=new Map(ba));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,!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.D?"|":"")+d;return this};x.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.D+=(this.D?"|":"")+a;this.N=null;this.cache&&L(this);return this};x.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}; x.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this}; x.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&L(this);return this}; -x.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(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 L(a){a.H=null;a.F.clear();a.G.clear()};let M,N;async function ia(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":N=a.options||{};(c=a.factory)?(Function("return "+c)()(self),M=new self.FlexSearch.Index(N),delete self.FlexSearch):M=new O(N);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=N.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await N.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[c].apply(M,e))&&d.then&&(d=await d);postMessage("search"===c?{id:b,msg:d}:{id:b})}};function ja(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let ka,la,Q;function ma(){ka=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]);ka?Q||(Q=Date.now()-la>=this.priority*this.priority*3):(ka=setTimeout(ma,0),la=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; +this.replacer[d+1]);this.cache&&k.length<=this.L&&(this.G.set(k,g),this.G.size>this.R&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function L(a){a.H=null;a.F.clear();a.G.clear()};let M,N;async function ha(a){a=a.data;var c=a.task;const b=a.id;let e=a.args;switch(c){case "init":N=a.options||{};(c=a.factory)?(Function("return "+c)()(self),M=new self.FlexSearch.Index(N),delete self.FlexSearch):M=new O(N);postMessage({id:b});break;default:let d;"export"===c&&(e[1]?(e[0]=N.export,e[2]=0,e[3]=1):e=null);"import"===c?e[0]&&(a=await N.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[c].apply(M,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?W.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?W.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};X.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?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};X.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?W.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=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} +function xa(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?W.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?W.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=xa(a,b,e),e=0));return f?this.resolve(b,e,d):this};X.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}=Aa(this,"and",arguments);return Ca.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; +function Ca(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=wa(a,c,b,e,g),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};X.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Aa(this,"xor",arguments);return Da.call(this,a,c,b,e,d,f,g)}; +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 return this.result=Ea.call(this,a,b,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} +function Ea(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=W.call(this,a));return a}}function W(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)}; -Y.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};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:function(a){return a.toLowerCase()}};const Oa=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 Pa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Qa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Ra={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const Sa=/[\x00-\x7F]+/g;const Ta=/[\x00-\x7F]+/g;const Ua=/[\x00-\x7F]+/g;var Wa={LatinExact:{split:/\s+/,normalize:!1},LatinDefault:Na,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Oa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Oa,matcher:Pa,replacer:Qa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Oa,replacer:Qa.concat([/(?!^)[aeo]/g,""]),matcher:Pa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Ya(r,e,p,d,u); -Z(this,m,g,k,a,b)}break}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 Ya(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};O.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else $a(this.map,a),this.depth&&$a(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function $a(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};function ab(a){let c=0;if(a.constructor===Array)for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.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};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Ma={normalize:!1,numeric:!1,split:/\s+/};const Na={normalize:!0};const Oa={normalize:!0,dedupe:!0};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:Ma,V:Na,X:Oa,LatinBalance:{normalize:!0,dedupe:!0,mapper:Pa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Pa,matcher:Qa,replacer:Ra},LatinExtra:{normalize:!0,dedupe:!0,mapper:Pa,replacer:Ra.concat([/(?!^)[aeo]/g,""]),matcher:Qa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Va(r,e,p,d,u); +Z(this,m,g,k,a,b)}break}case "bidirectional":case "reverse":if(1g?0:1),e,p, +k-1,h-1),u=this.bidirectional&&q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=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};O.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Ya(this.map,a),this.depth&&Ya(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Ya(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};function Za(a){let c=0;if(a.constructor===Array)for(let b=0,e;b= this.priority * this.priority * 3) : (Na = setTimeout(Qa, 0), Oa = Date.now()); - if (Pa) { + Ma ? Oa || (Oa = Date.now() - Na >= this.priority * this.priority * 3) : (Ma = setTimeout(Pa, 0), Na = Date.now()); + if (Oa) { var e = this; return new Promise(function(f) { setTimeout(function() { @@ -1209,8 +1200,8 @@ function Ma(a) { return c; }; } -;var Ra = 0; -function Sa(a) { +;var Qa = 0; +function Ra(a) { function b(f) { function h(k) { k = k.data || k; @@ -1223,11 +1214,11 @@ function Sa(a) { d ? this.worker.on("message", h) : this.worker.onmessage = h; if (a.config) { return new Promise(function(k) { - e.h[++Ra] = function() { + e.h[++Qa] = function() { k(e); - 1e9 < Ra && (Ra = 0); + 1e9 < Qa && (Qa = 0); }; - e.worker.postMessage({id:Ra, task:"init", factory:c, options:a}); + e.worker.postMessage({id:Qa, task:"init", factory:c, options:a}); }); } this.worker.postMessage({task:"init", factory:c, options:a}); @@ -1236,12 +1227,12 @@ function Sa(a) { } } a = void 0 === a ? {} : a; - if (!this || this.constructor !== Sa) { - return new Sa(a); + if (!this || this.constructor !== Ra) { + return new Ra(a); } var c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; c && (c = c.toString()); - var d = "undefined" === typeof window, e = this, g = Ta(c, d, a.worker); + var d = "undefined" === typeof window, e = this, g = Sa(c, d, a.worker); return g.then ? g.then(function(f) { return b.call(e, f); }) : b.call(this, g); @@ -1254,9 +1245,9 @@ S("remove"); S("clear"); S("export"); S("import"); -Ja(Sa.prototype); +Ia(Ra.prototype); function S(a) { - Sa.prototype[a] = function() { + Ra.prototype[a] = function() { var b = this, c = [].slice.call(arguments), d = c[c.length - 1]; if ("function" === typeof d) { var e = d; @@ -1264,17 +1255,17 @@ function S(a) { } d = new Promise(function(g) { "export" === a && "function" === typeof c[0] && (c[0] = null); - b.h[++Ra] = g; - b.worker.postMessage({task:a, id:Ra, args:c}); + b.h[++Qa] = g; + b.worker.postMessage({task:a, id:Qa, args:c}); }); return e ? (d.then(e), this) : d; }; } -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", +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", "module/worker/worker.js"), {type:"module"}); } -;function Ua(a, b) { +;function Ta(a, b) { b = void 0 === b ? 0 : b; var c = [], d = []; b && (b = 250000 / b * 5000 | 0); @@ -1285,32 +1276,32 @@ function Ta(a, b, c) { d.length && c.push(d); return c; } -function Va(a, b) { +function Ua(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 Wa(a, b) { +function Va(a, b) { b = void 0 === b ? 0 : b; var c = [], d = []; b && (b = 250000 / b * 1000 | 0); a = x(a.entries()); for (var e = a.next(); !e.done; e = a.next()) { - e = e.value, d.push([e[0], Ua(e[1])[0]]), d.length === b && (c.push(d), d = []); + e = e.value, d.push([e[0], Ta(e[1])[0]]), d.length === b && (c.push(d), d = []); } d.length && c.push(d); return c; } -function Xa(a, b) { +function Wa(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], Va(d[1], e)); + d = a[c], e = b.get(d[0]), b.set(d[0], Ua(d[1], e)); } return b; } -function Ya(a) { +function Xa(a) { var b = [], c = []; a = x(a.keys()); for (var d = a.next(); !d.done; d = a.next()) { @@ -1319,14 +1310,14 @@ function Ya(a) { c.length && b.push(c); return b; } -function Za(a, b) { +function Ya(a, b) { b || (b = new Set()); for (var c = 0; c < a.length; c++) { b.add(a[c]); } return b; } -function $a(a, b, c, d, e, g, f) { +function Za(a, b, c, d, e, g, f) { f = void 0 === f ? 0 : f; var h = d && d.constructor === Array, k = h ? d.shift() : d; if (!k) { @@ -1335,12 +1326,12 @@ function $a(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 $a.call(l, a, b, c, h ? d : null, e, g, f + 1); + return Za.call(l, a, b, c, h ? d : null, e, g, f + 1); }); } - return $a.call(this, a, b, c, h ? d : null, e, g, f + 1); + return Za.call(this, a, b, c, h ? d : null, e, g, f + 1); } -function ab(a, b) { +function $a(a, b) { var c = ""; a = x(a.entries()); for (var d = a.next(); !d.done; d = a.next()) { @@ -1360,7 +1351,7 @@ function ab(a, b) { } return c; } -;function bb(a, b, c, d) { +;function ab(a, b, c, d) { for (var e = [], g = 0, f; g < a.index.length; g++) { if (f = a.index[g], b >= f.length) { b -= f.length; @@ -1425,12 +1416,12 @@ function T(a) { } if ("slice" === d) { return function(e, g) { - return bb(b, e || 0, g || b.length, !1); + return ab(b, e || 0, g || b.length, !1); }; } if ("splice" === d) { return function(e, g) { - return bb(b, e || 0, g || b.length, !0); + return ab(b, e || 0, g || b.length, !0); }; } if ("constructor" === d) { @@ -1462,7 +1453,7 @@ function U(a) { this.index = J(); this.h = []; this.size = 0; - 32 < a ? (this.A = cb, this.B = BigInt(a)) : (this.A = db, this.B = a); + 32 < a ? (this.A = bb, this.B = BigInt(a)) : (this.A = cb, this.B = a); } U.prototype.get = function(a) { var b = this.A(a); @@ -1480,7 +1471,7 @@ function V(a) { this.index = J(); this.h = []; this.size = 0; - 32 < a ? (this.A = cb, this.B = BigInt(a)) : (this.A = db, this.B = a); + 32 < a ? (this.A = bb, this.B = BigInt(a)) : (this.A = cb, this.B = a); } V.prototype.add = function(a) { var b = this.A(a), c = this.index[b]; @@ -1500,9 +1491,9 @@ u.clear = V.prototype.clear = function() { this.h = []; this.size = 0; }; -u.values = V.prototype.values = function eb() { +u.values = V.prototype.values = function db() { var b, c = this, d, e, g; - return ra(eb, function(f) { + return ra(db, function(f) { switch(f.h) { case 1: b = 0; @@ -1526,9 +1517,9 @@ u.values = V.prototype.values = function eb() { } }); }; -u.keys = V.prototype.keys = function fb() { +u.keys = V.prototype.keys = function eb() { var b, c = this, d, e, g; - return ra(fb, function(f) { + return ra(eb, function(f) { switch(f.h) { case 1: b = 0; @@ -1552,9 +1543,9 @@ u.keys = V.prototype.keys = function fb() { } }); }; -u.entries = V.prototype.entries = function gb() { +u.entries = V.prototype.entries = function fb() { var b, c = this, d, e, g; - return ra(gb, function(f) { + return ra(fb, function(f) { switch(f.h) { case 1: b = 0; @@ -1578,7 +1569,7 @@ u.entries = V.prototype.entries = function gb() { } }); }; -function db(a) { +function cb(a) { var b = Math.pow(2, this.B) - 1; if ("number" == typeof a) { return a & b; @@ -1588,7 +1579,7 @@ function db(a) { } return 32 === this.B ? c + Math.pow(2, 31) : c; } -function cb() { +function bb() { throw Error("The keystore is limited to 32 for EcmaScript5"); } ;W.prototype.add = function(a, b, c) { @@ -1605,7 +1596,7 @@ function cb() { } else { var f = e.R; if (!f || f(b)) { - e.constructor === String ? e = ["" + e] : K(e) && (e = [e]), hb(b, e, this.S, 0, g, a, e[0], c); + e.constructor === String ? e = ["" + e] : K(e) && (e = [e]), gb(b, e, this.S, 0, g, a, e[0], c); } } } @@ -1670,7 +1661,7 @@ function cb() { q[d] = b[d]; continue; } - ib(b, q, d, 0, d[0], g); + hb(b, q, d, 0, d[0], g); } } } @@ -1680,21 +1671,21 @@ function cb() { } return this; }; -function ib(a, b, c, d, e, g) { +function hb(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++) { - ib(a, b, c, d, e); + hb(a, b, c, d, e); } } else { - b = b[e] || (b[e] = J()), e = c[++d], ib(a, b, c, d, e); + b = b[e] || (b[e] = J()), e = c[++d], hb(a, b, c, d, e); } } } -function hb(a, b, c, d, e, g, f, h) { +function gb(a, b, c, d, e, g, f, h) { if (a = a[f]) { if (d === b.length - 1) { if (a.constructor === Array) { @@ -1710,17 +1701,17 @@ function hb(a, b, c, d, e, g, f, h) { } else { if (a.constructor === Array) { for (f = 0; f < a.length; f++) { - hb(a, b, c, d, e, g, f, h); + gb(a, b, c, d, e, g, f, h); } } else { - f = b[++d], hb(a, b, c, d, e, g, f, h); + f = b[++d], gb(a, b, c, d, e, g, f, h); } } } else { e.db && e.remove(g); } } -;function jb(a, b, c, d, e, g, f) { +;function ib(a, b, c, d, e, g, f) { var h = a.length, k = []; var l = J(); for (var m = 0, n = void 0, p, q; m < b; m++) { @@ -1745,7 +1736,7 @@ function hb(a, b, c, d, e, g, f, h) { } if (a = k.length) { if (e) { - k = 1 < k.length ? kb(k, c, d, f, g) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; + k = 1 < k.length ? jb(k, c, d, f, g) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; } else { if (a < h) { return []; @@ -1778,7 +1769,7 @@ function hb(a, b, c, d, e, g, f, h) { } return k; } -function kb(a, b, c, d, e) { +function jb(a, b, c, d, e) { var g = [], f = J(), h = a.length, k; if (d) { for (e = h - 1; 0 <= e; e--) { @@ -1821,7 +1812,7 @@ function kb(a, b, c, d, e) { } return g; } -function lb(a, b, c) { +function kb(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++) { @@ -1841,7 +1832,7 @@ function lb(a, b, c) { } return e; } -;function mb(a, b, c, d) { +;function lb(a, b, c, d) { if (!a.length) { return a; } @@ -1871,7 +1862,7 @@ function lb(a, b, c) { e = 1 < e.length ? [].concat.apply([], e) : e[0]; return d ? X.call(this, e) : e; } -;function nb(a, b, c) { +;function mb(a, b, c) { var d = c[0]; if (d.then) { return Promise.all(c).then(function(q) { @@ -1917,10 +1908,10 @@ function lb(a, b, c) { return {W:d, $:e, limit:g, offset:f, enrich:h, resolve:k, suggest:l}; } ;Y.prototype.or = function() { - var a = nb(this, "or", arguments); - return ob.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve); + var a = mb(this, "or", arguments); + return nb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve); }; -function ob(a, b, c, d, e, g) { +function nb(a, b, c, d, e, g) { if (b.length) { var f = this; return Promise.all(b).then(function(h) { @@ -1928,10 +1919,10 @@ function ob(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 ob.call(f, a, [], c, d, e, g); + return nb.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 = kb(a, c, d, !1, this.h), d = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = jb(a, c, d, !1, this.h), d = 0)); return g ? this.resolve(c, d, e) : this; } ;Y.prototype.and = function() { @@ -1946,7 +1937,36 @@ function ob(a, b, c, d, e, g) { 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; + 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); }; function pb(a, b, c, d, e, g, f) { if (b.length) { @@ -1963,43 +1983,14 @@ 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 { - if (b = za(a)) { - return this.result = jb(a, b, c, d, f, this.h, g), g ? e ? X.call(this.index, this.result) : this.result : this; - } - this.result = []; + return this.result = qb.call(this, a, c, d, g, this.h), g ? e ? X.call(this.index, this.result) : this.result : this; } } else { f || (this.result = a); } return g ? this.resolve(c, d, e) : this; } -;Y.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 ? X.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) { +function qb(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); @@ -2043,10 +2034,10 @@ function rb(a, b, c, d, e) { return g; } ;Y.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); + var a = mb(this, "not", arguments); + return rb.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest); }; -function sb(a, b, c, d, e, g, f) { +function rb(a, b, c, d, e, g, f) { if (b.length) { var h = this; return Promise.all(b).then(function(k) { @@ -2054,17 +2045,17 @@ function sb(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 sb.call(h, a, [], c, d, e, g, f); + return rb.call(h, a, [], c, d, e, g, f); }); } if (a.length && this.result.length) { - this.result = tb.call(this, a, c, d, g); + this.result = sb.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; } -function tb(a, b, c, d) { +function sb(a, b, c, d) { var e = []; a = new Set(a.flat().flat()); for (var g = 0, f, h = 0; g < this.result.length; g++) { @@ -2137,7 +2128,7 @@ Y.prototype.boost = function(a) { Y.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), mb.call(e, d, a || 100, b, c)) : d; + return d.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), lb.call(e, d, a || 100, b, c)) : d; }; J(); W.prototype.search = function(a, b, c, d) { @@ -2212,7 +2203,7 @@ W.prototype.search = function(a, b, c, d) { } k.push(l = l.db.tag(r[g + 1], b, w, f)); } else { - l = ub.call(this, r[g], r[g + 1], b, w, f); + l = tb.call(this, r[g], r[g + 1], b, w, f); } e.push({field:r[g], tag:r[g + 1], result:l}); } @@ -2242,10 +2233,10 @@ W.prototype.search = function(a, b, c, d) { if (p) { if (this.db) { y.tag = p; - var Ka = v.db.support_tag_search; + var Ja = v.db.support_tag_search; y.field = n; } - Ka || (y.enrich = !1); + Ja || (y.enrich = !1); } if (r) { r[A] = v.search(a, b, y); @@ -2260,7 +2251,7 @@ W.prototype.search = function(a, b, c, d) { D = []; H = 0; if (this.db && d) { - if (!Ka) { + if (!Ja) { for (I = n.length; I < d.length; I++) { var M = d[I]; if (M && M.length) { @@ -2272,7 +2263,7 @@ W.prototype.search = function(a, b, c, d) { } } else { I = 0; - for (var Yb = M = void 0; I < p.length; I += 2) { + for (var Zb = 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) { @@ -2281,7 +2272,7 @@ W.prototype.search = function(a, b, c, d) { return k ? e : new Y(e); } } - if (Yb = (M = M && M.get(p[I + 1])) && M.length) { + if (Zb = (M = M && M.get(p[I + 1])) && M.length) { H++, D.push(M); } else if (!q) { return k ? e : new Y(e); @@ -2289,7 +2280,7 @@ W.prototype.search = function(a, b, c, d) { } } if (H) { - v = lb(v, D, k); + v = kb(v, D, k); y = v.length; if (!y && !q) { return k ? v : new Y(v); @@ -2305,7 +2296,7 @@ W.prototype.search = function(a, b, c, d) { } } if (r) { - if (this.db && p && p.length && !Ka) { + if (this.db && p && p.length && !Ja) { for (f = 0; f < p.length; f += 2) { g = this.index.get(p[f]); if (!g) { @@ -2318,9 +2309,9 @@ W.prototype.search = function(a, b, c, d) { r.push(g.db.tag(p[f + 1], b, w, !1)); } } - var Zb = this; + var $b = this; return Promise.all(r).then(function(Q) { - return Q.length ? Zb.search(a, b, c, Q) : Q; + return Q.length ? $b.search(a, b, c, Q) : Q; }); } if (!h) { @@ -2339,17 +2330,17 @@ W.prototype.search = function(a, b, c, d) { e[w] = {field:g[w], result:q}; } if (f && this.db && r.length) { - var La = this; + var Ka = this; return Promise.all(r).then(function(Q) { for (var R = 0; R < Q.length; R++) { e[R].result = Q[R]; } - return m ? vb(e, b) : t ? wb(e, a, La.index, La.field, La.J, t) : e; + return m ? ub(e, b) : t ? vb(e, a, Ka.index, Ka.field, Ka.J, t) : e; }); } - return m ? vb(e, b) : t ? wb(e, a, this.index, this.field, this.J, t) : e; + return m ? ub(e, b) : t ? vb(e, a, this.index, this.field, this.J, t) : e; }; -function wb(a, b, c, d, e, g) { +function vb(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; @@ -2387,7 +2378,7 @@ function wb(a, b, c, d, e, g) { } return a; } -function vb(a, b) { +function ub(a, b) { for (var c = [], d = J(), e = 0, g, f; e < a.length; e++) { g = a[e]; f = g.result; @@ -2405,7 +2396,7 @@ function vb(a, b) { } return c; } -function ub(a, b, c, d, e) { +function tb(a, b, c, d, e) { var g = this.tag.get(a); if (!g) { return console.warn("Tag '" + a + "' was not found"), []; @@ -2435,17 +2426,17 @@ function X(a) { this.J = []; this.field = []; this.S = []; - this.key = (c = b.key || b.id) && xb(c, this.S) || "id"; + this.key = (c = b.key || b.id) && wb(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.I = (c = b.store || null) && c && !0 !== c && []; this.store = c && (d ? new U(d) : new Map()); - this.cache = (c = a.cache || null) && new yb(c); + this.cache = (c = a.cache || null) && new xb(c); a.cache = !1; this.worker = a.worker; this.priority = a.priority || 4; - this.index = zb.call(this, a, b); + this.index = yb.call(this, a, b); this.tag = null; if (c = b.tag) { if ("string" === typeof c && (c = [c]), c.length) { @@ -2459,7 +2450,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] = 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)); + d.custom ? this.L[b] = d.custom : (this.L[b] = wb(e, this.S), d.filter && ("string" === typeof this.L[b] && (this.L[b] = new String(this.L[b])), this.L[b].R = d.filter)); this.aa[b] = e; this.tag.set(e, new Map()); } @@ -2539,7 +2530,7 @@ u.destroy = function() { } return Promise.all(a); }; -function zb(a, b) { +function yb(a, b) { var c = new Map(), d = b.index || b.field || b; K(d) && (d = [d]); for (var e = 0, g, f = void 0; e < d.length; e++) { @@ -2547,21 +2538,21 @@ function zb(a, b) { K(g) || (f = g, g = g.field); f = L(f) ? Object.assign({}, a, f) : a; if (this.worker) { - var h = new Sa(f); + var h = new Ra(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] = 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)); + 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.field[e] = g; } if (this.I) { for (a = b.store, K(a) && (a = [a]), b = 0; b < a.length; b++) { - d = a[b], e = d.field || d, d.custom ? (this.I[b] = d.custom, d.custom.ja = e) : (this.I[b] = 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)); + d = a[b], e = d.field || d, d.custom ? (this.I[b] = d.custom, d.custom.ja = e) : (this.I[b] = wb(e, this.S), d.filter && ("string" === typeof this.I[b] && (this.I[b] = new String(this.I[b])), this.I[b].R = d.filter)); } } return c; } -function xb(a, b) { +function wb(a, b) { for (var c = a.split(":"), d = 0, e = 0; e < c.length; e++) { a = c[e], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (b[d] = !0), a && (c[d++] = a); } @@ -2629,7 +2620,7 @@ u.set = function(a, b) { this.store.set(a, b); return this; }; -u.searchCache = Ab; +u.searchCache = zb; u.export = function(a, b, c, d) { c = void 0 === c ? 0 : c; d = void 0 === d ? 0 : d; @@ -2646,23 +2637,23 @@ u.export = function(a, b, c, d) { switch(d) { case 0: var f = "reg"; - var h = Ya(this.reg); + var h = Xa(this.reg); b = null; break; case 1: f = "tag"; - h = this.tag && Wa(this.tag, this.reg.size); + h = this.tag && Va(this.tag, this.reg.size); b = null; break; case 2: f = "doc"; - h = this.store && Ua(this.store); + h = this.store && Ta(this.store); b = null; break; default: return; } - return $a.call(this, a, b, f, h, c, d); + return Za.call(this, a, b, f, h, c, d); }; u.import = function(a, b) { var c = a.split("."); @@ -2680,7 +2671,7 @@ u.import = function(a, b) { switch(c) { case "reg": this.fastupdate = !1; - this.reg = Za(b, this.reg); + this.reg = Ya(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; } @@ -2694,17 +2685,17 @@ u.import = function(a, b) { } break; case "tag": - this.tag = Xa(b, this.tag); + this.tag = Wa(b, this.tag); break; case "doc": - this.store = Va(b, this.store); + this.store = Ua(b, this.store); } } }; -Ja(W.prototype); -function Ab(a, b, c) { +Ia(W.prototype); +function zb(a, b, c) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new yb()); + this.cache || (this.cache = new xb()); var d = this.cache.get(a); if (!d) { d = this.search(a, b, c); @@ -2719,54 +2710,45 @@ function Ab(a, b, c) { } return d; } -function yb(a) { +function xb(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.h = ""; } -yb.prototype.set = function(a, b) { +xb.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); }; -yb.prototype.get = function(a) { +xb.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; }; -yb.prototype.remove = function(a) { +xb.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); } }; -yb.prototype.clear = function() { +xb.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -var Bb = {normalize:function(a) { - return a.toLowerCase(); -}}; -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 = /[\x00-\x7F]+/g; -var Hb = /[\x00-\x7F]+/g; -var Ib = /[\x00-\x7F]+/g; -var Jb = {LatinExact:{split:/\s+/, normalize:!1}, LatinDefault:Bb, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Cb}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Cb, matcher:Db, replacer:Eb}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Cb, replacer:Eb.concat([/(?!^)[aeo]/g, ""]), matcher:Db}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +var Ab = {normalize:!1, numeric:!1, split:/\s+/}; +var Bb = {normalize:!0}; +var Cb = {normalize:!0, dedupe:!0}; +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 = {na:Ab, ma:Bb, oa:Cb, LatinBalance:{normalize:!0, dedupe:!0, mapper:Db}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Db, matcher:Eb, replacer:Fb}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Db, replacer:Fb.concat([/(?!^)[aeo]/g, ""]), matcher:Eb}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (var b = 0; b < a.length; b++) { - for (var c = a[b], d = c.charAt(0), e = 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++) { + for (var c = a[b], d = c.charAt(0), e = Gb[d], g = 1, f; g < c.length && (f = c.charAt(g), "h" === f || "w" === f || !(f = Gb[f]) || f === e || (d += f, e = f, 4 !== d.length)); g++) { } a[b] = d; } -}}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Gb, " "); -}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Hb, ""); -}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ib, " "); -}}}; -var Kb = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +}}, LatinExact:Ab, LatinDefault:Bb, LatinSimple:Cb}; +var Ib = {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) { if (b && (a || 0 === a)) { if (!d && !c && this.reg.has(a)) { @@ -2777,39 +2759,40 @@ P.prototype.add = function(a, b, c, d) { 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) : Lb(h, d, k), p = ""; + var n = this.score ? this.score(b, l, k, null, 0) : Jb(h, d, k), p = ""; switch(this.tokenize) { case "full": if (2 < m) { 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) : Lb(h, d, k, m, q), Mb(this, g, p, q, a, c); + p = l.substring(n, t), q = this.rtl ? m - 1 - n : n, q = this.score ? this.score(b, l, k, p, q) : Jb(h, d, k, m, q), Kb(this, g, p, q, a, c); } } break; } + 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) : Lb(h, d, k, m, t), Mb(this, g, p, q, a, c); + p = l[this.rtl ? m - 1 - t : t] + p, q = this.score ? this.score(b, l, k, p, t) : Jb(h, d, k, m, t), Kb(this, g, p, q, a, c); } p = ""; } case "forward": if (1 < m) { for (t = 0; t < m; t++) { - p += l[this.rtl ? m - 1 - t : t], Mb(this, g, p, n, a, c); + p += l[this.rtl ? m - 1 - t : t], Kb(this, g, p, n, a, c); } break; } default: - if (Mb(this, g, l, n, a, c), f && 1 < d && k < d - 1) { + if (Kb(this, g, l, n, a, c), f && 1 < d && k < d - 1) { for (m = J(), p = this.da, n = l, t = Math.min(f + 1, this.rtl ? k + 1 : d - k), q = m[n] = 1; q < t; q++) { if ((l = b[this.rtl ? d - 1 - k - q : k + q]) && !m[l]) { m[l] = 1; - var w = this.score ? this.score(b, n, k, l, q - 1) : Lb(p + (d / 2 > p ? 0 : 1), d, k, t - 1, q - 1), r = this.bidirectional && l > n; - Mb(this, e, r ? n : l, w, a, c, r ? l : n); + var w = this.score ? this.score(b, n, k, l, q - 1) : Jb(p + (d / 2 > p ? 0 : 1), d, k, t - 1, q - 1), r = this.bidirectional && l > n; + Kb(this, e, r ? n : l, w, a, c, r ? l : n); } } } @@ -2821,10 +2804,10 @@ P.prototype.add = function(a, b, c, d) { b = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.ca && Nb(this)); + this.db && (b || this.commit_task.push({del:a}), this.ca && Lb(this)); return this; }; -function Mb(a, b, c, d, e, g, f) { +function Kb(a, b, c, d, e, g, f) { var h = f ? a.ctx : a.map, k; if (!b[c] || f && !(k = b[c])[f]) { if (f ? (b = k || (b[c] = 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)) { @@ -2842,7 +2825,7 @@ function Mb(a, b, c, d, e, g, f) { } } } -function Lb(a, b, c, d, e) { +function Jb(a, b, c, d, e) { return c && 1 < a ? b + (d || 0) <= a ? c + (e || 0) : (a - 1) / (b + (d || 0)) * (c + (e || 0)) + 1 | 0 : 0; } ;P.prototype.search = function(a, b, c) { @@ -2865,11 +2848,11 @@ function Lb(a, b, c, d, e) { var q = p.length; b = b || (g ? 100 : 0); if (1 === q) { - return Ob.call(this, p[0], "", b, e, g, k, n); + return Mb.call(this, p[0], "", b, e, g, k, n); } f = this.depth && !1 !== f; if (2 === q && f && !h) { - return Ob.call(this, p[0], p[1], b, e, g, k, n); + return Mb.call(this, p[0], p[1], b, e, g, k, n); } var t = J(), w = 0; if (1 < q && f) { @@ -2899,10 +2882,10 @@ function Lb(a, b, c, d, e) { break; } t[v] = 1; - return E(y, Pb(A, v, r, 0, 0, !1, !1), 6); + return E(y, Nb(A, v, r, 0, 0, !1, !1), 6); case 6: z = y.D; - if (z = Qb(z, d, h, m)) { + if (z = Ob(z, d, h, m)) { d = z; y.h = 4; break; @@ -2914,7 +2897,7 @@ function Lb(a, b, c, d, e) { y.h = 2; break; case 4: - return y.return(Rb(d, m, b, e, h, l, g)); + return y.return(Pb(d, m, b, e, h, l, g)); } }); }(); @@ -2922,8 +2905,8 @@ function Lb(a, b, c, d, e) { for (c = a = void 0; w < q; w++) { if ((c = p[w]) && !t[c]) { t[c] = 1; - a = Pb(this, c, r, 0, 0, !1, !1); - if (a = Qb(a, d, h, m)) { + a = Nb(this, c, r, 0, 0, !1, !1); + if (a = Ob(a, d, h, m)) { d = a; break; } @@ -2931,24 +2914,24 @@ function Lb(a, b, c, d, e) { } h && r && w === q - 1 && !d.length && (m = this.resolution, r = "", w = -1, t = J()); } - return Rb(d, m, b, e, h, l, g); + return Pb(d, m, b, e, h, l, g); }; -function Rb(a, b, c, d, e, g, f) { +function Pb(a, b, c, d, e, g, f) { var h = a.length, k = a; if (1 < h) { - k = jb(a, b, c, d, e, g, f); + k = ib(a, b, c, d, e, g, f); } else if (1 === h) { - return f ? mb.call(null, a[0], c, d) : new Y(a[0]); + return f ? lb.call(null, a[0], c, d) : new Y(a[0]); } return f ? k : new Y(k); } -function Ob(a, b, c, d, e, g, f) { - a = Pb(this, a, b, c, d, e, g, f); +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 ? mb.call(this, a, c, d) : new Y(a) : e ? [] : new Y(); + }) : a && a.length ? e ? lb.call(this, a, c, d) : new Y(a) : e ? [] : new Y(); } -function Qb(a, b, c, d) { +function Ob(a, b, c, d) { var e = []; if (a && a.length) { if (a.length <= d) { @@ -2969,7 +2952,7 @@ function Qb(a, b, c, d) { return e; } } -function Pb(a, b, c, d, e, g, f, h) { +function Nb(a, b, c, d, e, g, f, h) { var k; c && (k = a.bidirectional && b > c) && (k = c, c = b, b = k); if (a.db) { @@ -2993,15 +2976,15 @@ function Pb(a, b, c, d, e, g, f, h) { } } } else { - Sb(this.map, a), this.depth && Sb(this.ctx, a); + Qb(this.map, a), this.depth && Qb(this.ctx, a); } b || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.ca && Nb(this)); + this.db && (this.commit_task.push({del:a}), this.ca && Lb(this)); this.cache && this.cache.remove(a); return this; }; -function Sb(a, b) { +function Qb(a, b) { var c = 0; if (a.constructor === Array) { for (var d = 0, e = void 0, g; d < a.length; d++) { @@ -3016,7 +2999,7 @@ function Sb(a, b) { } } else { for (d = x(a.entries()), e = d.next(); !e.done; e = d.next()) { - g = e.value, e = g[0], (g = Sb(g[1], b)) ? c += g : a.delete(e); + g = e.value, e = g[0], (g = Qb(g[1], b)) ? c += g : a.delete(e); } } return c; @@ -3027,15 +3010,15 @@ function Sb(a, b) { } if (a) { var c = K(a) ? a : a.preset; - c && (Kb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Kb[c], a)); + c && (Ib[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Ib[c], a)); } else { a = {}; } c = a.context; - var d = !0 === c ? {depth:1} : c || {}, e = K(a.encoder) ? Jb[a.encoder] : a.encode || a.encoder || Bb; - this.encoder = e.encode ? e : "object" === typeof e ? new Ga(e) : {encode:e}; + var d = !0 === c ? {depth:1} : c || {}, e = K(a.encoder) ? Hb[a.encoder] : a.encode || a.encoder || Bb; + 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 && c || "strict"; + 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; @@ -3047,7 +3030,7 @@ function Sb(a, b) { this.reg = b || (this.fastupdate ? c ? new U(c) : new Map() : c ? new V(c) : new Set()); this.da = d.resolution || 3; this.rtl = e.rtl || a.rtl || !1; - this.cache = (c = a.cache || null) && new yb(c); + this.cache = (c = a.cache || null) && new xb(c); this.resolve = !1 !== a.resolve; if (c = a.db) { this.db = this.mount(c); @@ -3070,7 +3053,7 @@ u.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function Nb(a) { +function Lb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); @@ -3096,7 +3079,7 @@ u.update = function(a, b) { return c.add(a, b); }) : this.add(a, b); }; -function Tb(a) { +function Rb(a) { var b = 0; if (a.constructor === Array) { for (var c = 0, d = void 0; c < a.length; c++) { @@ -3106,7 +3089,7 @@ function Tb(a) { for (c = x(a.entries()), d = c.next(); !d.done; d = c.next()) { var e = d.value; d = e[0]; - (e = Tb(e[1])) ? b += e : a.delete(d); + (e = Rb(e[1])) ? b += e : a.delete(d); } } return b; @@ -3115,18 +3098,18 @@ u.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Tb(this.map); - this.depth && Tb(this.ctx); + Rb(this.map); + this.depth && Rb(this.ctx); return this; }; -u.searchCache = Ab; +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); + var g = Xa(this.reg); break; case 1: e = "cfg"; @@ -3134,29 +3117,29 @@ u.export = function(a, b, c, d) { break; case 2: e = "map"; - g = Ua(this.map, this.reg.size); + g = Ta(this.map, this.reg.size); break; case 3: e = "ctx"; - g = Wa(this.ctx, this.reg.size); + g = Va(this.ctx, this.reg.size); break; default: return; } - return $a.call(this, a, b, e, g, c, d); + return Za.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 = Za(b, this.reg); + this.reg = Ya(b, this.reg); break; case "map": - this.map = Va(b, this.map); + this.map = Ua(b, this.map); break; case "ctx": - this.ctx = Xa(b, this.ctx); + this.ctx = Wa(b, this.ctx); } } }; @@ -3170,13 +3153,13 @@ u.serialize = function(a) { g = g.value, e || (e = typeof g), b += (b ? "," : "") + ("string" === e ? '"' + g + '"' : g); } b = "index.reg=new Set([" + b + "]);"; - c = ab(this.map, e); + c = $a(this.map, e); c = "index.map=new Map([" + c + "]);"; g = x(this.ctx.entries()); for (var f = g.next(); !f.done; f = g.next()) { var h = f.value; f = h[0]; - h = ab(h[1], e); + h = $a(h[1], e); h = "new Map([" + h + "])"; h = '["' + f + '",' + h + "]"; d += (d ? "," : "") + h; @@ -3185,12 +3168,12 @@ u.serialize = function(a) { } return a ? "function inject(index){" + b + c + d + "}" : b + c + d; }; -Ja(P.prototype); -var Ub = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Vb = ["map", "ctx", "tag", "reg", "cfg"], Wb = J(); -function Xb(a, b) { +Ia(P.prototype); +var Sb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Tb = ["map", "ctx", "tag", "reg", "cfg"], Ub = J(); +function Vb(a, b) { b = void 0 === b ? {} : b; if (!this) { - return new Xb(a, b); + return new Vb(a, b); } "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -3201,7 +3184,7 @@ function Xb(a, b) { this.db = null; this.h = {}; } -u = Xb.prototype; +u = Vb.prototype; u.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -3215,14 +3198,14 @@ u.open = function() { } var a = this; navigator.storage && navigator.storage.persist(); - Wb[a.id] || (Wb[a.id] = []); - Wb[a.id].push(a.field); - var b = Ub.open(a.id, 1); + Ub[a.id] || (Ub[a.id] = []); + Ub[a.id].push(a.field); + var b = Sb.open(a.id, 1); b.onupgradeneeded = function() { - for (var c = a.db = this.result, d = 0, e; d < Vb.length; d++) { - e = Vb[d]; - for (var g = 0, f; g < Wb[a.id].length; g++) { - f = Wb[a.id][g], c.objectStoreNames.contains(e + ("reg" !== e ? f ? ":" + f : "" : "")) || c.createObjectStore(e + ("reg" !== e ? f ? ":" + f : "" : "")); + for (var c = a.db = this.result, d = 0, e; d < Tb.length; d++) { + e = Tb[d]; + for (var g = 0, f; g < Ub[a.id].length; g++) { + f = Ub[a.id][g], c.objectStoreNames.contains(e + ("reg" !== e ? f ? ":" + f : "" : "")) || c.createObjectStore(e + ("reg" !== e ? f ? ":" + f : "" : "")); } } }; @@ -3238,14 +3221,14 @@ u.close = function() { this.db = null; }; u.destroy = function() { - var a = Ub.deleteDatabase(this.id); + var a = Sb.deleteDatabase(this.id); return Z(a); }; u.clear = function() { - for (var a = [], b = 0, c; b < Vb.length; b++) { - c = Vb[b]; - for (var d = 0, e; d < Wb[this.id].length; d++) { - e = Wb[this.id][d], a.push(c + ("reg" !== c ? e ? ":" + e : "" : "")); + for (var a = [], b = 0, c; b < Tb.length; b++) { + c = Tb[b]; + for (var d = 0, e; d < Ub[this.id].length; d++) { + e = Ub[this.id][d], a.push(c + ("reg" !== c ? e ? ":" + e : "" : "")); } } b = this.db.transaction(a, "readwrite"); @@ -3492,7 +3475,7 @@ u.commit = function(a, b, c) { } }); }; -function $b(a, b, c) { +function Wb(a, b, c) { for (var d = a.value, e, g = 0, f = 0, h; f < d.length; f++) { if (h = c ? d : d[f]) { for (var k = 0, l; k < b.length; k++) { @@ -3519,17 +3502,17 @@ u.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && $b(c, a); + c && Wb(c, a); }; }), this.transaction("ctx", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && $b(c, a); + c && Wb(c, a); }; }), this.transaction("tag", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && $b(c, a, !0); + c && Wb(c, a, !0); }; }), this.transaction("reg", "readwrite", function(b) { for (var c = 0; c < a.length; c++) { @@ -3548,8 +3531,8 @@ function Z(a, b) { a = null; }); } -;var ac = {Index:P, Charset:Jb, Encoder:Ga, Document:W, Worker:Sa, Resolver:Y, IndexedDB:Xb, Language:{}}, bc = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self, cc; -(cc = bc.define) && cc.amd ? cc([], function() { - return ac; -}) : "object" === typeof bc.exports ? bc.exports = ac : bc.FlexSearch = ac; +;var Xb = {Index:P, Charset:Hb, Encoder:Fa, Document:W, Worker:Ra, Resolver:Y, IndexedDB:Vb, Language:{}}, Yb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self, ac; +(ac = Yb.define) && ac.amd ? ac([], function() { + return Xb; +}) : "object" === typeof Yb.exports ? Yb.exports = Xb : Yb.FlexSearch = Xb; }(this||self)); diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js index b1131be..af30cb8 100644 --- a/dist/flexsearch.es5.min.js +++ b/dist/flexsearch.es5.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.142 (ES5) + * FlexSearch.js v0.8.143 (ES5) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -37,96 +37,90 @@ C("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d i C("String.prototype.includes",function(a){return a?a:function(b,c){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(b,c||0)}}); C("Array.prototype.flat",function(a){return a?a:function(b){b=void 0===b?1:b;var c=[];Array.prototype.forEach.call(this,function(d){Array.isArray(d)&&0"a1a".split(c).length; -this.numeric=G(a.numeric,e)}else{try{this.split=G(this.split,Ba)}catch(g){this.split=/\s+/}this.numeric=G(a.numeric,G(this.numeric,!0))}this.prepare=G(a.prepare,null,this.prepare);this.finalize=G(a.finalize,null,this.finalize);Fa||(this.mapper=new Map(Aa));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=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&&N(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&&N(this);return this}; +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=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&&N(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&&N(this);return this}; u.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&N(this);return this}; u.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&N(this);return this}; -u.encode=function(a){var b=this;if(this.cache&&a.length<=this.G)if(this.D){if(this.B.has(a))return this.B.get(a)}else this.D=setTimeout(N,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=Fa?a.normalize("NFKD").replace(Fa,"").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 N(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 O(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 Ma(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} +0;f&&kthis.T&&(this.C.clear(),this.H=this.H/1.1|0));f&&d.push(f)}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.G&&(this.B.set(a,d),this.B.size>this.T&&(this.B.clear(),this.G=this.G/1.1|0));return d};function N(a){a.D=null;a.B.clear();a.C.clear()};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 E(h,Ha.import.call(Ga,d[0]),9)}g=d&&Ga[b].apply(Ga,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,Ga.import(d[0],f);case 5:postMessage("search"===b?{id:c,msg:g}:{id:c}),h.h=0}})};function La(a){Ma.call(a,"add");Ma.call(a,"append");Ma.call(a,"search");Ma.call(a,"update");Ma.call(a,"remove")}var Na,Oa,Pa;function Qa(){Na=Pa=0} +function Ma(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=J();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+d)}else{e=[]; +J();for(c=0;cc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[]; for(g=0;gd)d-=f.length;else{if(f.length>c||d)f=f.slice(d,c+d),c-=f.length,d&&(d-=f.length);e.push(f);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,d?W.call(this,a):a;for(var e=[],g=0,f=void 0,h=void 0;g=h){c-=h;continue}cb&&(f=f.slice(0,b),h=b);if(!e.length&&h>=b)return d?W.call(this,f):f;e.push(f);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=lb(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=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=za(a))return this.result=kb(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=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?W.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;kb?b?a.slice(c,c+b):a.slice(c):a,d?W.call(this,a):a;for(var e=[],g=0,f=void 0,h=void 0;g=h){c-=h;continue}cb&&(f=f.slice(0,b),h=b);if(!e.length&&h>=b)return d?W.call(this,f):f;e.push(f);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=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=J(),h=0,k=0,l;kc||d)a=a.slice(d,d+c);e&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;for(var b=Array(a.length),c=0,d;cc||d)a=a.slice(d,d+c);e&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;for(var b=Array(a.length),c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -Y.prototype.get=function(a){var b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Y.prototype.remove=function(a){for(var b=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)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};var Bb={normalize:function(a){return a.toLowerCase()}};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=/[\x00-\x7F]+/g;var Hb=/[\x00-\x7F]+/g;var Ib=/[\x00-\x7F]+/g;var Jb={LatinExact:{split:/\s+/,normalize:!1},LatinDefault:Bb,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Cb},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Cb,matcher:Db,replacer:Eb},LatinExtra:{normalize:!0,dedupe:!0,mapper:Cb,replacer:Eb.concat([/(?!^)[aeo]/g,""]),matcher:Db},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;bn;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 "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&&Nb(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 S(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};O.prototype.remove=function(a,b){var c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(var d=0,e;de.length)e.pop();else{var g=e.indexOf(a);g===c.length-1?e.pop():e.splice(g,1)}}else Sb(this.map,a),this.depth&&Sb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Nb(this));this.cache&&this.cache.remove(a);return this}; -function Sb(a,b){var c=0;if(a.constructor===Array)for(var d=0,e=void 0,g;dthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.prototype.get=function(a){var b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Y.prototype.remove=function(a){for(var b=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)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};var Ab={normalize:!1,numeric:!1,split:/\s+/};var Bb={normalize:!0};var Cb={normalize:!0,dedupe:!0};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={na:Ab,ma:Bb,oa:Cb,LatinBalance:{normalize:!0,dedupe:!0,mapper:Db},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Db,matcher:Eb,replacer:Fb},LatinExtra:{normalize:!0,dedupe:!0,mapper:Db,replacer:Fb.concat([/(?!^)[aeo]/g,""]),matcher:Eb},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;bn;r--)p=l.substring(n,r),q=this.rtl?m-1-n:n,q=this.score?this.score(b,l,k,p,q):Jb(h,d,k,m,q),Kb(this,g,p, +q,a,c);break}case "bidirectional":case "reverse":if(1p?0:1),d,k,r-1,q-1),t=this.bidirectional&& +l>n;Kb(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&&Lb(this));return this}; +function Kb(a,b,c,d,e,g,f){var h=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])if(f?(b=k||(b[c]=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 S(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 Jb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,g,f,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};O.prototype.remove=function(a,b){var c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(var d=0,e;de.length)e.pop();else{var g=e.indexOf(a);g===c.length-1?e.pop():e.splice(g,1)}}else Qb(this.map,a),this.depth&&Qb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Lb(this));this.cache&&this.cache.remove(a);return this}; +function Qb(a,b){var c=0;if(a.constructor===Array)for(var d=0,e=void 0,g;d=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length, p=d;p=g.length)return[];if(!b&&!c)return g;g=g.slice(c,c+b);return d?e.enrich(g):g})}; u.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;d a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, c); + return this.addMapper(a, d); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, c); + this.matcher.set(a, d); this.g += (this.g ? "|" : "") + a; this.s = null; this.cache && G(this); return this; }; -r.addReplacer = function(a, c) { +r.addReplacer = function(a, d) { if ("string" === typeof a) { - return this.addMatcher(a, c); + return this.addMatcher(a, d); } this.replacer || (this.replacer = []); - this.replacer.push(a, c); + this.replacer.push(a, d); this.cache && G(this); return this; }; @@ -185,38 +185,38 @@ r.encode = function(a) { } this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = E ? a.normalize("NFKD").replace(E, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(B, "$1 $2").replace(C, "$1 $2").replace(z, "$1 ")); - const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + this.numeric && 3 < a.length && (a = a.replace(B, "$1 $2").replace(D, "$1 $2").replace(z, "$1 ")); + const d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let b = [], f = this.split || "" === this.split ? a.split(this.split) : a; for (let g = 0, e, h; g < f.length; g++) { if ((e = h = f[g]) && !(e.length < this.minlength)) { - if (c) { + 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 d = this.j.get(e); - if (d || "" === d) { - d && b.push(d); + var c = this.j.get(e); + if (c || "" === c) { + c && b.push(c); continue; } } else { this.l = setTimeout(G, 50, this); } } - this.stemmer && 2 < e.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), d = e, e = e.replace(this.u, k => this.stemmer.get(k)), d !== e && this.filter && e.length >= this.minlength && ("function" === typeof this.filter ? !this.filter(e) : this.filter.has(e)) && (e = "")); + this.stemmer && 2 < e.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), c = e, e = e.replace(this.u, k => this.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 && 1 < e.length)) { - d = ""; + c = ""; for (let k = 0, n = "", m, v; k < e.length; k++) { - m = e.charAt(k), m === n && this.dedupe || ((v = this.mapper && this.mapper.get(m)) || "" === v ? v === n && this.dedupe || !(n = v) || (d += v) : d += n = m); + m = e.charAt(k), m === n && this.dedupe || ((v = this.mapper && this.mapper.get(m)) || "" === v ? v === n && this.dedupe || !(n = v) || (c += v) : c += n = m); } - e = d; + e = c; } this.matcher && 1 < e.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), e = e.replace(this.s, k => this.matcher.get(k))); if (e && this.replacer) { - for (d = 0; e && d < this.replacer.length; d += 2) { - e = e.replace(this.replacer[d], this.replacer[d + 1]); + for (c = 0; e && c < this.replacer.length; c += 2) { + e = e.replace(this.replacer[c], this.replacer[c + 1]); } } this.cache && h.length <= this.o && (this.j.set(h, e), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); @@ -234,30 +234,30 @@ function G(a) { a.i.clear(); a.j.clear(); } -;function H(a, c, b) { +;function H(a, d, b) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a; + return a = a[0], a = b || a.length > d ? d ? a.slice(b, b + d) : a.slice(b) : a; } let f = []; - for (let d = 0, g, e; d < a.length; d++) { - if ((g = a[d]) && (e = g.length)) { + for (let c = 0, g, e; c < a.length; c++) { + if ((g = a[c]) && (e = g.length)) { if (b) { if (b >= e) { b -= e; continue; } - b < e && (g = c ? g.slice(b, b + c) : g.slice(b), e = g.length, b = 0); + b < e && (g = d ? g.slice(b, b + d) : g.slice(b), e = g.length, b = 0); } - e > c && (g = g.slice(0, c), e = c); - if (!f.length && e >= c) { + e > d && (g = g.slice(0, d), e = d); + if (!f.length && e >= d) { return g; } f.push(g); - c -= e; - if (!c) { + d -= e; + if (!d) { break; } } @@ -265,83 +265,58 @@ function G(a) { return f = 1 < f.length ? [].concat.apply([], f) : f[0]; } ;w(); -function I(a) { - this.limit = a && !0 !== a ? a : 1000; - this.cache = new Map(); - this.g = ""; -} -I.prototype.set = function(a, c) { - this.cache.set(this.g = a, c); - this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); -}; -I.prototype.get = function(a) { - const c = this.cache.get(a); - c && this.g !== a && (this.cache.delete(a), this.cache.set(this.g = a, c)); - return c; -}; -I.prototype.remove = function(a) { - for (const c of this.cache) { - const b = c[0]; - c[1].includes(a) && this.cache.delete(b); - } -}; -I.prototype.clear = function() { - this.cache.clear(); - this.g = ""; -}; -const J = {normalize:function(a) { - return a.toLowerCase(); -}}; -const K = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -L.prototype.add = function(a, c, b, f) { - if (c && (a || 0 === a)) { +const I = {normalize:!0}; +const J = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +K.prototype.add = function(a, d, b, f) { + if (d && (a || 0 === a)) { if (!f && !b && this.reg.has(a)) { - return this.update(a, c); + return this.update(a, d); } - c = this.encoder.encode(c); - if (f = c.length) { - const n = w(), m = w(), v = this.depth, D = this.resolution; + d = this.encoder.encode(d); + if (f = d.length) { + const n = w(), m = w(), v = this.depth, C = this.resolution; for (let p = 0; p < f; p++) { - let l = c[this.rtl ? f - 1 - p : p]; - var d = l.length; - if (d && (v || !m[l])) { - var g = this.score ? this.score(c, l, p, null, 0) : M(D, f, p), e = ""; + let l = d[this.rtl ? f - 1 - p : p]; + var c = l.length; + if (c && (v || !m[l])) { + var g = this.score ? this.score(d, l, p, null, 0) : L(C, f, p), e = ""; switch(this.tokenize) { case "full": - if (2 < d) { - for (let q = 0, t; q < d; q++) { - for (g = d; g > q; g--) { + if (2 < c) { + for (let q = 0, t; q < c; q++) { + for (g = c; g > q; g--) { e = l.substring(q, g); - t = this.rtl ? d - 1 - q : q; - var h = this.score ? this.score(c, l, p, e, t) : M(D, f, p, d, t); - N(this, m, e, h, a, b); + t = this.rtl ? c - 1 - q : q; + var h = this.score ? this.score(d, l, p, e, t) : L(C, f, p, c, t); + M(this, m, e, h, a, b); } } break; } + case "bidirectional": case "reverse": - if (1 < d) { - for (h = d - 1; 0 < h; h--) { - e = l[this.rtl ? d - 1 - h : h] + e; - var k = this.score ? this.score(c, l, p, e, h) : M(D, f, p, d, h); - N(this, m, e, k, a, b); + if (1 < c) { + for (h = c - 1; 0 < h; h--) { + e = l[this.rtl ? c - 1 - h : h] + e; + var k = this.score ? this.score(d, l, p, e, h) : L(C, f, p, c, h); + M(this, m, e, k, a, b); } e = ""; } case "forward": - if (1 < d) { - for (h = 0; h < d; h++) { - e += l[this.rtl ? d - 1 - h : h], N(this, m, e, g, a, b); + if (1 < c) { + for (h = 0; h < c; h++) { + e += l[this.rtl ? c - 1 - h : h], M(this, m, e, g, a, b); } break; } default: - if (N(this, m, l, g, a, b), v && 1 < f && p < f - 1) { - for (d = w(), e = this.v, g = l, h = Math.min(v + 1, this.rtl ? p + 1 : f - p), d[g] = 1, k = 1; k < h; k++) { - if ((l = c[this.rtl ? f - 1 - p - k : p + k]) && !d[l]) { - d[l] = 1; - const q = this.score ? this.score(c, g, p, l, k - 1) : M(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; - N(this, n, t ? g : l, q, a, b, t ? l : g); + if (M(this, m, l, g, a, b), v && 1 < f && p < f - 1) { + for (c = w(), e = this.v, g = l, h = Math.min(v + 1, this.rtl ? p + 1 : f - p), c[g] = 1, k = 1; k < h; k++) { + if ((l = d[this.rtl ? f - 1 - p - k : p + k]) && !c[l]) { + c[l] = 1; + const q = this.score ? this.score(d, g, p, l, k - 1) : L(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; + M(this, n, t ? g : l, q, a, b, t ? l : g); } } } @@ -353,22 +328,22 @@ L.prototype.add = function(a, c, b, f) { } return this; }; -function N(a, c, b, f, d, g, e) { +function M(a, d, b, f, c, g, e) { let h = e ? a.ctx : a.map, k; - if (!c[b] || e && !(k = c[b])[e]) { - e ? (c = k || (c[b] = w()), c[e] = 1, (k = h.get(e)) ? h = k : h.set(e, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[f] || (h[f] = []), g && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h]))); + if (!d[b] || e && !(k = d[b])[e]) { + e ? (d = k || (d[b] = w()), d[e] = 1, (k = h.get(e)) ? h = k : h.set(e, h = new Map())) : d[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[f] || (h[f] = []), g && h.includes(c) || (h.push(c), a.fastupdate && ((d = a.reg.get(c)) ? d.push(h) : a.reg.set(c, [h]))); } } -function M(a, c, b, f, d) { - return b && 1 < a ? c + (f || 0) <= a ? b + (d || 0) : (a - 1) / (c + (f || 0)) * (b + (d || 0)) + 1 | 0 : 0; +function L(a, d, b, f, c) { + return b && 1 < a ? d + (f || 0) <= a ? b + (c || 0) : (a - 1) / (d + (f || 0)) * (b + (c || 0)) + 1 | 0 : 0; } -;L.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); - var f = [], d = 0; +;K.prototype.search = function(a, d, b) { + b || (d || "object" !== typeof a ? "object" === typeof d && (b = d, d = 0) : (b = a, a = "")); + var f = [], c = 0; if (b) { a = b.query || a; - c = b.limit || c; - d = b.offset || 0; + d = b.limit || d; + c = b.offset || 0; var g = b.context; var e = b.suggest; var h = !0; @@ -378,13 +353,13 @@ function M(a, c, b, f, d) { } a = this.encoder.encode(a); b = a.length; - c = c || (h ? 100 : 0); + d = d || (h ? 100 : 0); if (1 === b) { - return e = d, (d = O(this, a[0], "")) && d.length ? H.call(this, d, c, e) : []; + return e = c, (c = N(this, a[0], "")) && c.length ? H.call(this, c, d, e) : []; } g = this.depth && !1 !== g; if (2 === b && g && !e) { - return e = d, (d = O(this, a[0], a[1])) && d.length ? H.call(this, d, c, e) : []; + return e = c, (c = N(this, a[0], a[1])) && c.length ? H.call(this, c, d, e) : []; } h = w(); var n = 0; @@ -396,10 +371,10 @@ function M(a, c, b, f, d) { for (let l, q; n < b; n++) { if ((q = a[n]) && !h[q]) { h[q] = 1; - l = O(this, q, m); + l = N(this, q, m); a: { g = l; - var v = f, D = e, p = k; + var v = f, C = e, p = k; let t = []; if (g && g.length) { if (g.length <= p) { @@ -418,7 +393,7 @@ function M(a, c, b, f, d) { break a; } } - l = D ? void 0 : t; + l = C ? void 0 : t; } if (l) { f = l; @@ -442,7 +417,7 @@ function M(a, c, b, f, d) { for (n = 0; n < m; n++) { if (x = a[n], l < x.length && (q = x[l])) { for (g = 0; g < q.length; g++) { - if (t = q[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), A = e[h] || (e[h] = []), A.push(t), c && h === m - 1 && A.length - d === c) { + if (t = q[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), A = e[h] || (e[h] = []), A.push(t), d && h === m - 1 && A.length - c === d) { m = A; break b; } @@ -458,10 +433,10 @@ function M(a, c, b, f, d) { if (b = (f = e[h]) && f.length) { for (n = 0; n < b; n++) { if (m = f[n], !k[m]) { - if (k[m] = 1, d) { - d--; + if (k[m] = 1, c) { + c--; } else { - if (a.push(m), a.length === c) { + if (a.push(m), a.length === d) { break c; } } @@ -471,7 +446,7 @@ function M(a, c, b, f, d) { } } } else { - a = (e = e[0]).length > c || d ? e.slice(d, c + d) : e; + a = (e = e[0]).length > d || c ? e.slice(c, d + c) : e; } e = a; } else { @@ -480,9 +455,9 @@ function M(a, c, b, f, d) { break b; } e = e[a - 1]; - if (c || d) { - if (e.length > c || d) { - e = e.slice(d, c + d); + if (d || c) { + if (e.length > d || c) { + e = e.slice(c, d + c); } } } @@ -490,48 +465,47 @@ function M(a, c, b, f, d) { m = e; } } else if (1 === f) { - c = H.call(null, a[0], c, d); + d = H.call(null, a[0], d, c); break a; } - c = m; + d = m; } - return c; + return d; }; -function O(a, c, b) { +function N(a, d, b) { let f; - b && (f = a.bidirectional && c > b) && (f = b, b = c, c = f); - a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); + 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; } -;L.prototype.remove = function(a, c) { +;K.prototype.remove = function(a, d) { const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); if (b) { if (this.fastupdate) { - for (let f = 0, d; f < b.length; f++) { - if (d = b[f]) { - if (2 > d.length) { - d.pop(); + for (let f = 0, c; f < b.length; f++) { + if (c = b[f]) { + if (2 > c.length) { + c.pop(); } else { - const g = d.indexOf(a); - g === b.length - 1 ? d.pop() : d.splice(g, 1); + const g = c.indexOf(a); + g === b.length - 1 ? c.pop() : c.splice(g, 1); } } } } else { - P(this.map, a), this.depth && P(this.ctx, a); + O(this.map, a), this.depth && O(this.ctx, a); } - c || this.reg.delete(a); + d || this.reg.delete(a); } - this.cache && this.cache.remove(a); return this; }; -function P(a, c) { +function O(a, d) { let b = 0; if (a.constructor === Array) { - for (let f = 0, d, g; f < a.length; f++) { - if ((d = a[f]) && d.length) { - if (g = d.indexOf(c), 0 <= g) { - 1 < d.length ? (d.splice(g, 1), b++) : delete a[f]; + for (let f = 0, c, g; f < a.length; f++) { + if ((c = a[f]) && c.length) { + if (g = c.indexOf(d), 0 <= g) { + 1 < c.length ? (c.splice(g, 1), b++) : delete a[f]; break; } else { b++; @@ -540,101 +514,81 @@ function P(a, c) { } } else { for (let f of a.entries()) { - const d = f[0], g = P(f[1], c); - g ? b += g : a.delete(d); + const c = f[0], g = O(f[1], d); + g ? b += g : a.delete(c); } } return b; } -;function L(a, c) { - if (!this || this.constructor !== L) { - return new L(a); +;function K(a, d) { + if (!this || this.constructor !== K) { + return new K(a); } if (a) { var b = "string" === typeof a ? a : a.preset; - b && (K[b] || console.warn("Preset not found: " + b), a = Object.assign({}, K[b], a)); + b && (J[b] || console.warn("Preset not found: " + b), a = Object.assign({}, J[b], a)); } else { a = {}; } b = a.context; - const f = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || J; - this.encoder = d.encode ? d : "object" === typeof d ? new F(d) : {encode:d}; + const f = !0 === b ? {depth:1} : b || {}, c = a.encode || a.encoder || I; + 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 && b || "strict"; + 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; f && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); - b = !1; this.map = new Map(); this.ctx = new Map(); - this.reg = c || (this.fastupdate ? new Map() : new Set()); + this.reg = d || (this.fastupdate ? new Map() : new Set()); this.v = f.resolution || 3; - this.rtl = d.rtl || a.rtl || !1; - this.cache = (b = a.cache || null) && new I(b); + this.rtl = c.rtl || a.rtl || !1; } -r = L.prototype; +r = K.prototype; r.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); - this.cache && this.cache.clear(); return this; }; -r.append = function(a, c) { - return this.add(a, c, !0); +r.append = function(a, d) { + return this.add(a, d, !0); }; r.contain = function(a) { return this.reg.has(a); }; -r.update = function(a, c) { +r.update = function(a, d) { const b = this, f = this.remove(a); - return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); + return f && f.then ? f.then(() => b.add(a, d)) : this.add(a, d); }; -function Q(a) { - let c = 0; +function P(a) { + let d = 0; if (a.constructor === Array) { for (let b = 0, f; b < a.length; b++) { - (f = a[b]) && (c += f.length); + (f = a[b]) && (d += f.length); } } else { for (const b of a.entries()) { - const f = b[0], d = Q(b[1]); - d ? c += d : a.delete(f); + const f = b[0], c = P(b[1]); + c ? d += c : a.delete(f); } } - return c; + return d; } r.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Q(this.map); - this.depth && Q(this.ctx); + P(this.map); + this.depth && P(this.ctx); return this; }; -r.searchCache = function(a, c, b) { - a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new I()); - let f = this.cache.get(a); - if (!f) { - f = this.search(a, c, b); - if (f.then) { - const d = this; - f.then(function(g) { - d.cache.set(a, g); - return g; - }); - } - this.cache.set(a, f); - } - return f; -}; w(); -const R = {Index:L, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, S = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; -let T; -(T = S.define) && T.amd ? T([], function() { - return R; -}) : "object" === typeof S.exports ? S.exports = R : S.FlexSearch = R; +const Q = {Index:K, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, R = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; +let S; +(S = R.define) && S.amd ? S([], function() { + return Q; +}) : "object" === typeof R.exports ? R.exports = Q : R.FlexSearch = Q; }(this||self)); diff --git a/dist/flexsearch.light.min.js b/dist/flexsearch.light.min.js index b0e3aeb..262aacc 100644 --- a/dist/flexsearch.light.min.js +++ b/dist/flexsearch.light.min.js @@ -1,28 +1,26 @@ /**! - * FlexSearch.js v0.8.142 (Light) + * FlexSearch.js v0.8.143 (Light) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function(self){'use strict';var r;function u(a,c,b){const f=typeof b,d=typeof a;if("undefined"!==f){if("undefined"!==d){if(b){if("function"===d&&f===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(c===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===d?c:a}function w(){return Object.create(null)};const y=/[^\p{L}\p{N}]+/u,z=/(\d{3})/g,B=/(\D)(\d{3})/g,C=/(\d{3})(\D)/g,E="".normalize&&/[\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,y)}catch(d){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);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 d of this.matcher.keys())this.g+=(this.g?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.h+= -(this.h?"|":"")+d;return this};r.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; -r.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this}; -r.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; -r.encode=function(a){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)),d!==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(d=0;e&&dthis.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,c,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let f=[];for(let d=0,g,e;d=e){b-=e;continue}bc&&(g=g.slice(0,c),e=c);if(!f.length&&e>=c)return g;f.push(g);c-=e;if(!c)break}return f=1this.limit&&this.cache.delete(this.cache.keys().next().value)};I.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};I.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}}; -I.prototype.clear=function(){this.cache.clear();this.g=""};const J={normalize:function(a){return a.toLowerCase()}};const K={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};L.prototype.add=function(a,c,b,f){if(c&&(a||0===a)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(f=c.length){const n=w(),m=w(),v=this.depth,D=this.resolution;for(let p=0;pq;g--){e=l.substring(q,g);t=this.rtl?d-1-q:q;var h=this.score?this.score(c,l,p,e,t):M(D,f,p,d,t);N(this, -m,e,h,a,b)}break}case "reverse":if(1e?0:1),f,p,h-1,k-1),t=this.bidirectional&& -l>g;N(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function N(a,c,b,f,d,g,e){let h=e?a.ctx:a.map,k;if(!c[b]||e&&!(k=c[b])[e])e?(c=k||(c[b]=w()),c[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function M(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}m=e}else if(1===f){c=H.call(null,a[0], -c,d);break a}c=m}return c};function O(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};L.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let f=0,d;fd.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else P(this.map,a),this.depth&&P(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function P(a,c){let b=0;if(a.constructor===Array)for(let f=0,d,g;fb.add(a,c)):this.add(a,c)}; -function Q(a){let c=0;if(a.constructor===Array)for(let b=0,f;b"a1a".split(b).length; +this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,y)}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.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=1q;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(C,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};K.prototype.remove=function(a,d){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let f=0,c;fc.length)c.pop();else{const g=c.indexOf(a);g===b.length-1?c.pop():c.splice(g,1)}}else O(this.map,a),this.depth&&O(this.ctx,a);d||this.reg.delete(a)}return this}; +function O(a,d){let b=0;if(a.constructor===Array)for(let f=0,c,g;fb.add(a,d)):this.add(a,d)}; +function P(a){let d=0;if(a.constructor===Array)for(let b=0,f;b a.length && (this.dedupe || this.mapper)) { - return this.addMapper(a, c); + return this.addMapper(a, d); } this.matcher || (this.matcher = new Map()); - this.matcher.set(a, c); + this.matcher.set(a, d); this.g += (this.g ? "|" : "") + a; this.s = null; this.cache && G(this); return this; }; -r.addReplacer = function(a, c) { +r.addReplacer = function(a, d) { if ("string" === typeof a) { - return this.addMatcher(a, c); + return this.addMatcher(a, d); } this.replacer || (this.replacer = []); - this.replacer.push(a, c); + this.replacer.push(a, d); this.cache && G(this); return this; }; @@ -184,38 +184,38 @@ r.encode = function(a) { } this.normalize && ("function" === typeof this.normalize ? a = this.normalize(a) : a = E ? a.normalize("NFKD").replace(E, "").toLowerCase() : a.toLowerCase()); this.prepare && (a = this.prepare(a)); - this.numeric && 3 < a.length && (a = a.replace(B, "$1 $2").replace(C, "$1 $2").replace(z, "$1 ")); - const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); + this.numeric && 3 < a.length && (a = a.replace(B, "$1 $2").replace(D, "$1 $2").replace(z, "$1 ")); + const d = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer); let b = [], f = this.split || "" === this.split ? a.split(this.split) : a; for (let g = 0, e, h; g < f.length; g++) { if ((e = h = f[g]) && !(e.length < this.minlength)) { - if (c) { + 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 d = this.j.get(e); - if (d || "" === d) { - d && b.push(d); + var c = this.j.get(e); + if (c || "" === c) { + c && b.push(c); continue; } } else { this.l = setTimeout(G, 50, this); } } - this.stemmer && 2 < e.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), d = e, e = e.replace(this.u, k => this.stemmer.get(k)), d !== e && this.filter && e.length >= this.minlength && ("function" === typeof this.filter ? !this.filter(e) : this.filter.has(e)) && (e = "")); + this.stemmer && 2 < e.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), c = e, e = e.replace(this.u, k => this.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 && 1 < e.length)) { - d = ""; + c = ""; for (let k = 0, n = "", m, v; k < e.length; k++) { - m = e.charAt(k), m === n && this.dedupe || ((v = this.mapper && this.mapper.get(m)) || "" === v ? v === n && this.dedupe || !(n = v) || (d += v) : d += n = m); + m = e.charAt(k), m === n && this.dedupe || ((v = this.mapper && this.mapper.get(m)) || "" === v ? v === n && this.dedupe || !(n = v) || (c += v) : c += n = m); } - e = d; + e = c; } this.matcher && 1 < e.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), e = e.replace(this.s, k => this.matcher.get(k))); if (e && this.replacer) { - for (d = 0; e && d < this.replacer.length; d += 2) { - e = e.replace(this.replacer[d], this.replacer[d + 1]); + for (c = 0; e && c < this.replacer.length; c += 2) { + e = e.replace(this.replacer[c], this.replacer[c + 1]); } } this.cache && h.length <= this.o && (this.j.set(h, e), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0)); @@ -233,30 +233,30 @@ function G(a) { a.i.clear(); a.j.clear(); } -;function H(a, c, b) { +;function H(a, d, b) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a; + return a = a[0], a = b || a.length > d ? d ? a.slice(b, b + d) : a.slice(b) : a; } let f = []; - for (let d = 0, g, e; d < a.length; d++) { - if ((g = a[d]) && (e = g.length)) { + for (let c = 0, g, e; c < a.length; c++) { + if ((g = a[c]) && (e = g.length)) { if (b) { if (b >= e) { b -= e; continue; } - b < e && (g = c ? g.slice(b, b + c) : g.slice(b), e = g.length, b = 0); + b < e && (g = d ? g.slice(b, b + d) : g.slice(b), e = g.length, b = 0); } - e > c && (g = g.slice(0, c), e = c); - if (!f.length && e >= c) { + e > d && (g = g.slice(0, d), e = d); + if (!f.length && e >= d) { return g; } f.push(g); - c -= e; - if (!c) { + d -= e; + if (!d) { break; } } @@ -264,83 +264,58 @@ function G(a) { return f = 1 < f.length ? [].concat.apply([], f) : f[0]; } ;w(); -function I(a) { - this.limit = a && !0 !== a ? a : 1000; - this.cache = new Map(); - this.g = ""; -} -I.prototype.set = function(a, c) { - this.cache.set(this.g = a, c); - this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); -}; -I.prototype.get = function(a) { - const c = this.cache.get(a); - c && this.g !== a && (this.cache.delete(a), this.cache.set(this.g = a, c)); - return c; -}; -I.prototype.remove = function(a) { - for (const c of this.cache) { - const b = c[0]; - c[1].includes(a) && this.cache.delete(b); - } -}; -I.prototype.clear = function() { - this.cache.clear(); - this.g = ""; -}; -const J = {normalize:function(a) { - return a.toLowerCase(); -}}; -const K = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; -L.prototype.add = function(a, c, b, f) { - if (c && (a || 0 === a)) { +const I = {normalize:!0}; +const J = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +K.prototype.add = function(a, d, b, f) { + if (d && (a || 0 === a)) { if (!f && !b && this.reg.has(a)) { - return this.update(a, c); + return this.update(a, d); } - c = this.encoder.encode(c); - if (f = c.length) { - const n = w(), m = w(), v = this.depth, D = this.resolution; + d = this.encoder.encode(d); + if (f = d.length) { + const n = w(), m = w(), v = this.depth, C = this.resolution; for (let p = 0; p < f; p++) { - let l = c[this.rtl ? f - 1 - p : p]; - var d = l.length; - if (d && (v || !m[l])) { - var g = this.score ? this.score(c, l, p, null, 0) : M(D, f, p), e = ""; + let l = d[this.rtl ? f - 1 - p : p]; + var c = l.length; + if (c && (v || !m[l])) { + var g = this.score ? this.score(d, l, p, null, 0) : L(C, f, p), e = ""; switch(this.tokenize) { case "full": - if (2 < d) { - for (let q = 0, t; q < d; q++) { - for (g = d; g > q; g--) { + if (2 < c) { + for (let q = 0, t; q < c; q++) { + for (g = c; g > q; g--) { e = l.substring(q, g); - t = this.rtl ? d - 1 - q : q; - var h = this.score ? this.score(c, l, p, e, t) : M(D, f, p, d, t); - N(this, m, e, h, a, b); + t = this.rtl ? c - 1 - q : q; + var h = this.score ? this.score(d, l, p, e, t) : L(C, f, p, c, t); + M(this, m, e, h, a, b); } } break; } + case "bidirectional": case "reverse": - if (1 < d) { - for (h = d - 1; 0 < h; h--) { - e = l[this.rtl ? d - 1 - h : h] + e; - var k = this.score ? this.score(c, l, p, e, h) : M(D, f, p, d, h); - N(this, m, e, k, a, b); + if (1 < c) { + for (h = c - 1; 0 < h; h--) { + e = l[this.rtl ? c - 1 - h : h] + e; + var k = this.score ? this.score(d, l, p, e, h) : L(C, f, p, c, h); + M(this, m, e, k, a, b); } e = ""; } case "forward": - if (1 < d) { - for (h = 0; h < d; h++) { - e += l[this.rtl ? d - 1 - h : h], N(this, m, e, g, a, b); + if (1 < c) { + for (h = 0; h < c; h++) { + e += l[this.rtl ? c - 1 - h : h], M(this, m, e, g, a, b); } break; } default: - if (N(this, m, l, g, a, b), v && 1 < f && p < f - 1) { - for (d = w(), e = this.v, g = l, h = Math.min(v + 1, this.rtl ? p + 1 : f - p), d[g] = 1, k = 1; k < h; k++) { - if ((l = c[this.rtl ? f - 1 - p - k : p + k]) && !d[l]) { - d[l] = 1; - const q = this.score ? this.score(c, g, p, l, k - 1) : M(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; - N(this, n, t ? g : l, q, a, b, t ? l : g); + if (M(this, m, l, g, a, b), v && 1 < f && p < f - 1) { + for (c = w(), e = this.v, g = l, h = Math.min(v + 1, this.rtl ? p + 1 : f - p), c[g] = 1, k = 1; k < h; k++) { + if ((l = d[this.rtl ? f - 1 - p - k : p + k]) && !c[l]) { + c[l] = 1; + const q = this.score ? this.score(d, g, p, l, k - 1) : L(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; + M(this, n, t ? g : l, q, a, b, t ? l : g); } } } @@ -352,22 +327,22 @@ L.prototype.add = function(a, c, b, f) { } return this; }; -function N(a, c, b, f, d, g, e) { +function M(a, d, b, f, c, g, e) { let h = e ? a.ctx : a.map, k; - if (!c[b] || e && !(k = c[b])[e]) { - e ? (c = k || (c[b] = w()), c[e] = 1, (k = h.get(e)) ? h = k : h.set(e, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[f] || (h[f] = []), g && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h]))); + if (!d[b] || e && !(k = d[b])[e]) { + e ? (d = k || (d[b] = w()), d[e] = 1, (k = h.get(e)) ? h = k : h.set(e, h = new Map())) : d[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[f] || (h[f] = []), g && h.includes(c) || (h.push(c), a.fastupdate && ((d = a.reg.get(c)) ? d.push(h) : a.reg.set(c, [h]))); } } -function M(a, c, b, f, d) { - return b && 1 < a ? c + (f || 0) <= a ? b + (d || 0) : (a - 1) / (c + (f || 0)) * (b + (d || 0)) + 1 | 0 : 0; +function L(a, d, b, f, c) { + return b && 1 < a ? d + (f || 0) <= a ? b + (c || 0) : (a - 1) / (d + (f || 0)) * (b + (c || 0)) + 1 | 0 : 0; } -;L.prototype.search = function(a, c, b) { - b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = "")); - var f = [], d = 0; +;K.prototype.search = function(a, d, b) { + b || (d || "object" !== typeof a ? "object" === typeof d && (b = d, d = 0) : (b = a, a = "")); + var f = [], c = 0; if (b) { a = b.query || a; - c = b.limit || c; - d = b.offset || 0; + d = b.limit || d; + c = b.offset || 0; var g = b.context; var e = b.suggest; var h = !0; @@ -377,13 +352,13 @@ function M(a, c, b, f, d) { } a = this.encoder.encode(a); b = a.length; - c = c || (h ? 100 : 0); + d = d || (h ? 100 : 0); if (1 === b) { - return e = d, (d = O(this, a[0], "")) && d.length ? H.call(this, d, c, e) : []; + return e = c, (c = N(this, a[0], "")) && c.length ? H.call(this, c, d, e) : []; } g = this.depth && !1 !== g; if (2 === b && g && !e) { - return e = d, (d = O(this, a[0], a[1])) && d.length ? H.call(this, d, c, e) : []; + return e = c, (c = N(this, a[0], a[1])) && c.length ? H.call(this, c, d, e) : []; } h = w(); var n = 0; @@ -395,10 +370,10 @@ function M(a, c, b, f, d) { for (let l, q; n < b; n++) { if ((q = a[n]) && !h[q]) { h[q] = 1; - l = O(this, q, m); + l = N(this, q, m); a: { g = l; - var v = f, D = e, p = k; + var v = f, C = e, p = k; let t = []; if (g && g.length) { if (g.length <= p) { @@ -417,7 +392,7 @@ function M(a, c, b, f, d) { break a; } } - l = D ? void 0 : t; + l = C ? void 0 : t; } if (l) { f = l; @@ -441,7 +416,7 @@ function M(a, c, b, f, d) { for (n = 0; n < m; n++) { if (x = a[n], l < x.length && (q = x[l])) { for (g = 0; g < q.length; g++) { - if (t = q[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), A = e[h] || (e[h] = []), A.push(t), c && h === m - 1 && A.length - d === c) { + if (t = q[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), A = e[h] || (e[h] = []), A.push(t), d && h === m - 1 && A.length - c === d) { m = A; break b; } @@ -457,10 +432,10 @@ function M(a, c, b, f, d) { if (b = (f = e[h]) && f.length) { for (n = 0; n < b; n++) { if (m = f[n], !k[m]) { - if (k[m] = 1, d) { - d--; + if (k[m] = 1, c) { + c--; } else { - if (a.push(m), a.length === c) { + if (a.push(m), a.length === d) { break c; } } @@ -470,7 +445,7 @@ function M(a, c, b, f, d) { } } } else { - a = (e = e[0]).length > c || d ? e.slice(d, c + d) : e; + a = (e = e[0]).length > d || c ? e.slice(c, d + c) : e; } e = a; } else { @@ -479,9 +454,9 @@ function M(a, c, b, f, d) { break b; } e = e[a - 1]; - if (c || d) { - if (e.length > c || d) { - e = e.slice(d, c + d); + if (d || c) { + if (e.length > d || c) { + e = e.slice(c, d + c); } } } @@ -489,48 +464,47 @@ function M(a, c, b, f, d) { m = e; } } else if (1 === f) { - c = H.call(null, a[0], c, d); + d = H.call(null, a[0], d, c); break a; } - c = m; + d = m; } - return c; + return d; }; -function O(a, c, b) { +function N(a, d, b) { let f; - b && (f = a.bidirectional && c > b) && (f = b, b = c, c = f); - a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); + 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; } -;L.prototype.remove = function(a, c) { +;K.prototype.remove = function(a, d) { const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a)); if (b) { if (this.fastupdate) { - for (let f = 0, d; f < b.length; f++) { - if (d = b[f]) { - if (2 > d.length) { - d.pop(); + for (let f = 0, c; f < b.length; f++) { + if (c = b[f]) { + if (2 > c.length) { + c.pop(); } else { - const g = d.indexOf(a); - g === b.length - 1 ? d.pop() : d.splice(g, 1); + const g = c.indexOf(a); + g === b.length - 1 ? c.pop() : c.splice(g, 1); } } } } else { - P(this.map, a), this.depth && P(this.ctx, a); + O(this.map, a), this.depth && O(this.ctx, a); } - c || this.reg.delete(a); + d || this.reg.delete(a); } - this.cache && this.cache.remove(a); return this; }; -function P(a, c) { +function O(a, d) { let b = 0; if (a.constructor === Array) { - for (let f = 0, d, g; f < a.length; f++) { - if ((d = a[f]) && d.length) { - if (g = d.indexOf(c), 0 <= g) { - 1 < d.length ? (d.splice(g, 1), b++) : delete a[f]; + for (let f = 0, c, g; f < a.length; f++) { + if ((c = a[f]) && c.length) { + if (g = c.indexOf(d), 0 <= g) { + 1 < c.length ? (c.splice(g, 1), b++) : delete a[f]; break; } else { b++; @@ -539,98 +513,78 @@ function P(a, c) { } } else { for (let f of a.entries()) { - const d = f[0], g = P(f[1], c); - g ? b += g : a.delete(d); + const c = f[0], g = O(f[1], d); + g ? b += g : a.delete(c); } } return b; } -;function L(a, c) { - if (!this || this.constructor !== L) { - return new L(a); +;function K(a, d) { + if (!this || this.constructor !== K) { + return new K(a); } if (a) { var b = "string" === typeof a ? a : a.preset; - b && (K[b] || console.warn("Preset not found: " + b), a = Object.assign({}, K[b], a)); + b && (J[b] || console.warn("Preset not found: " + b), a = Object.assign({}, J[b], a)); } else { a = {}; } b = a.context; - const f = !0 === b ? {depth:1} : b || {}, d = a.encode || a.encoder || J; - this.encoder = d.encode ? d : "object" === typeof d ? new F(d) : {encode:d}; + const f = !0 === b ? {depth:1} : b || {}, c = a.encode || a.encoder || I; + 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 && b || "strict"; + 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; f && "strict" !== this.tokenize && console.warn('Context-Search could not applied, because it is just supported when using the tokenizer "strict".'); - b = !1; this.map = new Map(); this.ctx = new Map(); - this.reg = c || (this.fastupdate ? new Map() : new Set()); + this.reg = d || (this.fastupdate ? new Map() : new Set()); this.v = f.resolution || 3; - this.rtl = d.rtl || a.rtl || !1; - this.cache = (b = a.cache || null) && new I(b); + this.rtl = c.rtl || a.rtl || !1; } -r = L.prototype; +r = K.prototype; r.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); - this.cache && this.cache.clear(); return this; }; -r.append = function(a, c) { - return this.add(a, c, !0); +r.append = function(a, d) { + return this.add(a, d, !0); }; r.contain = function(a) { return this.reg.has(a); }; -r.update = function(a, c) { +r.update = function(a, d) { const b = this, f = this.remove(a); - return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); + return f && f.then ? f.then(() => b.add(a, d)) : this.add(a, d); }; -function Q(a) { - let c = 0; +function P(a) { + let d = 0; if (a.constructor === Array) { for (let b = 0, f; b < a.length; b++) { - (f = a[b]) && (c += f.length); + (f = a[b]) && (d += f.length); } } else { for (const b of a.entries()) { - const f = b[0], d = Q(b[1]); - d ? c += d : a.delete(f); + const f = b[0], c = P(b[1]); + c ? d += c : a.delete(f); } } - return c; + return d; } r.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Q(this.map); - this.depth && Q(this.ctx); + P(this.map); + this.depth && P(this.ctx); return this; }; -r.searchCache = function(a, c, b) { - a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); - this.cache || (this.cache = new I()); - let f = this.cache.get(a); - if (!f) { - f = this.search(a, c, b); - if (f.then) { - const d = this; - f.then(function(g) { - d.cache.set(a, g); - return g; - }); - } - this.cache.set(a, f); - } - return f; -}; w(); -export default {Index:L, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; +export default {Index:K, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; -export const Index=L;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 +export const Index=K;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/flexsearch.light.module.min.js b/dist/flexsearch.light.module.min.js index 7cee0eb..2567537 100644 --- a/dist/flexsearch.light.module.min.js +++ b/dist/flexsearch.light.module.min.js @@ -1,29 +1,27 @@ /**! - * FlexSearch.js v0.8.142 (Bundle) + * FlexSearch.js v0.8.143 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var r;function u(a,c,b){const f=typeof b,d=typeof a;if("undefined"!==f){if("undefined"!==d){if(b){if("function"===d&&f===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(c===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===d?c:a}function w(){return Object.create(null)};const y=/[^\p{L}\p{N}]+/u,z=/(\d{3})/g,B=/(\D)(\d{3})/g,C=/(\d{3})(\D)/g,E="".normalize&&/[\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,y)}catch(d){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);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 d of this.matcher.keys())this.g+=(this.g?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.h+= -(this.h?"|":"")+d;return this};r.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){"function"===typeof a?this.filter=a:(this.filter||(this.filter=new Set),this.filter.add(a));this.cache&&G(this);return this}; -r.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this}; -r.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; -r.encode=function(a){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)),d!==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(d=0;e&&dthis.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,c,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let f=[];for(let d=0,g,e;d=e){b-=e;continue}bc&&(g=g.slice(0,c),e=c);if(!f.length&&e>=c)return g;f.push(g);c-=e;if(!c)break}return f=1this.limit&&this.cache.delete(this.cache.keys().next().value)};I.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};I.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}}; -I.prototype.clear=function(){this.cache.clear();this.g=""};const J={normalize:function(a){return a.toLowerCase()}};const K={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};L.prototype.add=function(a,c,b,f){if(c&&(a||0===a)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(f=c.length){const n=w(),m=w(),v=this.depth,D=this.resolution;for(let p=0;pq;g--){e=l.substring(q,g);t=this.rtl?d-1-q:q;var h=this.score?this.score(c,l,p,e,t):M(D,f,p,d,t);N(this, -m,e,h,a,b)}break}case "reverse":if(1e?0:1),f,p,h-1,k-1),t=this.bidirectional&& -l>g;N(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function N(a,c,b,f,d,g,e){let h=e?a.ctx:a.map,k;if(!c[b]||e&&!(k=c[b])[e])e?(c=k||(c[b]=w()),c[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function M(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}m=e}else if(1===f){c=H.call(null,a[0], -c,d);break a}c=m}return c};function O(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};L.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let f=0,d;fd.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else P(this.map,a),this.depth&&P(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function P(a,c){let b=0;if(a.constructor===Array)for(let f=0,d,g;fb.add(a,c)):this.add(a,c)}; -function Q(a){let c=0;if(a.constructor===Array)for(let b=0,f;b"a1a".split(b).length; +this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,y)}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.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=1q;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(C,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};K.prototype.remove=function(a,d){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let f=0,c;fc.length)c.pop();else{const g=c.indexOf(a);g===b.length-1?c.pop():c.splice(g,1)}}else O(this.map,a),this.depth&&O(this.ctx,a);d||this.reg.delete(a)}return this}; +function O(a,d){let b=0;if(a.constructor===Array)for(let f=0,c,g;fb.add(a,d)):this.add(a,d)}; +function P(a){let d=0;if(a.constructor===Array)for(let b=0,f;b>} */normalize_polyfill); - } + // if(SUPPORT_CHARSET && !normalize){ + // this.mapper = new Map( + // /** @type {Array>} */ ( + // normalize_polyfill + // ) + // ); + // } tmp = options.filter; this.filter = "function" == typeof tmp ? tmp : merge_option(tmp && new Set(tmp), null, this.filter); @@ -195,6 +198,7 @@ Encoder.prototype.assign = function (options) { this.rtl = merge_option(options.rtl, !1, this.rtl); // auto-balanced cache + //if(SUPPORT_CACHE){ this.cache = tmp = merge_option(options.cache, !0, this.cache); if (tmp) { this.timer = null; @@ -204,6 +208,7 @@ Encoder.prototype.assign = function (options) { this.cache_enc_length = 128; this.cache_term_length = 128; } + //} // regex temporary state this.matcher_str = ""; @@ -249,7 +254,7 @@ Encoder.prototype.addStemmer = function (match, replace) { this.stemmer.set(match, replace); this.stemmer_str += (this.stemmer_str ? "|" : "") + match; this.stemmer_test = null; - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -261,7 +266,7 @@ Encoder.prototype.addFilter = function (term) { this.filter || (this.filter = new Set()); this.filter.add(term); } - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -283,7 +288,7 @@ Encoder.prototype.addMapper = function (char_match, char_replace) { } this.mapper || (this.mapper = new Map()); this.mapper.set(char_match, char_replace); - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -308,7 +313,7 @@ Encoder.prototype.addMatcher = function (match, replace) { this.matcher.set(match, replace); this.matcher_str += (this.matcher_str ? "|" : "") + match; this.matcher_test = null; - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -324,7 +329,7 @@ Encoder.prototype.addReplacer = function (regex, replace) { } this.replacer || (this.replacer = []); this.replacer.push(regex, replace); - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -337,7 +342,7 @@ Encoder.prototype.encode = function (str) { //if(!str) return str; // todo remove dupe terms - if (this.cache && str.length <= this.cache_enc_length) { + if ( /*SUPPORT_CACHE &&*/this.cache && str.length <= this.cache_enc_length) { if (this.timer) { if (this.cache_enc.has(str)) { return this.cache_enc.get(str); @@ -404,7 +409,7 @@ Encoder.prototype.encode = function (str) { continue; } - if (this.cache && word.length <= this.cache_term_length) { + if ( /*SUPPORT_CACHE &&*/this.cache && word.length <= this.cache_term_length) { if (this.timer) { const tmp = this.cache_term.get(word); if (tmp || "" === tmp) { @@ -479,7 +484,7 @@ Encoder.prototype.encode = function (str) { //word = word.replace(/(.)\1+/g, "$1"); //word = word.replace(/(?<=(.))\1+/g, ""); - if (this.cache && base.length <= this.cache_term_length) { + if ( /*SUPPORT_CACHE &&*/this.cache && base.length <= this.cache_term_length) { this.cache_term.set(base, word); if (this.cache_term.size > this.cache_size) { this.cache_term.clear(); @@ -494,7 +499,7 @@ Encoder.prototype.encode = function (str) { final = this.finalize(final) || final; } - if (this.cache && str.length <= this.cache_enc_length) { + if ( /*SUPPORT_CACHE &&*/this.cache && str.length <= this.cache_enc_length) { this.cache_enc.set(str, final); if (this.cache_enc.size > this.cache_size) { this.cache_enc.clear(); diff --git a/dist/module-debug/index.js b/dist/module-debug/index.js index 520b32b..63fa421 100644 --- a/dist/module-debug/index.js +++ b/dist/module-debug/index.js @@ -48,7 +48,7 @@ export default function Index(options, _register) { this.resolution = options.resolution || 9; - this.tokenize = tmp = (tmp = options.tokenize) && "default" !== tmp && tmp || "strict"; + this.tokenize = tmp = (tmp = options.tokenize) && "default" !== tmp && "exact" !== tmp && tmp || "strict"; this.depth = "strict" === tmp && context.depth || 0; this.bidirectional = !1 !== context.bidirectional; this.fastupdate = !!options.fastupdate; diff --git a/dist/module-debug/index/add.js b/dist/module-debug/index/add.js index 211c72c..60435fe 100644 --- a/dist/module-debug/index/add.js +++ b/dist/module-debug/index/add.js @@ -72,6 +72,7 @@ Index.prototype.add = function (id, content, _append, _skip_update) { break; } // fallthrough to next case when term length < 3 + case "bidirectional": case "reverse": // skip last round (this token exist already in "forward") if (1 < term_length) { diff --git a/dist/module-min/charset.js b/dist/module-min/charset.js index 7c7956b..39214a8 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_default from"./charset/latin/default.js";import charset_latin_simple from"./charset/latin/simple.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";import charset_arabic_default from"./charset/arabic/default.js";import charset_cjk_default from"./charset/cjk/default.js";import charset_cyrillic_default from"./charset/cyrillic/default.js";export const LatinExact=charset_latin_exact;export const LatinDefault=charset_latin_default;export const LatinSimple=charset_latin_simple;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 ArabicDefault=charset_arabic_default;export const CjkDefault=charset_cjk_default;export const CyrillicDefault=charset_cyrillic_default;export default{LatinExact:charset_latin_exact,LatinDefault:charset_latin_default,LatinSimple:charset_latin_simple,LatinBalance:charset_latin_balance,LatinAdvanced:charset_latin_advanced,LatinExtra:charset_latin_extra,LatinSoundex:charset_latin_soundex,ArabicDefault:charset_arabic_default,CjkDefault:charset_cjk_default,CyrillicDefault:charset_cyrillic_default}; \ No newline at end of file +import charset_latin_exact from"./charset/latin/exact.js";import charset_latin_default from"./charset/latin/default.js";import charset_latin_simple from"./charset/latin/simple.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_default;export const Normalize=charset_latin_simple;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_default;export const LatinSimple=charset_latin_simple;export default{Exact:charset_latin_exact,Default:charset_latin_default,Normalize:charset_latin_simple,LatinBalance:charset_latin_balance,LatinAdvanced:charset_latin_advanced,LatinExtra:charset_latin_extra,LatinSoundex:charset_latin_soundex,LatinExact:charset_latin_exact,LatinDefault:charset_latin_default,LatinSimple:charset_latin_simple}; \ No newline at end of file diff --git a/dist/module-min/charset/arabic/default.js b/dist/module-min/charset/arabic/default.js deleted file mode 100644 index 703f825..0000000 --- a/dist/module-min/charset/arabic/default.js +++ /dev/null @@ -1 +0,0 @@ -import{EncoderOptions}from"../../type.js";const regex=/[\x00-\x7F]+/g,split=/\s+/,options={normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(regex," ")}};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/cjk/default.js b/dist/module-min/charset/cjk/default.js deleted file mode 100644 index e48bd09..0000000 --- a/dist/module-min/charset/cjk/default.js +++ /dev/null @@ -1 +0,0 @@ -import{EncoderOptions}from"../../type.js";const regex=/[\x00-\x7F]+/g,options={normalize:!1,dedupe:!0,split:"",prepare:function(a){return(""+a).replace(regex,"")}};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/cyrillic/default.js b/dist/module-min/charset/cyrillic/default.js deleted file mode 100644 index b66591a..0000000 --- a/dist/module-min/charset/cyrillic/default.js +++ /dev/null @@ -1 +0,0 @@ -import{EncoderOptions}from"../../type.js";const regex=/[\x00-\x7F]+/g,options={normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(regex," ")}};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/latin/default.js b/dist/module-min/charset/latin/default.js index 3e2e7ef..5b7192e 100644 --- a/dist/module-min/charset/latin/default.js +++ b/dist/module-min/charset/latin/default.js @@ -1 +1 @@ -import{EncoderOptions}from"../../type.js";const options={normalize:function(a){return a.toLowerCase()}};export default options; \ No newline at end of file +import{EncoderOptions}from"../../type.js";const options={normalize:!0};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 index d842cb3..e674552 100644 --- a/dist/module-min/charset/latin/exact.js +++ b/dist/module-min/charset/latin/exact.js @@ -1 +1 @@ -import{EncoderOptions}from"../../type.js";const options={split:/\s+/,normalize:!1};export default options; \ No newline at end of file +import{EncoderOptions}from"../../type.js";const options={normalize:!1,numeric:!1,split:/\s+/};export default options; \ No newline at end of file diff --git a/dist/module-min/encoder.js b/dist/module-min/encoder.js index bfb3b58..4861ece 100644 --- a/dist/module-min/encoder.js +++ b/dist/module-min/encoder.js @@ -1 +1 @@ -import{merge_option}from"./common.js";import normalize_polyfill from"./charset/normalize.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),!normalize&&(this.mapper=new Map(normalize_polyfill)),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};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/normalize.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,!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};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.js b/dist/module-min/index.js index 66f7bea..cba1dee 100644 --- a/dist/module-min/index.js +++ b/dist/module-min/index.js @@ -1 +1 @@ -import{IndexOptions,ContextOptions,EncoderOptions}from"./type.js";import Encoder from"./encoder.js";import Cache,{searchCache}from"./cache.js";import Charset from"./charset.js";import{KeystoreMap,KeystoreSet}from"./keystore.js";import{is_array,is_string}from"./common.js";import{exportIndex,importIndex,serialize}from"./serialize.js";import default_encoder from"./charset/latin/default.js";import apply_preset from"./preset.js";import apply_async from"./async.js";import tick from"./profiler.js";import"./index/add.js";import"./index/search.js";import"./index/remove.js";export default function Index(a,b){if(!this||this.constructor!==Index)return new Index(a);!1,a=a?apply_preset(a):{};let c=a.context;const d=!0===c?{depth:1}:c||{},e=is_string(a.encoder)?Charset[a.encoder]:a.encode||a.encoder||default_encoder;this.encoder=e.encode?e:"object"==typeof e?new Encoder(e):{encode:e},this.compress=a.compress||a.compression||!1,this.resolution=a.resolution||9,this.tokenize=c=(c=a.tokenize)&&"default"!==c&&c||"strict",this.depth="strict"===c&&d.depth||0,this.bidirectional=!1!==d.bidirectional,this.fastupdate=!!a.fastupdate,this.score=a.score||null,!1,c=a.keystore||0,c&&(this.keystore=c),this.map=c&&!0?new KeystoreMap(c):new Map,this.ctx=c&&!0?new KeystoreMap(c):new Map,this.reg=b||(this.fastupdate?c&&!0?new KeystoreMap(c):new Map:c&&!0?new KeystoreSet(c):new Set),this.resolution_ctx=d.resolution||3,this.rtl=e.rtl||a.rtl||!1,this.cache=(c=a.cache||null)&&new Cache(c),this.resolve=!1!==a.resolve,(c=a.db)&&(this.db=this.mount(c)),this.commit_auto=!1!==a.commit,this.commit_task=[],this.commit_timer=null,this.priority=a.priority||4}Index.prototype.mount=function(a){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),a.mount(this)},Index.prototype.commit=function(a,b){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.commit(this,a,b)},Index.prototype.destroy=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.destroy()};export function autoCommit(a,b,c){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null,a.db.commit(a,b,c)},1))}Index.prototype.clear=function(){return this.map.clear(),this.ctx.clear(),this.reg.clear(),this.cache&&this.cache.clear(),this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]),this},Index.prototype.append=function(a,b){return this.add(a,b,!0)},Index.prototype.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)},Index.prototype.update=function(a,b){const c=this,d=this.remove(a);return d&&d.then?d.then(()=>c.add(a,b)):this.add(a,b)};function cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;dc.add(a,b)):this.add(a,b)};function cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;dg;l--){m=i.substring(g,l),d=this.rtl?k-1-g:g;const n=this.score?this.score(b,i,j,m,d):get_score(h,e,j,k,d);this.push_index(f,m,n,a,c)}break}case"reverse":if(1h?0:1),e,j,l-1,g-1),n=this.bidirectional&&i>k;this.push_index(d,n?k:i,m,a,c,n?i:k)}}}}}this.fastupdate||this.reg.add(a)}else b=""}return this.db&&(b||this.commit_task.push({del:a}),this.commit_auto&&autoCommit(this)),this},Index.prototype.push_index=function(a,b,c,d,e,f){let g,h=f?this.ctx:this.map;if((!a[b]||f&&!(g=a[b])[f])&&(f?(a=g||(a[b]=create_object()),a[f]=1,this.compress&&(f=default_compress(f)),g=h.get(f),g?h=g:h.set(f,h=new Map)):a[b]=1,this.compress&&(b=default_compress(b)),g=h.get(b),g?h=g:h.set(b,h=g=[]),h=h[c]||(h[c]=[]),!e||!h.includes(d))){if(2147483647===h.length){const a=new KeystoreArray(h);if(this.fastupdate)for(let b of this.reg.values())b.includes(h)&&(b[b.indexOf(h)]=a);g[c]=h=a}if(h.push(d),this.fastupdate){const a=this.reg.get(d);a?a.push(h):this.reg.set(d,[h])}}};function get_score(a,b,c,d,e){return c&&1g;l--){m=i.substring(g,l),d=this.rtl?k-1-g:g;const n=this.score?this.score(b,i,j,m,d):get_score(h,e,j,k,d);this.push_index(f,m,n,a,c)}break}case"bidirectional":case"reverse":if(1h?0:1),e,j,l-1,g-1),n=this.bidirectional&&i>k;this.push_index(d,n?k:i,m,a,c,n?i:k)}}}}}this.fastupdate||this.reg.add(a)}else b=""}return this.db&&(b||this.commit_task.push({del:a}),this.commit_auto&&autoCommit(this)),this},Index.prototype.push_index=function(a,b,c,d,e,f){let g,h=f?this.ctx:this.map;if((!a[b]||f&&!(g=a[b])[f])&&(f?(a=g||(a[b]=create_object()),a[f]=1,this.compress&&(f=default_compress(f)),g=h.get(f),g?h=g:h.set(f,h=new Map)):a[b]=1,this.compress&&(b=default_compress(b)),g=h.get(b),g?h=g:h.set(b,h=g=[]),h=h[c]||(h[c]=[]),!e||!h.includes(d))){if(2147483647===h.length){const a=new KeystoreArray(h);if(this.fastupdate)for(let b of this.reg.values())b.includes(h)&&(b[b.indexOf(h)]=a);g[c]=h=a}if(h.push(d),this.fastupdate){const a=this.reg.get(d);a?a.push(h):this.reg.set(d,[h])}}};function get_score(a,b,c,d,e){return c&&1>} */normalize_polyfill); - } + // if(SUPPORT_CHARSET && !normalize){ + // this.mapper = new Map( + // /** @type {Array>} */ ( + // normalize_polyfill + // ) + // ); + // } tmp = options.filter; this.filter = "function" == typeof tmp ? tmp : merge_option(tmp && new Set(tmp), null, this.filter); @@ -193,6 +196,7 @@ Encoder.prototype.assign = function (options) { this.rtl = merge_option(options.rtl, !1, this.rtl); // auto-balanced cache + //if(SUPPORT_CACHE){ this.cache = tmp = merge_option(options.cache, !0, this.cache); if (tmp) { this.timer = null; @@ -202,6 +206,7 @@ Encoder.prototype.assign = function (options) { this.cache_enc_length = 128; this.cache_term_length = 128; } + //} // regex temporary state this.matcher_str = ""; @@ -247,7 +252,7 @@ Encoder.prototype.addStemmer = function (match, replace) { this.stemmer.set(match, replace); this.stemmer_str += (this.stemmer_str ? "|" : "") + match; this.stemmer_test = null; - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -259,7 +264,7 @@ Encoder.prototype.addFilter = function (term) { this.filter || (this.filter = new Set()); this.filter.add(term); } - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -281,7 +286,7 @@ Encoder.prototype.addMapper = function (char_match, char_replace) { } this.mapper || (this.mapper = new Map()); this.mapper.set(char_match, char_replace); - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -306,7 +311,7 @@ Encoder.prototype.addMatcher = function (match, replace) { this.matcher.set(match, replace); this.matcher_str += (this.matcher_str ? "|" : "") + match; this.matcher_test = null; - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -322,7 +327,7 @@ Encoder.prototype.addReplacer = function (regex, replace) { } this.replacer || (this.replacer = []); this.replacer.push(regex, replace); - this.cache && clear(this); + /*SUPPORT_CACHE &&*/this.cache && clear(this); return this; }; @@ -335,7 +340,7 @@ Encoder.prototype.encode = function (str) { //if(!str) return str; // todo remove dupe terms - if (this.cache && str.length <= this.cache_enc_length) { + if ( /*SUPPORT_CACHE &&*/this.cache && str.length <= this.cache_enc_length) { if (this.timer) { if (this.cache_enc.has(str)) { return this.cache_enc.get(str); @@ -402,7 +407,7 @@ Encoder.prototype.encode = function (str) { continue; } - if (this.cache && word.length <= this.cache_term_length) { + if ( /*SUPPORT_CACHE &&*/this.cache && word.length <= this.cache_term_length) { if (this.timer) { const tmp = this.cache_term.get(word); if (tmp || "" === tmp) { @@ -477,7 +482,7 @@ Encoder.prototype.encode = function (str) { //word = word.replace(/(.)\1+/g, "$1"); //word = word.replace(/(?<=(.))\1+/g, ""); - if (this.cache && base.length <= this.cache_term_length) { + if ( /*SUPPORT_CACHE &&*/this.cache && base.length <= this.cache_term_length) { this.cache_term.set(base, word); if (this.cache_term.size > this.cache_size) { this.cache_term.clear(); @@ -492,7 +497,7 @@ Encoder.prototype.encode = function (str) { final = this.finalize(final) || final; } - if (this.cache && str.length <= this.cache_enc_length) { + if ( /*SUPPORT_CACHE &&*/this.cache && str.length <= this.cache_enc_length) { this.cache_enc.set(str, final); if (this.cache_enc.size > this.cache_size) { this.cache_enc.clear(); diff --git a/dist/module/index.js b/dist/module/index.js index 4aa1ce7..7c3c6be 100644 --- a/dist/module/index.js +++ b/dist/module/index.js @@ -48,7 +48,7 @@ export default function Index(options, _register) { this.resolution = options.resolution || 9; - this.tokenize = tmp = (tmp = options.tokenize) && "default" !== tmp && tmp || "strict"; + this.tokenize = tmp = (tmp = options.tokenize) && "default" !== tmp && "exact" !== tmp && tmp || "strict"; this.depth = "strict" === tmp && context.depth || 0; this.bidirectional = !1 !== context.bidirectional; this.fastupdate = !!options.fastupdate; diff --git a/dist/module/index/add.js b/dist/module/index/add.js index 211c72c..60435fe 100644 --- a/dist/module/index/add.js +++ b/dist/module/index/add.js @@ -72,6 +72,7 @@ Index.prototype.add = function (id, content, _append, _skip_update) { break; } // fallthrough to next case when term length < 3 + case "bidirectional": case "reverse": // skip last round (this token exist already in "forward") if (1 < term_length) { diff --git a/index.d.ts b/index.d.ts index 6d5d732..808e088 100644 --- a/index.d.ts +++ b/index.d.ts @@ -35,28 +35,30 @@ declare module "flexsearch" { * * Add custom tokenizer: https://github.com/nextapps-de/flexsearch#add-custom-tokenizer */ type Tokenizer = - | "strict" + | "strict" | "exact" | "default" | "forward" - | "reverse" - | "full" - | "default"; + | "reverse" | "bidirectional" + | "full"; /** * **Document:** * * Encoders: https://github.com/nextapps-de/flexsearch#encoders */ type Encoders = + | "Exact" + | "Default" + | "Normalize" + /** @deprecated */ | "LatinExact" + /** @deprecated */ | "LatinDefault" + /** @deprecated */ | "LatinSimple" | "LatinBalance" | "LatinAdvanced" | "LatinExtra" | "LatinSoundex" - | "ArabicDefault" - | "CjkDefault" - | "CryllicDefault" - | ((x: string) => string[]); + | ((term: string) => string[]); /** * **Document:** @@ -93,7 +95,7 @@ declare module "flexsearch" { field?: FieldName | FieldName[] | FieldOptions | Array; index?: FieldName | FieldName[] | FieldOptions | Array; tag?: FieldName | FieldName[] | TagOptions | Array; - store?: FieldName | FieldName[] | StoreOptions | Array; + store?: FieldName | FieldName[] | StoreOptions | Array | boolean; }; type WorkerURL = string; @@ -581,3 +583,8 @@ declare module "flexsearch" { db: IDBDatabase } } + +// https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html +// https://github.com/futurGH/ts-to-jsdoc +// https://sethmac.com/typescript-to-jsdoc/ + diff --git a/package.json b/package.json index d52e0f6..b8d7f4b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "public": true, "preferGlobal": false, "name": "flexsearch", - "version": "0.8.142", + "version": "0.8.143", "description": "Next-Generation full-text search library for Browser and Node.js", "homepage": "https://github.com/nextapps-de/flexsearch/", "author": "Thomas Wilkerling", @@ -68,8 +68,8 @@ "build:bundle:debug": "node task/build RELEASE=bundle DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=false SUPPORT_PERSISTENT=true SUPPORT_RESOLVER=true SUPPORT_KEYSTORE=true SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", "build:compact": "node task/build RELEASE=compact DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false", "build:compact:debug": "node task/build RELEASE=compact DEBUG=true PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", - "build:light": "node task/build RELEASE=light DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=true SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false", - "build:light:debug": "node task/build RELEASE=light DEBUG=true PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=true SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", + "build:light": "node task/build RELEASE=light DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false", + "build:light:debug": "node task/build RELEASE=light DEBUG=true PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", "build:es5": "node task/build RELEASE=es5 DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=true SUPPORT_PERSISTENT=true SUPPORT_RESOLVER=true SUPPORT_KEYSTORE=true SUPPORT_COMPRESSION=false LANGUAGE_OUT=ECMASCRIPT5_STRICT", "build:es5:debug": "node task/build RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=true SUPPORT_PERSISTENT=true SUPPORT_RESOLVER=true SUPPORT_KEYSTORE=true SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT LANGUAGE_OUT=ECMASCRIPT5_STRICT", "build:lang": "node task/build RELEASE=lang", @@ -81,8 +81,8 @@ "build:module:bundle:debug": "node task/build RELEASE=bundle.module DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=false SUPPORT_PERSISTENT=true SUPPORT_RESOLVER=true SUPPORT_KEYSTORE=true SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", "build:module:compact": "node task/build RELEASE=compact.module DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false", "build:module:compact:debug": "node task/build RELEASE=compact.module DEBUG=true PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_STORE=true SUPPORT_TAGS=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_DOCUMENT=true POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", - "build:module:light": "node task/build RELEASE=light.module DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=true SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false", - "build:module:light:debug": "node task/build RELEASE=light.module DEBUG=true PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=true SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", + "build:module:light": "node task/build RELEASE=light.module DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false", + "build:module:light:debug": "node task/build RELEASE=light.module DEBUG=true PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", "build:all": "npm run build:bundle && npm run build:bundle:debug && npm run build:light && npm run build:light:debug && npm run build:compact && npm run build:compact:debug && npm run build:module && npm run build:module:debug && npm run build:module:min && npm run build:module:bundle && npm run build:module:bundle:debug && npm run build:module:light && npm run build:module:light:debug && npm run build:module:compact && npm run build:module:compact:debug && npm run build:es5 && npm run build:es5:debug && npm run build:lang && npm run build:db", "build:custom": "node task/build RELEASE=custom", "test:all": "cd test/ && npm install && npm run test:all && cd ..", diff --git a/src/charset.js b/src/charset.js index a3acb5a..8b84572 100644 --- a/src/charset.js +++ b/src/charset.js @@ -5,60 +5,33 @@ 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"; -import charset_arabic_default from "./charset/arabic/default.js"; -import charset_cjk_default from "./charset/cjk/default.js"; -import charset_cyrillic_default from "./charset/cyrillic/default.js"; -export const LatinExact = charset_latin_exact; -export const LatinDefault = charset_latin_default; -export const LatinSimple = charset_latin_simple; +// all charset +export const Exact = charset_latin_exact; +export const Default = charset_latin_default; +export const Normalize = charset_latin_simple; +// 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; -export const ArabicDefault = charset_arabic_default; -export const CjkDefault = charset_cjk_default; -export const CyrillicDefault = charset_cyrillic_default; - -// export const global_lang = create_object(); -//export const global_charset = create_object(); +// deprecated +export const LatinExact = charset_latin_exact; +export const LatinDefault = charset_latin_default; +export const LatinSimple = charset_latin_simple; export default { - LatinExact: charset_latin_exact, - LatinDefault: charset_latin_default, - LatinSimple: charset_latin_simple, + // all charset + Exact: charset_latin_exact, + Default: charset_latin_default, + Normalize: charset_latin_simple, + // latin charset LatinBalance: charset_latin_balance, LatinAdvanced: charset_latin_advanced, LatinExtra: charset_latin_extra, LatinSoundex: charset_latin_soundex, - ArabicDefault: charset_arabic_default, - CjkDefault: charset_cjk_default, - CyrillicDefault: charset_cyrillic_default + // deprecated + LatinExact: charset_latin_exact, + LatinDefault: charset_latin_default, + LatinSimple: charset_latin_simple, }; - -// global_charset["latin:exact"] = charset_exact; -// global_charset["latin:default"] = charset_default; -// global_charset["latin:simple"] = charset_simple; -// global_charset["latin:balance"] = charset_balance; -// global_charset["latin:advanced"] = charset_advanced; -// global_charset["latin:extra"] = charset_extra; -// global_charset["latin:soundex"] = charset_soundex; - - -/** - * @param {!string} name - * @param {Object} charset - */ - -// export function registerCharset(name, charset){ -// global_charset[name] = charset; -// } - -/** - * @param {!string} name - * @param {Object} lang - */ - -// export function registerLanguage(name, lang){ -// global_lang[name] = lang; -// } diff --git a/src/charset/arabic/default.js b/src/charset/arabic/default.js deleted file mode 100644 index 2d71351..0000000 --- a/src/charset/arabic/default.js +++ /dev/null @@ -1,16 +0,0 @@ -import { EncoderOptions } from "../../type.js"; -// non ascii control chars 0-31 -const regex = /[\x00-\x7F]+/g; -const split = /\s+/; - -/** @type EncoderOptions */ -const options = { - // the string is already encoded as RTL by default - //rtl: true, - normalize: false, - dedupe: true, - prepare: function(str){ - return ("" + str).replace(regex, " ") - } -}; -export default options; diff --git a/src/charset/cjk/default.js b/src/charset/cjk/default.js deleted file mode 100644 index f3b8338..0000000 --- a/src/charset/cjk/default.js +++ /dev/null @@ -1,14 +0,0 @@ -import { EncoderOptions } from "../../type.js"; -// non ascii control chars 0-31 -const regex = /[\x00-\x7F]+/g; - -/** @type EncoderOptions */ -const options = { - normalize: false, - dedupe: true, - split: "", - prepare: function(str){ - return ("" + str).replace(regex, "") - } -}; -export default options; diff --git a/src/charset/cyrillic/default.js b/src/charset/cyrillic/default.js deleted file mode 100644 index 18cc7a1..0000000 --- a/src/charset/cyrillic/default.js +++ /dev/null @@ -1,13 +0,0 @@ -import { EncoderOptions } from "../../type.js"; -// non ascii control chars 0-31 -const regex = /[\x00-\x7F]+/g; - -/** @type EncoderOptions */ -const options = { - normalize: false, - dedupe: true, - prepare: function(str){ - return ("" + str).replace(regex, " ") - } -}; -export default options; diff --git a/src/charset/latin/default.js b/src/charset/latin/default.js index 4c55e28..3fd6dd9 100644 --- a/src/charset/latin/default.js +++ b/src/charset/latin/default.js @@ -2,10 +2,10 @@ import { EncoderOptions } from "../../type.js"; /** @type EncoderOptions */ const options = { - normalize: function(str){ - return str.toLowerCase(); - }, - //numeric: false, + normalize: true + // normalize: function(str){ + // return str.toLowerCase(); + // }, //dedupe: false }; export default options; diff --git a/src/charset/latin/exact.js b/src/charset/latin/exact.js index aefdb18..5f7adb2 100644 --- a/src/charset/latin/exact.js +++ b/src/charset/latin/exact.js @@ -2,8 +2,10 @@ import { EncoderOptions } from "../../type.js"; /** @type EncoderOptions */ const options = { - split: /\s+/, normalize: false, + numeric: false, + split: /\s+/ + //normalize: false, //dedupe: false }; export default options; \ No newline at end of file diff --git a/src/encoder.js b/src/encoder.js index c637bd5..217db51 100644 --- a/src/encoder.js +++ b/src/encoder.js @@ -59,7 +59,7 @@ const numeric_split_next_char = /(\d{3})(\D)/g; //.replace(/(\d{3})/g, "$1 ") //.replace(/([^\d])([\d])/g, "$1 $2") //.replace(/([\d])([^\d])/g, "$1 $2") -const normalize = "".normalize && /[\u0300-\u036f]/g; // '´`’ʼ., +const normalize = /*"".normalize &&*/ /[\u0300-\u036f]/g; // '´`’ʼ., //const normalize_mapper = SUPPORT_CHARSET && !normalize && normalize_polyfill; /** @@ -201,13 +201,13 @@ Encoder.prototype.assign = function(options){ ); // assign the normalization fallback to the mapper - if(SUPPORT_CHARSET && !normalize){ - this.mapper = new Map( - /** @type {Array>} */ ( - normalize_polyfill - ) - ); - } + // if(SUPPORT_CHARSET && !normalize){ + // this.mapper = new Map( + // /** @type {Array>} */ ( + // normalize_polyfill + // ) + // ); + // } tmp = options.filter; this.filter = typeof tmp === "function" ? tmp : merge_option(tmp && new Set(tmp), null, this.filter); @@ -221,7 +221,7 @@ Encoder.prototype.assign = function(options){ this.rtl = merge_option(options.rtl, false, this.rtl); // auto-balanced cache - if(SUPPORT_CACHE){ + //if(SUPPORT_CACHE){ this.cache = tmp = merge_option(options.cache, true, this.cache); if(tmp){ this.timer = null; @@ -231,7 +231,7 @@ Encoder.prototype.assign = function(options){ this.cache_enc_length = 128; this.cache_term_length = 128; } - } + //} // regex temporary state this.matcher_str = ""; @@ -277,7 +277,7 @@ Encoder.prototype.addStemmer = function(match, replace){ this.stemmer.set(match, replace); this.stemmer_str += (this.stemmer_str ? "|" : "") + match; this.stemmer_test = null; - SUPPORT_CACHE && this.cache && clear(this); + /*SUPPORT_CACHE &&*/ this.cache && clear(this); return this; }; @@ -290,7 +290,7 @@ Encoder.prototype.addFilter = function(term){ this.filter || (this.filter = new Set()); this.filter.add(term); } - SUPPORT_CACHE && this.cache && clear(this); + /*SUPPORT_CACHE &&*/ this.cache && clear(this); return this; }; @@ -312,7 +312,7 @@ Encoder.prototype.addMapper = function(char_match, char_replace){ } this.mapper || (this.mapper = new Map()); this.mapper.set(char_match, char_replace); - SUPPORT_CACHE && this.cache && clear(this); + /*SUPPORT_CACHE &&*/ this.cache && clear(this); return this; }; @@ -337,7 +337,7 @@ Encoder.prototype.addMatcher = function(match, replace){ this.matcher.set(match , replace); this.matcher_str += (this.matcher_str ? "|" : "") + match; this.matcher_test = null; - SUPPORT_CACHE && this.cache && clear(this); + /*SUPPORT_CACHE &&*/ this.cache && clear(this); return this; }; @@ -353,7 +353,7 @@ Encoder.prototype.addReplacer = function(regex, replace){ } this.replacer || (this.replacer = []); this.replacer.push(regex, replace); - SUPPORT_CACHE && this.cache && clear(this); + /*SUPPORT_CACHE &&*/ this.cache && clear(this); return this; }; @@ -366,7 +366,7 @@ Encoder.prototype.encode = function(str){ //if(!str) return str; // todo remove dupe terms - if(SUPPORT_CACHE && this.cache && str.length <= this.cache_enc_length){ + if(/*SUPPORT_CACHE &&*/ this.cache && str.length <= this.cache_enc_length){ if(this.timer){ if(this.cache_enc.has(str)){ return this.cache_enc.get(str); @@ -444,7 +444,7 @@ Encoder.prototype.encode = function(str){ continue; } - if(SUPPORT_CACHE && this.cache && word.length <= this.cache_term_length){ + if(/*SUPPORT_CACHE &&*/ this.cache && word.length <= this.cache_term_length){ if(this.timer){ const tmp = this.cache_term.get(word); if(tmp || tmp === ""){ @@ -530,7 +530,7 @@ Encoder.prototype.encode = function(str){ //word = word.replace(/(.)\1+/g, "$1"); //word = word.replace(/(?<=(.))\1+/g, ""); - if(SUPPORT_CACHE && this.cache && base.length <= this.cache_term_length){ + if(/*SUPPORT_CACHE &&*/ this.cache && base.length <= this.cache_term_length){ this.cache_term.set(base, word); if(this.cache_term.size > this.cache_size){ this.cache_term.clear(); @@ -545,7 +545,7 @@ Encoder.prototype.encode = function(str){ final = this.finalize(final) || final; } - if(SUPPORT_CACHE && this.cache && str.length <= this.cache_enc_length){ + if(/*SUPPORT_CACHE &&*/ this.cache && str.length <= this.cache_enc_length){ this.cache_enc.set(str, final); if(this.cache_enc.size > this.cache_size){ this.cache_enc.clear(); diff --git a/src/index.js b/src/index.js index 9ef84f9..797311c 100644 --- a/src/index.js +++ b/src/index.js @@ -88,7 +88,7 @@ export default function Index(options, _register){ } this.resolution = options.resolution || 9; - this.tokenize = tmp = ((tmp = options.tokenize) && (tmp !== "default") && tmp) || "strict"; + this.tokenize = tmp = ((tmp = options.tokenize) && (tmp !== "default") && (tmp !== "exact") && tmp) || "strict"; this.depth = (tmp === "strict" && context.depth) || 0; this.bidirectional = context.bidirectional !== false; this.fastupdate = !!options.fastupdate; diff --git a/src/index/add.js b/src/index/add.js index 1a7b0fd..0899f7f 100644 --- a/src/index/add.js +++ b/src/index/add.js @@ -81,6 +81,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){ break; } // fallthrough to next case when term length < 3 + case "bidirectional": case "reverse": // skip last round (this token exist already in "forward") if(term_length > 1){ diff --git a/task/babel.js b/task/babel.js index 1804ee0..faf16ab 100644 --- a/task/babel.js +++ b/task/babel.js @@ -6,7 +6,7 @@ const minify = process.argv[2] && process.argv[2].toLowerCase().includes("releas console.log("Start build ....."); console.log('Bundle: ' + ('module' /* 'custom' */) + (debug ? ":debug" : (minify ? ":min" : ""))); -fs.rmSync("tmp/", { recursive: true }); +fs.existsSync("tmp") && fs.rmSync("tmp/", { recursive: true }); fs.mkdirSync("tmp"); fs.existsSync("dist") || fs.mkdirSync("dist"); @@ -49,9 +49,9 @@ fs.existsSync("dist") || fs.mkdirSync("dist"); "lang", "charset/", "charset/latin", - "charset/arabic", - "charset/cjk", - "charset/cyrillic" + //"charset/arabic", + //"charset/cjk", + //"charset/cyrillic" ]; for(let i = 0, path; i < dirs.length; i++){ diff --git a/task/build.js b/task/build.js index df5727f..1e9e444 100644 --- a/task/build.js +++ b/task/build.js @@ -3,7 +3,7 @@ const fs = require("fs"); console.log("Start build ....."); -fs.rmSync("tmp/", { recursive: true }); +fs.existsSync("tmp") && fs.rmSync("tmp/", { recursive: true }); fs.mkdirSync("tmp"); fs.existsSync("dist") || fs.mkdirSync("dist"); diff --git a/test/encoder.js b/test/encoder.js index 77dd34b..99c3a58 100644 --- a/test/encoder.js +++ b/test/encoder.js @@ -27,29 +27,29 @@ describe("Encoder", function(){ }); }); -describe("Encoder: Latin Charset", function(){ +describe("Encoder: Charset", function(){ - it("Should have been encoded properly: LatinDefault", function(){ + it("Should have been encoded properly: Default", function(){ - const index = new Index({ encoder: Charset.LatinDefault }); + const index = new Index({ encoder: Charset.Default }); expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql( - ["björn", "phillipp", "mayer"] + ["bjorn", "phillipp", "mayer"] ); }); if(!build_light){ - it("Should have been encoded properly: LatinExact", function(){ + it("Should have been encoded properly: Exact", function(){ - const index = new Index({ encoder: Charset.LatinExact }); + const index = new Index({ encoder: Charset.Exact }); expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql( ["Björn-Phillipp", "Mayer"] ); }); - it("Should have been encoded properly: LatinSimple", function(){ + it("Should have been encoded properly: Normalize", function(){ - const index = new Index({ encoder: Charset.LatinSimple }); + const index = new Index({ encoder: Charset.Normalize }); expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql( index.encoder.encode("bjorn/phillipp mayer") ); @@ -99,14 +99,11 @@ describe("Encoder: Latin Charset", function(){ }); }); -describe("Encoder: CJK Word Break", function(){ +describe("Encoder: CJK Charset", function(){ it("Should have been tokenized properly", function(){ - const index = Index({ - encoder: Charset.CjkDefault, - tokenize: "forward" - }); + const index = Index({ tokenize: "forward" }); index.add(0, "서울시가 잠이 든 시간에 아무 말, 미뤄, 미뤄"); expect(index.search("든")).to.include(0); @@ -117,14 +114,11 @@ describe("Encoder: CJK Word Break", function(){ }); }); -describe("Encoder: Cyrillic Word Break", function(){ +describe("Encoder: Cyrillic Charset", function(){ it("Should have been tokenized properly", function(){ - const index = Index({ - encoder: Charset.CyrillicDefault, - tokenize: "forward" - }); + const index = Index({ tokenize: "forward" }); index.add(0, "Фообар"); expect(index.search("Фообар")).to.include(0); @@ -132,28 +126,33 @@ describe("Encoder: Cyrillic Word Break", function(){ }); }); -describe("Encoder: Arabic Word Break", function(){ +describe("Encoder: Arabic Charset", function(){ it("Should have been tokenized properly", function(){ - let index = Index({ - encoder: Charset.ArabicDefault, - tokenize: "forward" - }); + let index = Index({ tokenize: "forward" }); index.add(0, "لكن لا بد أن أوضح لك أن كل"); expect(index.search("بد أن")).to.include(0); expect(index.search("أو")).to.include(0); - index = Index({ - encoder: Charset.ArabicDefault, - tokenize: "reverse" - }); + + index = Index({ tokenize: "reverse" }); index.add(0, "لكن لا بد أن أوضح لك أن كل"); expect(index.search("ضح")).to.include(0); }); }); +describe("Encoder: Greek Charset", function(){ + + it("Should have been tokenized properly", function(){ + + const index = Index({ tokenize: "forward" }); + index.add(0, "Μήγαρις ἔχω ἄλλο στὸ νοῦ μου πάρεξ ἐλευθερία καὶ γλώσσα"); + expect(index.search("Μηγαρις εχω αλλο στο νου μου παρε ελευθ και γλωσσα")).to.include(0); + }); +}); + describe("Encoder: Right-to-Left", function(){ it("Should have been scored properly", function(){