diff --git a/dist/db/indexeddb/index.js b/dist/db/indexeddb/index.js index c662431..daa5503 100644 --- a/dist/db/indexeddb/index.js +++ b/dist/db/indexeddb/index.js @@ -327,7 +327,7 @@ IdxDB.prototype.transaction = function(ref, modifier, task){ }; const promise = task.call(this, store); // transactions can just be used within the same event loop - // the indexeddb is just a stupid thing + // the indexeddb is such a stupid tool :( this.trx[ref+ ":" + modifier] = null; return promise; }); diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js index d27dbc5..7c1af9c 100644 --- a/dist/flexsearch.bundle.debug.js +++ b/dist/flexsearch.bundle.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.115 (Bundle/Debug) + * FlexSearch.js v0.8.117 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -301,29 +301,24 @@ async function ka(a) { } } ;function la(a) { - P.call(a, "add"); - P.call(a, "append"); - P.call(a, "search"); - P.call(a, "update"); - P.call(a, "remove"); + ma.call(a, "add"); + ma.call(a, "append"); + ma.call(a, "search"); + ma.call(a, "update"); + ma.call(a, "remove"); } -let ma, na; -const oa = {}, pa = {}; -function qa(a) { - ma = 0; - oa[a] = pa[a]; +let na, oa, pa; +function qa() { + na = pa = 0; } -function P(a) { +function ma(a) { this[a + "Async"] = function() { const b = arguments; var c = b[b.length - 1]; let e; "function" === typeof c && (e = c, delete b[b.length - 1]); - ma || (ma = setTimeout(qa, 0, a), na = Date.now()); - pa[a] || (pa[a] = oa[a] = 1000); - if (!--oa[a]) { - oa[a] = pa[a] = pa[a] * this.priority * this.priority * 3 / (Date.now() - na) | 0 || 1; - ma = clearTimeout(ma); + 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() { @@ -337,7 +332,7 @@ function P(a) { return c; }; } -;let ra = 0; +;let P = 0; function Q(a = {}) { function b(g) { function k(h) { @@ -351,13 +346,15 @@ function Q(a = {}) { e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { return new Promise(function(h) { - d.h[++ra] = function() { + d.h[++P] = function() { h(d); + 1e9 < P && (P = 0); }; - d.worker.postMessage({id:ra, task:"init", factory:c, options:a}); + d.worker.postMessage({id:P, task:"init", factory:c, options:a}); }); } this.worker.postMessage({task:"init", factory:c, options:a}); + this.priority = a.priority || 4; return this; } } @@ -366,7 +363,7 @@ function Q(a = {}) { } let c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; c && (c = c.toString()); - const e = "undefined" === typeof window, d = this, f = sa(c, e, a.worker); + const e = "undefined" === typeof window, d = this, f = ra(c, e, a.worker); return f.then ? f.then(function(g) { return b.call(d, g); }) : b.call(this, f); @@ -388,17 +385,17 @@ function R(a) { "function" === typeof e && (d = e, c.pop()); e = new Promise(function(f) { "export" === a && "function" === typeof c[0] && (c[0] = null); - b.h[++ra] = f; - b.worker.postMessage({task:a, id:ra, args:c}); + b.h[++P] = f; + b.worker.postMessage({task:a, id:P, args:c}); }); return d ? (e.then(d), this) : e; }; } -function sa(a, b, c) { +function ra(a, b, c) { return b ? "undefined" !== typeof module ? new (require("worker_threads")["Worker"])(__dirname + "/node/node.js") : import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); }) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function ta(a, b = 0) { +;function sa(a, b = 0) { let c = [], e = []; b && (b = 250000 / b * 5000 | 0); for (const d of a.entries()) { @@ -407,30 +404,30 @@ function sa(a, b, c) { e.length && c.push(e); return c; } -function ua(a, b) { +function ta(a, b) { b || (b = new Map()); for (let c = 0, e; c < a.length; c++) { e = a[c], b.set(e[0], e[1]); } return b; } -function va(a, b = 0) { +function ua(a, b = 0) { let c = [], e = []; b && (b = 250000 / b * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], ta(d[1])[0]]), e.length === b && (c.push(e), e = []); + e.push([d[0], sa(d[1])[0]]), e.length === b && (c.push(e), e = []); } e.length && c.push(e); return c; } -function wa(a, b) { +function va(a, b) { b || (b = new Map()); for (let c = 0, e, d; c < a.length; c++) { - e = a[c], d = b.get(e[0]), b.set(e[0], ua(e[1], d)); + e = a[c], d = b.get(e[0]), b.set(e[0], ta(e[1], d)); } return b; } -function xa(a) { +function wa(a) { let b = [], c = []; for (const e of a.keys()) { c.push(e), 250000 === c.length && (b.push(c), c = []); @@ -438,14 +435,14 @@ function xa(a) { c.length && b.push(c); return b; } -function ya(a, b) { +function xa(a, b) { b || (b = new Set()); for (let c = 0; c < a.length; c++) { b.add(a[c]); } return b; } -function za(a, b, c, e, d, f, g = 0) { +function ya(a, b, c, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { @@ -454,12 +451,12 @@ function za(a, b, c, e, d, f, g = 0) { if ((h = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(h))) && h.then) { const l = this; return h.then(function() { - return za.call(l, a, b, c, k ? e : null, d, f, g + 1); + return ya.call(l, a, b, c, k ? e : null, d, f, g + 1); }); } - return za.call(this, a, b, c, k ? e : null, d, f, g + 1); + return ya.call(this, a, b, c, k ? e : null, d, f, g + 1); } -;function Aa(a, b, c, e) { +;function za(a, b, c, e) { let d = []; for (let f = 0, g; f < a.index.length; f++) { if (g = a.index[f], b >= g.length) { @@ -525,12 +522,12 @@ function S(a) { } if ("slice" === e) { return function(d, f) { - return Aa(b, d || 0, f || b.length, !1); + return za(b, d || 0, f || b.length, !1); }; } if ("splice" === e) { return function(d, f) { - return Aa(b, d || 0, f || b.length, !0); + return za(b, d || 0, f || b.length, !0); }; } if ("constructor" === e) { @@ -561,7 +558,7 @@ function T(a = 8) { this.index = B(); this.B = []; this.size = 0; - 32 < a ? (this.h = Ba, this.A = BigInt(a)) : (this.h = Ca, this.A = a); + 32 < a ? (this.h = Aa, this.A = BigInt(a)) : (this.h = Ba, this.A = a); } T.prototype.get = function(a) { const b = this.index[this.h(a)]; @@ -578,7 +575,7 @@ function U(a = 8) { } this.index = B(); this.h = []; - 32 < a ? (this.B = Ba, this.A = BigInt(a)) : (this.B = Ca, this.A = a); + 32 < a ? (this.B = Aa, this.A = BigInt(a)) : (this.B = Ba, this.A = a); } U.prototype.add = function(a) { var b = this.B(a); @@ -620,7 +617,7 @@ t.entries = U.prototype.entries = function*() { } } }; -function Ca(a) { +function Ba(a) { let b = 2 ** this.A - 1; if ("number" == typeof a) { return a & b; @@ -631,7 +628,7 @@ function Ca(a) { } return 32 === this.A ? c + 2 ** 31 : c; } -function Ba(a) { +function Aa(a) { let b = BigInt(2) ** this.A - BigInt(1); var c = typeof a; if ("bigint" === c) { @@ -661,7 +658,7 @@ function Ba(a) { d && e.add(a, d, !1, !0); } else { if (d = h.I, !d || d(b)) { - h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Da(b, h, this.J, 0, e, a, h[0], c); + h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Ca(b, h, this.J, 0, e, a, h[0], c); } } } @@ -724,7 +721,7 @@ function Ba(a) { k[l] = b[l]; continue; } - Ea(b, k, l, 0, l[0], n); + Da(b, k, l, 0, l[0], n); } } this.store.set(a, k || b); @@ -733,21 +730,21 @@ function Ba(a) { } return this; }; -function Ea(a, b, c, e, d, f) { +function Da(a, b, c, e, d, f) { a = a[d]; if (e === c.length - 1) { b[d] = f || a; } else if (a) { if (a.constructor === Array) { for (b = b[d] = Array(a.length), d = 0; d < a.length; d++) { - Ea(a, b, c, e, d); + Da(a, b, c, e, d); } } else { - b = b[d] || (b[d] = B()), d = c[++e], Ea(a, b, c, e, d); + b = b[d] || (b[d] = B()), d = c[++e], Da(a, b, c, e, d); } } } -function Da(a, b, c, e, d, f, g, k) { +function Ca(a, b, c, e, d, f, g, k) { if (a = a[g]) { if (e === b.length - 1) { if (a.constructor === Array) { @@ -763,17 +760,17 @@ function Da(a, b, c, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Da(a, b, c, e, d, f, g, k); + Ca(a, b, c, e, d, f, g, k); } } else { - g = b[++e], Da(a, b, c, e, d, f, g, k); + g = b[++e], Ca(a, b, c, e, d, f, g, k); } } } else { d.db && d.remove(f); } } -;function Fa(a, b, c, e, d, f, g) { +;function Ea(a, b, c, e, d, f, g) { const k = a.length; let h = [], l; var n; @@ -789,7 +786,7 @@ function Da(a, b, c, e, d, f, g, k) { } if (a = h.length) { if (d) { - h = 1 < h.length ? Ga(h, c, e, g, f) : (h = h[0]).length > c || e ? h.slice(e, c + e) : h; + h = 1 < h.length ? Fa(h, c, e, g, f) : (h = h[0]).length > c || e ? h.slice(e, c + e) : h; } else { if (a < k) { return []; @@ -822,7 +819,7 @@ function Da(a, b, c, e, d, f, g, k) { } return h; } -function Ga(a, b, c, e, d) { +function Fa(a, b, c, e, d) { const f = [], g = B(); let k; var h = a.length; @@ -867,7 +864,7 @@ function Ga(a, b, c, e, d) { } return f; } -function Ha(a, b, c) { +function Ga(a, b, c) { const e = B(), d = []; for (let f = 0, g; f < b.length; f++) { g = b[f]; @@ -888,7 +885,7 @@ function Ha(a, b, c) { } return d; } -;function Ia(a, b, c, e) { +;function Ha(a, b, c, e) { if (!a.length) { return a; } @@ -919,7 +916,7 @@ function Ha(a, b, c) { d = 1 < d.length ? [].concat.apply([], d) : d[0]; return e ? W.call(this, d) : d; } -;function Ja(a, b, c) { +;function Ia(a, b, c) { var e = c[0]; if (e.then) { return Promise.all(c).then(function(n) { @@ -966,10 +963,10 @@ function Ha(a, b, c) { return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; } ;X.prototype.or = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f} = Ja(this, "or", arguments); - return Ka.call(this, a, b, c, e, d, f); + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f} = Ia(this, "or", arguments); + return Ja.call(this, a, b, c, e, d, f); }; -function Ka(a, b, c, e, d, f) { +function Ja(a, b, c, e, d, f) { if (b.length) { const g = this; return Promise.all(b).then(function(k) { @@ -977,10 +974,10 @@ function Ka(a, b, c, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return Ka.call(g, a, [], c, e, d, f); + return Ja.call(g, a, [], c, e, d, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ga(a, c, e, !1, this.h), e = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Fa(a, c, e, !1, this.h), e = 0)); return f ? this.resolve(c, e, d) : this; } ;X.prototype.and = function() { @@ -990,11 +987,40 @@ function Ka(a, b, c, e, d, f) { f && (a = !!f.suggest, d = f.resolve, b = f.limit, c = f.offset, e = f.enrich && d); } if (a) { - const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:n, suggest:m} = Ja(this, "and", arguments); - return La.call(this, f, g, k, h, l, n, m); + const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:n, suggest:m} = Ia(this, "and", arguments); + return Ka.call(this, f, g, k, h, l, n, m); } return d ? this.resolve(b, c, e) : this; }; +function Ka(a, b, c, e, d, f, g) { + if (b.length) { + const k = this; + return Promise.all(b).then(function(h) { + a = []; + for (let l = 0, n; l < h.length; l++) { + (n = h[l]).length && (a[l] = n); + } + return Ka.call(k, a, [], c, e, d, f, g); + }); + } + if (a.length) { + if (this.result.length && a.unshift(this.result), 2 > a.length) { + this.result = a[0]; + } else { + if (b = ca(a)) { + return this.result = Ea(a, b, c, e, g, this.h, f), f ? d ? W.call(this.index, this.result) : this.result : this; + } + this.result = []; + } + } else { + g || (this.result = a); + } + return f ? this.resolve(c, e, d) : this; +} +;X.prototype.xor = function() { + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ia(this, "xor", arguments); + return La.call(this, a, b, c, e, d, f, g); +}; function La(a, b, c, e, d, f, g) { if (b.length) { const k = this; @@ -1010,43 +1036,14 @@ function La(a, b, c, e, d, f, g) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (b = ca(a)) { - return this.result = Fa(a, b, c, e, g, this.h, f), f ? d ? W.call(this.index, this.result) : this.result : this; - } - this.result = []; + return this.result = Ma.call(this, a, c, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(c, e, d) : this; } -;X.prototype.xor = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "xor", arguments); - return Ma.call(this, a, b, c, e, d, f, g); -}; -function Ma(a, b, c, e, d, f, g) { - if (b.length) { - const k = this; - return Promise.all(b).then(function(h) { - a = []; - for (let l = 0, n; l < h.length; l++) { - (n = h[l]).length && (a[l] = n); - } - return Ma.call(k, a, [], c, e, d, f, g); - }); - } - if (a.length) { - if (this.result.length && a.unshift(this.result), 2 > a.length) { - this.result = a[0]; - } else { - return this.result = Na.call(this, a, c, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; - } - } else { - g || (this.result = a); - } - return f ? this.resolve(c, e, d) : this; -} -function Na(a, b, c, e, d) { +function Ma(a, b, c, e, d) { const f = [], g = B(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -1092,10 +1089,10 @@ function Na(a, b, c, e, d) { return f; } ;X.prototype.not = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "not", arguments); - return Oa.call(this, a, b, c, e, d, f, g); + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ia(this, "not", arguments); + return Na.call(this, a, b, c, e, d, f, g); }; -function Oa(a, b, c, e, d, f, g) { +function Na(a, b, c, e, d, f, g) { if (b.length) { const k = this; return Promise.all(b).then(function(h) { @@ -1103,17 +1100,17 @@ function Oa(a, b, c, e, d, f, g) { for (let l = 0, n; l < h.length; l++) { (n = h[l]).length && (a[l] = n); } - return Oa.call(k, a, [], c, e, d, f, g); + return Na.call(k, a, [], c, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Pa.call(this, a, c, e, f); + this.result = Oa.call(this, a, c, e, f); } else if (f) { return this.resolve(c, e, d); } return f ? d ? W.call(this.index, this.result) : this.result : this; } -function Pa(a, b, c, e) { +function Oa(a, b, c, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, k = 0; f < this.result.length; f++) { @@ -1188,7 +1185,7 @@ X.prototype.boost = function(a) { X.prototype.resolve = function(a, b, c) { const e = this.result, d = this.index; this.result = this.index = null; - return e.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ia.call(d, e, a || 100, b, c)) : e; + return e.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ha.call(d, e, a || 100, b, c)) : e; }; B(); V.prototype.search = function(a, b, c, e) { @@ -1268,7 +1265,7 @@ V.prototype.search = function(a, b, c, e) { } r.push(m = m.db.tag(v[p + 1], b, l, u)); } else { - m = Qa.call(this, v[p], v[p + 1], b, l, u); + m = Pa.call(this, v[p], v[p + 1], b, l, u); } d.push({field:v[p], tag:v[p + 1], result:m}); } @@ -1320,7 +1317,7 @@ V.prototype.search = function(a, b, c, e) { } } } else { - for (let G = 0, K, rb; G < p.length; G += 2) { + for (let G = 0, K, qb; G < p.length; G += 2) { K = this.tag.get(p[G]); if (!K) { if (console.warn("Tag '" + p[G] + ":" + p[G + 1] + "' will be skipped because there is no field '" + p[G] + "'."), r) { @@ -1329,7 +1326,7 @@ V.prototype.search = function(a, b, c, e) { return m ? d : new X(d); } } - if (rb = (K = K && K.get(p[G + 1])) && K.length) { + if (qb = (K = K && K.get(p[G + 1])) && K.length) { y++, x.push(K); } else if (!r) { return m ? d : new X(d); @@ -1337,7 +1334,7 @@ V.prototype.search = function(a, b, c, e) { } } if (y) { - w = Ha(w, x, m); + w = Ga(w, x, m); H = w.length; if (!H && !r) { return m ? w : new X(w); @@ -1391,12 +1388,12 @@ V.prototype.search = function(a, b, c, e) { for (let D = 0; D < w.length; D++) { d[D].result = w[D]; } - return k ? Ra(d, b) : q ? Sa(d, a, z.index, z.field, z.D, q) : d; + return k ? Qa(d, b) : q ? Ra(d, a, z.index, z.field, z.D, q) : d; }); } - return k ? Ra(d, b) : q ? Sa(d, a, this.index, this.field, this.D, q) : d; + return k ? Qa(d, b) : q ? Ra(d, a, this.index, this.field, this.D, q) : d; }; -function Sa(a, b, c, e, d, f) { +function Ra(a, b, c, e, d, f) { let g, k, h; for (let n = 0, m, q, p, r, u; n < a.length; n++) { m = a[n].result; @@ -1438,7 +1435,7 @@ function Sa(a, b, c, e, d, f) { } return a; } -function Ra(a, b) { +function Qa(a, b) { const c = [], e = B(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1457,7 +1454,7 @@ function Ra(a, b) { } return c; } -function Qa(a, b, c, e, d) { +function Pa(a, b, c, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1489,7 +1486,7 @@ function W(a) { this.D = []; this.field = []; this.J = []; - this.key = (c = b.key || b.id) && Ta(c, this.J) || "id"; + this.key = (c = b.key || b.id) && Sa(c, this.J) || "id"; (e = a.keystore || 0) && (this.keystore = e); this.fastupdate = !!a.fastupdate; this.reg = !this.fastupdate || a.worker || a.db ? e ? new U(e) : new Set() : e ? new T(e) : new Map(); @@ -1498,7 +1495,8 @@ function W(a) { this.cache = (c = a.cache || null) && new Y(c); a.cache = !1; this.worker = a.worker; - this.index = Ua.call(this, a, b); + this.priority = a.priority || 4; + this.index = Ta.call(this, a, b); this.tag = null; if (c = b.tag) { if ("string" === typeof c && (c = [c]), c.length) { @@ -1511,7 +1509,7 @@ function W(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.F[d] = f.custom : (this.F[d] = Ta(g, this.J), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = f.filter)); + f.custom ? this.F[d] = f.custom : (this.F[d] = Sa(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()); } @@ -1583,7 +1581,7 @@ t.destroy = function() { } return Promise.all(a); }; -function Ua(a, b) { +function Ta(a, b) { const c = new Map(); let e = b.index || b.field || b; E(e) && (e = [e]); @@ -1596,19 +1594,19 @@ function Ua(a, b) { c.set(f, k); } this.worker || c.set(f, new O(g, this.reg)); - g.custom ? this.D[d] = g.custom : (this.D[d] = Ta(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); + g.custom ? this.D[d] = g.custom : (this.D[d] = Sa(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); this.field[d] = f; } if (this.C) { a = b.store; E(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = 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)); + f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = Sa(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); } } return c; } -function Ta(a, b) { +function Sa(a, b) { const c = a.split(":"); let e = 0; for (let d = 0; d < c.length; d++) { @@ -1674,7 +1672,7 @@ t.set = function(a, b) { this.store.set(a, b); return this; }; -t.searchCache = Va; +t.searchCache = Ua; t.export = function(a, b, c = 0, e = 0) { if (c < this.field.length) { const g = this.field[c]; @@ -1690,27 +1688,23 @@ t.export = function(a, b, c = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = xa(this.reg); + f = wa(this.reg); b = null; break; case 1: d = "tag"; - f = va(this.tag, this.reg.size); + f = this.tag && ua(this.tag, this.reg.size); b = null; break; case 2: d = "doc"; - f = ta(this.store); + f = this.store && sa(this.store); b = null; break; - case 3: - d = "cfg"; - b = f = null; - break; default: return; } - return za.call(this, a, b, d, f, c, e); + return ya.call(this, a, b, d, f, c, e); }; t.import = function(a, b) { var c = a.split("."); @@ -1728,7 +1722,7 @@ t.import = function(a, b) { switch(c) { case "reg": this.fastupdate = !1; - this.reg = ya(b, this.reg); + this.reg = xa(b, 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; } @@ -1741,15 +1735,15 @@ t.import = function(a, b) { } break; case "tag": - this.tag = wa(b, this.tag); + this.tag = va(b, this.tag); break; case "doc": - this.store = ua(b, this.store); + this.store = ta(b, this.store); } } }; la(V.prototype); -function Va(a, b, c) { +function Ua(a, b, c) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Y()); let e = this.cache.get(a); @@ -1790,31 +1784,31 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Wa = {normalize:function(a) { +const Va = {normalize:function(a) { return a.toLowerCase(); }}; -const Xa = 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 Ya = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Za = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -const $a = {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 Wa = 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 Xa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Ya = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const Za = {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 $a = /[\x00-\x7F]+/g; const ab = /[\x00-\x7F]+/g; const bb = /[\x00-\x7F]+/g; -const cb = /[\x00-\x7F]+/g; -var db = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Wa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Xa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Xa, matcher:Ya, replacer:Za}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Xa, replacer:Za.concat([/(?!^)[aeo]/g, ""]), matcher:Ya}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +var cb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Va, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Wa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Wa, matcher:Xa, replacer:Ya}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Wa, replacer:Ya.concat([/(?!^)[aeo]/g, ""]), matcher:Xa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let c = 0; c < a.length; c++) { var b = a[c]; - let e = b.charAt(0), d = $a[e]; - for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = $a[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = b.charAt(0), d = Za[e]; + for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = Za[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[c] = e; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(ab, " "); + return ("" + a).replace($a, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(bb, ""); + return ("" + a).replace(ab, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(cb, " "); + return ("" + a).replace(bb, " "); }}}; -const eb = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +const db = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; O.prototype.add = function(a, b, c, e) { if (b && (a || 0 === a)) { if (!e && !c && this.reg.has(a)) { @@ -1827,15 +1821,15 @@ O.prototype.add = function(a, b, c, e) { let r = b[this.rtl ? e - 1 - p : p]; var d = r.length; if (d && (m || !n[r])) { - var f = this.score ? this.score(b, r, p, null, 0) : fb(q, e, p), g = ""; + var f = this.score ? this.score(b, r, p, null, 0) : eb(q, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { for (f = 0; f < d; f++) { for (var k = d; k > f; k--) { g = r.substring(f, k); - var h = this.score ? this.score(b, r, p, g, f) : fb(q, e, p, d, f); - gb(this, n, g, h, a, c); + var h = this.score ? this.score(b, r, p, g, f) : eb(q, e, p, d, f); + fb(this, n, g, h, a, c); } } break; @@ -1843,24 +1837,24 @@ O.prototype.add = function(a, b, c, e) { case "reverse": if (1 < d) { for (k = d - 1; 0 < k; k--) { - g = r[k] + g, h = this.score ? this.score(b, r, p, g, k) : fb(q, e, p, d, k), gb(this, n, g, h, a, c); + g = r[k] + g, h = this.score ? this.score(b, r, p, g, k) : eb(q, e, p, d, k), fb(this, n, g, h, a, c); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += r[k], gb(this, n, g, f, a, c); + g += r[k], fb(this, n, g, f, a, c); } break; } default: - if (gb(this, n, r, f, a, c), m && 1 < e && p < e - 1) { + if (fb(this, n, r, f, a, c), m && 1 < e && p < e - 1) { for (d = B(), g = this.U, f = r, k = Math.min(m + 1, e - p), d[f] = 1, h = 1; h < k; h++) { if ((r = b[this.rtl ? e - 1 - p - h : p + h]) && !d[r]) { d[r] = 1; - const u = this.score ? this.score(b, f, p, r, h) : fb(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), v = this.bidirectional && r > f; - gb(this, l, v ? f : r, u, a, c, v ? r : f); + const u = this.score ? this.score(b, f, p, r, h) : 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, c, v ? r : f); } } } @@ -1872,10 +1866,10 @@ O.prototype.add = function(a, b, c, e) { b = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.T && hb(this)); + this.db && (b || this.commit_task.push({del:a}), this.T && gb(this)); return this; }; -function gb(a, b, c, e, d, f, g) { +function fb(a, b, c, e, d, f, g) { let k = g ? a.ctx : a.map, h; if (!b[c] || g && !(h = b[c])[g]) { if (g ? (b = h || (b[c] = B()), b[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : b[c] = 1, (h = k.get(c)) ? k = h : k.set(c, k = h = []), k = k[e] || (k[e] = []), !f || !k.includes(d)) { @@ -1893,7 +1887,7 @@ function gb(a, b, c, e, d, f, g) { } } } -function fb(a, b, c, e, d) { +function eb(a, b, c, e, d) { return c && 1 < a ? b + (e || 0) <= a ? c + (d || 0) : (a - 1) / (b + (e || 0)) * (c + (d || 0)) + 1 | 0 : 0; } ;O.prototype.search = function(a, b, c) { @@ -1904,11 +1898,11 @@ function fb(a, b, c, e, d) { d = p.length; b = b || (h ? 100 : 0); if (1 === d) { - return ib.call(this, p[0], "", b, k, h, q, l); + return hb.call(this, p[0], "", b, k, h, q, l); } f = this.depth && !1 !== f; if (2 === d && f && !g) { - return ib.call(this, p[0], p[1], b, k, h, q, l); + return hb.call(this, p[0], p[1], b, k, h, q, l); } let r = B(), u = 0, v; 1 < d && f && (v = p[0], u = 1); @@ -1922,8 +1916,8 @@ function fb(a, b, c, e, d) { for (let y, F; u < d; u++) { if ((F = p[u]) && !r[F]) { r[F] = 1; - y = await jb(x, F, v, 0, 0, !1, !1); - if (y = kb(y, e, g, m)) { + y = await ib(x, F, v, 0, 0, !1, !1); + if (y = jb(y, e, g, m)) { e = y; break; } @@ -1931,14 +1925,14 @@ function fb(a, b, c, e, d) { } g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); } - return lb(e, m, b, k, g, n, h); + return kb(e, m, b, k, g, n, h); }(); } for (let x, y; u < d; u++) { if ((y = p[u]) && !r[y]) { r[y] = 1; - x = jb(this, y, v, 0, 0, !1, !1); - if (x = kb(x, e, g, m)) { + x = ib(this, y, v, 0, 0, !1, !1); + if (x = jb(x, e, g, m)) { e = x; break; } @@ -1946,24 +1940,24 @@ function fb(a, b, c, e, d) { } g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); } - return lb(e, m, b, k, g, n, h); + return kb(e, m, b, k, g, n, h); }; -function lb(a, b, c, e, d, f, g) { +function kb(a, b, c, e, d, f, g) { let k = a.length, h = a; if (1 < k) { - h = Fa(a, b, c, e, d, f, g); + h = Ea(a, b, c, e, d, f, g); } else if (1 === k) { - return g ? Ia.call(null, a[0], c, e) : new X(a[0]); + return g ? Ha.call(null, a[0], c, e) : new X(a[0]); } return g ? h : new X(h); } -function ib(a, b, c, e, d, f, g) { - a = jb(this, a, b, c, e, d, f, g); +function hb(a, b, c, e, d, f, g) { + a = ib(this, a, b, c, e, d, f, g); return this.db ? a.then(function(k) { return d ? k || [] : new X(k); - }) : a && a.length ? d ? Ia.call(this, a, c, e) : new X(a) : d ? [] : new X(); + }) : a && a.length ? d ? Ha.call(this, a, c, e) : new X(a) : d ? [] : new X(); } -function kb(a, b, c, e) { +function jb(a, b, c, e) { let d = []; if (a && a.length) { if (a.length <= e) { @@ -1984,7 +1978,7 @@ function kb(a, b, c, e) { return d; } } -function jb(a, b, c, e, d, f, g, k) { +function ib(a, b, c, e, d, f, g, k) { let h; c && (h = a.bidirectional && b > c) && (h = c, c = b, b = h); if (a.db) { @@ -2008,15 +2002,15 @@ function jb(a, b, c, e, d, f, g, k) { } } } else { - mb(this.map, a), this.depth && mb(this.ctx, a); + lb(this.map, a), this.depth && lb(this.ctx, a); } b || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.T && hb(this)); + this.db && (this.commit_task.push({del:a}), this.T && gb(this)); this.cache && this.cache.remove(a); return this; }; -function mb(a, b) { +function lb(a, b) { let c = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -2031,7 +2025,7 @@ function mb(a, b) { } } else { for (let e of a.entries()) { - const d = e[0], f = mb(e[1], b); + const d = e[0], f = lb(e[1], b); f ? c += f : a.delete(d); } } @@ -2043,12 +2037,12 @@ function mb(a, b) { } if (a) { var c = E(a) ? a : a.preset; - c && (eb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, eb[c], a)); + c && (db[c] || console.warn("Preset not found: " + c), a = Object.assign({}, db[c], a)); } else { a = {}; } c = a.context; - const e = !0 === c ? {depth:1} : c || {}, d = E(a.encoder) ? db[a.encoder] : a.encode || a.encoder || Wa; + const e = !0 === c ? {depth:1} : c || {}, d = E(a.encoder) ? cb[a.encoder] : a.encode || a.encoder || Va; this.encoder = d.encode ? d : "object" === typeof d ? new J(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = (c = a.tokenize) && "default" !== c && c || "strict"; @@ -2085,11 +2079,11 @@ t.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function hb(a) { +function gb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); - }, 0)); + }, 1)); } t.clear = function() { this.map.clear(); @@ -2109,7 +2103,7 @@ t.update = function(a, b) { const c = this, e = this.remove(a); return e && e.then ? e.then(() => c.add(a, b)) : this.add(a, b); }; -function nb(a) { +function mb(a) { let b = 0; if (a.constructor === Array) { for (let c = 0, e; c < a.length; c++) { @@ -2117,7 +2111,7 @@ function nb(a) { } } else { for (const c of a) { - const e = c[0], d = nb(c[1]); + const e = c[0], d = mb(c[1]); d ? b += d : a.delete(e); } } @@ -2127,17 +2121,17 @@ t.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - nb(this.map); - this.depth && nb(this.ctx); + mb(this.map); + this.depth && mb(this.ctx); return this; }; -t.searchCache = Va; +t.searchCache = Ua; t.export = function(a, b, c = 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"; @@ -2145,29 +2139,29 @@ t.export = function(a, b, c = 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, b, d, f, c, e); + return ya.call(this, a, b, d, f, c, e); }; t.import = function(a, b) { if (b) { switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = ya(b, this.reg); + this.reg = xa(b, this.reg); break; case "map": - this.map = ua(b, this.map); + this.map = ta(b, this.map); break; case "ctx": - this.ctx = wa(b, this.ctx); + this.ctx = va(b, this.ctx); } } }; @@ -2222,10 +2216,10 @@ t.serialize = function(a = !0) { return a ? "function inject(index){" + b + e + d + "}" : b + e + d; }; la(O.prototype); -const ob = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), pb = ["map", "ctx", "tag", "reg", "cfg"]; -function qb(a, b = {}) { +const nb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), ob = ["map", "ctx", "tag", "reg", "cfg"]; +function pb(a, b = {}) { if (!this) { - return new qb(a, b); + return new pb(a, b); } "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -2236,7 +2230,7 @@ function qb(a, b = {}) { this.db = null; this.h = {}; } -t = qb.prototype; +t = pb.prototype; t.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -2248,10 +2242,10 @@ t.open = function() { let a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { - const e = ob.open(a.id + (a.field ? ":" + a.field : ""), 1); + const e = nb.open(a.id + (a.field ? ":" + a.field : ""), 1); e.onupgradeneeded = function() { const d = a.db = this.result; - pb.forEach(f => { + ob.forEach(f => { d.objectStoreNames.contains(f) || d.createObjectStore(f); }); }; @@ -2277,13 +2271,13 @@ t.close = function() { this.db = null; }; t.destroy = function() { - const a = ob.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); + const a = nb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); return Z(a); }; t.clear = function() { - const a = this.db.transaction(pb, "readwrite"); - for (let b = 0; b < pb.length; b++) { - a.objectStore(pb[b]).clear(); + const a = this.db.transaction(ob, "readwrite"); + for (let b = 0; b < ob.length; b++) { + a.objectStore(ob[b]).clear(); } return Z(a); }; @@ -2468,7 +2462,7 @@ t.commit = async function(a, b, c) { } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function sb(a, b, c) { +function rb(a, b, c) { const e = a.value; let d, f, g = 0; for (let k = 0, h; k < e.length; k++) { @@ -2497,17 +2491,17 @@ t.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && sb(c, a); + c && rb(c, a); }; }), this.transaction("ctx", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && sb(c, a); + c && rb(c, a); }; }), this.transaction("tag", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && sb(c, a, !0); + c && rb(c, a, !0); }; }), this.transaction("reg", "readwrite", function(b) { for (let c = 0; c < a.length; c++) { @@ -2527,9 +2521,9 @@ function Z(a) { a = null; }); } -;const tb = {Index:O, Charset:db, Encoder:J, Document:V, Worker:Q, Resolver:X, IndexedDB:qb, Language:{}}, ub = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : "undefined" !== typeof window ? window : {}; -let vb; -(vb = ub.define) && vb.amd ? vb([], function() { - return tb; -}) : "object" === typeof ub.exports ? ub.exports = tb : ub.FlexSearch = tb; +;const sb = {Index:O, Charset:cb, Encoder:J, Document:V, Worker:Q, Resolver:X, IndexedDB:pb, Language:{}}, tb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : "undefined" !== typeof window ? window : {}; +let ub; +(ub = tb.define) && ub.amd ? ub([], function() { + return sb; +}) : "object" === typeof tb.exports ? tb.exports = sb : tb.FlexSearch = sb; }(this||self)); diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index 6583bf6..142b48e 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.115 (Bundle) + * FlexSearch.js v0.8.117 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -21,73 +21,73 @@ t.addMatcher=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);i t.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ja?a.normalize("NFKD").replace(ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),g.lengththis.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&d -this.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function L(a){a.H=null;a.B.clear();a.G.clear()};let M,N;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":N=a.options||{};(b=a.factory)?(Function("return "+b)()(self),M=new self.FlexSearch.Index(N),delete self.FlexSearch):M=new O(N);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=N.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await N.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[b].apply(M,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let ma,na;const oa={},pa={};function qa(a){ma=0;oa[a]=pa[a]} -function P(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);ma||(ma=setTimeout(qa,0,a),na=Date.now());pa[a]||(pa[a]=oa[a]=1E3);if(!--oa[a]){oa[a]=pa[a]=pa[a]*this.priority*this.priority*3/(Date.now()-na)|0||1;ma=clearTimeout(ma);const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let ra=0; -function Q(a={}){function b(g){function k(h){h=h.data||h;const l=h.id,n=l&&d.h[l];n&&(n(h.msg),delete d.h[l])}this.worker=g;this.h=B();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++ra]=function(){h(d)};d.worker.postMessage({id:ra,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==Q)return new Q(a);let c="undefined"!==typeof self?self._factory:"undefined"!== -typeof window?window._factory:null;c&&(c=c.toString());const e="undefined"===typeof window,d=this,f=sa(c,e,a.worker);return f.then?f.then(function(g){return b.call(d,g)}):b.call(this,f)}R("add");R("append");R("search");R("update");R("remove");R("clear");R("export");R("import");la(Q.prototype); -function R(a){Q.prototype[a]=function(){const b=this,c=[].slice.call(arguments);var e=c[c.length-1];let d;"function"===typeof e&&(d=e,c.pop());e=new Promise(function(f){"export"===a&&"function"===typeof c[0]&&(c[0]=null);b.h[++ra]=f;b.worker.postMessage({task:a,id:ra,args:c})});return d?(e.then(d),this):e}} -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="+ka.toString()],{type:"text/javascript"}))):new window.Worker("string"===typeof c?c:(0,eval)("import.meta.url").replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", -"module/worker/worker.js"),{type:"module"})};function ta(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function ua(a,b){b||(b=new Map);for(let c=0,e;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} +this.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function L(a){a.H=null;a.B.clear();a.G.clear()};let M,N;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":N=a.options||{};(b=a.factory)?(Function("return "+b)()(self),M=new self.FlexSearch.Index(N),delete self.FlexSearch):M=new O(N);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=N.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await N.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[b].apply(M,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} +function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);na?pa||(pa=Date.now()-oa>=this.priority*this.priority*3):(na=setTimeout(qa,0),oa=Date.now());if(pa){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let P=0; +function Q(a={}){function b(g){function k(h){h=h.data||h;const l=h.id,n=l&&d.h[l];n&&(n(h.msg),delete d.h[l])}this.worker=g;this.h=B();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++P]=function(){h(d);1E9=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} function S(a){if(!this)return new S(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,k,h;gc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d=[];for(let m=0,q;me)e-= +this.C[h];if((c=l.I)&&!c(b))continue;let n;if("function"===typeof l){n=l(b);if(!n)continue;l=[l.V]}else if(E(l)||l.constructor===String){k[l]=b[l];continue}Da(b,k,l,0,l[0],n)}}this.store.set(a,k||b)}this.worker&&(this.fastupdate||this.reg.add(a))}return this};function Da(a,b,c,e,d,f){a=a[d];if(e===c.length-1)b[d]=f||a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;dc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d=[];for(let m=0,q;me)e-= q.length;else{if(q.length>c||e)q=q.slice(e,c+e),c-=q.length,e&&(e-=q.length);d.push(q);if(!c)break}h=1b?b?a.slice(c,c+b):a.slice(c):a,e?W.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?W.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ga(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};X.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:n,suggest:m}=Ja(this,"and",arguments);return La.call(this,f,g,k,h,l,n,m)}return d?this.resolve(b,c,e):this}; -function La(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Fa(a,b,c,e,g,this.h,f),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};X.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,e,d,f,g)}; -function Ma(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function Na(a,b,c,e,d){const f=[],g=B();let k=0;for(let h=0,l;hb?b?a.slice(c,c+b):a.slice(c):a,e?W.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?W.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Fa(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};X.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:n,suggest:m}=Ia(this,"and",arguments);return Ka.call(this,f,g,k,h,l,n,m)}return d?this.resolve(b,c,e):this}; +function Ka(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Ea(a,b,c,e,g,this.h,f),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};X.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ia(this,"xor",arguments);return La.call(this,a,b,c,e,d,f,g)}; +function La(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Ma.call(this,a,c,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} +function Ma(a,b,c,e,d){const f=[],g=B();let k=0;for(let h=0,l;hc||e)a=a.slice(e,e+c);d&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;cc||e)a=a.slice(e,e+c);d&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -Y.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Y.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:function(a){return a.toLowerCase()}};const Xa=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 Ya=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Za=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const $a={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 ab=/[\x00-\x7F]+/g;const bb=/[\x00-\x7F]+/g;const cb=/[\x00-\x7F]+/g;var db={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Wa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Xa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Xa,matcher:Ya,replacer:Za},LatinExtra:{normalize:!0,dedupe:!0,mapper:Xa,replacer:Za.concat([/(?!^)[aeo]/g,""]),matcher:Ya},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;k--){g=r.substring(f,k);var h=this.score?this.score(b,r,p,g,f):fb(q,e,p,d,f);gb(this,n,g,h,a,c)}break}case "reverse":if(1< -d){for(k=d-1;0g?0:1),e,p,k-1,h-1),v=this.bidirectional&&r>f;gb(this,l,v?f:r,u,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& -(b||this.commit_task.push({del:a}),this.T&&hb(this));return this};function gb(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=B()),b[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):b[c]=1,(h=k.get(c))?k=h:k.set(c,k=h=[]),k=k[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new S(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} -function fb(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};O.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else mb(this.map,a),this.depth&&mb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&hb(this));this.cache&&this.cache.remove(a);return this}; -function mb(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ethis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Y.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Va={normalize:function(a){return a.toLowerCase()}};const Wa=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 Xa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ya=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Za={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 $a=/[\x00-\x7F]+/g;const ab=/[\x00-\x7F]+/g;const bb=/[\x00-\x7F]+/g;var cb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Va,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Wa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Wa,matcher:Xa,replacer:Ya},LatinExtra:{normalize:!0,dedupe:!0,mapper:Wa,replacer:Ya.concat([/(?!^)[aeo]/g,""]),matcher:Xa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;k--){g=r.substring(f,k);var h=this.score?this.score(b,r,p,g,f):eb(q,e,p,d,f);fb(this,n,g,h,a,c)}break}case "reverse":if(1< +d){for(k=d-1;0g?0:1),e,p,k-1,h-1),v=this.bidirectional&&r>f;fb(this,l,v?f:r,u,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& +(b||this.commit_task.push({del:a}),this.T&&gb(this));return this};function fb(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=B()),b[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):b[c]=1,(h=k.get(c))?k=h:k.set(c,k=h=[]),k=k[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new S(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} +function eb(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};O.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else lb(this.map,a),this.depth&&lb(this.ctx,a);b||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,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ec.add(a,b)):this.add(a,b)}; -function nb(a){let b=0;if(a.constructor===Array)for(let c=0,e;c{d.objectStoreNames.contains(f)||d.createObjectStore(f)})};e.onblocked=function(d){console.error("blocked",d);c()};e.onerror=function(d){console.error(this.error,d);c()};e.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; -t.close=function(){this.db.close();this.db=null};t.destroy=function(){const a=ob.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};t.clear=function(){const a=this.db.transaction(pb,"readwrite");for(let b=0;b{d.objectStoreNames.contains(f)||d.createObjectStore(f)})};e.onblocked=function(d){console.error("blocked",d);c()};e.onerror=function(d){console.error(this.error,d);c()};e.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; +t.close=function(){this.db.close();this.db=null};t.destroy=function(){const a=nb.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};t.clear=function(){const a=this.db.transaction(ob,"readwrite");for(let b=0;b=n.length){e-=n.length;continue}const m=c?e+Math.min(n.length-e,c):n.length;for(let q=e;q=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; t.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;en&&!f&&"string"===typeof m&&!isNaN(m)&&(n=h.indexOf(parseInt(m,10)))&&(f=1),0<=n)if(d=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};const tb={Index:O,Charset:db,Encoder:J,Document:V,Worker:Q,Resolver:X,IndexedDB:rb,Language:{}},ub="undefined"!==typeof self?self:"undefined"!==typeof global?global:"undefined"!==typeof window?window:{};let vb;(vb=ub.define)&&vb.amd?vb([],function(){return tb}):"object"===typeof ub.exports?ub.exports=tb:ub.FlexSearch=tb;}(this||self)); +function rb(a,b,c){const e=a.value;let d,f,g=0;for(let k=0,h;kn&&!f&&"string"===typeof m&&!isNaN(m)&&(n=h.indexOf(parseInt(m,10)))&&(f=1),0<=n)if(d=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};const sb={Index:O,Charset:cb,Encoder:J,Document:V,Worker:Q,Resolver:X,IndexedDB:qb,Language:{}},tb="undefined"!==typeof self?self:"undefined"!==typeof global?global:"undefined"!==typeof window?window:{};let ub;(ub=tb.define)&&ub.amd?ub([],function(){return sb}):"object"===typeof tb.exports?tb.exports=sb:tb.FlexSearch=sb;}(this||self)); diff --git a/dist/flexsearch.bundle.module.debug.js b/dist/flexsearch.bundle.module.debug.js index 30316a2..32e88f3 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.115 (Bundle/Module/Debug) + * FlexSearch.js v0.8.117 (Bundle/Module/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -300,29 +300,24 @@ async function ka(a) { } } ;function la(a) { - P.call(a, "add"); - P.call(a, "append"); - P.call(a, "search"); - P.call(a, "update"); - P.call(a, "remove"); + ma.call(a, "add"); + ma.call(a, "append"); + ma.call(a, "search"); + ma.call(a, "update"); + ma.call(a, "remove"); } -let ma, na; -const oa = {}, pa = {}; -function qa(a) { - ma = 0; - oa[a] = pa[a]; +let na, oa, pa; +function qa() { + na = pa = 0; } -function P(a) { +function ma(a) { this[a + "Async"] = function() { const b = arguments; var c = b[b.length - 1]; let e; "function" === typeof c && (e = c, delete b[b.length - 1]); - ma || (ma = setTimeout(qa, 0, a), na = Date.now()); - pa[a] || (pa[a] = oa[a] = 1000); - if (!--oa[a]) { - oa[a] = pa[a] = pa[a] * this.priority * this.priority * 3 / (Date.now() - na) | 0 || 1; - ma = clearTimeout(ma); + 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() { @@ -336,7 +331,7 @@ function P(a) { return c; }; } -;let ra = 0; +;let P = 0; function Q(a = {}) { function b(g) { function k(h) { @@ -350,13 +345,15 @@ function Q(a = {}) { e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { return new Promise(function(h) { - d.h[++ra] = function() { + d.h[++P] = function() { h(d); + 1e9 < P && (P = 0); }; - d.worker.postMessage({id:ra, task:"init", factory:c, options:a}); + d.worker.postMessage({id:P, task:"init", factory:c, options:a}); }); } this.worker.postMessage({task:"init", factory:c, options:a}); + this.priority = a.priority || 4; return this; } } @@ -365,7 +362,7 @@ function Q(a = {}) { } let c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; c && (c = c.toString()); - const e = "undefined" === typeof window, d = this, f = sa(c, e, a.worker); + const e = "undefined" === typeof window, d = this, f = ra(c, e, a.worker); return f.then ? f.then(function(g) { return b.call(d, g); }) : b.call(this, f); @@ -387,17 +384,17 @@ function R(a) { "function" === typeof e && (d = e, c.pop()); e = new Promise(function(f) { "export" === a && "function" === typeof c[0] && (c[0] = null); - b.h[++ra] = f; - b.worker.postMessage({task:a, id:ra, args:c}); + b.h[++P] = f; + b.worker.postMessage({task:a, id:P, args:c}); }); return d ? (e.then(d), this) : e; }; } -function sa(a, b, c) { +function ra(a, b, c) { return b ? "undefined" !== typeof module ? new (require("worker_threads")["Worker"])(__dirname + "/node/node.js") : import("worker_threads").then(function(worker){ return new worker["Worker"](import.meta.dirname + "/node/node.mjs"); }) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } -;function ta(a, b = 0) { +;function sa(a, b = 0) { let c = [], e = []; b && (b = 250000 / b * 5000 | 0); for (const d of a.entries()) { @@ -406,30 +403,30 @@ function sa(a, b, c) { e.length && c.push(e); return c; } -function ua(a, b) { +function ta(a, b) { b || (b = new Map()); for (let c = 0, e; c < a.length; c++) { e = a[c], b.set(e[0], e[1]); } return b; } -function va(a, b = 0) { +function ua(a, b = 0) { let c = [], e = []; b && (b = 250000 / b * 1000 | 0); for (const d of a.entries()) { - e.push([d[0], ta(d[1])[0]]), e.length === b && (c.push(e), e = []); + e.push([d[0], sa(d[1])[0]]), e.length === b && (c.push(e), e = []); } e.length && c.push(e); return c; } -function wa(a, b) { +function va(a, b) { b || (b = new Map()); for (let c = 0, e, d; c < a.length; c++) { - e = a[c], d = b.get(e[0]), b.set(e[0], ua(e[1], d)); + e = a[c], d = b.get(e[0]), b.set(e[0], ta(e[1], d)); } return b; } -function xa(a) { +function wa(a) { let b = [], c = []; for (const e of a.keys()) { c.push(e), 250000 === c.length && (b.push(c), c = []); @@ -437,14 +434,14 @@ function xa(a) { c.length && b.push(c); return b; } -function ya(a, b) { +function xa(a, b) { b || (b = new Set()); for (let c = 0; c < a.length; c++) { b.add(a[c]); } return b; } -function za(a, b, c, e, d, f, g = 0) { +function ya(a, b, c, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { @@ -453,12 +450,12 @@ function za(a, b, c, e, d, f, g = 0) { if ((h = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(h))) && h.then) { const l = this; return h.then(function() { - return za.call(l, a, b, c, k ? e : null, d, f, g + 1); + return ya.call(l, a, b, c, k ? e : null, d, f, g + 1); }); } - return za.call(this, a, b, c, k ? e : null, d, f, g + 1); + return ya.call(this, a, b, c, k ? e : null, d, f, g + 1); } -;function Aa(a, b, c, e) { +;function za(a, b, c, e) { let d = []; for (let f = 0, g; f < a.index.length; f++) { if (g = a.index[f], b >= g.length) { @@ -524,12 +521,12 @@ function S(a) { } if ("slice" === e) { return function(d, f) { - return Aa(b, d || 0, f || b.length, !1); + return za(b, d || 0, f || b.length, !1); }; } if ("splice" === e) { return function(d, f) { - return Aa(b, d || 0, f || b.length, !0); + return za(b, d || 0, f || b.length, !0); }; } if ("constructor" === e) { @@ -560,7 +557,7 @@ function T(a = 8) { this.index = B(); this.B = []; this.size = 0; - 32 < a ? (this.h = Ba, this.A = BigInt(a)) : (this.h = Ca, this.A = a); + 32 < a ? (this.h = Aa, this.A = BigInt(a)) : (this.h = Ba, this.A = a); } T.prototype.get = function(a) { const b = this.index[this.h(a)]; @@ -577,7 +574,7 @@ function U(a = 8) { } this.index = B(); this.h = []; - 32 < a ? (this.B = Ba, this.A = BigInt(a)) : (this.B = Ca, this.A = a); + 32 < a ? (this.B = Aa, this.A = BigInt(a)) : (this.B = Ba, this.A = a); } U.prototype.add = function(a) { var b = this.B(a); @@ -619,7 +616,7 @@ t.entries = U.prototype.entries = function*() { } } }; -function Ca(a) { +function Ba(a) { let b = 2 ** this.A - 1; if ("number" == typeof a) { return a & b; @@ -630,7 +627,7 @@ function Ca(a) { } return 32 === this.A ? c + 2 ** 31 : c; } -function Ba(a) { +function Aa(a) { let b = BigInt(2) ** this.A - BigInt(1); var c = typeof a; if ("bigint" === c) { @@ -660,7 +657,7 @@ function Ba(a) { d && e.add(a, d, !1, !0); } else { if (d = h.I, !d || d(b)) { - h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Da(b, h, this.J, 0, e, a, h[0], c); + h.constructor === String ? h = ["" + h] : E(h) && (h = [h]), Ca(b, h, this.J, 0, e, a, h[0], c); } } } @@ -723,7 +720,7 @@ function Ba(a) { k[l] = b[l]; continue; } - Ea(b, k, l, 0, l[0], n); + Da(b, k, l, 0, l[0], n); } } this.store.set(a, k || b); @@ -732,21 +729,21 @@ function Ba(a) { } return this; }; -function Ea(a, b, c, e, d, f) { +function Da(a, b, c, e, d, f) { a = a[d]; if (e === c.length - 1) { b[d] = f || a; } else if (a) { if (a.constructor === Array) { for (b = b[d] = Array(a.length), d = 0; d < a.length; d++) { - Ea(a, b, c, e, d); + Da(a, b, c, e, d); } } else { - b = b[d] || (b[d] = B()), d = c[++e], Ea(a, b, c, e, d); + b = b[d] || (b[d] = B()), d = c[++e], Da(a, b, c, e, d); } } } -function Da(a, b, c, e, d, f, g, k) { +function Ca(a, b, c, e, d, f, g, k) { if (a = a[g]) { if (e === b.length - 1) { if (a.constructor === Array) { @@ -762,17 +759,17 @@ function Da(a, b, c, e, d, f, g, k) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - Da(a, b, c, e, d, f, g, k); + Ca(a, b, c, e, d, f, g, k); } } else { - g = b[++e], Da(a, b, c, e, d, f, g, k); + g = b[++e], Ca(a, b, c, e, d, f, g, k); } } } else { d.db && d.remove(f); } } -;function Fa(a, b, c, e, d, f, g) { +;function Ea(a, b, c, e, d, f, g) { const k = a.length; let h = [], l; var n; @@ -788,7 +785,7 @@ function Da(a, b, c, e, d, f, g, k) { } if (a = h.length) { if (d) { - h = 1 < h.length ? Ga(h, c, e, g, f) : (h = h[0]).length > c || e ? h.slice(e, c + e) : h; + h = 1 < h.length ? Fa(h, c, e, g, f) : (h = h[0]).length > c || e ? h.slice(e, c + e) : h; } else { if (a < k) { return []; @@ -821,7 +818,7 @@ function Da(a, b, c, e, d, f, g, k) { } return h; } -function Ga(a, b, c, e, d) { +function Fa(a, b, c, e, d) { const f = [], g = B(); let k; var h = a.length; @@ -866,7 +863,7 @@ function Ga(a, b, c, e, d) { } return f; } -function Ha(a, b, c) { +function Ga(a, b, c) { const e = B(), d = []; for (let f = 0, g; f < b.length; f++) { g = b[f]; @@ -887,7 +884,7 @@ function Ha(a, b, c) { } return d; } -;function Ia(a, b, c, e) { +;function Ha(a, b, c, e) { if (!a.length) { return a; } @@ -918,7 +915,7 @@ function Ha(a, b, c) { d = 1 < d.length ? [].concat.apply([], d) : d[0]; return e ? W.call(this, d) : d; } -;function Ja(a, b, c) { +;function Ia(a, b, c) { var e = c[0]; if (e.then) { return Promise.all(c).then(function(n) { @@ -965,10 +962,10 @@ function Ha(a, b, c) { return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; } ;X.prototype.or = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f} = Ja(this, "or", arguments); - return Ka.call(this, a, b, c, e, d, f); + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f} = Ia(this, "or", arguments); + return Ja.call(this, a, b, c, e, d, f); }; -function Ka(a, b, c, e, d, f) { +function Ja(a, b, c, e, d, f) { if (b.length) { const g = this; return Promise.all(b).then(function(k) { @@ -976,10 +973,10 @@ function Ka(a, b, c, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return Ka.call(g, a, [], c, e, d, f); + return Ja.call(g, a, [], c, e, d, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Ga(a, c, e, !1, this.h), e = 0)); + a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = Fa(a, c, e, !1, this.h), e = 0)); return f ? this.resolve(c, e, d) : this; } ;X.prototype.and = function() { @@ -989,11 +986,40 @@ function Ka(a, b, c, e, d, f) { f && (a = !!f.suggest, d = f.resolve, b = f.limit, c = f.offset, e = f.enrich && d); } if (a) { - const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:n, suggest:m} = Ja(this, "and", arguments); - return La.call(this, f, g, k, h, l, n, m); + const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:n, suggest:m} = Ia(this, "and", arguments); + return Ka.call(this, f, g, k, h, l, n, m); } return d ? this.resolve(b, c, e) : this; }; +function Ka(a, b, c, e, d, f, g) { + if (b.length) { + const k = this; + return Promise.all(b).then(function(h) { + a = []; + for (let l = 0, n; l < h.length; l++) { + (n = h[l]).length && (a[l] = n); + } + return Ka.call(k, a, [], c, e, d, f, g); + }); + } + if (a.length) { + if (this.result.length && a.unshift(this.result), 2 > a.length) { + this.result = a[0]; + } else { + if (b = ca(a)) { + return this.result = Ea(a, b, c, e, g, this.h, f), f ? d ? W.call(this.index, this.result) : this.result : this; + } + this.result = []; + } + } else { + g || (this.result = a); + } + return f ? this.resolve(c, e, d) : this; +} +;X.prototype.xor = function() { + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ia(this, "xor", arguments); + return La.call(this, a, b, c, e, d, f, g); +}; function La(a, b, c, e, d, f, g) { if (b.length) { const k = this; @@ -1009,43 +1035,14 @@ function La(a, b, c, e, d, f, g) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - if (b = ca(a)) { - return this.result = Fa(a, b, c, e, g, this.h, f), f ? d ? W.call(this.index, this.result) : this.result : this; - } - this.result = []; + return this.result = Ma.call(this, a, c, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(c, e, d) : this; } -;X.prototype.xor = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "xor", arguments); - return Ma.call(this, a, b, c, e, d, f, g); -}; -function Ma(a, b, c, e, d, f, g) { - if (b.length) { - const k = this; - return Promise.all(b).then(function(h) { - a = []; - for (let l = 0, n; l < h.length; l++) { - (n = h[l]).length && (a[l] = n); - } - return Ma.call(k, a, [], c, e, d, f, g); - }); - } - if (a.length) { - if (this.result.length && a.unshift(this.result), 2 > a.length) { - this.result = a[0]; - } else { - return this.result = Na.call(this, a, c, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; - } - } else { - g || (this.result = a); - } - return f ? this.resolve(c, e, d) : this; -} -function Na(a, b, c, e, d) { +function Ma(a, b, c, e, d) { const f = [], g = B(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -1091,10 +1088,10 @@ function Na(a, b, c, e, d) { return f; } ;X.prototype.not = function() { - const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ja(this, "not", arguments); - return Oa.call(this, a, b, c, e, d, f, g); + const {O:a, P:b, limit:c, offset:e, enrich:d, resolve:f, suggest:g} = Ia(this, "not", arguments); + return Na.call(this, a, b, c, e, d, f, g); }; -function Oa(a, b, c, e, d, f, g) { +function Na(a, b, c, e, d, f, g) { if (b.length) { const k = this; return Promise.all(b).then(function(h) { @@ -1102,17 +1099,17 @@ function Oa(a, b, c, e, d, f, g) { for (let l = 0, n; l < h.length; l++) { (n = h[l]).length && (a[l] = n); } - return Oa.call(k, a, [], c, e, d, f, g); + return Na.call(k, a, [], c, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Pa.call(this, a, c, e, f); + this.result = Oa.call(this, a, c, e, f); } else if (f) { return this.resolve(c, e, d); } return f ? d ? W.call(this.index, this.result) : this.result : this; } -function Pa(a, b, c, e) { +function Oa(a, b, c, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, k = 0; f < this.result.length; f++) { @@ -1187,7 +1184,7 @@ X.prototype.boost = function(a) { X.prototype.resolve = function(a, b, c) { const e = this.result, d = this.index; this.result = this.index = null; - return e.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ia.call(d, e, a || 100, b, c)) : e; + return e.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), Ha.call(d, e, a || 100, b, c)) : e; }; B(); V.prototype.search = function(a, b, c, e) { @@ -1267,7 +1264,7 @@ V.prototype.search = function(a, b, c, e) { } r.push(m = m.db.tag(v[p + 1], b, l, u)); } else { - m = Qa.call(this, v[p], v[p + 1], b, l, u); + m = Pa.call(this, v[p], v[p + 1], b, l, u); } d.push({field:v[p], tag:v[p + 1], result:m}); } @@ -1319,7 +1316,7 @@ V.prototype.search = function(a, b, c, e) { } } } else { - for (let G = 0, K, ob; G < p.length; G += 2) { + for (let G = 0, K, nb; G < p.length; G += 2) { K = this.tag.get(p[G]); if (!K) { if (console.warn("Tag '" + p[G] + ":" + p[G + 1] + "' will be skipped because there is no field '" + p[G] + "'."), r) { @@ -1328,7 +1325,7 @@ V.prototype.search = function(a, b, c, e) { return m ? d : new X(d); } } - if (ob = (K = K && K.get(p[G + 1])) && K.length) { + if (nb = (K = K && K.get(p[G + 1])) && K.length) { y++, x.push(K); } else if (!r) { return m ? d : new X(d); @@ -1336,7 +1333,7 @@ V.prototype.search = function(a, b, c, e) { } } if (y) { - w = Ha(w, x, m); + w = Ga(w, x, m); H = w.length; if (!H && !r) { return m ? w : new X(w); @@ -1390,12 +1387,12 @@ V.prototype.search = function(a, b, c, e) { for (let D = 0; D < w.length; D++) { d[D].result = w[D]; } - return k ? Ra(d, b) : q ? Sa(d, a, z.index, z.field, z.D, q) : d; + return k ? Qa(d, b) : q ? Ra(d, a, z.index, z.field, z.D, q) : d; }); } - return k ? Ra(d, b) : q ? Sa(d, a, this.index, this.field, this.D, q) : d; + return k ? Qa(d, b) : q ? Ra(d, a, this.index, this.field, this.D, q) : d; }; -function Sa(a, b, c, e, d, f) { +function Ra(a, b, c, e, d, f) { let g, k, h; for (let n = 0, m, q, p, r, u; n < a.length; n++) { m = a[n].result; @@ -1437,7 +1434,7 @@ function Sa(a, b, c, e, d, f) { } return a; } -function Ra(a, b) { +function Qa(a, b) { const c = [], e = B(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1456,7 +1453,7 @@ function Ra(a, b) { } return c; } -function Qa(a, b, c, e, d) { +function Pa(a, b, c, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1488,7 +1485,7 @@ function W(a) { this.D = []; this.field = []; this.J = []; - this.key = (c = b.key || b.id) && Ta(c, this.J) || "id"; + this.key = (c = b.key || b.id) && Sa(c, this.J) || "id"; (e = a.keystore || 0) && (this.keystore = e); this.fastupdate = !!a.fastupdate; this.reg = !this.fastupdate || a.worker || a.db ? e ? new U(e) : new Set() : e ? new T(e) : new Map(); @@ -1497,7 +1494,8 @@ function W(a) { this.cache = (c = a.cache || null) && new Y(c); a.cache = !1; this.worker = a.worker; - this.index = Ua.call(this, a, b); + this.priority = a.priority || 4; + this.index = Ta.call(this, a, b); this.tag = null; if (c = b.tag) { if ("string" === typeof c && (c = [c]), c.length) { @@ -1510,7 +1508,7 @@ function W(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.F[d] = f.custom : (this.F[d] = Ta(g, this.J), f.filter && ("string" === typeof this.F[d] && (this.F[d] = new String(this.F[d])), this.F[d].I = f.filter)); + f.custom ? this.F[d] = f.custom : (this.F[d] = Sa(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()); } @@ -1582,7 +1580,7 @@ t.destroy = function() { } return Promise.all(a); }; -function Ua(a, b) { +function Ta(a, b) { const c = new Map(); let e = b.index || b.field || b; E(e) && (e = [e]); @@ -1595,19 +1593,19 @@ function Ua(a, b) { c.set(f, k); } this.worker || c.set(f, new O(g, this.reg)); - g.custom ? this.D[d] = g.custom : (this.D[d] = Ta(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); + g.custom ? this.D[d] = g.custom : (this.D[d] = Sa(f, this.J), g.filter && ("string" === typeof this.D[d] && (this.D[d] = new String(this.D[d])), this.D[d].I = g.filter)); this.field[d] = f; } if (this.C) { a = b.store; E(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = 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)); + f = a[d], g = f.field || f, f.custom ? (this.C[d] = f.custom, f.custom.V = g) : (this.C[d] = Sa(g, this.J), f.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = f.filter)); } } return c; } -function Ta(a, b) { +function Sa(a, b) { const c = a.split(":"); let e = 0; for (let d = 0; d < c.length; d++) { @@ -1673,7 +1671,7 @@ t.set = function(a, b) { this.store.set(a, b); return this; }; -t.searchCache = Va; +t.searchCache = Ua; t.export = function(a, b, c = 0, e = 0) { if (c < this.field.length) { const g = this.field[c]; @@ -1689,27 +1687,23 @@ t.export = function(a, b, c = 0, e = 0) { switch(e) { case 0: d = "reg"; - f = xa(this.reg); + f = wa(this.reg); b = null; break; case 1: d = "tag"; - f = va(this.tag, this.reg.size); + f = this.tag && ua(this.tag, this.reg.size); b = null; break; case 2: d = "doc"; - f = ta(this.store); + f = this.store && sa(this.store); b = null; break; - case 3: - d = "cfg"; - b = f = null; - break; default: return; } - return za.call(this, a, b, d, f, c, e); + return ya.call(this, a, b, d, f, c, e); }; t.import = function(a, b) { var c = a.split("."); @@ -1727,7 +1721,7 @@ t.import = function(a, b) { switch(c) { case "reg": this.fastupdate = !1; - this.reg = ya(b, this.reg); + this.reg = xa(b, 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; } @@ -1740,15 +1734,15 @@ t.import = function(a, b) { } break; case "tag": - this.tag = wa(b, this.tag); + this.tag = va(b, this.tag); break; case "doc": - this.store = ua(b, this.store); + this.store = ta(b, this.store); } } }; la(V.prototype); -function Va(a, b, c) { +function Ua(a, b, c) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Y()); let e = this.cache.get(a); @@ -1789,31 +1783,31 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Wa = {normalize:function(a) { +const Va = {normalize:function(a) { return a.toLowerCase(); }}; -const Xa = 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 Ya = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Za = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -const $a = {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 Wa = 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 Xa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Ya = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const Za = {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 $a = /[\x00-\x7F]+/g; const ab = /[\x00-\x7F]+/g; const bb = /[\x00-\x7F]+/g; -const cb = /[\x00-\x7F]+/g; -var db = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Wa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Xa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Xa, matcher:Ya, replacer:Za}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Xa, replacer:Za.concat([/(?!^)[aeo]/g, ""]), matcher:Ya}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +var cb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Va, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Wa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Wa, matcher:Xa, replacer:Ya}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Wa, replacer:Ya.concat([/(?!^)[aeo]/g, ""]), matcher:Xa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let c = 0; c < a.length; c++) { var b = a[c]; - let e = b.charAt(0), d = $a[e]; - for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = $a[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = b.charAt(0), d = Za[e]; + for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = Za[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[c] = e; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(ab, " "); + return ("" + a).replace($a, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(bb, ""); + return ("" + a).replace(ab, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(cb, " "); + return ("" + a).replace(bb, " "); }}}; -const eb = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +const db = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; O.prototype.add = function(a, b, c, e) { if (b && (a || 0 === a)) { if (!e && !c && this.reg.has(a)) { @@ -1826,15 +1820,15 @@ O.prototype.add = function(a, b, c, e) { let r = b[this.rtl ? e - 1 - p : p]; var d = r.length; if (d && (m || !n[r])) { - var f = this.score ? this.score(b, r, p, null, 0) : fb(q, e, p), g = ""; + var f = this.score ? this.score(b, r, p, null, 0) : eb(q, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { for (f = 0; f < d; f++) { for (var k = d; k > f; k--) { g = r.substring(f, k); - var h = this.score ? this.score(b, r, p, g, f) : fb(q, e, p, d, f); - gb(this, n, g, h, a, c); + var h = this.score ? this.score(b, r, p, g, f) : eb(q, e, p, d, f); + fb(this, n, g, h, a, c); } } break; @@ -1842,24 +1836,24 @@ O.prototype.add = function(a, b, c, e) { case "reverse": if (1 < d) { for (k = d - 1; 0 < k; k--) { - g = r[k] + g, h = this.score ? this.score(b, r, p, g, k) : fb(q, e, p, d, k), gb(this, n, g, h, a, c); + g = r[k] + g, h = this.score ? this.score(b, r, p, g, k) : eb(q, e, p, d, k), fb(this, n, g, h, a, c); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += r[k], gb(this, n, g, f, a, c); + g += r[k], fb(this, n, g, f, a, c); } break; } default: - if (gb(this, n, r, f, a, c), m && 1 < e && p < e - 1) { + if (fb(this, n, r, f, a, c), m && 1 < e && p < e - 1) { for (d = B(), g = this.U, f = r, k = Math.min(m + 1, e - p), d[f] = 1, h = 1; h < k; h++) { if ((r = b[this.rtl ? e - 1 - p - h : p + h]) && !d[r]) { d[r] = 1; - const u = this.score ? this.score(b, f, p, r, h) : fb(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), v = this.bidirectional && r > f; - gb(this, l, v ? f : r, u, a, c, v ? r : f); + const u = this.score ? this.score(b, f, p, r, h) : 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, c, v ? r : f); } } } @@ -1871,10 +1865,10 @@ O.prototype.add = function(a, b, c, e) { b = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.T && hb(this)); + this.db && (b || this.commit_task.push({del:a}), this.T && gb(this)); return this; }; -function gb(a, b, c, e, d, f, g) { +function fb(a, b, c, e, d, f, g) { let k = g ? a.ctx : a.map, h; if (!b[c] || g && !(h = b[c])[g]) { if (g ? (b = h || (b[c] = B()), b[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : b[c] = 1, (h = k.get(c)) ? k = h : k.set(c, k = h = []), k = k[e] || (k[e] = []), !f || !k.includes(d)) { @@ -1892,7 +1886,7 @@ function gb(a, b, c, e, d, f, g) { } } } -function fb(a, b, c, e, d) { +function eb(a, b, c, e, d) { return c && 1 < a ? b + (e || 0) <= a ? c + (d || 0) : (a - 1) / (b + (e || 0)) * (c + (d || 0)) + 1 | 0 : 0; } ;O.prototype.search = function(a, b, c) { @@ -1903,11 +1897,11 @@ function fb(a, b, c, e, d) { d = p.length; b = b || (h ? 100 : 0); if (1 === d) { - return ib.call(this, p[0], "", b, k, h, q, l); + return hb.call(this, p[0], "", b, k, h, q, l); } f = this.depth && !1 !== f; if (2 === d && f && !g) { - return ib.call(this, p[0], p[1], b, k, h, q, l); + return hb.call(this, p[0], p[1], b, k, h, q, l); } let r = B(), u = 0, v; 1 < d && f && (v = p[0], u = 1); @@ -1921,8 +1915,8 @@ function fb(a, b, c, e, d) { for (let y, F; u < d; u++) { if ((F = p[u]) && !r[F]) { r[F] = 1; - y = await jb(x, F, v, 0, 0, !1, !1); - if (y = kb(y, e, g, m)) { + y = await ib(x, F, v, 0, 0, !1, !1); + if (y = jb(y, e, g, m)) { e = y; break; } @@ -1930,14 +1924,14 @@ function fb(a, b, c, e, d) { } g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); } - return lb(e, m, b, k, g, n, h); + return kb(e, m, b, k, g, n, h); }(); } for (let x, y; u < d; u++) { if ((y = p[u]) && !r[y]) { r[y] = 1; - x = jb(this, y, v, 0, 0, !1, !1); - if (x = kb(x, e, g, m)) { + x = ib(this, y, v, 0, 0, !1, !1); + if (x = jb(x, e, g, m)) { e = x; break; } @@ -1945,24 +1939,24 @@ function fb(a, b, c, e, d) { } g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); } - return lb(e, m, b, k, g, n, h); + return kb(e, m, b, k, g, n, h); }; -function lb(a, b, c, e, d, f, g) { +function kb(a, b, c, e, d, f, g) { let k = a.length, h = a; if (1 < k) { - h = Fa(a, b, c, e, d, f, g); + h = Ea(a, b, c, e, d, f, g); } else if (1 === k) { - return g ? Ia.call(null, a[0], c, e) : new X(a[0]); + return g ? Ha.call(null, a[0], c, e) : new X(a[0]); } return g ? h : new X(h); } -function ib(a, b, c, e, d, f, g) { - a = jb(this, a, b, c, e, d, f, g); +function hb(a, b, c, e, d, f, g) { + a = ib(this, a, b, c, e, d, f, g); return this.db ? a.then(function(k) { return d ? k || [] : new X(k); - }) : a && a.length ? d ? Ia.call(this, a, c, e) : new X(a) : d ? [] : new X(); + }) : a && a.length ? d ? Ha.call(this, a, c, e) : new X(a) : d ? [] : new X(); } -function kb(a, b, c, e) { +function jb(a, b, c, e) { let d = []; if (a && a.length) { if (a.length <= e) { @@ -1983,7 +1977,7 @@ function kb(a, b, c, e) { return d; } } -function jb(a, b, c, e, d, f, g, k) { +function ib(a, b, c, e, d, f, g, k) { let h; c && (h = a.bidirectional && b > c) && (h = c, c = b, b = h); if (a.db) { @@ -2007,15 +2001,15 @@ function jb(a, b, c, e, d, f, g, k) { } } } else { - mb(this.map, a), this.depth && mb(this.ctx, a); + lb(this.map, a), this.depth && lb(this.ctx, a); } b || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.T && hb(this)); + this.db && (this.commit_task.push({del:a}), this.T && gb(this)); this.cache && this.cache.remove(a); return this; }; -function mb(a, b) { +function lb(a, b) { let c = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -2030,7 +2024,7 @@ function mb(a, b) { } } else { for (let e of a.entries()) { - const d = e[0], f = mb(e[1], b); + const d = e[0], f = lb(e[1], b); f ? c += f : a.delete(d); } } @@ -2042,12 +2036,12 @@ function mb(a, b) { } if (a) { var c = E(a) ? a : a.preset; - c && (eb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, eb[c], a)); + c && (db[c] || console.warn("Preset not found: " + c), a = Object.assign({}, db[c], a)); } else { a = {}; } c = a.context; - const e = !0 === c ? {depth:1} : c || {}, d = E(a.encoder) ? db[a.encoder] : a.encode || a.encoder || Wa; + const e = !0 === c ? {depth:1} : c || {}, d = E(a.encoder) ? cb[a.encoder] : a.encode || a.encoder || Va; this.encoder = d.encode ? d : "object" === typeof d ? new J(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = (c = a.tokenize) && "default" !== c && c || "strict"; @@ -2084,11 +2078,11 @@ t.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function hb(a) { +function gb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); - }, 0)); + }, 1)); } t.clear = function() { this.map.clear(); @@ -2108,7 +2102,7 @@ t.update = function(a, b) { const c = this, e = this.remove(a); return e && e.then ? e.then(() => c.add(a, b)) : this.add(a, b); }; -function nb(a) { +function mb(a) { let b = 0; if (a.constructor === Array) { for (let c = 0, e; c < a.length; c++) { @@ -2116,7 +2110,7 @@ function nb(a) { } } else { for (const c of a) { - const e = c[0], d = nb(c[1]); + const e = c[0], d = mb(c[1]); d ? b += d : a.delete(e); } } @@ -2126,17 +2120,17 @@ t.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - nb(this.map); - this.depth && nb(this.ctx); + mb(this.map); + this.depth && mb(this.ctx); return this; }; -t.searchCache = Va; +t.searchCache = Ua; t.export = function(a, b, c = 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"; @@ -2144,29 +2138,29 @@ t.export = function(a, b, c = 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, b, d, f, c, e); + return ya.call(this, a, b, d, f, c, e); }; t.import = function(a, b) { if (b) { switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": this.fastupdate = !1; - this.reg = ya(b, this.reg); + this.reg = xa(b, this.reg); break; case "map": - this.map = ua(b, this.map); + this.map = ta(b, this.map); break; case "ctx": - this.ctx = wa(b, this.ctx); + this.ctx = va(b, this.ctx); } } }; @@ -2221,10 +2215,10 @@ t.serialize = function(a = !0) { return a ? "function inject(index){" + b + e + d + "}" : b + e + d; }; la(O.prototype); -const pb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), qb = ["map", "ctx", "tag", "reg", "cfg"]; -function rb(a, b = {}) { +const ob = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), pb = ["map", "ctx", "tag", "reg", "cfg"]; +function qb(a, b = {}) { if (!this) { - return new rb(a, b); + return new qb(a, b); } "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -2235,7 +2229,7 @@ function rb(a, b = {}) { this.db = null; this.h = {}; } -t = rb.prototype; +t = qb.prototype; t.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -2247,10 +2241,10 @@ t.open = function() { let a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { - const e = pb.open(a.id + (a.field ? ":" + a.field : ""), 1); + const e = ob.open(a.id + (a.field ? ":" + a.field : ""), 1); e.onupgradeneeded = function() { const d = a.db = this.result; - qb.forEach(f => { + pb.forEach(f => { d.objectStoreNames.contains(f) || d.createObjectStore(f); }); }; @@ -2276,13 +2270,13 @@ t.close = function() { this.db = null; }; t.destroy = function() { - const a = pb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); + const a = ob.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); return Z(a); }; t.clear = function() { - const a = this.db.transaction(qb, "readwrite"); - for (let b = 0; b < qb.length; b++) { - a.objectStore(qb[b]).clear(); + const a = this.db.transaction(pb, "readwrite"); + for (let b = 0; b < pb.length; b++) { + a.objectStore(pb[b]).clear(); } return Z(a); }; @@ -2467,7 +2461,7 @@ t.commit = async function(a, b, c) { } }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear()); }; -function sb(a, b, c) { +function rb(a, b, c) { const e = a.value; let d, f, g = 0; for (let k = 0, h; k < e.length; k++) { @@ -2496,17 +2490,17 @@ t.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && sb(c, a); + c && rb(c, a); }; }), this.transaction("ctx", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && sb(c, a); + c && rb(c, a); }; }), this.transaction("tag", "readwrite", function(b) { b.openCursor().onsuccess = function() { const c = this.result; - c && sb(c, a, !0); + c && rb(c, a, !0); }; }), this.transaction("reg", "readwrite", function(b) { for (let c = 0; c < a.length; c++) { @@ -2526,6 +2520,6 @@ function Z(a) { a = null; }); } -;export default {Index:O, Charset:db, Encoder:J, Document:V, Worker:Q, Resolver:X, IndexedDB:rb, Language:{}}; +;export default {Index:O, Charset:cb, Encoder:J, Document:V, Worker:Q, Resolver:X, IndexedDB:qb, Language:{}}; -export const Index=O;export const Charset=db;export const Encoder=J;export const Document=V;export const Worker=Q;export const Resolver=X;export const IndexedDB=rb;export const Language={}; \ No newline at end of file +export const Index=O;export const Charset=cb;export const Encoder=J;export const Document=V;export const Worker=Q;export const Resolver=X;export const IndexedDB=qb;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 a9f9e06..201c2d6 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.115 (Bundle/Module) + * FlexSearch.js v0.8.117 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -21,73 +21,73 @@ t.addMatcher=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);i t.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ja?a.normalize("NFKD").replace(ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),g.lengththis.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&d -this.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function L(a){a.H=null;a.B.clear();a.G.clear()};let M,N;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":N=a.options||{};(b=a.factory)?(Function("return "+b)()(self),M=new self.FlexSearch.Index(N),delete self.FlexSearch):M=new O(N);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=N.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await N.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[b].apply(M,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}let ma,na;const oa={},pa={};function qa(a){ma=0;oa[a]=pa[a]} -function P(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);ma||(ma=setTimeout(qa,0,a),na=Date.now());pa[a]||(pa[a]=oa[a]=1E3);if(!--oa[a]){oa[a]=pa[a]=pa[a]*this.priority*this.priority*3/(Date.now()-na)|0||1;ma=clearTimeout(ma);const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let ra=0; -function Q(a={}){function b(g){function k(h){h=h.data||h;const l=h.id,n=l&&d.h[l];n&&(n(h.msg),delete d.h[l])}this.worker=g;this.h=B();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++ra]=function(){h(d)};d.worker.postMessage({id:ra,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==Q)return new Q(a);let c="undefined"!==typeof self?self._factory:"undefined"!== -typeof window?window._factory:null;c&&(c=c.toString());const e="undefined"===typeof window,d=this,f=sa(c,e,a.worker);return f.then?f.then(function(g){return b.call(d,g)}):b.call(this,f)}R("add");R("append");R("search");R("update");R("remove");R("clear");R("export");R("import");la(Q.prototype); -function R(a){Q.prototype[a]=function(){const b=this,c=[].slice.call(arguments);var e=c[c.length-1];let d;"function"===typeof e&&(d=e,c.pop());e=new Promise(function(f){"export"===a&&"function"===typeof c[0]&&(c[0]=null);b.h[++ra]=f;b.worker.postMessage({task:a,id:ra,args:c})});return d?(e.then(d),this):e}} -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"](import.meta.dirname + "/node/node.mjs"); }):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ka.toString()],{type:"text/javascript"}))):new window.Worker("string"===typeof c?c:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", -"module/worker/worker.js"),{type:"module"})};function ta(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function ua(a,b){b||(b=new Map);for(let c=0,e;c=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} +this.S&&(this.G.clear(),this.L=this.L/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.K&&(this.B.set(a,c),this.B.size>this.S&&(this.B.clear(),this.K=this.K/1.1|0));return c};function L(a){a.H=null;a.B.clear();a.G.clear()};let M,N;async function ka(a){a=a.data;var b=a.task;const c=a.id;let e=a.args;switch(b){case "init":N=a.options||{};(b=a.factory)?(Function("return "+b)()(self),M=new self.FlexSearch.Index(N),delete self.FlexSearch):M=new O(N);postMessage({id:c});break;default:let d;"export"===b&&(e[1]?(e[0]=N.export,e[2]=0,e[3]=1):e=null);"import"===b?e[0]&&(a=await N.import.call(M,e[0]),M.import(e[0],a)):(d=e&&M[b].apply(M,e))&&d.then&&(d=await d);postMessage("search"===b?{id:c,msg:d}:{id:c})}};function la(a){ma.call(a,"add");ma.call(a,"append");ma.call(a,"search");ma.call(a,"update");ma.call(a,"remove")}let na,oa,pa;function qa(){na=pa=0} +function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);na?pa||(pa=Date.now()-oa>=this.priority*this.priority*3):(na=setTimeout(qa,0),oa=Date.now());if(pa){const f=this;return new Promise(g=>{setTimeout(function(){g(f[a+"Async"].apply(f,b))},0)})}const d=this[a].apply(this,b);c=d.then?d:new Promise(f=>f(d));e&&c.then(e);return c}};let P=0; +function Q(a={}){function b(g){function k(h){h=h.data||h;const l=h.id,n=l&&d.h[l];n&&(n(h.msg),delete d.h[l])}this.worker=g;this.h=B();if(this.worker){e?this.worker.on("message",k):this.worker.onmessage=k;if(a.config)return new Promise(function(h){d.h[++P]=function(){h(d);1E9=g.length)b-=g.length;else{b=g[e?"splice":"slice"](b,c);const k=b.length;if(k&&(d=d.length?d.concat(b):b,c-=k,e&&(a.length-=k),!c))break;b=0}return d} function S(a){if(!this)return new S(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(c,e){if("length"===e)return b.length;if("push"===e)return function(d){b.index[b.index.length-1].push(d);b.length++};if("pop"===e)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===e)return function(d){let f=0;for(let g=0,k,h;gc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d=[];for(let m=0,q;me)e-= +this.C[h];if((c=l.I)&&!c(b))continue;let n;if("function"===typeof l){n=l(b);if(!n)continue;l=[l.V]}else if(E(l)||l.constructor===String){k[l]=b[l];continue}Da(b,k,l,0,l[0],n)}}this.store.set(a,k||b)}this.worker&&(this.fastupdate||this.reg.add(a))}return this};function Da(a,b,c,e,d,f){a=a[d];if(e===c.length-1)b[d]=f||a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;dc||e?h.slice(e,c+e):h;else{if(ac||e)h=h.slice(e,c+e)}else{d=[];for(let m=0,q;me)e-= q.length;else{if(q.length>c||e)q=q.slice(e,c+e),c-=q.length,e&&(e-=q.length);d.push(q);if(!c)break}h=1b?b?a.slice(c,c+b):a.slice(c):a,e?W.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?W.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Ga(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};X.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:n,suggest:m}=Ja(this,"and",arguments);return La.call(this,f,g,k,h,l,n,m)}return d?this.resolve(b,c,e):this}; -function La(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Fa(a,b,c,e,g,this.h,f),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};X.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ja(this,"xor",arguments);return Ma.call(this,a,b,c,e,d,f,g)}; -function Ma(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Na.call(this,a,c,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} -function Na(a,b,c,e,d){const f=[],g=B();let k=0;for(let h=0,l;hb?b?a.slice(c,c+b):a.slice(c):a,e?W.call(this,a):a;let d=[];for(let f=0,g,k;f=k){c-=k;continue}cb&&(g=g.slice(0,b),k=b);if(!d.length&&k>=b)return e?W.call(this,g):g;d.push(g);b-=k;if(!b)break}d=1a.length?this.result=a[0]:(this.result=Fa(a,c,e,!1,this.h),e=0));return f?this.resolve(c,e,d):this};X.prototype.and=function(){let a=this.result.length,b,c,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,b=f.limit,c=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:n,suggest:m}=Ia(this,"and",arguments);return Ka.call(this,f,g,k,h,l,n,m)}return d?this.resolve(b,c,e):this}; +function Ka(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else{if(b=ca(a))return this.result=Ea(a,b,c,e,g,this.h,f),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(c,e,d):this};X.prototype.xor=function(){const {O:a,P:b,limit:c,offset:e,enrich:d,resolve:f,suggest:g}=Ia(this,"xor",arguments);return La.call(this,a,b,c,e,d,f,g)}; +function La(a,b,c,e,d,f,g){if(b.length){const k=this;return Promise.all(b).then(function(h){a=[];for(let l=0,n;la.length)this.result=a[0];else return this.result=Ma.call(this,a,c,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(c,e,d):this} +function Ma(a,b,c,e,d){const f=[],g=B();let k=0;for(let h=0,l;hc||e)a=a.slice(e,e+c);d&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;cc||e)a=a.slice(e,e+c);d&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const b=Array(a.length);for(let c=0,e;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -Y.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Y.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Wa={normalize:function(a){return a.toLowerCase()}};const Xa=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 Ya=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Za=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const $a={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 ab=/[\x00-\x7F]+/g;const bb=/[\x00-\x7F]+/g;const cb=/[\x00-\x7F]+/g;var db={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Wa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Xa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Xa,matcher:Ya,replacer:Za},LatinExtra:{normalize:!0,dedupe:!0,mapper:Xa,replacer:Za.concat([/(?!^)[aeo]/g,""]),matcher:Ya},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;k--){g=r.substring(f,k);var h=this.score?this.score(b,r,p,g,f):fb(q,e,p,d,f);gb(this,n,g,h,a,c)}break}case "reverse":if(1< -d){for(k=d-1;0g?0:1),e,p,k-1,h-1),v=this.bidirectional&&r>f;gb(this,l,v?f:r,u,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& -(b||this.commit_task.push({del:a}),this.T&&hb(this));return this};function gb(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=B()),b[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):b[c]=1,(h=k.get(c))?k=h:k.set(c,k=h=[]),k=k[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new S(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} -function fb(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};O.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else mb(this.map,a),this.depth&&mb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&hb(this));this.cache&&this.cache.remove(a);return this}; -function mb(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ethis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};Y.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Va={normalize:function(a){return a.toLowerCase()}};const Wa=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 Xa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ya=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Za={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 $a=/[\x00-\x7F]+/g;const ab=/[\x00-\x7F]+/g;const bb=/[\x00-\x7F]+/g;var cb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Va,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Wa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Wa,matcher:Xa,replacer:Ya},LatinExtra:{normalize:!0,dedupe:!0,mapper:Wa,replacer:Ya.concat([/(?!^)[aeo]/g,""]),matcher:Xa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cf;k--){g=r.substring(f,k);var h=this.score?this.score(b,r,p,g,f):eb(q,e,p,d,f);fb(this,n,g,h,a,c)}break}case "reverse":if(1< +d){for(k=d-1;0g?0:1),e,p,k-1,h-1),v=this.bidirectional&&r>f;fb(this,l,v?f:r,u,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& +(b||this.commit_task.push({del:a}),this.T&&gb(this));return this};function fb(a,b,c,e,d,f,g){let k=g?a.ctx:a.map,h;if(!b[c]||g&&!(h=b[c])[g])if(g?(b=h||(b[c]=B()),b[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):b[c]=1,(h=k.get(c))?k=h:k.set(c,k=h=[]),k=k[e]||(k[e]=[]),!f||!k.includes(d)){if(k.length===2**31-1){b=new S(k);if(a.fastupdate)for(let l of a.reg.values())l.includes(k)&&(l[l.indexOf(k)]=b);h[e]=k=b}k.push(d);a.fastupdate&&((e=a.reg.get(d))?e.push(k):a.reg.set(d,[k]))}} +function eb(a,b,c,e,d){return c&&1c)&&(h=c,c=b,b=h);if(a.db)return a.db.get(b,c,e,d,f,g,k);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};O.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===c.length-1?d.pop():d.splice(f,1)}}else lb(this.map,a),this.depth&&lb(this.ctx,a);b||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,b){let c=0;if(a.constructor===Array)for(let e=0,d,f;ec.add(a,b)):this.add(a,b)}; -function ob(a){let b=0;if(a.constructor===Array)for(let c=0,e;c{d.objectStoreNames.contains(f)||d.createObjectStore(f)})};e.onblocked=function(d){console.error("blocked",d);c()};e.onerror=function(d){console.error(this.error,d);c()};e.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; -t.close=function(){this.db.close();this.db=null};t.destroy=function(){const a=pb.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};t.clear=function(){const a=this.db.transaction(qb,"readwrite");for(let b=0;b{d.objectStoreNames.contains(f)||d.createObjectStore(f)})};e.onblocked=function(d){console.error("blocked",d);c()};e.onerror=function(d){console.error(this.error,d);c()};e.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; +t.close=function(){this.db.close();this.db=null};t.destroy=function(){const a=ob.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};t.clear=function(){const a=this.db.transaction(pb,"readwrite");for(let b=0;b=n.length){e-=n.length;continue}const m=c?e+Math.min(n.length-e,c):n.length;for(let q=e;q=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return e?d.enrich(f):f})}; t.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;en&&!f&&"string"===typeof m&&!isNaN(m)&&(n=h.indexOf(parseInt(m,10)))&&(f=1),0<=n)if(d=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};export default {Index:O,Charset:db,Encoder:J,Document:V,Worker:Q,Resolver:X,IndexedDB:rb,Language:{}}; -export const Index=O;export const Charset=db;export const Encoder=J;export const Document=V;export const Worker=Q;export const Resolver=X;export const IndexedDB=rb;export const Language={}; \ No newline at end of file +function rb(a,b,c){const e=a.value;let d,f,g=0;for(let k=0,h;kn&&!f&&"string"===typeof m&&!isNaN(m)&&(n=h.indexOf(parseInt(m,10)))&&(f=1),0<=n)if(d=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};export default {Index:O,Charset:cb,Encoder:J,Document:V,Worker:Q,Resolver:X,IndexedDB:qb,Language:{}}; +export const Index=O;export const Charset=cb;export const Encoder=J;export const Document=V;export const Worker=Q;export const Resolver=X;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 8f1703e..7625b2d 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.115 (Bundle/Debug) + * FlexSearch.js v0.8.117 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -300,11 +300,9 @@ async function ia(a) { P.call(a, "update"); P.call(a, "remove"); } -let Q, ka; -const R = {}, S = {}; -function la(a) { - Q = 0; - R[a] = S[a]; +let ka, la, Q; +function ma() { + ka = Q = 0; } function P(a) { this[a + "Async"] = function() { @@ -312,11 +310,8 @@ function P(a) { var b = c[c.length - 1]; let e; "function" === typeof b && (e = b, delete c[c.length - 1]); - Q || (Q = setTimeout(la, 0, a), ka = Date.now()); - S[a] || (S[a] = R[a] = 1000); - if (!--R[a]) { - R[a] = S[a] = S[a] * this.priority * this.priority * 3 / (Date.now() - ka) | 0 || 1; - Q = clearTimeout(Q); + 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() { @@ -330,8 +325,8 @@ function P(a) { return b; }; } -;let T = 0; -function ma(a = {}) { +;let R = 0; +function S(a = {}) { function c(g) { function k(h) { h = h.data || h; @@ -344,18 +339,20 @@ function ma(a = {}) { e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { return new Promise(function(h) { - d.h[++T] = function() { + d.h[++R] = function() { h(d); + 1e9 < R && (R = 0); }; - d.worker.postMessage({id:T, task:"init", factory:b, options:a}); + d.worker.postMessage({id:R, task:"init", factory:b, options:a}); }); } this.worker.postMessage({task:"init", factory:b, options:a}); + this.priority = a.priority || 4; return this; } } - if (!this || this.constructor !== ma) { - return new ma(a); + if (!this || this.constructor !== S) { + return new S(a); } let b = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; b && (b = b.toString()); @@ -364,25 +361,25 @@ function ma(a = {}) { return c.call(d, g); }) : c.call(this, f); } -U("add"); -U("append"); -U("search"); -U("update"); -U("remove"); -U("clear"); -U("export"); -U("import"); -ja(ma.prototype); -function U(a) { - ma.prototype[a] = function() { +T("add"); +T("append"); +T("search"); +T("update"); +T("remove"); +T("clear"); +T("export"); +T("import"); +ja(S.prototype); +function T(a) { + S.prototype[a] = function() { const c = this, b = [].slice.call(arguments); var e = b[b.length - 1]; let d; "function" === typeof e && (d = e, b.pop()); e = new Promise(function(f) { "export" === a && "function" === typeof b[0] && (b[0] = null); - c.h[++T] = f; - c.worker.postMessage({task:a, id:T, args:b}); + c.h[++R] = f; + c.worker.postMessage({task:a, id:R, args:b}); }); return d ? (e.then(d), this) : e; }; @@ -438,7 +435,7 @@ function ta(a, c) { } return c; } -function ua(a, c, b, e, d, f, g = 0) { +function U(a, c, b, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { @@ -447,10 +444,10 @@ function ua(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 ua.call(l, a, c, b, k ? e : null, d, f, g + 1); + return U.call(l, a, c, b, k ? e : null, d, f, g + 1); }); } - return ua.call(this, a, c, b, k ? e : null, d, f, g + 1); + return U.call(this, a, c, b, k ? e : null, d, f, g + 1); } ;V.prototype.add = function(a, c, b) { I(a) && (c = a, a = J(c, this.key)); @@ -466,7 +463,7 @@ function ua(a, c, b, e, d, f, g = 0) { 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); } } } @@ -517,7 +514,7 @@ function ua(a, c, b, e, d, f, g = 0) { 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); @@ -525,21 +522,21 @@ function ua(a, c, b, e, d, f, g = 0) { } 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) { @@ -555,15 +552,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(); @@ -578,7 +575,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 []; @@ -593,7 +590,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; @@ -615,7 +612,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]; @@ -628,7 +625,7 @@ function za(a, c) { } return e; } -;function Aa(a, c, b, e) { +;function za(a, c, b, e) { if (!a.length) { return a; } @@ -659,7 +656,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) { @@ -706,10 +703,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) { @@ -717,10 +714,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() { @@ -730,11 +727,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; @@ -750,43 +776,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++) { @@ -832,10 +829,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) { @@ -843,17 +840,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++) { @@ -928,7 +925,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) { @@ -989,7 +986,7 @@ V.prototype.search = function(a, c, b, e) { e = []; if (u.length) { for (f = 0; f < u.length; f += 2) { - y = Ia.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:y}); + y = Ha.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:y}); } } return e.length ? Promise.all(e).then(function(x) { @@ -1023,7 +1020,7 @@ V.prototype.search = function(a, c, b, e) { if (m && F) { v = []; z = 0; - for (let G = 0, H, Za; G < m.length; G += 2) { + for (let G = 0, H, Ya; G < m.length; G += 2) { H = this.tag.get(m[G]); if (!H) { if (console.warn("Tag '" + m[G] + ":" + m[G + 1] + "' will be skipped because there is no field '" + m[G] + "'."), h) { @@ -1032,14 +1029,14 @@ V.prototype.search = function(a, c, b, e) { return p ? d : new X(d); } } - if (Za = (H = H && H.get(m[G + 1])) && H.length) { + if (Ya = (H = H && H.get(m[G + 1])) && H.length) { z++, v.push(H); } else if (!h) { return p ? d : new X(d); } } if (z) { - r = za(r, v); + r = ya(r, v); F = r.length; if (!F && !h) { return p ? r : new X(r); @@ -1074,9 +1071,9 @@ V.prototype.search = function(a, c, b, e) { } d[x] = {field:f[x], result:r}; } - return k ? Ja(d, c) : q ? Ka(d, a, this.index, this.field, this.C, q) : d; + return k ? Ia(d, c) : q ? Ja(d, a, this.index, this.field, this.C, q) : 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, t, p, q, y; m < a.length; m++) { n = a[m].result; @@ -1118,7 +1115,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]; @@ -1137,7 +1134,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"), []; @@ -1169,23 +1166,24 @@ 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(); this.cache = (b = a.cache || null) && new Y(b); a.cache = !1; + this.priority = a.priority || 4; b = new Map(); let e = c.index || c.field || c; D(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], 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; @@ -1201,14 +1199,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++) { @@ -1273,7 +1271,7 @@ w.set = function(a, c) { this.store.set(a, c); return this; }; -w.searchCache = Ma; +w.searchCache = La; w.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1294,22 +1292,18 @@ w.export = function(a, c, b = 0, e = 0) { break; case 1: d = "tag"; - f = qa(this.tag, this.reg.size); + f = this.tag && qa(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = oa(this.store); + f = this.store && oa(this.store); c = null; break; - case 3: - d = "cfg"; - c = f = null; - break; default: return; } - return ua.call(this, a, c, d, f, b, e); + return U.call(this, a, c, d, f, b, e); }; w.import = function(a, c) { var b = a.split("."); @@ -1338,7 +1332,7 @@ w.import = function(a, c) { } }; ja(V.prototype); -function Ma(a, c, b) { +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); @@ -1379,31 +1373,31 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Na = {normalize:function(a) { +const Ma = {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"], ["pf", "f"]]), Qa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\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 Na = 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 Oa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Pa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const Qa = {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 Ra = /[\x00-\x7F]+/g; const Sa = /[\x00-\x7F]+/g; const Ta = /[\x00-\x7F]+/g; -const Ua = /[\x00-\x7F]+/g; -var Va = {LatinExact:{normalize:!1, dedupe:!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) { +var Ua = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ma, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Na}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Na, matcher:Oa, replacer:Pa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Na, replacer:Pa.concat([/(?!^)[aeo]/g, ""]), matcher:Oa}, 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 = Qa[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Qa[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Sa, " "); + return ("" + a).replace(Ra, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Ta, ""); + return ("" + a).replace(Sa, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ua, " "); + return ("" + a).replace(Ta, " "); }}}; -const Wa = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +const Va = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; O.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { @@ -1416,14 +1410,14 @@ 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(t, e, p), g = ""; + var f = this.score ? this.score(c, q, p, null, 0) : Wa(t, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { for (f = 0; f < d; f++) { for (var k = d; k > f; k--) { g = q.substring(f, k); - var h = this.score ? this.score(c, q, p, g, f) : Xa(t, e, p, d, f); + var h = this.score ? this.score(c, q, p, g, f) : Wa(t, e, p, d, f); Z(this, m, g, h, a, b); } } @@ -1432,7 +1426,7 @@ O.prototype.add = function(a, c, b, e) { case "reverse": if (1 < d) { for (k = d - 1; 0 < k; k--) { - g = q[k] + g, h = this.score ? this.score(c, q, p, g, k) : Xa(t, e, p, d, k), Z(this, m, g, h, a, b); + g = q[k] + g, h = this.score ? this.score(c, q, p, g, k) : Wa(t, e, p, d, k), Z(this, m, g, h, a, b); } g = ""; } @@ -1448,7 +1442,7 @@ O.prototype.add = function(a, c, b, e) { for (d = C(), g = this.S, f = q, k = Math.min(n + 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 y = this.score ? this.score(c, f, p, q, h) : Xa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; + const y = this.score ? this.score(c, f, p, q, h) : Wa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; Z(this, l, u ? f : q, y, a, b, u ? q : f); } } @@ -1467,7 +1461,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 Wa(a, c, b, e, d) { return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; } ;O.prototype.search = function(a, c, b) { @@ -1488,11 +1482,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 = Xa(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 = Xa(this, a[0], a[1])) && c.length ? za.call(this, c, g, d) : []; } k = C(); let l = 0; @@ -1504,7 +1498,7 @@ function Xa(a, c, b, e, d) { for (let q, y; l < b; l++) { if ((y = a[l]) && !k[y]) { k[y] = 1; - q = Ya(this, y, m); + q = Xa(this, y, m); a: { f = q; var n = e, t = g, p = h; @@ -1541,16 +1535,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 Xa(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); @@ -1571,14 +1565,14 @@ function Ya(a, c, b) { } } } else { - $a(this.map, a), this.depth && $a(this.ctx, a); + Za(this.map, a), this.depth && Za(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function $a(a, c) { +function Za(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1593,7 +1587,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 = Za(e[1], c); f ? b += f : a.delete(d); } } @@ -1605,12 +1599,12 @@ 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 && (Va[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Va[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) ? Ua[a.encoder] : a.encode || a.encoder || Ma; this.encoder = d.encode ? d : "object" === typeof d ? new K(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = (b = a.tokenize) && "default" !== b && b || "strict"; @@ -1645,7 +1639,7 @@ w.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; -function ab(a) { +function $a(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1653,7 +1647,7 @@ function ab(a) { } } else { for (const b of a) { - const e = b[0], d = ab(b[1]); + const e = b[0], d = $a(b[1]); d ? c += d : a.delete(e); } } @@ -1663,11 +1657,11 @@ w.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); + $a(this.map); + this.depth && $a(this.ctx); return this; }; -w.searchCache = Ma; +w.searchCache = La; w.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { @@ -1690,7 +1684,7 @@ w.export = function(a, c, b = 0, e = 0) { default: return; } - return ua.call(this, a, c, d, f, b, e); + return U.call(this, a, c, d, f, b, e); }; w.import = function(a, c) { if (c) { @@ -1758,9 +1752,9 @@ w.serialize = function(a = !0) { return a ? "function inject(index){" + c + e + d + "}" : c + e + d; }; ja(O.prototype); -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 : "undefined" !== typeof window ? window : {}; -let db; -(db = cb.define) && db.amd ? db([], function() { - return bb; -}) : "object" === typeof cb.exports ? cb.exports = bb : cb.FlexSearch = bb; +const ab = {Index:O, Charset:Ua, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, bb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : "undefined" !== typeof window ? window : {}; +let cb; +(cb = bb.define) && cb.amd ? cb([], function() { + return ab; +}) : "object" === typeof bb.exports ? bb.exports = ab : bb.FlexSearch = ab; }(this||self)); diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index aa4981d..c1a4597 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.115 (Bundle) + * FlexSearch.js v0.8.117 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -21,49 +21,49 @@ v.addMatcher=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);i v.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),g.lengththis.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&d -this.R&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function L(a){a.H=null;a.F.clear();a.G.clear()};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 Q,ka;const R={},S={};function la(a){Q=0;R[a]=S[a]} -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]);Q||(Q=setTimeout(la,0,a),ka=Date.now());S[a]||(S[a]=R[a]=1E3);if(!--R[a]){R[a]=S[a]=S[a]*this.priority*this.priority*3/(Date.now()-ka)|0||1;Q=clearTimeout(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 T=0; -function ma(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[++T]=function(){h(d)};d.worker.postMessage({id:T,task:"init",factory:b,options:a})});this.worker.postMessage({task:"init",factory:b,options:a});return this}}if(!this||this.constructor!==ma)return new ma(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);return f.then?f.then(function(g){return c.call(d,g)}):c.call(this,f)}U("add");U("append");U("search");U("update");U("remove");U("clear");U("export");U("import");ja(ma.prototype); -function U(a){ma.prototype[a]=function(){const c=this,b=[].slice.call(arguments);var e=b[b.length-1];let d;"function"===typeof e&&(d=e,b.pop());e=new Promise(function(f){"export"===a&&"function"===typeof b[0]&&(b[0]=null);c.h[++T]=f;c.worker.postMessage({task:a,id:T,args:b})});return d?(e.then(d),this):e}} +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 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; +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?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;bb||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"],["pf","f"]]),Qa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\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:{normalize:!1,dedupe:!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;bf;k--){g=q.substring(f,k);var h=this.score?this.score(c,q,p,g,f):Xa(t,e,p,d,f);Z(this,m,g,h,a,b)}break}case "reverse":if(1< -d){for(k=d-1;0g?0:1),e,p,k-1,h-1),w=this.bidirectional&&q>f;Z(this,l,w?f:q,y,a,b,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function Z(a,c,b,e,d,f,g){let 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;ethis.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:function(a){return a.toLowerCase()}};const Na=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 Oa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Pa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Qa={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 Ra=/[\x00-\x7F]+/g;const Sa=/[\x00-\x7F]+/g;const Ta=/[\x00-\x7F]+/g;var Ua={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ma,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Na},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Na,matcher:Oa,replacer:Pa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Na,replacer:Pa.concat([/(?!^)[aeo]/g,""]),matcher:Oa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bf;k--){g=q.substring(f,k);var h=this.score?this.score(c,q,p,g,f):Wa(t,e,p,d,f);Z(this,m,g,h,a,b)}break}case "reverse":if(1< +d){for(k=d-1;0g?0:1),e,p,k-1,h-1),w=this.bidirectional&&q>f;Z(this,l,w?f:q,y,a,b,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Wa(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};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 Za(this.map,a),this.depth&&Za(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Za(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;bb.add(a,c)):this.add(a,c)};function $a(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()); + if (Q) { const f = this; return new Promise(g => { setTimeout(function() { @@ -329,8 +324,8 @@ function P(a) { return b; }; } -;let T = 0; -function ma(a = {}) { +;let R = 0; +function S(a = {}) { function c(g) { function k(h) { h = h.data || h; @@ -343,18 +338,20 @@ function ma(a = {}) { e ? this.worker.on("message", k) : this.worker.onmessage = k; if (a.config) { return new Promise(function(h) { - d.h[++T] = function() { + d.h[++R] = function() { h(d); + 1e9 < R && (R = 0); }; - d.worker.postMessage({id:T, task:"init", factory:b, options:a}); + d.worker.postMessage({id:R, task:"init", factory:b, options:a}); }); } this.worker.postMessage({task:"init", factory:b, options:a}); + this.priority = a.priority || 4; return this; } } - if (!this || this.constructor !== ma) { - return new ma(a); + if (!this || this.constructor !== S) { + return new S(a); } let b = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null; b && (b = b.toString()); @@ -363,25 +360,25 @@ function ma(a = {}) { return c.call(d, g); }) : c.call(this, f); } -U("add"); -U("append"); -U("search"); -U("update"); -U("remove"); -U("clear"); -U("export"); -U("import"); -ja(ma.prototype); -function U(a) { - ma.prototype[a] = function() { +T("add"); +T("append"); +T("search"); +T("update"); +T("remove"); +T("clear"); +T("export"); +T("import"); +ja(S.prototype); +function T(a) { + S.prototype[a] = function() { const c = this, b = [].slice.call(arguments); var e = b[b.length - 1]; let d; "function" === typeof e && (d = e, b.pop()); e = new Promise(function(f) { "export" === a && "function" === typeof b[0] && (b[0] = null); - c.h[++T] = f; - c.worker.postMessage({task:a, id:T, args:b}); + c.h[++R] = f; + c.worker.postMessage({task:a, id:R, args:b}); }); return d ? (e.then(d), this) : e; }; @@ -437,7 +434,7 @@ function ta(a, c) { } return c; } -function ua(a, c, b, e, d, f, g = 0) { +function U(a, c, b, e, d, f, g = 0) { const k = e && e.constructor === Array; var h = k ? e.shift() : e; if (!h) { @@ -446,10 +443,10 @@ function ua(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 ua.call(l, a, c, b, k ? e : null, d, f, g + 1); + return U.call(l, a, c, b, k ? e : null, d, f, g + 1); }); } - return ua.call(this, a, c, b, k ? e : null, d, f, g + 1); + return U.call(this, a, c, b, k ? e : null, d, f, g + 1); } ;V.prototype.add = function(a, c, b) { I(a) && (c = a, a = J(c, this.key)); @@ -465,7 +462,7 @@ function ua(a, c, b, e, d, f, g = 0) { 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); } } } @@ -516,7 +513,7 @@ function ua(a, c, b, e, d, f, g = 0) { 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); @@ -524,21 +521,21 @@ function ua(a, c, b, e, d, f, g = 0) { } 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) { @@ -554,15 +551,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(); @@ -577,7 +574,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 []; @@ -592,7 +589,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; @@ -614,7 +611,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]; @@ -627,7 +624,7 @@ function za(a, c) { } return e; } -;function Aa(a, c, b, e) { +;function za(a, c, b, e) { if (!a.length) { return a; } @@ -658,7 +655,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) { @@ -705,10 +702,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) { @@ -716,10 +713,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() { @@ -729,11 +726,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; @@ -749,43 +775,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++) { @@ -831,10 +828,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) { @@ -842,17 +839,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++) { @@ -927,7 +924,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) { @@ -988,7 +985,7 @@ V.prototype.search = function(a, c, b, e) { e = []; if (u.length) { for (f = 0; f < u.length; f += 2) { - y = Ia.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:y}); + y = Ha.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:y}); } } return e.length ? Promise.all(e).then(function(x) { @@ -1022,7 +1019,7 @@ V.prototype.search = function(a, c, b, e) { if (m && F) { v = []; z = 0; - for (let G = 0, H, Wa; G < m.length; G += 2) { + for (let G = 0, H, Va; G < m.length; G += 2) { H = this.tag.get(m[G]); if (!H) { if (console.warn("Tag '" + m[G] + ":" + m[G + 1] + "' will be skipped because there is no field '" + m[G] + "'."), h) { @@ -1031,14 +1028,14 @@ V.prototype.search = function(a, c, b, e) { return p ? d : new X(d); } } - if (Wa = (H = H && H.get(m[G + 1])) && H.length) { + if (Va = (H = H && H.get(m[G + 1])) && H.length) { z++, v.push(H); } else if (!h) { return p ? d : new X(d); } } if (z) { - r = za(r, v); + r = ya(r, v); F = r.length; if (!F && !h) { return p ? r : new X(r); @@ -1073,9 +1070,9 @@ V.prototype.search = function(a, c, b, e) { } d[x] = {field:f[x], result:r}; } - return k ? Ja(d, c) : q ? Ka(d, a, this.index, this.field, this.C, q) : d; + return k ? Ia(d, c) : q ? Ja(d, a, this.index, this.field, this.C, q) : 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, t, p, q, y; m < a.length; m++) { n = a[m].result; @@ -1117,7 +1114,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]; @@ -1136,7 +1133,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"), []; @@ -1168,23 +1165,24 @@ 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(); this.cache = (b = a.cache || null) && new Y(b); a.cache = !1; + this.priority = a.priority || 4; b = new Map(); let e = c.index || c.field || c; D(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], 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; @@ -1200,14 +1198,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++) { @@ -1272,7 +1270,7 @@ w.set = function(a, c) { this.store.set(a, c); return this; }; -w.searchCache = Ma; +w.searchCache = La; w.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1293,22 +1291,18 @@ w.export = function(a, c, b = 0, e = 0) { break; case 1: d = "tag"; - f = qa(this.tag, this.reg.size); + f = this.tag && qa(this.tag, this.reg.size); c = null; break; case 2: d = "doc"; - f = oa(this.store); + f = this.store && oa(this.store); c = null; break; - case 3: - d = "cfg"; - c = f = null; - break; default: return; } - return ua.call(this, a, c, d, f, b, e); + return U.call(this, a, c, d, f, b, e); }; w.import = function(a, c) { var b = a.split("."); @@ -1337,7 +1331,7 @@ w.import = function(a, c) { } }; ja(V.prototype); -function Ma(a, c, b) { +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); @@ -1378,31 +1372,31 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Na = {normalize:function(a) { +const Ma = {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"], ["pf", "f"]]), Qa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\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 Na = 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 Oa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Pa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const Qa = {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 Ra = /[\x00-\x7F]+/g; const Sa = /[\x00-\x7F]+/g; const Ta = /[\x00-\x7F]+/g; -const Ua = /[\x00-\x7F]+/g; -var Va = {LatinExact:{normalize:!1, dedupe:!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) { +var Ua = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ma, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Na}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Na, matcher:Oa, replacer:Pa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Na, replacer:Pa.concat([/(?!^)[aeo]/g, ""]), matcher:Oa}, 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 = Qa[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Qa[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Sa, " "); + return ("" + a).replace(Ra, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Ta, ""); + return ("" + a).replace(Sa, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ua, " "); + return ("" + a).replace(Ta, " "); }}}; -const Xa = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +const Wa = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; O.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { @@ -1415,14 +1409,14 @@ 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(t, e, p), g = ""; + var f = this.score ? this.score(c, q, p, null, 0) : Xa(t, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { for (f = 0; f < d; f++) { for (var k = d; k > f; k--) { g = q.substring(f, k); - var h = this.score ? this.score(c, q, p, g, f) : Ya(t, e, p, d, f); + var h = this.score ? this.score(c, q, p, g, f) : Xa(t, e, p, d, f); Z(this, m, g, h, a, b); } } @@ -1431,7 +1425,7 @@ O.prototype.add = function(a, c, b, e) { case "reverse": if (1 < d) { for (k = d - 1; 0 < k; k--) { - g = q[k] + g, h = this.score ? this.score(c, q, p, g, k) : Ya(t, e, p, d, k), Z(this, m, g, h, a, b); + g = q[k] + g, h = this.score ? this.score(c, q, p, g, k) : Xa(t, e, p, d, k), Z(this, m, g, h, a, b); } g = ""; } @@ -1447,7 +1441,7 @@ O.prototype.add = function(a, c, b, e) { for (d = C(), g = this.S, f = q, k = Math.min(n + 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 y = this.score ? this.score(c, f, p, q, h) : Ya(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; + const y = this.score ? this.score(c, f, p, q, h) : Xa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; Z(this, l, u ? f : q, y, a, b, u ? q : f); } } @@ -1466,7 +1460,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 Xa(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) { @@ -1487,11 +1481,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 = Ya(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 = Ya(this, a[0], a[1])) && c.length ? za.call(this, c, g, d) : []; } k = C(); let l = 0; @@ -1503,7 +1497,7 @@ function Ya(a, c, b, e, d) { for (let q, y; l < b; l++) { if ((y = a[l]) && !k[y]) { k[y] = 1; - q = Za(this, y, m); + q = Ya(this, y, m); a: { f = q; var n = e, t = g, p = h; @@ -1540,16 +1534,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 Ya(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); @@ -1570,14 +1564,14 @@ function Za(a, c, b) { } } } else { - $a(this.map, a), this.depth && $a(this.ctx, a); + Za(this.map, a), this.depth && Za(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function $a(a, c) { +function Za(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1592,7 +1586,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 = Za(e[1], c); f ? b += f : a.delete(d); } } @@ -1604,12 +1598,12 @@ 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 && (Wa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Wa[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) ? Ua[a.encoder] : a.encode || a.encoder || Ma; this.encoder = d.encode ? d : "object" === typeof d ? new K(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = (b = a.tokenize) && "default" !== b && b || "strict"; @@ -1644,7 +1638,7 @@ w.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; -function ab(a) { +function $a(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1652,7 +1646,7 @@ function ab(a) { } } else { for (const b of a) { - const e = b[0], d = ab(b[1]); + const e = b[0], d = $a(b[1]); d ? c += d : a.delete(e); } } @@ -1662,11 +1656,11 @@ w.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); + $a(this.map); + this.depth && $a(this.ctx); return this; }; -w.searchCache = Ma; +w.searchCache = La; w.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { @@ -1689,7 +1683,7 @@ w.export = function(a, c, b = 0, e = 0) { default: return; } - return ua.call(this, a, c, d, f, b, e); + return U.call(this, a, c, d, f, b, e); }; w.import = function(a, c) { if (c) { @@ -1757,6 +1751,6 @@ w.serialize = function(a = !0) { return a ? "function inject(index){" + c + e + d + "}" : c + e + d; }; ja(O.prototype); -export default {Index:O, Charset:Va, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; +export default {Index:O, Charset:Ua, 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=Ua;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 6d188cb..c881e0f 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.115 (Bundle) + * FlexSearch.js v0.8.117 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -21,50 +21,50 @@ v.addMatcher=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);i v.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),g.lengththis.matcher.get(h)));if(g&&this.replacer)for(d=0;g&&d -this.R&&(this.G.clear(),this.L=this.L/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.K&&(this.F.set(a,b),this.F.size>this.R&&(this.F.clear(),this.K=this.K/1.1|0));return b};function L(a){a.H=null;a.F.clear();a.G.clear()};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 Q,ka;const R={},S={};function la(a){Q=0;R[a]=S[a]} -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]);Q||(Q=setTimeout(la,0,a),ka=Date.now());S[a]||(S[a]=R[a]=1E3);if(!--R[a]){R[a]=S[a]=S[a]*this.priority*this.priority*3/(Date.now()-ka)|0||1;Q=clearTimeout(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 T=0; -function ma(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[++T]=function(){h(d)};d.worker.postMessage({id:T,task:"init",factory:b,options:a})});this.worker.postMessage({task:"init",factory:b,options:a});return this}}if(!this||this.constructor!==ma)return new ma(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);return f.then?f.then(function(g){return c.call(d,g)}):c.call(this,f)}U("add");U("append");U("search");U("update");U("remove");U("clear");U("export");U("import");ja(ma.prototype); -function U(a){ma.prototype[a]=function(){const c=this,b=[].slice.call(arguments);var e=b[b.length-1];let d;"function"===typeof e&&(d=e,b.pop());e=new Promise(function(f){"export"===a&&"function"===typeof b[0]&&(b[0]=null);c.h[++T]=f;c.worker.postMessage({task:a,id:T,args:b})});return d?(e.then(d),this):e}} +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 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; +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?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;bb||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"],["pf","f"]]),Qa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\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:{normalize:!1,dedupe:!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;bf;k--){g=q.substring(f,k);var h=this.score?this.score(c,q,p,g,f):Ya(t,e,p,d,f);Z(this,m,g,h,a,b)}break}case "reverse":if(1< -d){for(k=d-1;0g?0:1),e,p,k-1,h-1),w=this.bidirectional&&q>f;Z(this,l,w?f:q,y,a,b,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function Z(a,c,b,e,d,f,g){let 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;ethis.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:function(a){return a.toLowerCase()}};const Na=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 Oa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Pa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Qa={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 Ra=/[\x00-\x7F]+/g;const Sa=/[\x00-\x7F]+/g;const Ta=/[\x00-\x7F]+/g;var Va={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ma,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Na},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Na,matcher:Oa,replacer:Pa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Na,replacer:Pa.concat([/(?!^)[aeo]/g,""]),matcher:Oa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bf;k--){g=q.substring(f,k);var h=this.score?this.score(c,q,p,g,f):Xa(t,e,p,d,f);Z(this,m,g,h,a,b)}break}case "reverse":if(1< +d){for(k=d-1;0g?0:1),e,p,k-1,h-1),w=this.bidirectional&&q>f;Z(this,l,w?f:q,y,a,b,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function Z(a,c,b,e,d,f,g){let 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 Za(this.map,a),this.depth&&Za(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Za(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;bb.add(a,c)):this.add(a,c)};function $a(a){let c=0;if(a.constructor===Array)for(let b=0,e;b= this.priority * this.priority * 3) : (Ma = setTimeout(Pa, 0), Na = Date.now()); + if (Oa) { var e = this; return new Promise(function(g) { setTimeout(function() { @@ -1195,8 +1191,8 @@ function Ja(a) { return c; }; } -;var Ra = 0; -function Sa(a) { +;var Qa = 0; +function Ra(a) { function b(g) { function h(k) { k = k.data || k; @@ -1209,23 +1205,25 @@ 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 < 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}); + this.priority = a.priority || 4; return this; } } 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, f = Ta(c, d, a.worker); + var d = "undefined" === typeof window, e = this, f = Sa(c, d, a.worker); return f.then ? f.then(function(g) { return b.call(e, g); }) : b.call(this, f); @@ -1238,9 +1236,9 @@ T("remove"); T("clear"); T("export"); T("import"); -Ia(Sa.prototype); +Ia(Ra.prototype); function T(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; @@ -1248,17 +1246,17 @@ function T(a) { } d = new Promise(function(f) { "export" === a && "function" === typeof c[0] && (c[0] = null); - b.h[++Ra] = f; - b.worker.postMessage({task:a, id:Ra, args:c}); + b.h[++Qa] = f; + b.worker.postMessage({task:a, id:Qa, args:c}); }); return e ? (d.then(e), this) : d; }; } -function Ta(a, b, c) { +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); @@ -1269,32 +1267,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 = w(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 = w(a.keys()); for (var d = a.next(); !d.done; d = a.next()) { @@ -1303,14 +1301,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, f, g) { +function Za(a, b, c, d, e, f, g) { g = void 0 === g ? 0 : g; var h = d && d.constructor === Array, k = h ? d.shift() : d; if (!k) { @@ -1319,12 +1317,12 @@ function $a(a, b, c, d, e, f, g) { if ((k = a((b ? b + "." : "") + (g + 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, f, g + 1); + return Za.call(l, a, b, c, h ? d : null, e, f, g + 1); }); } - return $a.call(this, a, b, c, h ? d : null, e, f, g + 1); + return Za.call(this, a, b, c, h ? d : null, e, f, g + 1); } -;function ab(a, b, c, d) { +;function $a(a, b, c, d) { for (var e = [], f = 0, g; f < a.index.length; f++) { if (g = a.index[f], b >= g.length) { b -= g.length; @@ -1340,9 +1338,9 @@ function $a(a, b, c, d, e, f, g) { } return e; } -function bb(a) { +function ab(a) { if (!this) { - return new bb(a); + return new ab(a); } this.index = a ? [a] : []; this.length = a ? a.length : 0; @@ -1389,12 +1387,12 @@ function bb(a) { } if ("slice" === d) { return function(e, f) { - return ab(b, e || 0, f || b.length, !1); + return $a(b, e || 0, f || b.length, !1); }; } if ("splice" === d) { return function(e, f) { - return ab(b, e || 0, f || b.length, !0); + return $a(b, e || 0, f || b.length, !0); }; } if ("constructor" === d) { @@ -1410,13 +1408,13 @@ function bb(a) { return !0; }}); } -bb.prototype.clear = function() { +ab.prototype.clear = function() { this.index.length = 0; }; -bb.prototype.destroy = function() { +ab.prototype.destroy = function() { this.proxy = this.index = null; }; -bb.prototype.push = function() { +ab.prototype.push = function() { }; function U(a) { a = void 0 === a ? 8 : a; @@ -1426,7 +1424,7 @@ function U(a) { this.index = J(); this.B = []; this.size = 0; - 32 < a ? (this.h = cb, this.A = BigInt(a)) : (this.h = db, this.A = a); + 32 < a ? (this.h = bb, this.A = BigInt(a)) : (this.h = cb, this.A = a); } U.prototype.get = function(a) { var b = this.h(a); @@ -1443,7 +1441,7 @@ function V(a) { } this.index = J(); this.h = []; - 32 < a ? (this.B = cb, this.A = BigInt(a)) : (this.B = db, this.A = a); + 32 < a ? (this.B = bb, this.A = BigInt(a)) : (this.B = cb, this.A = a); } V.prototype.add = function(a) { var b = this.B(a), c = this.index[b]; @@ -1463,9 +1461,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, f; - return ra(eb, function(g) { + return ra(db, function(g) { switch(g.h) { case 1: b = 0; @@ -1489,9 +1487,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, f; - return ra(fb, function(g) { + return ra(eb, function(g) { switch(g.h) { case 1: b = 0; @@ -1515,9 +1513,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, f; - return ra(gb, function(g) { + return ra(fb, function(g) { switch(g.h) { case 1: b = 0; @@ -1541,7 +1539,7 @@ u.entries = V.prototype.entries = function gb() { } }); }; -function db(a) { +function cb(a) { var b = Math.pow(2, this.A) - 1; if ("number" == typeof a) { return a & b; @@ -1551,7 +1549,7 @@ function db(a) { } return 32 === this.A ? 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) { @@ -1568,7 +1566,7 @@ function cb() { } else { var g = e.R; if (!g || g(b)) { - e.constructor === String ? e = ["" + e] : K(e) && (e = [e]), hb(b, e, this.S, 0, f, a, e[0], c); + e.constructor === String ? e = ["" + e] : K(e) && (e = [e]), gb(b, e, this.S, 0, f, a, e[0], c); } } } @@ -1599,7 +1597,7 @@ function cb() { (m = f.get(l)) ? k = m : f.set(l, k = []); if (!c || !k.includes(a)) { if (k.length === Math.pow(2, 31) - 1) { - m = new bb(k); + m = new ab(k); if (this.fastupdate) { for (var n = w(this.reg.values()), p = n.next(); !p.done; p = n.next()) { p = p.value, p.includes(k) && (p[p.indexOf(k)] = m); @@ -1633,7 +1631,7 @@ function cb() { q[d] = b[d]; continue; } - ib(b, q, d, 0, d[0], f); + hb(b, q, d, 0, d[0], f); } } } @@ -1643,21 +1641,21 @@ function cb() { } return this; }; -function ib(a, b, c, d, e, f) { +function hb(a, b, c, d, e, f) { a = a[e]; if (d === c.length - 1) { b[e] = f || a; } else if (a) { if (a.constructor === Array) { for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) { - 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, f, g, h) { +function gb(a, b, c, d, e, f, g, h) { if (a = a[g]) { if (d === b.length - 1) { if (a.constructor === Array) { @@ -1673,17 +1671,17 @@ function hb(a, b, c, d, e, f, g, h) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - hb(a, b, c, d, e, f, g, h); + gb(a, b, c, d, e, f, g, h); } } else { - g = b[++d], hb(a, b, c, d, e, f, g, h); + g = b[++d], gb(a, b, c, d, e, f, g, h); } } } else { e.db && e.remove(f); } } -;function jb(a, b, c, d, e, f, g) { +;function ib(a, b, c, d, e, f, g) { var h = a.length, k = [], l; var m = J(); for (var n = 0, p = void 0, q; n < b; n++) { @@ -1704,7 +1702,7 @@ function hb(a, b, c, d, e, f, g, h) { } if (a = k.length) { if (e) { - k = 1 < k.length ? kb(k, c, d, g, f) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; + k = 1 < k.length ? jb(k, c, d, g, f) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; } else { if (a < h) { return []; @@ -1737,7 +1735,7 @@ function hb(a, b, c, d, e, f, g, h) { } return k; } -function kb(a, b, c, d, e) { +function jb(a, b, c, d, e) { var f = [], g = J(), h = a.length, k; if (d) { for (e = h - 1; 0 <= e; e--) { @@ -1780,7 +1778,7 @@ function kb(a, b, c, d, e) { } return f; } -function lb(a, b, c) { +function kb(a, b, c) { for (var d = J(), e = [], f = 0, g; f < b.length; f++) { g = b[f]; for (var h = 0; h < g.length; h++) { @@ -1800,7 +1798,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; } @@ -1830,7 +1828,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) { @@ -1876,10 +1874,10 @@ function lb(a, b, c) { return {W:d, $:e, limit:f, offset:g, 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, f) { +function nb(a, b, c, d, e, f) { if (b.length) { var g = this; return Promise.all(b).then(function(h) { @@ -1887,10 +1885,10 @@ function ob(a, b, c, d, e, f) { for (var k = 0, l = void 0; k < h.length; k++) { (l = h[k]).length && (a[k] = l); } - return ob.call(g, a, [], c, d, e, f); + return nb.call(g, a, [], c, d, e, f); }); } - a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = 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 f ? this.resolve(c, d, e) : this; } ;Y.prototype.and = function() { @@ -1905,7 +1903,36 @@ function ob(a, b, c, d, e, f) { var f = 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, f) : this; + return a ? (a = mb(this, "and", arguments), ob.call(this, a.W, a.$, a.limit, a.offset, a.enrich, a.resolve, a.suggest)) : c ? this.resolve(d, e, f) : this; +}; +function ob(a, b, c, d, e, f, g) { + 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, f, g); + }); + } + 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, g, this.h, f), f ? e ? X.call(this.index, this.result) : this.result : this; + } + this.result = []; + } + } else { + g || (this.result = a); + } + return f ? 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, f, g) { if (b.length) { @@ -1922,43 +1949,14 @@ function pb(a, b, c, d, e, f, g) { 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, g, this.h, f), f ? e ? X.call(this.index, this.result) : this.result : this; - } - this.result = []; + return this.result = qb.call(this, a, c, d, f, this.h), f ? e ? X.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? 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, f, g) { - 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, f, g); - }); - } - 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, f, this.h), f ? e ? X.call(this.index, this.result) : this.result : this; - } - } else { - g || (this.result = a); - } - return f ? this.resolve(c, d, e) : this; -} -function rb(a, b, c, d, e) { +function qb(a, b, c, d, e) { for (var f = [], g = J(), h = 0, k = 0, l; k < a.length; k++) { if (l = a[k]) { h < l.length && (h = l.length); @@ -2002,10 +2000,10 @@ function rb(a, b, c, d, e) { return f; } ;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, f, g) { +function rb(a, b, c, d, e, f, g) { if (b.length) { var h = this; return Promise.all(b).then(function(k) { @@ -2013,17 +2011,17 @@ function sb(a, b, c, d, e, f, g) { for (var l = 0, m = void 0; l < k.length; l++) { (m = k[l]).length && (a[l] = m); } - return sb.call(h, a, [], c, d, e, f, g); + return rb.call(h, a, [], c, d, e, f, g); }); } if (a.length && this.result.length) { - this.result = tb.call(this, a, c, d, f); + this.result = sb.call(this, a, c, d, f); } else if (f) { return this.resolve(c, d, e); } return f ? e ? 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 f = 0, g, h = 0; f < this.result.length; f++) { @@ -2096,7 +2094,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) { @@ -2172,7 +2170,7 @@ W.prototype.search = function(a, b, c, d) { } h.push(k = k.db.tag(r[f + 1], b, x, q)); } else { - k = ub.call(this, r[f], r[f + 1], b, x, q); + k = tb.call(this, r[f], r[f + 1], b, x, q); } e.push({field:r[f], tag:r[f + 1], result:k}); } @@ -2202,10 +2200,10 @@ W.prototype.search = function(a, b, c, d) { if (n) { if (this.db) { y.tag = n; - var Ka = v.db.support_tag_search; + var Ja = v.db.support_tag_search; y.field = m; } - Ka || (y.enrich = !1); + Ja || (y.enrich = !1); } if (r) { r[A] = v.search(a, b, y); @@ -2220,7 +2218,7 @@ W.prototype.search = function(a, b, c, d) { D = []; G = 0; if (this.db && d) { - if (!Ka) { + if (!Ja) { for (H = m.length; H < d.length; H++) { var L = d[H]; if (L && L.length) { @@ -2232,7 +2230,7 @@ W.prototype.search = function(a, b, c, d) { } } else { H = 0; - for (var Xb = L = void 0; H < n.length; H += 2) { + for (var Wb = L = void 0; H < n.length; H += 2) { L = this.tag.get(n[H]); if (!L) { if (console.warn("Tag '" + n[H] + ":" + n[H + 1] + "' will be skipped because there is no field '" + n[H] + "'."), p) { @@ -2241,7 +2239,7 @@ W.prototype.search = function(a, b, c, d) { return h ? e : new Y(e); } } - if (Xb = (L = L && L.get(n[H + 1])) && L.length) { + if (Wb = (L = L && L.get(n[H + 1])) && L.length) { G++, D.push(L); } else if (!p) { return h ? e : new Y(e); @@ -2249,7 +2247,7 @@ W.prototype.search = function(a, b, c, d) { } } if (G) { - v = lb(v, D, h); + v = kb(v, D, h); y = v.length; if (!y && !p) { return h ? v : new Y(v); @@ -2265,7 +2263,7 @@ W.prototype.search = function(a, b, c, d) { } } if (r) { - if (this.db && n && n.length && !Ka) { + if (this.db && n && n.length && !Ja) { for (q = 0; q < n.length; q += 2) { f = this.index.get(n[q]); if (!f) { @@ -2278,9 +2276,9 @@ W.prototype.search = function(a, b, c, d) { r.push(f.db.tag(n[q + 1], b, x, !1)); } } - var Yb = this; + var Xb = this; return Promise.all(r).then(function(Q) { - return Q.length ? Yb.search(a, b, c, Q) : Q; + return Q.length ? Xb.search(a, b, c, Q) : Q; }); } if (!g) { @@ -2300,17 +2298,17 @@ W.prototype.search = function(a, b, c, d) { e[x] = {field:f[x], result:p}; } if (q && 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 l ? vb(e, b) : t ? wb(e, a, La.index, La.field, La.J, t) : e; + return l ? ub(e, b) : t ? vb(e, a, Ka.index, Ka.field, Ka.J, t) : e; }); } - return l ? vb(e, b) : t ? wb(e, a, this.index, this.field, this.J, t) : e; + return l ? ub(e, b) : t ? vb(e, a, this.index, this.field, this.J, t) : e; }; -function wb(a, b, c, d, e, f) { +function vb(a, b, c, d, e, f) { for (var g, h, k, l = 0, m, n, p; l < a.length; l++) { for (m = a[l].result, n = a[l].field, k = c.get(n), p = k.encoder, k = k.tokenize, n = e[d.indexOf(n)], p !== g && (g = p, h = g.encode(b)), p = 0; p < m.length; p++) { var q = "", t = ya(m[p].doc, n), x = g.encode(t); @@ -2341,7 +2339,7 @@ function wb(a, b, c, d, e, f) { } return a; } -function vb(a, b) { +function ub(a, b) { for (var c = [], d = J(), e = 0, f, g; e < a.length; e++) { f = a[e]; g = f.result; @@ -2359,7 +2357,7 @@ function vb(a, b) { } return c; } -function ub(a, b, c, d, e) { +function tb(a, b, c, d, e) { var f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -2389,7 +2387,7 @@ 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(); @@ -2398,7 +2396,8 @@ function X(a) { this.cache = (c = a.cache || null) && new Z(c); a.cache = !1; this.worker = a.worker; - this.index = yb.call(this, a, b); + this.priority = a.priority || 4; + this.index = xb.call(this, a, b); this.tag = null; if (c = b.tag) { if ("string" === typeof c && (c = [c]), c.length) { @@ -2412,7 +2411,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()); } @@ -2492,7 +2491,7 @@ u.destroy = function() { } return Promise.all(a); }; -function yb(a, b) { +function xb(a, b) { var c = new Map(), d = b.index || b.field || b; K(d) && (d = [d]); for (var e = 0, f, g = void 0; e < d.length; e++) { @@ -2500,21 +2499,21 @@ function yb(a, b) { K(f) || (g = f, f = f.field); g = M(g) ? Object.assign({}, a, g) : a; if (this.worker) { - var h = new Sa(g); + var h = new Ra(g); c.set(f, h); } this.worker || c.set(f, new S(g, this.reg)); - g.custom ? this.J[e] = g.custom : (this.J[e] = xb(f, this.S), g.filter && ("string" === typeof this.J[e] && (this.J[e] = new String(this.J[e])), this.J[e].R = g.filter)); + g.custom ? this.J[e] = g.custom : (this.J[e] = wb(f, this.S), g.filter && ("string" === typeof this.J[e] && (this.J[e] = new String(this.J[e])), this.J[e].R = g.filter)); this.field[e] = f; } if (this.I) { for (a = b.store, K(a) && (a = [a]), b = 0; b < a.length; b++) { - d = a[b], e = d.field || d, d.custom ? (this.I[b] = d.custom, d.custom.ja = e) : (this.I[b] = 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); } @@ -2581,7 +2580,7 @@ u.set = function(a, b) { this.store.set(a, b); return this; }; -u.searchCache = zb; +u.searchCache = yb; u.export = function(a, b, c, d) { c = void 0 === c ? 0 : c; d = void 0 === d ? 0 : d; @@ -2598,27 +2597,23 @@ u.export = function(a, b, c, d) { switch(d) { case 0: var g = "reg"; - var h = Ya(this.reg); + var h = Xa(this.reg); b = null; break; case 1: g = "tag"; - h = Wa(this.tag, this.reg.size); + h = this.tag && Va(this.tag, this.reg.size); b = null; break; case 2: g = "doc"; - h = Ua(this.store); + h = this.store && Ta(this.store); b = null; break; - case 3: - g = "cfg"; - b = h = null; - break; default: return; } - return $a.call(this, a, b, g, h, c, d); + return Za.call(this, a, b, g, h, c, d); }; u.import = function(a, b) { var c = a.split("."); @@ -2636,7 +2631,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; } @@ -2650,15 +2645,15 @@ 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); } } }; Ia(W.prototype); -function zb(a, b, c) { +function yb(a, b, c) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Z()); var d = this.cache.get(a); @@ -2700,29 +2695,29 @@ Z.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -var Ab = {normalize:function(a) { +var zb = {normalize:function(a) { return a.toLowerCase(); }}; -var Bb = 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 Cb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Db = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -var Eb = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; +var Ab = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); +var Bb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Cb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +var Db = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; +var Eb = /[\x00-\x7F]+/g; var Fb = /[\x00-\x7F]+/g; var Gb = /[\x00-\x7F]+/g; -var Hb = /[\x00-\x7F]+/g; -var Ib = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ab, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Bb}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Bb, matcher:Cb, replacer:Db}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Bb, replacer:Db.concat([/(?!^)[aeo]/g, ""]), matcher:Cb}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +var Hb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:zb, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ab}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ab, matcher:Bb, replacer:Cb}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ab, replacer:Cb.concat([/(?!^)[aeo]/g, ""]), matcher:Bb}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (var b = 0; b < a.length; b++) { - for (var c = a[b], d = c.charAt(0), e = Eb[d], f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Eb[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { + for (var c = a[b], d = c.charAt(0), e = Db[d], f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Db[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) { } a[b] = d; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Fb, " "); + return ("" + a).replace(Eb, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Gb, ""); + return ("" + a).replace(Fb, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Hb, " "); + return ("" + a).replace(Gb, " "); }}}; -var Jb = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +var Ib = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; S.prototype.add = function(a, b, c, d) { if (b && (a || 0 === a)) { if (!d && !c && this.reg.has(a)) { @@ -2733,15 +2728,15 @@ S.prototype.add = function(a, b, c, d) { for (var e = J(), f = J(), g = this.depth, h = this.resolution, k = 0; k < d; k++) { var l = b[this.rtl ? d - 1 - k : k], m = l.length; if (m && (g || !f[l])) { - var n = this.score ? this.score(b, l, k, null, 0) : Kb(h, d, k), p = ""; + var n = this.score ? this.score(b, l, k, null, 0) : Jb(h, d, k), p = ""; switch(this.tokenize) { case "full": if (2 < m) { for (n = 0; n < m; n++) { for (var q = m; q > n; q--) { p = l.substring(n, q); - var t = this.score ? this.score(b, l, k, p, n) : Kb(h, d, k, m, n); - Lb(this, f, p, t, a, c); + var t = this.score ? this.score(b, l, k, p, n) : Jb(h, d, k, m, n); + Kb(this, f, p, t, a, c); } } break; @@ -2749,24 +2744,24 @@ S.prototype.add = function(a, b, c, d) { case "reverse": if (1 < m) { for (q = m - 1; 0 < q; q--) { - p = l[q] + p, t = this.score ? this.score(b, l, k, p, q) : Kb(h, d, k, m, q), Lb(this, f, p, t, a, c); + p = l[q] + p, t = this.score ? this.score(b, l, k, p, q) : Jb(h, d, k, m, q), Kb(this, f, p, t, a, c); } p = ""; } case "forward": if (1 < m) { for (q = 0; q < m; q++) { - p += l[q], Lb(this, f, p, n, a, c); + p += l[q], Kb(this, f, p, n, a, c); } break; } default: - if (Lb(this, f, l, n, a, c), g && 1 < d && k < d - 1) { + if (Kb(this, f, l, n, a, c), g && 1 < d && k < d - 1) { for (m = J(), p = this.da, n = l, q = Math.min(g + 1, d - k), t = m[n] = 1; t < q; t++) { if ((l = b[this.rtl ? d - 1 - k - t : k + t]) && !m[l]) { m[l] = 1; - var x = this.score ? this.score(b, n, k, l, t) : Kb(p + (d / 2 > p ? 0 : 1), d, k, q - 1, t - 1), r = this.bidirectional && l > n; - Lb(this, e, r ? n : l, x, a, c, r ? l : n); + var x = this.score ? this.score(b, n, k, l, t) : Jb(p + (d / 2 > p ? 0 : 1), d, k, q - 1, t - 1), r = this.bidirectional && l > n; + Kb(this, e, r ? n : l, x, a, c, r ? l : n); } } } @@ -2778,15 +2773,15 @@ S.prototype.add = function(a, b, c, d) { b = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.ca && Mb(this)); + this.db && (b || this.commit_task.push({del:a}), this.ca && Lb(this)); return this; }; -function Lb(a, b, c, d, e, f, g) { +function Kb(a, b, c, d, e, f, g) { var h = g ? a.ctx : a.map, k; if (!b[c] || g && !(k = b[c])[g]) { if (g ? (b = k || (b[c] = J()), b[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : b[c] = 1, (k = h.get(c)) ? h = k : h.set(c, h = k = []), h = h[d] || (h[d] = []), !f || !h.includes(e)) { if (h.length === Math.pow(2, 31) - 1) { - b = new bb(h); + b = new ab(h); if (a.fastupdate) { for (c = w(a.reg.values()), f = c.next(); !f.done; f = c.next()) { f = f.value, f.includes(h) && (f[f.indexOf(h)] = b); @@ -2799,7 +2794,7 @@ function Lb(a, b, c, d, e, f, g) { } } } -function Kb(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; } ;S.prototype.search = function(a, b, c) { @@ -2822,11 +2817,11 @@ function Kb(a, b, c, d, e) { var q = p.length; b = b || (f ? 100 : 0); if (1 === q) { - return Nb.call(this, p[0], "", b, e, f, k, n); + return Mb.call(this, p[0], "", b, e, f, k, n); } g = this.depth && !1 !== g; if (2 === q && g && !h) { - return Nb.call(this, p[0], p[1], b, e, f, k, n); + return Mb.call(this, p[0], p[1], b, e, f, k, n); } var t = J(), x = 0; if (1 < q && g) { @@ -2856,10 +2851,10 @@ function Kb(a, b, c, d, e) { break; } t[v] = 1; - return E(y, Ob(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 = Pb(z, d, h, m)) { + if (z = Ob(z, d, h, m)) { d = z; y.h = 4; break; @@ -2871,7 +2866,7 @@ function Kb(a, b, c, d, e) { y.h = 2; break; case 4: - return y.return(Qb(d, m, b, e, h, l, f)); + return y.return(Pb(d, m, b, e, h, l, f)); } }); }(); @@ -2879,8 +2874,8 @@ function Kb(a, b, c, d, e) { for (c = a = void 0; x < q; x++) { if ((c = p[x]) && !t[c]) { t[c] = 1; - a = Ob(this, c, r, 0, 0, !1, !1); - if (a = Pb(a, d, h, m)) { + a = Nb(this, c, r, 0, 0, !1, !1); + if (a = Ob(a, d, h, m)) { d = a; break; } @@ -2888,24 +2883,24 @@ function Kb(a, b, c, d, e) { } h && r && x === q - 1 && !d.length && (r = "", x = -1, t = J()); } - return Qb(d, m, b, e, h, l, f); + return Pb(d, m, b, e, h, l, f); }; -function Qb(a, b, c, d, e, f, g) { +function Pb(a, b, c, d, e, f, g) { var h = a.length, k = a; if (1 < h) { - k = jb(a, b, c, d, e, f, g); + k = ib(a, b, c, d, e, f, g); } else if (1 === h) { - return g ? mb.call(null, a[0], c, d) : new Y(a[0]); + return g ? lb.call(null, a[0], c, d) : new Y(a[0]); } return g ? k : new Y(k); } -function Nb(a, b, c, d, e, f, g) { - a = Ob(this, a, b, c, d, e, f, g); +function Mb(a, b, c, d, e, f, g) { + a = Nb(this, a, b, c, d, e, f, g); return this.db ? a.then(function(h) { return e ? h || [] : new 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 Pb(a, b, c, d) { +function Ob(a, b, c, d) { var e = []; if (a && a.length) { if (a.length <= d) { @@ -2926,7 +2921,7 @@ function Pb(a, b, c, d) { return e; } } -function Ob(a, b, c, d, e, f, g, h) { +function Nb(a, b, c, d, e, f, g, h) { var k; c && (k = a.bidirectional && b > c) && (k = c, c = b, b = k); if (a.db) { @@ -2950,15 +2945,15 @@ function Ob(a, b, c, d, e, f, g, h) { } } } else { - Rb(this.map, a), this.depth && Rb(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 && Mb(this)); + this.db && (this.commit_task.push({del:a}), this.ca && Lb(this)); this.cache && this.cache.remove(a); return this; }; -function Rb(a, b) { +function Qb(a, b) { var c = 0; if (a.constructor === Array) { for (var d = 0, e = void 0, f; d < a.length; d++) { @@ -2973,7 +2968,7 @@ function Rb(a, b) { } } else { for (d = w(a.entries()), e = d.next(); !e.done; e = d.next()) { - f = e.value, e = f[0], (f = Rb(f[1], b)) ? c += f : a.delete(e); + f = e.value, e = f[0], (f = Qb(f[1], b)) ? c += f : a.delete(e); } } return c; @@ -2984,12 +2979,12 @@ function Rb(a, b) { } if (a) { var c = K(a) ? a : a.preset; - c && (Jb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Jb[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) ? Ib[a.encoder] : a.encode || a.encoder || Ab; + var d = !0 === c ? {depth:1} : c || {}, e = K(a.encoder) ? Hb[a.encoder] : a.encode || a.encoder || zb; this.encoder = e.encode ? e : "object" === typeof e ? new Ga(e) : {encode:e}; this.resolution = a.resolution || 9; this.tokenize = (c = a.tokenize) && "default" !== c && c || "strict"; @@ -3026,11 +3021,11 @@ u.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function Mb(a) { +function Lb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); - }, 0)); + }, 1)); } u.clear = function() { this.map.clear(); @@ -3052,7 +3047,7 @@ u.update = function(a, b) { return c.add(a, b); }) : this.add(a, b); }; -function Sb(a) { +function Rb(a) { var b = 0; if (a.constructor === Array) { for (var c = 0, d = void 0; c < a.length; c++) { @@ -3062,7 +3057,7 @@ function Sb(a) { for (c = w(a), d = c.next(); !d.done; d = c.next()) { var e = d.value; d = e[0]; - (e = Sb(e[1])) ? b += e : a.delete(d); + (e = Rb(e[1])) ? b += e : a.delete(d); } } return b; @@ -3071,18 +3066,18 @@ u.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Sb(this.map); - this.depth && Sb(this.ctx); + Rb(this.map); + this.depth && Rb(this.ctx); return this; }; -u.searchCache = zb; +u.searchCache = yb; u.export = function(a, b, c, d) { c = void 0 === c ? 0 : c; d = void 0 === d ? 0 : d; switch(d) { case 0: var e = "reg"; - var f = Ya(this.reg); + var f = Xa(this.reg); break; case 1: e = "cfg"; @@ -3090,29 +3085,29 @@ u.export = function(a, b, c, d) { break; case 2: e = "map"; - f = Ua(this.map, this.reg.size); + f = Ta(this.map, this.reg.size); break; case 3: e = "ctx"; - f = Wa(this.ctx, this.reg.size); + f = Va(this.ctx, this.reg.size); break; default: return; } - return $a.call(this, a, b, e, f, c, d); + return Za.call(this, a, b, e, f, c, d); }; u.import = function(a, b) { if (b) { switch("string" === typeof b && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 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); } } }; @@ -3169,11 +3164,11 @@ u.serialize = function(a) { return a ? "function inject(index){" + b + d + e + "}" : b + d + e; }; Ia(S.prototype); -var Tb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Ub = ["map", "ctx", "tag", "reg", "cfg"]; -function Vb(a, b) { +var Sb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Tb = ["map", "ctx", "tag", "reg", "cfg"]; +function Ub(a, b) { b = void 0 === b ? {} : b; if (!this) { - return new Vb(a, b); + return new Ub(a, b); } "object" === typeof a && (b = a, a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -3184,7 +3179,7 @@ function Vb(a, b) { this.db = null; this.h = {}; } -u = Vb.prototype; +u = Ub.prototype; u.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -3196,10 +3191,10 @@ u.open = function() { var a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { - var d = Tb.open(a.id + (a.field ? ":" + a.field : ""), 1); + var d = Sb.open(a.id + (a.field ? ":" + a.field : ""), 1); d.onupgradeneeded = function() { var e = a.db = this.result; - Ub.forEach(function(f) { + Tb.forEach(function(f) { e.objectStoreNames.contains(f) || e.createObjectStore(f); }); }; @@ -3225,14 +3220,14 @@ u.close = function() { this.db = null; }; u.destroy = function() { - var a = Tb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); - return Wb(a); + var a = Sb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); + return Vb(a); }; u.clear = function() { - for (var a = this.db.transaction(Ub, "readwrite"), b = 0; b < Ub.length; b++) { - a.objectStore(Ub[b]).clear(); + for (var a = this.db.transaction(Tb, "readwrite"), b = 0; b < Tb.length; b++) { + a.objectStore(Tb[b]).clear(); } - return Wb(a); + return Vb(a); }; u.get = function(a, b, c, d, e, f) { c = void 0 === c ? 0 : c; @@ -3241,7 +3236,7 @@ u.get = function(a, b, c, d, e, f) { f = void 0 === f ? !1 : f; a = this.db.transaction(b ? "ctx" : "map", "readonly").objectStore(b ? "ctx" : "map").get(b ? b + ":" + a : a); var g = this; - return Wb(a).then(function(h) { + return Vb(a).then(function(h) { var k = []; if (!h || !h.length) { return k; @@ -3276,7 +3271,7 @@ u.tag = function(a, b, c, d) { d = void 0 === d ? !1 : d; a = this.db.transaction("tag", "readonly").objectStore("tag").get(a); var e = this; - return Wb(a).then(function(f) { + return Vb(a).then(function(f) { if (!f || !f.length || c >= f.length) { return []; } @@ -3290,7 +3285,7 @@ u.tag = function(a, b, c, d) { 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; d++) { - c[d] = Wb(b.get(a[d])); + c[d] = Vb(b.get(a[d])); } return Promise.all(c).then(function(e) { for (var f = 0; f < e.length; f++) { @@ -3301,7 +3296,7 @@ u.enrich = function(a) { }; u.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); - return Wb(a); + return Vb(a); }; u.search = null; u.info = function() { @@ -3379,8 +3374,8 @@ u.commit = function(a, b, c) { a.commit_task = []; case 3: return a.reg.size ? E(h, d.transaction("map", "readwrite", function(k) { - for (var l = w(a.map), m = l.next(), n = {}; !m.done; n = {O:void 0, Z:void 0}, m = l.next()) { - m = m.value, n.Z = m[0], n.O = m[1], n.O.length && (b ? k.put(n.O, n.Z) : k.get(n.Z).onsuccess = function(p) { + for (var l = w(a.map), m = l.next(), n = {}; !m.done; n = {O:void 0, Y:void 0}, m = l.next()) { + m = m.value, n.Y = m[0], n.O = m[1], n.O.length && (b ? k.put(n.O, n.Y) : k.get(n.Y).onsuccess = function(p) { return function() { var q = this.result, t; if (q && q.length) { @@ -3399,7 +3394,7 @@ u.commit = function(a, b, c) { } else { q = p.O, t = 1; } - t && k.put(q, p.Z); + t && k.put(q, p.Y); }; }(n)); } @@ -3410,8 +3405,8 @@ u.commit = function(a, b, c) { m = m.value; n.V = m[0]; m = w(m[1]); - for (var p = m.next(), q = {}; !p.done; q = {P:void 0, Y:void 0}, p = m.next()) { - p = p.value, q.Y = p[0], q.P = p[1], q.P.length && (b ? k.put(q.P, n.V + ":" + q.Y) : k.get(n.V + ":" + q.Y).onsuccess = function(t, x) { + for (var p = m.next(), q = {}; !p.done; q = {P:void 0, Z:void 0}, p = m.next()) { + p = p.value, q.Z = p[0], q.P = p[1], q.P.length && (b ? k.put(q.P, n.V + ":" + q.Z) : k.get(n.V + ":" + q.Z).onsuccess = function(t, x) { return function() { var r = this.result, A; if (r && r.length) { @@ -3430,7 +3425,7 @@ u.commit = function(a, b, c) { } else { r = t.P, A = 1; } - A && k.put(r, x.V + ":" + t.Y); + A && k.put(r, x.V + ":" + t.Z); }; }(q, n)); } @@ -3477,7 +3472,7 @@ u.commit = function(a, b, c) { } }); }; -function Zb(a, b, c) { +function Yb(a, b, c) { for (var d = a.value, e, f, g = 0, h = 0, k; h < d.length; h++) { if (k = c ? d : d[h]) { for (var l = 0, m, n; l < b.length; l++) { @@ -3504,17 +3499,17 @@ u.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && Zb(c, a); + c && Yb(c, a); }; }), this.transaction("ctx", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && Zb(c, a); + c && Yb(c, a); }; }), this.transaction("tag", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && Zb(c, a, !0); + c && Yb(c, a, !0); }; }), this.transaction("reg", "readwrite", function(b) { for (var c = 0; c < a.length; c++) { @@ -3522,7 +3517,7 @@ u.remove = function(a) { } })]); }; -function Wb(a) { +function Vb(a) { return new Promise(function(b, c) { a.onsuccess = function() { b(this.result); @@ -3534,8 +3529,8 @@ function Wb(a) { a = null; }); } -;var $b = {Index:S, Charset:Ib, Encoder:Ga, Document:W, Worker:Sa, Resolver:Y, IndexedDB:Vb, Language:{}}, ac = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : "undefined" !== typeof window ? window : {}, bc; -(bc = ac.define) && bc.amd ? bc([], function() { - return $b; -}) : "object" === typeof ac.exports ? ac.exports = $b : ac.FlexSearch = $b; +;var Zb = {Index:S, Charset:Hb, Encoder:Ga, Document:W, Worker:Ra, Resolver:Y, IndexedDB:Ub, Language:{}}, $b = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : "undefined" !== typeof window ? window : {}, ac; +(ac = $b.define) && ac.amd ? ac([], function() { + return Zb; +}) : "object" === typeof $b.exports ? $b.exports = Zb : $b.FlexSearch = Zb; }(this||self)); diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js index 8082aaf..a90a7f1 100644 --- a/dist/flexsearch.es5.min.js +++ b/dist/flexsearch.es5.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.115 (ES5) + * FlexSearch.js v0.8.117 (ES5) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -53,86 +53,86 @@ d=[],e=this.split||""===this.split?a.split(this.split):a,g=0,f=void 0,h=void 0;g (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 O,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),O=new self.FlexSearch.Index(Ha),delete self.FlexSearch):O=new R(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(O,d[0]),9)}g=d&&O[b].apply(O,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,O.import(d[0],f);case 5:postMessage("search"===b?{id:c,msg:g}:{id:c}),h.h=0}})};function Ja(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={},Qa={};function Ra(a){Na=0;Pa[a]=Qa[a]} -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||(Na=setTimeout(Ra,0,a),Oa=Date.now());Qa[a]||(Qa[a]=Pa[a]=1E3);if(!--Pa[a]){Pa[a]=Qa[a]=Qa[a]*this.priority*this.priority*3/(Date.now()-Oa)|0||1;Na=clearTimeout(Na);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 S(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)};e.worker.postMessage({id:Sa,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}a=void 0===a?{}:a;if(!this||this.constructor!==S)return new S(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);return g.then?g.then(function(f){return b.call(e,f)}):b.call(this,g)}T("add");T("append");T("search");T("update");T("remove");T("clear");T("export");T("import");Ja(S.prototype); -function T(a){S.prototype[a]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if("function"===typeof d){var e=d;c.pop()}d=new Promise(function(g){"export"===a&&"function"===typeof c[0]&&(c[0]=null);b.h[++Sa]=g;b.worker.postMessage({task:a,id:Sa,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", -"module/worker/worker.js"),{type:"module"})};function Ua(a,b){b=void 0===b?0:b;var c=[],d=[];b&&(b=25E4/b*5E3|0);a=w(a.entries());for(var e=a.next();!e.done;e=a.next())d.push(e.value),d.length===b&&(c.push(d),d=[]);d.length&&c.push(d);return c}function Va(a,b){b||(b=new Map);for(var c=0,d;c=f.length)b-=f.length;else{b=f[d?"splice":"slice"](b,c);if(f=b.length)if(e=e.length?e.concat(b):b,c-=f,d&&(a.length-=f),!c)break;b=0}return e} -function bb(a){if(!this)return new bb(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var g=0,f=0,h,k;fc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(g=0;gd)d-=f.length; +break}return E(h,g,7);case 7:g=h.D;h.h=5;break;case 9:f=h.D,O.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 S=0; +function Ra(a){function b(f){function h(k){k=k.data||k;var l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}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[++S]=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 ab(a){if(!this)return new ab(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var g=0,f=0,h,k;fc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(g=0;gd)d-=f.length; else{if(f.length>c||d)f=f.slice(d,c+d),c-=f.length,d&&(d-=f.length);e.push(f);if(!c)break}k=1b?b?a.slice(c,c+b):a.slice(c):a,d?X.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?X.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};Y.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?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=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?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){for(var g=[],f=J(),h=0,k=0,l;kb?b?a.slice(c,c+b):a.slice(c):a,d?X.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?X.call(this,f):f;e.push(f);b-=h;if(!b)break}e=1a.length?this.result=a[0]:(this.result=jb(a,c,d,!1,this.h),d=0));return g?this.resolve(c,d,e):this};Y.prototype.and=function(){var a=this.result.length;if(!a){var b=arguments[0];if(b){a=!!b.suggest;var c=b.resolve;var d=b.limit;var e=b.offset;var g=b.enrich&&c}}return a?(a=mb(this,"and",arguments),ob.call(this,a.W,a.$,a.limit,a.offset,a.enrich,a.resolve,a.suggest)):c?this.resolve(d,e,g):this}; +function ob(a,b,c,d,e,g,f){if(b.length){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else{if(b=za(a))return this.result=ib(a,b,c,d,f,this.h,g),g?e?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){var h=this;return Promise.all(b).then(function(k){a=[];for(var l=0,m=void 0;la.length)this.result=a[0];else return this.result=qb.call(this,a,c,d,g,this.h),g?e?X.call(this.index,this.result):this.result:this;else f||(this.result=a);return g?this.resolve(c,d,e):this} +function qb(a,b,c,d,e){for(var g=[],f=J(),h=0,k=0,l;kc||d)a=a.slice(d,d+c);e&&(a=X.call(this,a));return a}} -function X(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=X.call(this,a));return a}} +function X(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)}; -Z.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};Z.prototype.remove=function(a){for(var b=w(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};Z.prototype.clear=function(){this.cache.clear();this.h=""};var Ab={normalize:function(a){return a.toLowerCase()}};var Bb=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 Cb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Db=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];var Eb={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Fb=/[\x00-\x7F]+/g;var Gb=/[\x00-\x7F]+/g;var Hb=/[\x00-\x7F]+/g;var Ib={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:Ab,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Bb},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Bb,matcher:Cb,replacer:Db},LatinExtra:{normalize:!0,dedupe:!0,mapper:Bb,replacer:Db.concat([/(?!^)[aeo]/g,""]),matcher:Cb},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;bn;q--){p=l.substring(n,q);var r=this.score?this.score(b,l,k,p,n):Kb(h,d,k,m,n);Lb(this,g,p,r,a,c)}break}case "reverse":if(1< -m){for(q=m-1;0p?0:1),d,k,q-1,r-1),t=this.bidirectional&&l>n;Lb(this,e,t?n:l,x,a,c,t?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& -(b||this.commit_task.push({del:a}),this.ca&&Mb(this));return this}; -function Lb(a,b,c,d,e,g,f){var h=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])if(f?(b=k||(b[c]=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 bb(h);if(a.fastupdate)for(c=w(a.reg.values()),g=c.next();!g.done;g=c.next())g=g.value,g.includes(h)&&(g[g.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} -function Kb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,g,f,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};R.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 Rb(this.map,a),this.depth&&Rb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.ca&&Mb(this));this.cache&&this.cache.remove(a);return this}; -function Rb(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)}; +Z.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};Z.prototype.remove=function(a){for(var b=w(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};Z.prototype.clear=function(){this.cache.clear();this.h=""};var zb={normalize:function(a){return a.toLowerCase()}};var Ab=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);var Bb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Cb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];var Db={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};var Eb=/[\x00-\x7F]+/g;var Fb=/[\x00-\x7F]+/g;var Gb=/[\x00-\x7F]+/g;var Hb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:zb,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Ab},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Ab,matcher:Bb,replacer:Cb},LatinExtra:{normalize:!0,dedupe:!0,mapper:Ab,replacer:Cb.concat([/(?!^)[aeo]/g,""]),matcher:Bb},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;bn;q--){p=l.substring(n,q);var r=this.score?this.score(b,l,k,p,n):Jb(h,d,k,m,n);Kb(this,g,p,r,a,c)}break}case "reverse":if(1< +m){for(q=m-1;0p?0:1),d,k,q-1,r-1),t=this.bidirectional&&l>n;Kb(this,e,t?n:l,x,a,c,t?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& +(b||this.commit_task.push({del:a}),this.ca&&Lb(this));return this}; +function Kb(a,b,c,d,e,g,f){var h=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])if(f?(b=k||(b[c]=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 ab(h);if(a.fastupdate)for(c=w(a.reg.values()),g=c.next();!g.done;g=c.next())g=g.value,g.includes(h)&&(g[g.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} +function Jb(a,b,c,d,e){return c&&1c)&&(k=c,c=b,b=k);if(a.db)return a.db.get(b,c,d,e,g,f,h);a=c?(a=a.ctx.get(c))&&a.get(b):a.map.get(b);return a};R.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=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length,p=d;p=g.length)return[];if(!b&&!c)return g;g=g.slice(c,c+b);return d?e.enrich(g):g})}; +u.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;dm&&!g&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(g=1),0<=m)if(e=1,1m&&!g&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(g=1),0<=m)if(e=1,1= target; + } + + // cycle all instances from this point + if (cycle) { const self = this; + // move the next microtask onto the next macrotask queue return new Promise(resolve => { setTimeout(function () { resolve(self[key + "Async"].apply(self, args)); @@ -60,14 +59,14 @@ function register(key) { }); } - //this.async = true; const res = this[key].apply(this, args), promise = res.then ? res : new Promise(resolve => resolve(res)); - //this.async = false; + if (callback) { promise.then(callback); } + return promise; }; } \ No newline at end of file diff --git a/dist/module-debug/bundle.js b/dist/module-debug/bundle.js index 6767c99..2f49e72 100644 --- a/dist/module-debug/bundle.js +++ b/dist/module-debug/bundle.js @@ -186,6 +186,7 @@ import Charset from "./charset.js"; /** @export */DocumentDescriptor.index; /** @export */DocumentDescriptor.tag; /** @export */DocumentDescriptor.store; +/** @export */DocumentDescriptor.id; /** @export */TagOptions.field; /** @export */TagOptions.tag; diff --git a/dist/module-debug/compress.js b/dist/module-debug/compress.js index 8efa91a..7da6af0 100644 --- a/dist/module-debug/compress.js +++ b/dist/module-debug/compress.js @@ -32,7 +32,7 @@ export default function (str) { return cache.get(str); } } else { - timer = setTimeout(clear); + timer = setTimeout(clear, 1); } /* 2 ** ((level + 1.5) * 1.6 | 0) */ diff --git a/dist/module-debug/db/indexeddb/index.js b/dist/module-debug/db/indexeddb/index.js index 8472e50..8963b04 100644 --- a/dist/module-debug/db/indexeddb/index.js +++ b/dist/module-debug/db/indexeddb/index.js @@ -296,7 +296,8 @@ IdxDB.prototype.transaction = function (ref, modifier, task) { //db.close; }; const promise = task.call(this, store); - // + // transactions can just be used within the same event loop + // the indexeddb is such a stupid tool :( this.trx[ref + ":" + modifier] = null; return promise; }); diff --git a/dist/module-debug/document.js b/dist/module-debug/document.js index 0afdec6..d465b76 100644 --- a/dist/module-debug/document.js +++ b/dist/module-debug/document.js @@ -55,6 +55,8 @@ export default function Document(options) { this.worker = options.worker; + this.priority = options.priority || 4; + // if(SUPPORT_ASYNC){ // // this switch is used by recall of promise callbacks // this.async = false; @@ -124,6 +126,8 @@ export default function Document(options) { } else { if (options.db) { this.fastupdate = !1; + // think about to return the promise here + // actually it can be awaited on "await index.db" this.mount(options.db); } } diff --git a/dist/module-debug/index.js b/dist/module-debug/index.js index 2ececbb..afb61ff 100644 --- a/dist/module-debug/index.js +++ b/dist/module-debug/index.js @@ -109,7 +109,7 @@ export function autoCommit(self, replace, append) { self.commit_timer = setTimeout(function () { self.commit_timer = null; self.db.commit(self, replace, append); - }, 0); + }, 1); } } diff --git a/dist/module-debug/serialize.js b/dist/module-debug/serialize.js index 54b09ca..83482ed 100644 --- a/dist/module-debug/serialize.js +++ b/dist/module-debug/serialize.js @@ -288,23 +288,23 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) case 1: key = "tag"; - chunk = ctx_to_json(this.tag, this.reg.size); + chunk = this.tag && ctx_to_json(this.tag, this.reg.size); _field = null; break; case 2: key = "doc"; - chunk = map_to_json(this.store); + chunk = this.store && map_to_json(this.store); _field = null; break; - case 3: - - key = "cfg"; - chunk = null; - _field = null; - break; + // case 3: + // + // key = "cfg"; + // chunk = null; + // _field = null; + // break; default: diff --git a/dist/module-debug/type.js b/dist/module-debug/type.js index e32479f..da6a70e 100644 --- a/dist/module-debug/type.js +++ b/dist/module-debug/type.js @@ -44,6 +44,7 @@ export let IndexOptions = {}; * db: (StorageInterface|undefined), * commit: (boolean|undefined), * config: (string|undefined), + * priority: (number|undefined), * field: (string|undefined), * filter: (Function|undefined), * custom: (Function|undefined) diff --git a/dist/module-debug/worker.js b/dist/module-debug/worker.js index 1efa946..332abbf 100644 --- a/dist/module-debug/worker.js +++ b/dist/module-debug/worker.js @@ -60,6 +60,7 @@ export default function WorkerIndex(options = /** @type IndexOptions */{}) { _self.resolver[++pid] = function () { resolve(_self); + if (1e9 < pid) pid = 0; }; _self.worker.postMessage({ @@ -77,6 +78,9 @@ export default function WorkerIndex(options = /** @type IndexOptions */{}) { options: options }); + this.priority = options.priority || 4; + + return this; } diff --git a/dist/module-min/async.js b/dist/module-min/async.js index ca8a04b..1717b4f 100644 --- a/dist/module-min/async.js +++ b/dist/module-min/async.js @@ -1 +1 @@ -import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";export default function(a){register.call(a,"add"),register.call(a,"append"),register.call(a,"search"),register.call(a,"update"),register.call(a,"remove")}let timer,timestamp;const current={},limit={};function tick(a){timer=0,current[a]=limit[a]}function register(a){this[a+"Async"]=function(){const b=arguments,c=b[b.length-1];let d;if("function"==typeof c&&(d=c,delete b[b.length-1]),timer||(timer=setTimeout(tick,0,a),timestamp=Date.now()),limit[a]||(limit[a]=current[a]=1000),! --current[a]){const c=Date.now(),d=c-timestamp,e=3*(this.priority*this.priority);current[a]=limit[a]=0|limit[a]*e/d||1,timer=clearTimeout(timer);const f=this;return new Promise(c=>{setTimeout(function(){c(f[a+"Async"].apply(f,b))},0)})}const e=this[a].apply(this,b),f=e.then?e:new Promise(a=>a(e));return d&&f.then(d),f}} \ No newline at end of file +import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";export default function(a){register.call(a,"add"),register.call(a,"append"),register.call(a,"search"),register.call(a,"update"),register.call(a,"remove")}let timer,timestamp,cycle;function tick(){timer=cycle=0}function register(a){this[a+"Async"]=function(){const b=arguments,c=b[b.length-1];let d;if("function"==typeof c&&(d=c,delete b[b.length-1]),!timer)timer=setTimeout(tick,0),timestamp=Date.now();else if(!cycle){const a=Date.now(),b=a-timestamp,c=3*(this.priority*this.priority);cycle=b>=c}if(cycle){const c=this;return new Promise(d=>{setTimeout(function(){d(c[a+"Async"].apply(c,b))},0)})}const e=this[a].apply(this,b),f=e.then?e:new Promise(a=>a(e));return d&&f.then(d),f}} \ No newline at end of file diff --git a/dist/module-min/bundle.js b/dist/module-min/bundle.js index b12c4b3..0b1671d 100644 --- a/dist/module-min/bundle.js +++ b/dist/module-min/bundle.js @@ -1 +1 @@ -import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,FieldOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions,PersistentOptions,ResolverOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/index.js";import Charset from"./charset.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.serialize,Index.prototype.mount,Index.prototype.commit,Index.prototype.destroy,Index.prototype.reg,Index.prototype.map,Index.prototype.ctx,Index.prototype.db,Index.prototype.tag,Index.prototype.store,Index.prototype.depth,Index.prototype.bidirectional,Index.prototype.commit_task,Index.prototype.commit_timer,Index.prototype.cache,Index.prototype.bypass,Index.prototype.document,Index.prototype.encoder,Encoder.prototype.assign,Encoder.prototype.encode,Encoder.prototype.addMatcher,Encoder.prototype.addStemmer,Encoder.prototype.addFilter,Encoder.prototype.addMapper,Encoder.prototype.addReplacer,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.prototype.destroy,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Document.prototype.field,Document.prototype.index,Document.prototype.reg,Document.prototype.tag,Document.prototype.store,Document.prototype.fastupdate,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Resolver.prototype.result,StorageInterface.db,StorageInterface.id,StorageInterface.support_tag_search,StorageInterface.fastupdate,StorageInterface.prototype.mount,StorageInterface.prototype.open,StorageInterface.prototype.close,StorageInterface.prototype.destroy,StorageInterface.prototype.clear,StorageInterface.prototype.get,StorageInterface.prototype.tag,StorageInterface.prototype.enrich,StorageInterface.prototype.has,StorageInterface.prototype.search,StorageInterface.prototype.info,StorageInterface.prototype.commit,StorageInterface.prototype.remove,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.worker,IndexOptions.config,IndexOptions.priority,IndexOptions.export,IndexOptions.import,FieldOptions.preset,FieldOptions.context,FieldOptions.encoder,FieldOptions.encode,FieldOptions.resolution,FieldOptions.tokenize,FieldOptions.fastupdate,FieldOptions.score,FieldOptions.keystore,FieldOptions.rtl,FieldOptions.cache,FieldOptions.db,FieldOptions.config,FieldOptions.resolve,FieldOptions.field,FieldOptions.filter,FieldOptions.custom,FieldOptions.worker,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,DocumentOptions.priority,DocumentOptions.export,DocumentOptions.import,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,SearchOptions.resolution,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,DocumentSearchOptions.highlight,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char,PersistentOptions.name,PersistentOptions.field,PersistentOptions.type,PersistentOptions.db,ResolverOptions.index,ResolverOptions.query,ResolverOptions.limit,ResolverOptions.offset,ResolverOptions.enrich,ResolverOptions.resolve,ResolverOptions.suggest,ResolverOptions.and,ResolverOptions.or,ResolverOptions.xor,ResolverOptions.not;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{FlexSearch.Language={};const a="undefined"==typeof self?"undefined"==typeof global?"undefined"==typeof window?{}:window:global:self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}export default FlexSearch;export{Index,Document,Encoder,Charset,WorkerIndex as Worker,Resolver,IdxDB as IndexedDB}; \ No newline at end of file +import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,FieldOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions,PersistentOptions,ResolverOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/index.js";import Charset from"./charset.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.serialize,Index.prototype.mount,Index.prototype.commit,Index.prototype.destroy,Index.prototype.reg,Index.prototype.map,Index.prototype.ctx,Index.prototype.db,Index.prototype.tag,Index.prototype.store,Index.prototype.depth,Index.prototype.bidirectional,Index.prototype.commit_task,Index.prototype.commit_timer,Index.prototype.cache,Index.prototype.bypass,Index.prototype.document,Index.prototype.encoder,Encoder.prototype.assign,Encoder.prototype.encode,Encoder.prototype.addMatcher,Encoder.prototype.addStemmer,Encoder.prototype.addFilter,Encoder.prototype.addMapper,Encoder.prototype.addReplacer,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.prototype.destroy,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Document.prototype.field,Document.prototype.index,Document.prototype.reg,Document.prototype.tag,Document.prototype.store,Document.prototype.fastupdate,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Resolver.prototype.result,StorageInterface.db,StorageInterface.id,StorageInterface.support_tag_search,StorageInterface.fastupdate,StorageInterface.prototype.mount,StorageInterface.prototype.open,StorageInterface.prototype.close,StorageInterface.prototype.destroy,StorageInterface.prototype.clear,StorageInterface.prototype.get,StorageInterface.prototype.tag,StorageInterface.prototype.enrich,StorageInterface.prototype.has,StorageInterface.prototype.search,StorageInterface.prototype.info,StorageInterface.prototype.commit,StorageInterface.prototype.remove,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.worker,IndexOptions.config,IndexOptions.priority,IndexOptions.export,IndexOptions.import,FieldOptions.preset,FieldOptions.context,FieldOptions.encoder,FieldOptions.encode,FieldOptions.resolution,FieldOptions.tokenize,FieldOptions.fastupdate,FieldOptions.score,FieldOptions.keystore,FieldOptions.rtl,FieldOptions.cache,FieldOptions.db,FieldOptions.config,FieldOptions.resolve,FieldOptions.field,FieldOptions.filter,FieldOptions.custom,FieldOptions.worker,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,DocumentOptions.priority,DocumentOptions.export,DocumentOptions.import,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,DocumentDescriptor.id,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,SearchOptions.resolution,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,DocumentSearchOptions.highlight,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char,PersistentOptions.name,PersistentOptions.field,PersistentOptions.type,PersistentOptions.db,ResolverOptions.index,ResolverOptions.query,ResolverOptions.limit,ResolverOptions.offset,ResolverOptions.enrich,ResolverOptions.resolve,ResolverOptions.suggest,ResolverOptions.and,ResolverOptions.or,ResolverOptions.xor,ResolverOptions.not;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{FlexSearch.Language={};const a="undefined"==typeof self?"undefined"==typeof global?"undefined"==typeof window?{}:window:global:self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}export default FlexSearch;export{Index,Document,Encoder,Charset,WorkerIndex as Worker,Resolver,IdxDB as IndexedDB}; \ No newline at end of file diff --git a/dist/module-min/compress.js b/dist/module-min/compress.js index 0057655..c8adfbc 100644 --- a/dist/module-min/compress.js +++ b/dist/module-min/compress.js @@ -1 +1 @@ -let table,timer;const cache=new Map;function toRadix(a,b=255){if(!table){table=Array(b);for(let a=0;ac.add(a,b)):this.add(a,b)};function cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;dc.add(a,b)):this.add(a,b)};function cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;d= target; + } + + // cycle all instances from this point + if (cycle) { const self = this; + // move the next microtask onto the next macrotask queue return new Promise(resolve => { setTimeout(function () { resolve(self[key + "Async"].apply(self, args)); @@ -60,14 +59,14 @@ function register(key) { }); } - //this.async = true; const res = this[key].apply(this, args), promise = res.then ? res : new Promise(resolve => resolve(res)); - //this.async = false; + if (callback) { promise.then(callback); } + return promise; }; } \ No newline at end of file diff --git a/dist/module/bundle.js b/dist/module/bundle.js index 6767c99..2f49e72 100644 --- a/dist/module/bundle.js +++ b/dist/module/bundle.js @@ -186,6 +186,7 @@ import Charset from "./charset.js"; /** @export */DocumentDescriptor.index; /** @export */DocumentDescriptor.tag; /** @export */DocumentDescriptor.store; +/** @export */DocumentDescriptor.id; /** @export */TagOptions.field; /** @export */TagOptions.tag; diff --git a/dist/module/compress.js b/dist/module/compress.js index 8efa91a..7da6af0 100644 --- a/dist/module/compress.js +++ b/dist/module/compress.js @@ -32,7 +32,7 @@ export default function (str) { return cache.get(str); } } else { - timer = setTimeout(clear); + timer = setTimeout(clear, 1); } /* 2 ** ((level + 1.5) * 1.6 | 0) */ diff --git a/dist/module/db/indexeddb/index.js b/dist/module/db/indexeddb/index.js index 8472e50..8963b04 100644 --- a/dist/module/db/indexeddb/index.js +++ b/dist/module/db/indexeddb/index.js @@ -296,7 +296,8 @@ IdxDB.prototype.transaction = function (ref, modifier, task) { //db.close; }; const promise = task.call(this, store); - // + // transactions can just be used within the same event loop + // the indexeddb is such a stupid tool :( this.trx[ref + ":" + modifier] = null; return promise; }); diff --git a/dist/module/document.js b/dist/module/document.js index 4248511..7cf3324 100644 --- a/dist/module/document.js +++ b/dist/module/document.js @@ -55,6 +55,8 @@ export default function Document(options) { this.worker = options.worker; + this.priority = options.priority || 4; + // if(SUPPORT_ASYNC){ // // this switch is used by recall of promise callbacks // this.async = false; @@ -124,6 +126,8 @@ export default function Document(options) { } else { if (options.db) { this.fastupdate = !1; + // think about to return the promise here + // actually it can be awaited on "await index.db" this.mount(options.db); } } diff --git a/dist/module/index.js b/dist/module/index.js index 76e715e..caa4743 100644 --- a/dist/module/index.js +++ b/dist/module/index.js @@ -109,7 +109,7 @@ export function autoCommit(self, replace, append) { self.commit_timer = setTimeout(function () { self.commit_timer = null; self.db.commit(self, replace, append); - }, 0); + }, 1); } } diff --git a/dist/module/serialize.js b/dist/module/serialize.js index 54b09ca..83482ed 100644 --- a/dist/module/serialize.js +++ b/dist/module/serialize.js @@ -288,23 +288,23 @@ export function exportDocument(callback, _field, _index_doc = 0, _index_obj = 0) case 1: key = "tag"; - chunk = ctx_to_json(this.tag, this.reg.size); + chunk = this.tag && ctx_to_json(this.tag, this.reg.size); _field = null; break; case 2: key = "doc"; - chunk = map_to_json(this.store); + chunk = this.store && map_to_json(this.store); _field = null; break; - case 3: - - key = "cfg"; - chunk = null; - _field = null; - break; + // case 3: + // + // key = "cfg"; + // chunk = null; + // _field = null; + // break; default: diff --git a/dist/module/type.js b/dist/module/type.js index e32479f..da6a70e 100644 --- a/dist/module/type.js +++ b/dist/module/type.js @@ -44,6 +44,7 @@ export let IndexOptions = {}; * db: (StorageInterface|undefined), * commit: (boolean|undefined), * config: (string|undefined), + * priority: (number|undefined), * field: (string|undefined), * filter: (Function|undefined), * custom: (Function|undefined) diff --git a/dist/module/worker.js b/dist/module/worker.js index 1efa946..332abbf 100644 --- a/dist/module/worker.js +++ b/dist/module/worker.js @@ -60,6 +60,7 @@ export default function WorkerIndex(options = /** @type IndexOptions */{}) { _self.resolver[++pid] = function () { resolve(_self); + if (1e9 < pid) pid = 0; }; _self.worker.postMessage({ @@ -77,6 +78,9 @@ export default function WorkerIndex(options = /** @type IndexOptions */{}) { options: options }); + this.priority = options.priority || 4; + + return this; } diff --git a/doc/async.md b/doc/async.md new file mode 100644 index 0000000..ea07443 --- /dev/null +++ b/doc/async.md @@ -0,0 +1,39 @@ +## Asynchronous Runtime Balancer + +> The async processing model is automatically observed by a runtime balancer to prevent any blocking issues, even on page load. + +The most methods of each index type provides an async version, e.g.: + +- addAsync() +- updateAsync() +- removeAsync() +- searchAsync() + +All those async versions always return a `Promise`, although a callback can be passed additionally as the last parameter. + +When calling async methods of the index, a runtime balancer observe the current event loop and will pass to the next event loop automatically. + +You can control how early the process should move over to the next event loop by passing the option property `priority`: + +```js +const index = new Index({ + // a value between 1 and 9 + priority: 4 +}); +``` + +The lowest valid priority number is `1` and is typically known as `idle` (event loop cycles by native ~4ms). The default priority is `4` which is optimized for non-blocking user interfaces within a browser (event loop cycles every ~40ms). +When you have some very smooth running animation you should use a priority of `2` to keep the animation running by 60 fps without any stutter. Targeting 120 fps or higher you should use `1`. + +On Node.js you can slightly increase this priority e.g. to `6`, because here there is no UI involved. +A priority value of `9` will cycle the event loop on every ~500ms which is the maximum recommended blocking time. You should not use a value higher than this. + +Do not forget to `await` on every async task you apply to the index: + +```js +for(let i = 0; i < 99999999; i++){ + await index.addAsync(i, "test " + i); +} +``` + +You can perform queries to the index during any other async batch is running. \ No newline at end of file diff --git a/example/browser-module/document-worker-extern-config/index.html b/example/browser-module/document-worker-extern-config/index.html index bc5d3ae..4aa780a 100644 --- a/example/browser-module/document-worker-extern-config/index.html +++ b/example/browser-module/document-worker-extern-config/index.html @@ -8,7 +8,7 @@