From 63531ef4f10618015449e446a4a8c39a719495cb Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Sat, 22 Mar 2025 15:42:12 +0100 Subject: [PATCH] (re)adding tests, migration --- CHANGELOG.md | 7 + README.md | 2 +- dist/flexsearch.bundle.debug.js | 297 +-- dist/flexsearch.bundle.min.js | 113 +- dist/flexsearch.bundle.module.debug.js | 295 +-- dist/flexsearch.bundle.module.min.js | 111 +- dist/flexsearch.compact.debug.js | 227 +- dist/flexsearch.compact.min.js | 66 +- dist/flexsearch.compact.module.debug.js | 225 +- dist/flexsearch.compact.module.min.js | 64 +- dist/flexsearch.es5.debug.js | 208 +- dist/flexsearch.es5.min.js | 24 +- dist/flexsearch.light.debug.js | 141 +- dist/flexsearch.light.min.js | 34 +- dist/flexsearch.light.module.debug.js | 139 +- dist/flexsearch.light.module.min.js | 34 +- dist/module-debug/bundle.js | 8 +- dist/module-debug/charset/arabic/default.js | 3 +- dist/module-debug/charset/latin/advanced.js | 5 +- dist/module-debug/charset/latin/exact.js | 5 +- dist/module-debug/document.js | 10 +- dist/module-debug/document/search.js | 15 +- dist/module-debug/encoder.js | 16 +- dist/module-debug/index/add.js | 37 +- dist/module-debug/index/search.js | 5 +- dist/module-debug/preset.js | 7 +- dist/module-debug/type.js | 2 +- dist/module-debug/worker.js | 20 +- dist/module-debug/worker/handler.js | 2 +- dist/module-min/bundle.js | 2 +- dist/module-min/charset/arabic/default.js | 2 +- dist/module-min/charset/latin/advanced.js | 2 +- dist/module-min/charset/latin/exact.js | 2 +- dist/module-min/document/search.js | 2 +- dist/module-min/encoder.js | 2 +- dist/module-min/index/add.js | 2 +- dist/module-min/index/search.js | 2 +- dist/module-min/preset.js | 2 +- dist/module-min/worker.js | 2 +- dist/module/bundle.js | 8 +- dist/module/charset/arabic/default.js | 3 +- dist/module/charset/latin/advanced.js | 5 +- dist/module/charset/latin/exact.js | 5 +- dist/module/document.js | 10 +- dist/module/document/search.js | 15 +- dist/module/encoder.js | 16 +- dist/module/index/add.js | 37 +- dist/module/index/search.js | 5 +- dist/module/preset.js | 7 +- dist/module/type.js | 2 +- dist/module/worker.js | 20 +- dist/module/worker/handler.js | 2 +- doc/async.md | 4 +- index.d.ts | 1 + package-lock.json | 2421 ++++++++++++++++++- package.json | 12 +- src/bundle.js | 10 +- src/charset/arabic/default.js | 3 +- src/charset/latin/advanced.js | 9 +- src/charset/latin/exact.js | 3 +- src/config.js | 2 +- src/document.js | 1 + src/document/search.js | 18 +- src/encoder.js | 11 +- src/index/add.js | 68 +- src/index/search.js | 2 + src/preset.js | 7 +- src/type.js | 12 +- src/worker.js | 19 +- src/worker/handler.js | 2 +- task/babel.js | 33 +- task/build.js | 24 +- test/.c8rc.json | 19 + test/async.js | 97 + test/basic.js | 958 ++++++++ test/context.js | 56 + test/document.js | 404 ++++ test/document.tag.js | 204 ++ test/encoder.js | 338 +++ test/issues.js | 90 + test/misc/reporter.js | 21 + test/misc/runner.js | 0 test/persistent.js | 11 + test/resolver.js | 431 ++++ test/scoring.js | 118 + test/serialize.js | 11 + test/tokenize.js | 57 + test/worker.js | 102 + 88 files changed, 6688 insertions(+), 1168 deletions(-) create mode 100644 test/.c8rc.json create mode 100644 test/async.js create mode 100644 test/basic.js create mode 100644 test/context.js create mode 100644 test/document.js create mode 100644 test/document.tag.js create mode 100644 test/encoder.js create mode 100644 test/issues.js create mode 100644 test/misc/reporter.js create mode 100644 test/misc/runner.js create mode 100644 test/persistent.js create mode 100644 test/resolver.js create mode 100644 test/scoring.js create mode 100644 test/serialize.js create mode 100644 test/tokenize.js create mode 100644 test/worker.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 789ab40..e63bd7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### v0.8.1 + +- Resolver Support for Documents +- Asynchronous Runtime Balancer, new option `priority` +- Export/Import Worker Indexes + Document Worker +- Improved interoperability of the different build packages, including source folder + ### v0.8.0 - Persistent indexes support for: `IndexedDB` (Browser), `Redis`, `SQLite`, `Postgres`, `MongoDB`, `Clickhouse` diff --git a/README.md b/README.md index fc4b5a0..0bf18a5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ FlexSearch v0.8: [Overview and Migration Guide](doc/0.8.0.md) - + Basic Start  •  API Reference  •  diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js index 7c1af9c..854e5db 100644 --- a/dist/flexsearch.bundle.debug.js +++ b/dist/flexsearch.bundle.debug.js @@ -1,12 +1,12 @@ /**! - * FlexSearch.js v0.8.117 (Bundle/Debug) + * FlexSearch.js v0.8.123 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ (function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f; -var t; +var u; function A(a, b, c) { const e = typeof c, d = typeof a; if ("undefined" !== e) { @@ -86,16 +86,20 @@ function ca(a) { "\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db", "\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]]; const ea = /[^\p{L}\p{N}]+/u, fa = /(\d{3})/g, ha = /(\D)(\d{3})/g, ia = /(\d{3})(\D)/g, ja = "".normalize && /[\u0300-\u036f]/g; -function J(a) { +function J(a = {}) { if (!this || this.constructor !== J) { return new J(...arguments); } - for (let b = 0; b < arguments.length; b++) { - this.assign(arguments[b]); + if (arguments.length) { + for (a = 0; a < arguments.length; a++) { + this.assign(arguments[a]); + } + } else { + this.assign(a); } } -t = J.prototype; -t.assign = function(a) { +u = J.prototype; +u.assign = function(a) { this.normalize = A(a.normalize, !0, this.normalize); let b = a.include, c = b || a.exclude || a.split, e; if (c || "" === c) { @@ -159,7 +163,7 @@ t.assign = function(a) { } return this; }; -t.addStemmer = function(a, b) { +u.addStemmer = function(a, b) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; @@ -167,13 +171,13 @@ t.addStemmer = function(a, b) { this.cache && L(this); return this; }; -t.addFilter = function(a) { +u.addFilter = function(a) { this.filter || (this.filter = new Set()); this.filter.add(a); this.cache && L(this); return this; }; -t.addMapper = function(a, b) { +u.addMapper = function(a, b) { if ("object" === typeof a) { return this.addReplacer(a, b); } @@ -185,7 +189,7 @@ t.addMapper = function(a, b) { this.cache && L(this); return this; }; -t.addMatcher = function(a, b) { +u.addMatcher = function(a, b) { if ("object" === typeof a) { return this.addReplacer(a, b); } @@ -199,7 +203,7 @@ t.addMatcher = function(a, b) { this.cache && L(this); return this; }; -t.addReplacer = function(a, b) { +u.addReplacer = function(a, b) { if ("string" === typeof a) { return this.addMatcher(a, b); } @@ -208,7 +212,7 @@ t.addReplacer = function(a, b) { this.cache && L(this); return this; }; -t.encode = function(a) { +u.encode = function(a) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.B.has(a)) { @@ -392,7 +396,7 @@ function R(a) { }; } 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", + return b ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/node/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)("import.meta.dirname")+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } ;function sa(a, b = 0) { @@ -582,35 +586,35 @@ U.prototype.add = function(a) { let c = this.index[b]; c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c)); }; -t = T.prototype; -t.has = U.prototype.has = function(a) { +u = T.prototype; +u.has = U.prototype.has = function(a) { const b = this.index[this.B(a)]; return b && b.has(a); }; -t.delete = U.prototype.delete = function(a) { +u.delete = U.prototype.delete = function(a) { const b = this.index[this.B(a)]; b && b.delete(a) && this.size--; }; -t.clear = U.prototype.clear = function() { +u.clear = U.prototype.clear = function() { this.index = B(); this.h = []; this.size = 0; }; -t.values = U.prototype.values = function*() { +u.values = U.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].values()) { yield b; } } }; -t.keys = U.prototype.keys = function*() { +u.keys = U.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].keys()) { yield b; } } }; -t.entries = U.prototype.entries = function*() { +u.entries = U.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].entries()) { yield b; @@ -775,11 +779,11 @@ function Ca(a, b, c, e, d, f, g, k) { let h = [], l; var n; l = B(); - for (let m = 0, q, p, r, u; m < b; m++) { + for (let m = 0, q, p, t, r; m < b; m++) { for (let v = 0; v < k; v++) { - if (r = a[v], m < r.length && (q = r[m])) { + if (t = a[v], m < t.length && (q = t[m])) { for (let x = 0; x < q.length; x++) { - p = q[x], (n = l[p]) ? l[p]++ : (n = 0, l[p] = 1), u = h[n] || (h[n] = []), g || (n = m + (v || !d ? 0 : f || 0), u = u[n] || (u[n] = [])), u.push(p); + p = q[x], (n = l[p]) ? l[p]++ : (n = 0, l[p] = 1), r = h[n] || (h[n] = []), g || (n = m + (v || !d ? 0 : f || 0), r = r[n] || (r[n] = [])), r.push(p); } } } @@ -845,13 +849,13 @@ function Fa(a, b, c, e, d) { m = a[n]; for (let p = 0; p < m.length; p++) { if (l = (e = m[p]) && e.length) { - for (let r = 0; r < l; r++) { - if (k = e[r], !g[k]) { + for (let t = 0; t < l; t++) { + if (k = e[t], !g[k]) { if (g[k] = 1, c) { c--; } else { - let u = (p + (n < h - 1 ? d || 0 : 0)) / (n + 1) | 0; - (f[u] || (f[u] = [])).push(k); + let r = (p + (n < h - 1 ? d || 0 : 0)) / (n + 1) | 0; + (f[r] || (f[r] = [])).push(k); if (++q === b) { return f; } @@ -1062,19 +1066,19 @@ function Ma(a, b, c, e, d) { for (let m = 0, q; m < a.length; m++) { if (q = a[m]) { if (l = q[h]) { - for (let p = 0, r; p < l.length; p++) { - if (r = l[p], 1 === g[r]) { + for (let p = 0, t; p < l.length; p++) { + if (t = l[p], 1 === g[t]) { if (c) { c--; } else { if (e) { - if (f.push(r), f.length === b) { + if (f.push(t), f.length === b) { return f; } } else { - const u = h + (m ? d : 0); - f[u] || (f[u] = []); - f[u].push(r); + const r = h + (m ? d : 0); + f[r] || (f[r] = []); + f[r].push(t); if (++n === b) { return f; } @@ -1203,7 +1207,7 @@ V.prototype.search = function(a, b, c, e) { k = c.merge; h = g || c.field || (h = c.index) && (h.index ? null : h); var p = this.tag && c.tag; - var r = c.suggest; + var t = c.suggest; m = !1 !== c.resolve; if (!m && !g) { if (h = h || this.field) { @@ -1214,8 +1218,8 @@ V.prototype.search = function(a, b, c, e) { } } this.store && c.enrich && !m && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - var u = this.store && c.enrich && m; - q = c.highlight && u; + var r = this.store && c.enrich && m; + q = c.highlight && r; b = c.limit || b; l = c.offset || 0; b || (b = 100); @@ -1254,7 +1258,7 @@ V.prototype.search = function(a, b, c, e) { } p = v; if (!a) { - r = []; + t = []; if (v.length) { for (p = 0; p < v.length; p += 2) { if (this.db) { @@ -1263,14 +1267,14 @@ V.prototype.search = function(a, b, c, e) { console.warn("Tag '" + v[p] + ":" + v[p + 1] + "' will be skipped because there is no field '" + v[p] + "'."); continue; } - r.push(m = m.db.tag(v[p + 1], b, l, u)); + t.push(m = m.db.tag(v[p + 1], b, l, r)); } else { - m = Pa.call(this, v[p], v[p + 1], b, l, u); + m = Pa.call(this, v[p], v[p + 1], b, l, r); } d.push({field:v[p], tag:v[p + 1], result:m}); } } - return r.length ? Promise.all(r).then(function(z) { + return t.length ? Promise.all(t).then(function(z) { for (let w = 0; w < z.length; w++) { d[w].result = z[w]; } @@ -1289,16 +1293,16 @@ V.prototype.search = function(a, b, c, e) { continue; } let C; - E(D) || (C = D, D = C.field, a = C.query || a, b = C.limit || b, l = C.offset || l, r = C.suggest || r, u = this.store && (C.enrich || u)); + E(D) || (C = D, D = C.field, a = C.query || a, b = C.limit || b, l = C.offset || l, t = C.suggest || t, r = this.store && (C.enrich || r)); if (e) { w = e[z]; } else { if (x = C || c, y = this.index.get(D), p && (this.db && (x.tag = p, F = y.db.support_tag_search, x.field = h), F || (x.enrich = !1)), v) { v[z] = y.search(a, b, x); - x && u && (x.enrich = u); + x && r && (x.enrich = r); continue; } else { - w = y.search(a, b, x), x && u && (x.enrich = u); + w = y.search(a, b, x), x && r && (x.enrich = r); } } H = w && (m ? w.length : w.result.length); @@ -1311,7 +1315,7 @@ V.prototype.search = function(a, b, c, e) { let K = e[G]; if (K && K.length) { y++, x.push(K); - } else if (!r) { + } else if (!t) { return m ? d : new X(d); } } @@ -1320,7 +1324,7 @@ V.prototype.search = function(a, b, c, e) { 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) { + if (console.warn("Tag '" + p[G] + ":" + p[G + 1] + "' will be skipped because there is no field '" + p[G] + "'."), t) { continue; } else { return m ? d : new X(d); @@ -1328,7 +1332,7 @@ V.prototype.search = function(a, b, c, e) { } if (qb = (K = K && K.get(p[G + 1])) && K.length) { y++, x.push(K); - } else if (!r) { + } else if (!t) { return m ? d : new X(d); } } @@ -1336,7 +1340,7 @@ V.prototype.search = function(a, b, c, e) { if (y) { w = Ga(w, x, m); H = w.length; - if (!H && !r) { + if (!H && !t) { return m ? w : new X(w); } y--; @@ -1350,16 +1354,16 @@ V.prototype.search = function(a, b, c, e) { } if (v) { if (this.db && p && p.length && !F) { - for (u = 0; u < p.length; u += 2) { - e = this.index.get(p[u]); + for (r = 0; r < p.length; r += 2) { + e = this.index.get(p[r]); if (!e) { - if (console.warn("Tag '" + p[u] + ":" + p[u + 1] + "' was not found because there is no field '" + p[u] + "'."), r) { + if (console.warn("Tag '" + p[r] + ":" + p[r + 1] + "' was not found because there is no field '" + p[r] + "'."), t) { continue; } else { return m ? d : new X(d); } } - v.push(e.db.tag(p[u + 1], b, l, !1)); + v.push(e.db.tag(p[r + 1], b, l, !1)); } } const z = this; @@ -1370,19 +1374,19 @@ V.prototype.search = function(a, b, c, e) { if (!n) { return m ? d : new X(d); } - if (g && (!u || !this.store)) { + if (g && (!r || !this.store)) { return d[0]; } v = []; for (let z = 0, w; z < f.length; z++) { w = d[z]; - u && w.length && !w[0].doc && (this.db ? v.push(w = this.index.get(this.field[0]).db.enrich(w)) : w = W.call(this, w)); + r && w.length && !w[0].doc && (this.db ? v.push(w = this.index.get(this.field[0]).db.enrich(w)) : w = W.call(this, w)); if (g) { return m ? w : new X(w); } d[z] = {field:f[z], result:w}; } - if (u && this.db && v.length) { + if (r && this.db && v.length) { const z = this; return Promise.all(v).then(function(w) { for (let D = 0; D < w.length; D++) { @@ -1395,17 +1399,17 @@ V.prototype.search = function(a, b, c, e) { }; 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++) { + for (let n = 0, m, q, p, t, r; n < a.length; n++) { m = a[n].result; q = a[n].field; - r = c.get(q); - p = r.encoder; - h = r.tokenize; - u = d[e.indexOf(q)]; + t = c.get(q); + p = t.encoder; + h = t.tokenize; + r = d[e.indexOf(q)]; p !== g && (g = p, k = g.encode(b)); for (let v = 0; v < m.length; v++) { let x = ""; - var l = ba(m[v].doc, u); + var l = ba(m[v].doc, r); let y = g.encode(l); l = l.split(g.split); for (let F = 0, z, w; F < y.length; F++) { @@ -1441,7 +1445,7 @@ function Qa(a, b) { f = a[d]; g = f.result; for (let k = 0, h, l, n; k < g.length; k++) { - if (l = g[k], h = l.id, n = e[h]) { + if (l = g[k], "object" !== typeof l && (l = {id:l}), h = l.id, n = e[h]) { n.push(f.field); } else { if (c.length === b) { @@ -1536,8 +1540,8 @@ function W(a) { a.db && (this.fastupdate = !1, this.mount(a.db)); } } -t = V.prototype; -t.mount = function(a) { +u = V.prototype; +u.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); } @@ -1566,7 +1570,7 @@ t.mount = function(a) { this.db = !0; return Promise.all(c); }; -t.commit = async function(a, b) { +u.commit = async function(a, b) { const c = []; for (const e of this.index.values()) { c.push(e.db.commit(e, a, b)); @@ -1574,7 +1578,7 @@ t.commit = async function(a, b) { await Promise.all(c); this.reg.clear(); }; -t.destroy = function() { +u.destroy = function() { const a = []; for (const b of this.index.values()) { a.push(b.destroy()); @@ -1615,13 +1619,13 @@ function Sa(a, b) { e < c.length && (c.length = e); return 1 < e ? c : c[0]; } -t.append = function(a, b) { +u.append = function(a, b) { return this.add(a, b, !0); }; -t.update = function(a, b) { +u.update = function(a, b) { return this.remove(a).add(a, b); }; -t.remove = function(a) { +u.remove = function(a) { I(a) && (a = ba(a, this.key)); for (var b of this.index.values()) { b.remove(a, !0); @@ -1642,7 +1646,7 @@ t.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -t.clear = function() { +u.clear = function() { for (const a of this.index.values()) { a.clear(); } @@ -1654,26 +1658,26 @@ t.clear = function() { this.store && this.store.clear(); return this; }; -t.contain = function(a) { +u.contain = function(a) { return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a); }; -t.cleanup = function() { +u.cleanup = function() { for (const a of this.index.values()) { a.cleanup(); } return this; }; -t.get = function(a) { +u.get = function(a) { return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(b) { return b[0] && b[0].doc; }) : this.store.get(a); }; -t.set = function(a, b) { +u.set = function(a, b) { this.store.set(a, b); return this; }; -t.searchCache = Ua; -t.export = function(a, b, c = 0, e = 0) { +u.searchCache = Ua; +u.export = function(a, b, c = 0, e = 0) { if (c < this.field.length) { const g = this.field[c]; if ((b = this.index.get(g).export(a, g, c, e = 1)) && b.then) { @@ -1706,7 +1710,7 @@ t.export = function(a, b, c = 0, e = 0) { } return ya.call(this, a, b, d, f, c, e); }; -t.import = function(a, b) { +u.import = function(a, b) { var c = a.split("."); "json" === c[c.length - 1] && c.pop(); const e = 2 < c.length ? c[0] : ""; @@ -1788,12 +1792,12 @@ 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 Xa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Ya = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\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) { +var cb = {LatinExact:{split:/\s+/, normalize:!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 = Za[e]; @@ -1801,14 +1805,14 @@ var cb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Va, LatinSimple:{no } a[c] = e; } -}}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { +}}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { return ("" + a).replace($a, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { return ("" + a).replace(ab, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { return ("" + a).replace(bb, " "); }}}; -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}}}; +const db = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; O.prototype.add = function(a, b, c, e) { if (b && (a || 0 === a)) { if (!e && !c && this.reg.has(a)) { @@ -1818,18 +1822,19 @@ O.prototype.add = function(a, b, c, e) { if (e = b.length) { const l = B(), n = B(), m = this.depth, q = this.resolution; for (let p = 0; p < e; p++) { - 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) : eb(q, e, p), g = ""; + let t = b[this.rtl ? e - 1 - p : p]; + var d = t.length; + if (d && (m || !n[t])) { + var f = this.score ? this.score(b, t, 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) : eb(q, e, p, d, f); - fb(this, n, g, h, a, c); + for (let r = 0, v; r < d; r++) { + for (f = d; f > r; f--) { + g = t.substring(r, f); + v = this.rtl ? d - 1 - r : r; + var k = this.score ? this.score(b, t, p, g, v) : eb(q, e, p, d, v); + fb(this, n, g, k, a, c); } } break; @@ -1837,24 +1842,26 @@ 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) : eb(q, e, p, d, k), fb(this, n, g, h, a, c); + g = t[this.rtl ? d - 1 - k : k] + g; + var h = this.score ? this.score(b, t, 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], fb(this, n, g, f, a, c); + g += t[this.rtl ? d - 1 - k : k], fb(this, n, g, f, a, c); } break; } default: - 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) : 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); + if (fb(this, n, t, f, a, c), m && 1 < e && p < e - 1) { + for (d = B(), g = this.U, f = t, k = Math.min(m + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { + if ((t = b[this.rtl ? e - 1 - p - h : p + h]) && !d[t]) { + d[t] = 1; + const r = this.score ? this.score(b, f, p, t, h - 1) : eb(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), v = this.bidirectional && t > f; + fb(this, l, v ? f : t, r, a, c, v ? t : f); } } } @@ -1904,8 +1911,8 @@ function eb(a, b, c, e, d) { if (2 === d && f && !g) { 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); + let t = B(), r = 0, v; + 1 < d && f && (v = p[0], r = 1); m || 0 === m || (m = v ? this.U : this.resolution); if (this.db) { if (this.db.search && (a = this.db.search(this, p, b, k, g, h, q, l), !1 !== a)) { @@ -1913,9 +1920,9 @@ function eb(a, b, c, e, d) { } const x = this; return async function() { - for (let y, F; u < d; u++) { - if ((F = p[u]) && !r[F]) { - r[F] = 1; + for (let y, F; r < d; r++) { + if ((F = p[r]) && !t[F]) { + t[F] = 1; y = await ib(x, F, v, 0, 0, !1, !1); if (y = jb(y, e, g, m)) { e = y; @@ -1923,14 +1930,14 @@ function eb(a, b, c, e, d) { } v && (g && y && e.length || (v = F)); } - g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); + g && v && r === d - 1 && !e.length && (m = x.resolution, v = "", r = -1, t = B()); } 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; + for (let x, y; r < d; r++) { + if ((y = p[r]) && !t[y]) { + t[y] = 1; x = ib(this, y, v, 0, 0, !1, !1); if (x = jb(x, e, g, m)) { e = x; @@ -1938,7 +1945,7 @@ function eb(a, b, c, e, d) { } v && (g && x && e.length || (v = y)); } - g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); + g && v && r === d - 1 && !e.length && (m = this.resolution, v = "", r = -1, t = B()); } return kb(e, m, b, k, g, n, h); }; @@ -2066,16 +2073,16 @@ function lb(a, b) { this.commit_timer = null; this.priority = a.priority || 4; } -t = O.prototype; -t.mount = function(a) { +u = O.prototype; +u.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); }; -t.commit = function(a, b) { +u.commit = function(a, b) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.commit(this, a, b); }; -t.destroy = function() { +u.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; @@ -2085,7 +2092,7 @@ function gb(a) { a.db.commit(a, void 0, void 0); }, 1)); } -t.clear = function() { +u.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); @@ -2093,13 +2100,13 @@ t.clear = function() { this.db && (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [{clear:!0}]); return this; }; -t.append = function(a, b) { +u.append = function(a, b) { return this.add(a, b, !0); }; -t.contain = function(a) { +u.contain = function(a) { return this.db ? this.db.has(a) : this.reg.has(a); }; -t.update = function(a, b) { +u.update = function(a, b) { const c = this, e = this.remove(a); return e && e.then ? e.then(() => c.add(a, b)) : this.add(a, b); }; @@ -2117,7 +2124,7 @@ function mb(a) { } return b; } -t.cleanup = function() { +u.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -2125,8 +2132,8 @@ t.cleanup = function() { this.depth && mb(this.ctx); return this; }; -t.searchCache = Ua; -t.export = function(a, b, c = 0, e = 0) { +u.searchCache = Ua; +u.export = function(a, b, c = 0, e = 0) { let d, f; switch(e) { case 0: @@ -2150,7 +2157,7 @@ t.export = function(a, b, c = 0, e = 0) { } return ya.call(this, a, b, d, f, c, e); }; -t.import = function(a, b) { +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": @@ -2165,7 +2172,7 @@ t.import = function(a, b) { } } }; -t.serialize = function(a = !0) { +u.serialize = function(a = !0) { if (!this.reg.size) { return ""; } @@ -2201,8 +2208,8 @@ t.serialize = function(a = !0) { for (let q = 0, p; q < k.length; q++) { p = k[q] || [""]; l = ""; - for (let r = 0; r < p.length; r++) { - l += (l ? "," : "") + ("string" === c ? '"' + p[r] + '"' : p[r]); + for (let t = 0; t < p.length; t++) { + l += (l ? "," : "") + ("string" === c ? '"' + p[t] + '"' : p[t]); } l = "[" + l + "]"; h += (h ? "," : "") + l; @@ -2230,15 +2237,15 @@ function pb(a, b = {}) { this.db = null; this.h = {}; } -t = pb.prototype; -t.mount = function(a) { +u = pb.prototype; +u.mount = function(a) { if (!a.encoder) { return a.mount(this); } a.db = this; return this.open(); }; -t.open = function() { +u.open = function() { let a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { @@ -2266,22 +2273,22 @@ t.open = function() { }; }); }; -t.close = function() { +u.close = function() { this.db.close(); this.db = null; }; -t.destroy = function() { +u.destroy = function() { const a = nb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); return Z(a); }; -t.clear = function() { +u.clear = function() { const a = this.db.transaction(ob, "readwrite"); for (let b = 0; b < ob.length; b++) { a.objectStore(ob[b]).clear(); } return Z(a); }; -t.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { +u.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { a = this.db.transaction(b ? "ctx" : "map", "readonly").objectStore(b ? "ctx" : "map").get(b ? b + ":" + a : a); const g = this; return Z(a).then(function(k) { @@ -2314,7 +2321,7 @@ t.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { return k; }); }; -t.tag = function(a, b = 0, c = 0, e = !1) { +u.tag = function(a, b = 0, c = 0, e = !1) { a = this.db.transaction("tag", "readonly").objectStore("tag").get(a); const d = this; return Z(a).then(function(f) { @@ -2328,7 +2335,7 @@ t.tag = function(a, b = 0, c = 0, e = !1) { return e ? d.enrich(f) : f; }); }; -t.enrich = function(a) { +u.enrich = function(a) { "object" !== typeof a && (a = [a]); const b = this.db.transaction("reg", "readonly").objectStore("reg"), c = []; for (let e = 0; e < a.length; e++) { @@ -2341,14 +2348,14 @@ t.enrich = function(a) { return e; }); }; -t.has = function(a) { +u.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); return Z(a); }; -t.search = null; -t.info = function() { +u.search = null; +u.info = function() { }; -t.transaction = function(a, b, c) { +u.transaction = function(a, b, c) { let e = this.h[a + ":" + b]; if (e) { return c.call(this, e); @@ -2370,7 +2377,7 @@ t.transaction = function(a, b, c) { return k; }); }; -t.commit = async function(a, b, c) { +u.commit = async function(a, b, c) { if (b) { await this.clear(), a.commit_task = []; } else { @@ -2423,14 +2430,14 @@ t.commit = async function(a, b, c) { var m; if (n && n.length) { const q = Math.max(n.length, l.length); - for (let p = 0, r, u; p < q; p++) { - if ((u = l[p]) && u.length) { - if ((r = n[p]) && r.length) { - for (m = 0; m < u.length; m++) { - r.push(u[m]); + for (let p = 0, t, r; p < q; p++) { + if ((r = l[p]) && r.length) { + if ((t = n[p]) && t.length) { + for (m = 0; m < r.length; m++) { + t.push(r[m]); } } else { - n[p] = u; + n[p] = r; } m = 1; } @@ -2486,7 +2493,7 @@ function rb(a, b, c) { g ? d && a.update(e) : a.delete(); a.continue(); } -t.remove = function(a) { +u.remove = function(a) { "object" !== typeof a && (a = [a]); return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { @@ -2521,7 +2528,7 @@ function Z(a) { a = null; }); } -;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 : {}; +;const sb = {Index:O, Charset:cb, Encoder:J, Document:V, Worker:Q, Resolver:X, IndexedDB:pb, Language:{}}, tb = self; let ub; (ub = tb.define) && ub.amd ? ub([], function() { return sb; diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index 142b48e..4f50729 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -1,24 +1,24 @@ /**! - * FlexSearch.js v0.8.117 (Bundle) + * FlexSearch.js v0.8.123 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var t;function A(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(k){return a(c(k))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function B(){return Object.create(null)}function E(a){return"string"===typeof a} +(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var u;function A(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(k){return a(c(k))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function B(){return Object.create(null)}function E(a){return"string"===typeof a} function I(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function ba(a,b){if(E(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; +["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const ea=/[^\p{L}\p{N}]+/u,fa=/(\d{3})/g,ha=/(\D)(\d{3})/g,ia=/(\d{3})(\D)/g,ja="".normalize&&/[\u0300-\u036f]/g;function J(a={}){if(!this||this.constructor!==J)return new J(...arguments);if(arguments.length)for(a=0;a"a1a".split(c).length; this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ea)}catch(d){this.split=/\s+/}this.numeric=A(a.numeric,A(this.numeric,!0))}this.prepare=A(a.prepare,null,this.prepare);this.finalize=A(a.finalize,null,this.finalize);ja||(this.mapper=new Map(da));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((c=a.filter)&&new Set(c),null,this.filter);this.matcher=A((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=A((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= A((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=A(a.replacer,null,this.replacer);this.minlength=A(a.minlength,1,this.minlength);this.maxlength=A(a.maxlength,0,this.maxlength);if(this.cache=c=A(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.A+= -(this.A?"|":"")+d;return this};t.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&L(this);return this};t.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&L(this);return this};t.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this};t.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&L(this);return this}; -t.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ja?a.normalize("NFKD").replace(ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this};u.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&L(this);return this}; +u.encode=function(a){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){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} @@ -26,76 +26,77 @@ function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1]; 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-= +function Ca(a,b,c,e,d,f,g,k){if(a=a[g])if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;bc||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=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;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 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&&1t;f--){g=r.substring(t,f);v=this.rtl?d-1-t:t;var k=this.score?this.score(b,r,p,g,v):eb(q,e,p,d,v); +fb(this,n,g,k,a,c)}break}case "reverse":if(1g?0:1),e,p,k-1,h-1),v=this.bidirectional&& +r>f;fb(this,l,v?f:r,t,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&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 mb(a){let b=0;if(a.constructor===Array)for(let c=0,e;cc.add(a,b)):this.add(a,b)}; +function mb(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=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;e{d.onerror=h=>{d.abort();d=e=null;g(h)};d.oncomplete=h=>{d=e=null;f(h||!0)};const k=c.call(this,e);this.h[a+":"+b]=null;return k})}; -t.commit=async function(a,b,c){if(b)await this.clear(),a.commit_task=[];else{let e=a.commit_task;a.commit_task=[];for(let d=0,f;d{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)}})}; +u.close=function(){this.db.close();this.db=null};u.destroy=function(){const a=nb.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};u.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})}; +u.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e{d.onerror=h=>{d.abort();d=e=null;g(h)};d.oncomplete=h=>{d=e=null;f(h||!0)};const k=c.call(this,e);this.h[a+":"+b]=null;return k})}; +u.commit=async function(a,b,c){if(b)await this.clear(),a.commit_task=[];else{let e=a.commit_task;a.commit_task=[];for(let d=0,f;dn&&!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)); +u.remove=function(a){"object"!==typeof a&&(a=[a]);return Promise.all([this.transaction("map","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&rb(c,a)}}),this.transaction("ctx","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&rb(c,a)}}),this.transaction("tag","readwrite",function(b){b.openCursor().onsuccess=function(){const c=this.result;c&&rb(c,a,!0)}}),this.transaction("reg","readwrite",function(b){for(let c=0;c{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=self;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 32e88f3..4f33c7e 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -1,11 +1,11 @@ /**! - * FlexSearch.js v0.8.117 (Bundle/Module/Debug) + * FlexSearch.js v0.8.123 (Bundle/Module/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var t; +var u; function A(a, b, c) { const e = typeof c, d = typeof a; if ("undefined" !== e) { @@ -85,16 +85,20 @@ function ca(a) { "\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db", "\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]]; const ea = /[^\p{L}\p{N}]+/u, fa = /(\d{3})/g, ha = /(\D)(\d{3})/g, ia = /(\d{3})(\D)/g, ja = "".normalize && /[\u0300-\u036f]/g; -function J(a) { +function J(a = {}) { if (!this || this.constructor !== J) { return new J(...arguments); } - for (let b = 0; b < arguments.length; b++) { - this.assign(arguments[b]); + if (arguments.length) { + for (a = 0; a < arguments.length; a++) { + this.assign(arguments[a]); + } + } else { + this.assign(a); } } -t = J.prototype; -t.assign = function(a) { +u = J.prototype; +u.assign = function(a) { this.normalize = A(a.normalize, !0, this.normalize); let b = a.include, c = b || a.exclude || a.split, e; if (c || "" === c) { @@ -158,7 +162,7 @@ t.assign = function(a) { } return this; }; -t.addStemmer = function(a, b) { +u.addStemmer = function(a, b) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, b); this.A += (this.A ? "|" : "") + a; @@ -166,13 +170,13 @@ t.addStemmer = function(a, b) { this.cache && L(this); return this; }; -t.addFilter = function(a) { +u.addFilter = function(a) { this.filter || (this.filter = new Set()); this.filter.add(a); this.cache && L(this); return this; }; -t.addMapper = function(a, b) { +u.addMapper = function(a, b) { if ("object" === typeof a) { return this.addReplacer(a, b); } @@ -184,7 +188,7 @@ t.addMapper = function(a, b) { this.cache && L(this); return this; }; -t.addMatcher = function(a, b) { +u.addMatcher = function(a, b) { if ("object" === typeof a) { return this.addReplacer(a, b); } @@ -198,7 +202,7 @@ t.addMatcher = function(a, b) { this.cache && L(this); return this; }; -t.addReplacer = function(a, b) { +u.addReplacer = function(a, b) { if ("string" === typeof a) { return this.addMatcher(a, b); } @@ -207,7 +211,7 @@ t.addReplacer = function(a, b) { this.cache && L(this); return this; }; -t.encode = function(a) { +u.encode = function(a) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.B.has(a)) { @@ -391,7 +395,7 @@ function R(a) { }; } 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", + return b ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ka.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof c ? c : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } ;function sa(a, b = 0) { @@ -581,35 +585,35 @@ U.prototype.add = function(a) { let c = this.index[b]; c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c)); }; -t = T.prototype; -t.has = U.prototype.has = function(a) { +u = T.prototype; +u.has = U.prototype.has = function(a) { const b = this.index[this.B(a)]; return b && b.has(a); }; -t.delete = U.prototype.delete = function(a) { +u.delete = U.prototype.delete = function(a) { const b = this.index[this.B(a)]; b && b.delete(a) && this.size--; }; -t.clear = U.prototype.clear = function() { +u.clear = U.prototype.clear = function() { this.index = B(); this.h = []; this.size = 0; }; -t.values = U.prototype.values = function*() { +u.values = U.prototype.values = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].values()) { yield b; } } }; -t.keys = U.prototype.keys = function*() { +u.keys = U.prototype.keys = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].keys()) { yield b; } } }; -t.entries = U.prototype.entries = function*() { +u.entries = U.prototype.entries = function*() { for (let a = 0; a < this.h.length; a++) { for (let b of this.h[a].entries()) { yield b; @@ -774,11 +778,11 @@ function Ca(a, b, c, e, d, f, g, k) { let h = [], l; var n; l = B(); - for (let m = 0, q, p, r, u; m < b; m++) { + for (let m = 0, q, p, t, r; m < b; m++) { for (let v = 0; v < k; v++) { - if (r = a[v], m < r.length && (q = r[m])) { + if (t = a[v], m < t.length && (q = t[m])) { for (let x = 0; x < q.length; x++) { - p = q[x], (n = l[p]) ? l[p]++ : (n = 0, l[p] = 1), u = h[n] || (h[n] = []), g || (n = m + (v || !d ? 0 : f || 0), u = u[n] || (u[n] = [])), u.push(p); + p = q[x], (n = l[p]) ? l[p]++ : (n = 0, l[p] = 1), r = h[n] || (h[n] = []), g || (n = m + (v || !d ? 0 : f || 0), r = r[n] || (r[n] = [])), r.push(p); } } } @@ -844,13 +848,13 @@ function Fa(a, b, c, e, d) { m = a[n]; for (let p = 0; p < m.length; p++) { if (l = (e = m[p]) && e.length) { - for (let r = 0; r < l; r++) { - if (k = e[r], !g[k]) { + for (let t = 0; t < l; t++) { + if (k = e[t], !g[k]) { if (g[k] = 1, c) { c--; } else { - let u = (p + (n < h - 1 ? d || 0 : 0)) / (n + 1) | 0; - (f[u] || (f[u] = [])).push(k); + let r = (p + (n < h - 1 ? d || 0 : 0)) / (n + 1) | 0; + (f[r] || (f[r] = [])).push(k); if (++q === b) { return f; } @@ -1061,19 +1065,19 @@ function Ma(a, b, c, e, d) { for (let m = 0, q; m < a.length; m++) { if (q = a[m]) { if (l = q[h]) { - for (let p = 0, r; p < l.length; p++) { - if (r = l[p], 1 === g[r]) { + for (let p = 0, t; p < l.length; p++) { + if (t = l[p], 1 === g[t]) { if (c) { c--; } else { if (e) { - if (f.push(r), f.length === b) { + if (f.push(t), f.length === b) { return f; } } else { - const u = h + (m ? d : 0); - f[u] || (f[u] = []); - f[u].push(r); + const r = h + (m ? d : 0); + f[r] || (f[r] = []); + f[r].push(t); if (++n === b) { return f; } @@ -1202,7 +1206,7 @@ V.prototype.search = function(a, b, c, e) { k = c.merge; h = g || c.field || (h = c.index) && (h.index ? null : h); var p = this.tag && c.tag; - var r = c.suggest; + var t = c.suggest; m = !1 !== c.resolve; if (!m && !g) { if (h = h || this.field) { @@ -1213,8 +1217,8 @@ V.prototype.search = function(a, b, c, e) { } } this.store && c.enrich && !m && console.warn("Enrich results can only be done on a final resolver task or when calling .resolve({ enrich: true })"); - var u = this.store && c.enrich && m; - q = c.highlight && u; + var r = this.store && c.enrich && m; + q = c.highlight && r; b = c.limit || b; l = c.offset || 0; b || (b = 100); @@ -1253,7 +1257,7 @@ V.prototype.search = function(a, b, c, e) { } p = v; if (!a) { - r = []; + t = []; if (v.length) { for (p = 0; p < v.length; p += 2) { if (this.db) { @@ -1262,14 +1266,14 @@ V.prototype.search = function(a, b, c, e) { console.warn("Tag '" + v[p] + ":" + v[p + 1] + "' will be skipped because there is no field '" + v[p] + "'."); continue; } - r.push(m = m.db.tag(v[p + 1], b, l, u)); + t.push(m = m.db.tag(v[p + 1], b, l, r)); } else { - m = Pa.call(this, v[p], v[p + 1], b, l, u); + m = Pa.call(this, v[p], v[p + 1], b, l, r); } d.push({field:v[p], tag:v[p + 1], result:m}); } } - return r.length ? Promise.all(r).then(function(z) { + return t.length ? Promise.all(t).then(function(z) { for (let w = 0; w < z.length; w++) { d[w].result = z[w]; } @@ -1288,16 +1292,16 @@ V.prototype.search = function(a, b, c, e) { continue; } let C; - E(D) || (C = D, D = C.field, a = C.query || a, b = C.limit || b, l = C.offset || l, r = C.suggest || r, u = this.store && (C.enrich || u)); + E(D) || (C = D, D = C.field, a = C.query || a, b = C.limit || b, l = C.offset || l, t = C.suggest || t, r = this.store && (C.enrich || r)); if (e) { w = e[z]; } else { if (x = C || c, y = this.index.get(D), p && (this.db && (x.tag = p, F = y.db.support_tag_search, x.field = h), F || (x.enrich = !1)), v) { v[z] = y.search(a, b, x); - x && u && (x.enrich = u); + x && r && (x.enrich = r); continue; } else { - w = y.search(a, b, x), x && u && (x.enrich = u); + w = y.search(a, b, x), x && r && (x.enrich = r); } } H = w && (m ? w.length : w.result.length); @@ -1310,7 +1314,7 @@ V.prototype.search = function(a, b, c, e) { let K = e[G]; if (K && K.length) { y++, x.push(K); - } else if (!r) { + } else if (!t) { return m ? d : new X(d); } } @@ -1319,7 +1323,7 @@ V.prototype.search = function(a, b, c, e) { 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) { + if (console.warn("Tag '" + p[G] + ":" + p[G + 1] + "' will be skipped because there is no field '" + p[G] + "'."), t) { continue; } else { return m ? d : new X(d); @@ -1327,7 +1331,7 @@ V.prototype.search = function(a, b, c, e) { } if (nb = (K = K && K.get(p[G + 1])) && K.length) { y++, x.push(K); - } else if (!r) { + } else if (!t) { return m ? d : new X(d); } } @@ -1335,7 +1339,7 @@ V.prototype.search = function(a, b, c, e) { if (y) { w = Ga(w, x, m); H = w.length; - if (!H && !r) { + if (!H && !t) { return m ? w : new X(w); } y--; @@ -1349,16 +1353,16 @@ V.prototype.search = function(a, b, c, e) { } if (v) { if (this.db && p && p.length && !F) { - for (u = 0; u < p.length; u += 2) { - e = this.index.get(p[u]); + for (r = 0; r < p.length; r += 2) { + e = this.index.get(p[r]); if (!e) { - if (console.warn("Tag '" + p[u] + ":" + p[u + 1] + "' was not found because there is no field '" + p[u] + "'."), r) { + if (console.warn("Tag '" + p[r] + ":" + p[r + 1] + "' was not found because there is no field '" + p[r] + "'."), t) { continue; } else { return m ? d : new X(d); } } - v.push(e.db.tag(p[u + 1], b, l, !1)); + v.push(e.db.tag(p[r + 1], b, l, !1)); } } const z = this; @@ -1369,19 +1373,19 @@ V.prototype.search = function(a, b, c, e) { if (!n) { return m ? d : new X(d); } - if (g && (!u || !this.store)) { + if (g && (!r || !this.store)) { return d[0]; } v = []; for (let z = 0, w; z < f.length; z++) { w = d[z]; - u && w.length && !w[0].doc && (this.db ? v.push(w = this.index.get(this.field[0]).db.enrich(w)) : w = W.call(this, w)); + r && w.length && !w[0].doc && (this.db ? v.push(w = this.index.get(this.field[0]).db.enrich(w)) : w = W.call(this, w)); if (g) { return m ? w : new X(w); } d[z] = {field:f[z], result:w}; } - if (u && this.db && v.length) { + if (r && this.db && v.length) { const z = this; return Promise.all(v).then(function(w) { for (let D = 0; D < w.length; D++) { @@ -1394,17 +1398,17 @@ V.prototype.search = function(a, b, c, e) { }; 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++) { + for (let n = 0, m, q, p, t, r; n < a.length; n++) { m = a[n].result; q = a[n].field; - r = c.get(q); - p = r.encoder; - h = r.tokenize; - u = d[e.indexOf(q)]; + t = c.get(q); + p = t.encoder; + h = t.tokenize; + r = d[e.indexOf(q)]; p !== g && (g = p, k = g.encode(b)); for (let v = 0; v < m.length; v++) { let x = ""; - var l = ba(m[v].doc, u); + var l = ba(m[v].doc, r); let y = g.encode(l); l = l.split(g.split); for (let F = 0, z, w; F < y.length; F++) { @@ -1440,7 +1444,7 @@ function Qa(a, b) { f = a[d]; g = f.result; for (let k = 0, h, l, n; k < g.length; k++) { - if (l = g[k], h = l.id, n = e[h]) { + if (l = g[k], "object" !== typeof l && (l = {id:l}), h = l.id, n = e[h]) { n.push(f.field); } else { if (c.length === b) { @@ -1535,8 +1539,8 @@ function W(a) { a.db && (this.fastupdate = !1, this.mount(a.db)); } } -t = V.prototype; -t.mount = function(a) { +u = V.prototype; +u.mount = function(a) { if (this.worker) { throw Error("You can't use Worker-Indexes on a persistent model. That would be useless, since each of the persistent model acts like Worker-Index by default (Master/Slave)."); } @@ -1565,7 +1569,7 @@ t.mount = function(a) { this.db = !0; return Promise.all(c); }; -t.commit = async function(a, b) { +u.commit = async function(a, b) { const c = []; for (const e of this.index.values()) { c.push(e.db.commit(e, a, b)); @@ -1573,7 +1577,7 @@ t.commit = async function(a, b) { await Promise.all(c); this.reg.clear(); }; -t.destroy = function() { +u.destroy = function() { const a = []; for (const b of this.index.values()) { a.push(b.destroy()); @@ -1614,13 +1618,13 @@ function Sa(a, b) { e < c.length && (c.length = e); return 1 < e ? c : c[0]; } -t.append = function(a, b) { +u.append = function(a, b) { return this.add(a, b, !0); }; -t.update = function(a, b) { +u.update = function(a, b) { return this.remove(a).add(a, b); }; -t.remove = function(a) { +u.remove = function(a) { I(a) && (a = ba(a, this.key)); for (var b of this.index.values()) { b.remove(a, !0); @@ -1641,7 +1645,7 @@ t.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -t.clear = function() { +u.clear = function() { for (const a of this.index.values()) { a.clear(); } @@ -1653,26 +1657,26 @@ t.clear = function() { this.store && this.store.clear(); return this; }; -t.contain = function(a) { +u.contain = function(a) { return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a); }; -t.cleanup = function() { +u.cleanup = function() { for (const a of this.index.values()) { a.cleanup(); } return this; }; -t.get = function(a) { +u.get = function(a) { return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(b) { return b[0] && b[0].doc; }) : this.store.get(a); }; -t.set = function(a, b) { +u.set = function(a, b) { this.store.set(a, b); return this; }; -t.searchCache = Ua; -t.export = function(a, b, c = 0, e = 0) { +u.searchCache = Ua; +u.export = function(a, b, c = 0, e = 0) { if (c < this.field.length) { const g = this.field[c]; if ((b = this.index.get(g).export(a, g, c, e = 1)) && b.then) { @@ -1705,7 +1709,7 @@ t.export = function(a, b, c = 0, e = 0) { } return ya.call(this, a, b, d, f, c, e); }; -t.import = function(a, b) { +u.import = function(a, b) { var c = a.split("."); "json" === c[c.length - 1] && c.pop(); const e = 2 < c.length ? c[0] : ""; @@ -1787,12 +1791,12 @@ 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 Xa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Ya = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\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) { +var cb = {LatinExact:{split:/\s+/, normalize:!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 = Za[e]; @@ -1800,14 +1804,14 @@ var cb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Va, LatinSimple:{no } a[c] = e; } -}}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { +}}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { return ("" + a).replace($a, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { return ("" + a).replace(ab, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { return ("" + a).replace(bb, " "); }}}; -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}}}; +const db = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; O.prototype.add = function(a, b, c, e) { if (b && (a || 0 === a)) { if (!e && !c && this.reg.has(a)) { @@ -1817,18 +1821,19 @@ O.prototype.add = function(a, b, c, e) { if (e = b.length) { const l = B(), n = B(), m = this.depth, q = this.resolution; for (let p = 0; p < e; p++) { - 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) : eb(q, e, p), g = ""; + let t = b[this.rtl ? e - 1 - p : p]; + var d = t.length; + if (d && (m || !n[t])) { + var f = this.score ? this.score(b, t, 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) : eb(q, e, p, d, f); - fb(this, n, g, h, a, c); + for (let r = 0, v; r < d; r++) { + for (f = d; f > r; f--) { + g = t.substring(r, f); + v = this.rtl ? d - 1 - r : r; + var k = this.score ? this.score(b, t, p, g, v) : eb(q, e, p, d, v); + fb(this, n, g, k, a, c); } } break; @@ -1836,24 +1841,26 @@ 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) : eb(q, e, p, d, k), fb(this, n, g, h, a, c); + g = t[this.rtl ? d - 1 - k : k] + g; + var h = this.score ? this.score(b, t, 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], fb(this, n, g, f, a, c); + g += t[this.rtl ? d - 1 - k : k], fb(this, n, g, f, a, c); } break; } default: - 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) : 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); + if (fb(this, n, t, f, a, c), m && 1 < e && p < e - 1) { + for (d = B(), g = this.U, f = t, k = Math.min(m + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { + if ((t = b[this.rtl ? e - 1 - p - h : p + h]) && !d[t]) { + d[t] = 1; + const r = this.score ? this.score(b, f, p, t, h - 1) : eb(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), v = this.bidirectional && t > f; + fb(this, l, v ? f : t, r, a, c, v ? t : f); } } } @@ -1903,8 +1910,8 @@ function eb(a, b, c, e, d) { if (2 === d && f && !g) { 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); + let t = B(), r = 0, v; + 1 < d && f && (v = p[0], r = 1); m || 0 === m || (m = v ? this.U : this.resolution); if (this.db) { if (this.db.search && (a = this.db.search(this, p, b, k, g, h, q, l), !1 !== a)) { @@ -1912,9 +1919,9 @@ function eb(a, b, c, e, d) { } const x = this; return async function() { - for (let y, F; u < d; u++) { - if ((F = p[u]) && !r[F]) { - r[F] = 1; + for (let y, F; r < d; r++) { + if ((F = p[r]) && !t[F]) { + t[F] = 1; y = await ib(x, F, v, 0, 0, !1, !1); if (y = jb(y, e, g, m)) { e = y; @@ -1922,14 +1929,14 @@ function eb(a, b, c, e, d) { } v && (g && y && e.length || (v = F)); } - g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); + g && v && r === d - 1 && !e.length && (m = x.resolution, v = "", r = -1, t = B()); } 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; + for (let x, y; r < d; r++) { + if ((y = p[r]) && !t[y]) { + t[y] = 1; x = ib(this, y, v, 0, 0, !1, !1); if (x = jb(x, e, g, m)) { e = x; @@ -1937,7 +1944,7 @@ function eb(a, b, c, e, d) { } v && (g && x && e.length || (v = y)); } - g && v && u === d - 1 && !e.length && (v = "", u = -1, r = B()); + g && v && r === d - 1 && !e.length && (m = this.resolution, v = "", r = -1, t = B()); } return kb(e, m, b, k, g, n, h); }; @@ -2065,16 +2072,16 @@ function lb(a, b) { this.commit_timer = null; this.priority = a.priority || 4; } -t = O.prototype; -t.mount = function(a) { +u = O.prototype; +u.mount = function(a) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return a.mount(this); }; -t.commit = function(a, b) { +u.commit = function(a, b) { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.commit(this, a, b); }; -t.destroy = function() { +u.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; @@ -2084,7 +2091,7 @@ function gb(a) { a.db.commit(a, void 0, void 0); }, 1)); } -t.clear = function() { +u.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); @@ -2092,13 +2099,13 @@ t.clear = function() { this.db && (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [{clear:!0}]); return this; }; -t.append = function(a, b) { +u.append = function(a, b) { return this.add(a, b, !0); }; -t.contain = function(a) { +u.contain = function(a) { return this.db ? this.db.has(a) : this.reg.has(a); }; -t.update = function(a, b) { +u.update = function(a, b) { const c = this, e = this.remove(a); return e && e.then ? e.then(() => c.add(a, b)) : this.add(a, b); }; @@ -2116,7 +2123,7 @@ function mb(a) { } return b; } -t.cleanup = function() { +u.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -2124,8 +2131,8 @@ t.cleanup = function() { this.depth && mb(this.ctx); return this; }; -t.searchCache = Ua; -t.export = function(a, b, c = 0, e = 0) { +u.searchCache = Ua; +u.export = function(a, b, c = 0, e = 0) { let d, f; switch(e) { case 0: @@ -2149,7 +2156,7 @@ t.export = function(a, b, c = 0, e = 0) { } return ya.call(this, a, b, d, f, c, e); }; -t.import = function(a, b) { +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": @@ -2164,7 +2171,7 @@ t.import = function(a, b) { } } }; -t.serialize = function(a = !0) { +u.serialize = function(a = !0) { if (!this.reg.size) { return ""; } @@ -2200,8 +2207,8 @@ t.serialize = function(a = !0) { for (let q = 0, p; q < k.length; q++) { p = k[q] || [""]; l = ""; - for (let r = 0; r < p.length; r++) { - l += (l ? "," : "") + ("string" === c ? '"' + p[r] + '"' : p[r]); + for (let t = 0; t < p.length; t++) { + l += (l ? "," : "") + ("string" === c ? '"' + p[t] + '"' : p[t]); } l = "[" + l + "]"; h += (h ? "," : "") + l; @@ -2229,15 +2236,15 @@ function qb(a, b = {}) { this.db = null; this.h = {}; } -t = qb.prototype; -t.mount = function(a) { +u = qb.prototype; +u.mount = function(a) { if (!a.encoder) { return a.mount(this); } a.db = this; return this.open(); }; -t.open = function() { +u.open = function() { let a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { @@ -2265,22 +2272,22 @@ t.open = function() { }; }); }; -t.close = function() { +u.close = function() { this.db.close(); this.db = null; }; -t.destroy = function() { +u.destroy = function() { const a = ob.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); return Z(a); }; -t.clear = function() { +u.clear = function() { const a = this.db.transaction(pb, "readwrite"); for (let b = 0; b < pb.length; b++) { a.objectStore(pb[b]).clear(); } return Z(a); }; -t.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { +u.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { a = this.db.transaction(b ? "ctx" : "map", "readonly").objectStore(b ? "ctx" : "map").get(b ? b + ":" + a : a); const g = this; return Z(a).then(function(k) { @@ -2313,7 +2320,7 @@ t.get = function(a, b, c = 0, e = 0, d = !0, f = !1) { return k; }); }; -t.tag = function(a, b = 0, c = 0, e = !1) { +u.tag = function(a, b = 0, c = 0, e = !1) { a = this.db.transaction("tag", "readonly").objectStore("tag").get(a); const d = this; return Z(a).then(function(f) { @@ -2327,7 +2334,7 @@ t.tag = function(a, b = 0, c = 0, e = !1) { return e ? d.enrich(f) : f; }); }; -t.enrich = function(a) { +u.enrich = function(a) { "object" !== typeof a && (a = [a]); const b = this.db.transaction("reg", "readonly").objectStore("reg"), c = []; for (let e = 0; e < a.length; e++) { @@ -2340,14 +2347,14 @@ t.enrich = function(a) { return e; }); }; -t.has = function(a) { +u.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); return Z(a); }; -t.search = null; -t.info = function() { +u.search = null; +u.info = function() { }; -t.transaction = function(a, b, c) { +u.transaction = function(a, b, c) { let e = this.h[a + ":" + b]; if (e) { return c.call(this, e); @@ -2369,7 +2376,7 @@ t.transaction = function(a, b, c) { return k; }); }; -t.commit = async function(a, b, c) { +u.commit = async function(a, b, c) { if (b) { await this.clear(), a.commit_task = []; } else { @@ -2422,14 +2429,14 @@ t.commit = async function(a, b, c) { var m; if (n && n.length) { const q = Math.max(n.length, l.length); - for (let p = 0, r, u; p < q; p++) { - if ((u = l[p]) && u.length) { - if ((r = n[p]) && r.length) { - for (m = 0; m < u.length; m++) { - r.push(u[m]); + for (let p = 0, t, r; p < q; p++) { + if ((r = l[p]) && r.length) { + if ((t = n[p]) && t.length) { + for (m = 0; m < r.length; m++) { + t.push(r[m]); } } else { - n[p] = u; + n[p] = r; } m = 1; } @@ -2485,7 +2492,7 @@ function rb(a, b, c) { g ? d && a.update(e) : a.delete(); a.continue(); } -t.remove = function(a) { +u.remove = function(a) { "object" !== typeof a && (a = [a]); return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js index 201c2d6..495bc46 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -1,24 +1,24 @@ /**! - * FlexSearch.js v0.8.117 (Bundle/Module) + * FlexSearch.js v0.8.123 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var t;function A(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(k){return a(c(k))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function B(){return Object.create(null)}function E(a){return"string"===typeof a} +var u;function A(a,b,c){const e=typeof c,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(c){if("function"===d&&e===d)return function(k){return a(c(k))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===d?b:a}function B(){return Object.create(null)}function E(a){return"string"===typeof a} function I(a){return"object"===typeof a}function aa(a){const b=[];for(const c of a.keys())b.push(c);return b}function ba(a,b){if(E(b))a=a[b];else for(let c=0;a&&c"a1a".split(c).length; +["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const ea=/[^\p{L}\p{N}]+/u,fa=/(\d{3})/g,ha=/(\D)(\d{3})/g,ia=/(\d{3})(\D)/g,ja="".normalize&&/[\u0300-\u036f]/g;function J(a={}){if(!this||this.constructor!==J)return new J(...arguments);if(arguments.length)for(a=0;a"a1a".split(c).length; this.numeric=A(a.numeric,e)}else{try{this.split=A(this.split,ea)}catch(d){this.split=/\s+/}this.numeric=A(a.numeric,A(this.numeric,!0))}this.prepare=A(a.prepare,null,this.prepare);this.finalize=A(a.finalize,null,this.finalize);ja||(this.mapper=new Map(da));this.rtl=A(a.rtl,!1,this.rtl);this.dedupe=A(a.dedupe,!1,this.dedupe);this.filter=A((c=a.filter)&&new Set(c),null,this.filter);this.matcher=A((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=A((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= A((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=A(a.replacer,null,this.replacer);this.minlength=A(a.minlength,1,this.minlength);this.maxlength=A(a.maxlength,0,this.maxlength);if(this.cache=c=A(a.cache,!0,this.cache))this.H=null,this.S="number"===typeof c?c:2E5,this.B=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.A+= -(this.A?"|":"")+d;return this};t.addStemmer=function(a,b){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,b);this.A+=(this.A?"|":"")+a;this.N=null;this.cache&&L(this);return this};t.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&L(this);return this};t.addMapper=function(a,b){if("object"===typeof a)return this.addReplacer(a,b);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this};t.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&L(this);return this}; -t.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.B.has(a))return this.B.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ja?a.normalize("NFKD").replace(ja,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3a.length&&(this.dedupe||this.mapper))return this.addMapper(a,b);this.matcher||(this.matcher=new Map);this.matcher.set(a,b);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this};u.addReplacer=function(a,b){if("string"===typeof a)return this.addMatcher(a,b);this.replacer||(this.replacer=[]);this.replacer.push(a,b);this.cache&&L(this);return this}; +u.encode=function(a){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){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} @@ -26,77 +26,78 @@ function ma(a){this[a+"Async"]=function(){const b=arguments;var c=b[b.length-1]; 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-= +function Ca(a,b,c,e,d,f,g,k){if(a=a[g])if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;bc||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=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;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 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&&1t;f--){g=r.substring(t,f);v=this.rtl?d-1-t:t;var k=this.score?this.score(b,r,p,g,v):eb(q,e,p,d,v); +fb(this,n,g,k,a,c)}break}case "reverse":if(1g?0:1),e,p,k-1,h-1),v=this.bidirectional&& +r>f;fb(this,l,v?f:r,t,a,c,v?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&(b||this.commit_task.push({del:a}),this.T&&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;cc.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=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;e{d.onerror=h=>{d.abort();d=e=null;g(h)};d.oncomplete=h=>{d=e=null;f(h||!0)};const k=c.call(this,e);this.h[a+":"+b]=null;return k})}; -t.commit=async function(a,b,c){if(b)await this.clear(),a.commit_task=[];else{let e=a.commit_task;a.commit_task=[];for(let d=0,f;d{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)}})}; +u.close=function(){this.db.close();this.db=null};u.destroy=function(){const a=ob.deleteDatabase(this.id+(this.field?":"+this.field:""));return Z(a)};u.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})}; +u.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let e=0;e{d.onerror=h=>{d.abort();d=e=null;g(h)};d.oncomplete=h=>{d=e=null;f(h||!0)};const k=c.call(this,e);this.h[a+":"+b]=null;return k})}; +u.commit=async function(a,b,c){if(b)await this.clear(),a.commit_task=[];else{let e=a.commit_task;a.commit_task=[];for(let d=0,f;dn&&!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 7625b2d..91ba9ff 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -1,12 +1,12 @@ /**! - * FlexSearch.js v0.8.117 (Bundle/Debug) + * FlexSearch.js v0.8.123 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ (function(self){'use strict'; -var w; +var x; function B(a, c, b) { const e = typeof b, d = typeof a; if ("undefined" !== e) { @@ -79,16 +79,20 @@ function aa(a) { "\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db", "\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]]; const ca = /[^\p{L}\p{N}]+/u, da = /(\d{3})/g, ea = /(\D)(\d{3})/g, fa = /(\d{3})(\D)/g, ha = "".normalize && /[\u0300-\u036f]/g; -function K(a) { +function K(a = {}) { if (!this || this.constructor !== K) { return new K(...arguments); } - for (let c = 0; c < arguments.length; c++) { - this.assign(arguments[c]); + if (arguments.length) { + for (a = 0; a < arguments.length; a++) { + this.assign(arguments[a]); + } + } else { + this.assign(a); } } -w = K.prototype; -w.assign = function(a) { +x = K.prototype; +x.assign = function(a) { this.normalize = B(a.normalize, !0, this.normalize); let c = a.include, b = c || a.exclude || a.split, e; if (b || "" === b) { @@ -152,7 +156,7 @@ w.assign = function(a) { } return this; }; -w.addStemmer = function(a, c) { +x.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, c); this.D += (this.D ? "|" : "") + a; @@ -160,13 +164,13 @@ w.addStemmer = function(a, c) { this.cache && L(this); return this; }; -w.addFilter = function(a) { +x.addFilter = function(a) { this.filter || (this.filter = new Set()); this.filter.add(a); this.cache && L(this); return this; }; -w.addMapper = function(a, c) { +x.addMapper = function(a, c) { if ("object" === typeof a) { return this.addReplacer(a, c); } @@ -178,7 +182,7 @@ w.addMapper = function(a, c) { this.cache && L(this); return this; }; -w.addMatcher = function(a, c) { +x.addMatcher = function(a, c) { if ("object" === typeof a) { return this.addReplacer(a, c); } @@ -192,7 +196,7 @@ w.addMatcher = function(a, c) { this.cache && L(this); return this; }; -w.addReplacer = function(a, c) { +x.addReplacer = function(a, c) { if ("string" === typeof a) { return this.addMatcher(a, c); } @@ -201,7 +205,7 @@ w.addReplacer = function(a, c) { this.cache && L(this); return this; }; -w.encode = function(a) { +x.encode = function(a) { if (this.cache && a.length <= this.K) { if (this.H) { if (this.F.has(a)) { @@ -385,7 +389,7 @@ function T(a) { }; } function na(a, c, b) { - return c ? "undefined" !== typeof module ? new (require("worker_threads")["Worker"])(__dirname + "/node/node.js") : import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); }) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ia.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", + return c ? "undefined" !== typeof module ? new(require("worker_threads")["Worker"])(__dirname+"/node/node.js") : import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)("import.meta.dirname")+"/node/node.mjs")}) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + ia.toString()], {type:"text/javascript"}))) : new window.Worker("string" === typeof b ? b : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js"), {type:"module"}); } ;function oa(a, c = 0) { @@ -567,8 +571,8 @@ function ua(a, c, b, e, d, f, g, k) { for (let l = 0, m, n, t, p; l < c; l++) { for (let q = 0; q < f; q++) { if (t = a[q], l < t.length && (m = t[l])) { - for (let y = 0; y < m.length; y++) { - n = m[y], (h = k[n]) ? k[n]++ : (h = 0, k[n] = 1), p = g[h] || (g[h] = []), p.push(n); + for (let v = 0; v < m.length; v++) { + n = m[v], (h = k[n]) ? k[n]++ : (h = 0, k[n] = 1), p = g[h] || (g[h] = []), p.push(n); } } } @@ -812,9 +816,9 @@ function Ea(a, c, b, e, d) { return f; } } else { - const y = h + (n ? d : 0); - f[y] || (f[y] = []); - f[y].push(q); + const v = h + (n ? d : 0); + f[v] || (f[v] = []); + f[v].push(q); if (++m === c) { return f; } @@ -936,9 +940,9 @@ V.prototype.search = function(a, c, b, e) { if (b) { b.constructor === Array && (b = {index:b}); a = b.query || a; - var y = b.pluck; + var v = b.pluck; k = b.merge; - l = y || b.field || (l = b.index) && (l.index ? null : l); + l = v || b.field || (l = b.index) && (l.index ? null : l); m = this.tag && b.tag; h = b.suggest; p = !0; @@ -951,24 +955,24 @@ V.prototype.search = function(a, c, b, e) { if (m) { m.constructor !== Array && (m = [m]); var u = []; - for (let x = 0, r; x < m.length; x++) { - r = m[x]; + for (let y = 0, r; y < m.length; y++) { + r = m[y]; if (D(r)) { throw Error("A tag option can't be a string, instead it needs a { field: tag } format."); } if (r.field && r.tag) { - var v = r.tag; - if (v.constructor === Array) { - for (var z = 0; z < v.length; z++) { - u.push(r.field, v[z]); + var w = r.tag; + if (w.constructor === Array) { + for (var z = 0; z < w.length; z++) { + u.push(r.field, w[z]); } } else { - u.push(r.field, v); + u.push(r.field, w); } } else { - v = Object.keys(r); - for (let E = 0, F, A; E < v.length; E++) { - if (F = v[E], A = r[F], A.constructor === Array) { + w = Object.keys(r); + for (let E = 0, F, A; E < w.length; E++) { + if (F = w[E], A = r[F], A.constructor === Array) { for (z = 0; z < A.length; z++) { u.push(F, A[z]); } @@ -986,12 +990,12 @@ V.prototype.search = function(a, c, b, e) { e = []; if (u.length) { for (f = 0; f < u.length; f += 2) { - y = Ha.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:y}); + v = Ha.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:v}); } } - return e.length ? Promise.all(e).then(function(x) { - for (let r = 0; r < x.length; r++) { - d[r].result = x[r]; + return e.length ? Promise.all(e).then(function(y) { + for (let r = 0; r < y.length; r++) { + d[r].result = y[r]; } return d; }) : d; @@ -1001,24 +1005,24 @@ V.prototype.search = function(a, c, b, e) { } l || (l = this.field); u = !e && (this.worker || this.db) && []; - for (let x = 0, r, E, F; x < l.length; x++) { - E = l[x]; + for (let y = 0, r, E, F; y < l.length; y++) { + E = l[y]; let A; D(E) || (A = E, E = A.field, a = A.query || a, c = A.limit || c, n = A.offset || n, h = A.suggest || h, g = this.store && (A.enrich || g)); if (e) { - r = e[x]; + r = e[y]; } else { - if (v = A || b, z = this.index.get(E), m && (v.enrich = !1), u) { - u[x] = z.search(a, c, v); - v && g && (v.enrich = g); + if (w = A || b, z = this.index.get(E), m && (w.enrich = !1), u) { + u[y] = z.search(a, c, w); + w && g && (w.enrich = g); continue; } else { - r = z.search(a, c, v), v && g && (v.enrich = g); + r = z.search(a, c, w), w && g && (w.enrich = g); } } F = r && (p ? r.length : r.result.length); if (m && F) { - v = []; + w = []; z = 0; for (let G = 0, H, Ya; G < m.length; G += 2) { H = this.tag.get(m[G]); @@ -1030,13 +1034,13 @@ V.prototype.search = function(a, c, b, e) { } } if (Ya = (H = H && H.get(m[G + 1])) && H.length) { - z++, v.push(H); + z++, w.push(H); } else if (!h) { return p ? d : new X(d); } } if (z) { - r = ya(r, v); + r = ya(r, w); F = r.length; if (!F && !h) { return p ? r : new X(r); @@ -1051,66 +1055,66 @@ V.prototype.search = function(a, c, b, e) { } } if (u) { - const x = this; + const y = this; return Promise.all(u).then(function(r) { - return r.length ? x.search(a, c, b, r) : r; + return r.length ? y.search(a, c, b, r) : r; }); } if (!t) { return p ? d : new X(d); } - if (y && (!g || !this.store)) { + if (v && (!g || !this.store)) { return d[0]; } u = []; - for (let x = 0, r; x < f.length; x++) { - r = d[x]; + for (let y = 0, r; y < f.length; y++) { + r = d[y]; g && r.length && !r[0].doc && (r = W.call(this, r)); - if (y) { + if (v) { return p ? r : new X(r); } - d[x] = {field:f[x], result:r}; + d[y] = {field:f[y], result:r}; } return k ? Ia(d, c) : q ? Ja(d, a, this.index, this.field, this.C, q) : d; }; 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++) { + for (let m = 0, n, t, p, q, v; m < a.length; m++) { n = a[m].result; t = a[m].field; q = b.get(t); p = q.encoder; h = q.tokenize; - y = d[e.indexOf(t)]; + v = d[e.indexOf(t)]; p !== g && (g = p, k = g.encode(c)); for (let u = 0; u < n.length; u++) { - let v = ""; - var l = J(n[u].doc, y); + let w = ""; + var l = J(n[u].doc, v); let z = g.encode(l); l = l.split(g.split); - for (let x = 0, r, E; x < z.length; x++) { - r = z[x]; - E = l[x]; + for (let y = 0, r, E; y < z.length; y++) { + r = z[y]; + E = l[y]; let F; for (let A = 0, G; A < k.length; A++) { if (G = k[A], "strict" === h) { if (r === G) { - v += (v ? " " : "") + f.replace("$1", E); + w += (w ? " " : "") + f.replace("$1", E); F = !0; break; } } else { const H = r.indexOf(G); if (-1 < H) { - v += (v ? " " : "") + E.substring(0, H) + f.replace("$1", E.substring(H, G.length)) + E.substring(H + G.length); + w += (w ? " " : "") + E.substring(0, H) + f.replace("$1", E.substring(H, G.length)) + E.substring(H + G.length); F = !0; break; } } } - F || (v += (v ? " " : "") + l[x]); + F || (w += (w ? " " : "") + l[y]); } - n[u].highlight = v; + n[u].highlight = w; } } return a; @@ -1121,7 +1125,7 @@ function Ia(a, c) { f = a[d]; g = f.result; for (let k = 0, h, l, m; k < g.length; k++) { - if (l = g[k], h = l.id, m = e[h]) { + if (l = g[k], "object" !== typeof l && (l = {id:l}), h = l.id, m = e[h]) { m.push(f.field); } else { if (b.length === c) { @@ -1215,14 +1219,14 @@ function Ka(a, c) { e < b.length && (b.length = e); return 1 < e ? b : b[0]; } -w = V.prototype; -w.append = function(a, c) { +x = V.prototype; +x.append = function(a, c) { return this.add(a, c, !0); }; -w.update = function(a, c) { +x.update = function(a, c) { return this.remove(a).add(a, c); }; -w.remove = function(a) { +x.remove = function(a) { I(a) && (a = J(a, this.key)); for (var c of this.index.values()) { c.remove(a, !0); @@ -1243,7 +1247,7 @@ w.remove = function(a) { this.cache && this.cache.remove(a); return this; }; -w.clear = function() { +x.clear = function() { for (const a of this.index.values()) { a.clear(); } @@ -1255,24 +1259,24 @@ w.clear = function() { this.store && this.store.clear(); return this; }; -w.contain = function(a) { +x.contain = function(a) { return this.reg.has(a); }; -w.cleanup = function() { +x.cleanup = function() { for (const a of this.index.values()) { a.cleanup(); } return this; }; -w.get = function(a) { +x.get = function(a) { return this.store.get(a); }; -w.set = function(a, c) { +x.set = function(a, c) { this.store.set(a, c); return this; }; -w.searchCache = La; -w.export = function(a, c, b = 0, e = 0) { +x.searchCache = La; +x.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { @@ -1305,7 +1309,7 @@ w.export = function(a, c, b = 0, e = 0) { } return U.call(this, a, c, d, f, b, e); }; -w.import = function(a, c) { +x.import = function(a, c) { var b = a.split("."); "json" === b[b.length - 1] && b.pop(); a = 2 < b.length ? b[0] : ""; @@ -1377,12 +1381,12 @@ 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 Oa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Pa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\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) { +var Ua = {LatinExact:{split:/\s+/, normalize:!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 = Qa[e]; @@ -1390,14 +1394,14 @@ var Ua = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ma, LatinSimple:{no } a[b] = e; } -}}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { +}}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { return ("" + a).replace(Ra, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { return ("" + a).replace(Sa, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { return ("" + a).replace(Ta, " "); }}}; -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}}}; +const Va = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; O.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { @@ -1414,11 +1418,12 @@ O.prototype.add = function(a, c, b, e) { 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) : Wa(t, e, p, d, f); - Z(this, m, g, h, a, b); + for (let v = 0, u; v < d; v++) { + for (f = d; f > v; f--) { + g = q.substring(v, f); + u = this.rtl ? d - 1 - v : v; + var k = this.score ? this.score(c, q, p, g, u) : Wa(t, e, p, d, u); + Z(this, m, g, k, a, b); } } break; @@ -1426,24 +1431,26 @@ 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) : Wa(t, e, p, d, k), Z(this, m, g, h, a, b); + g = q[this.rtl ? d - 1 - k : k] + g; + var h = this.score ? this.score(c, q, p, g, k) : Wa(t, e, p, d, k); + Z(this, m, g, h, a, b); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += q[k], Z(this, m, g, f, a, b); + g += q[this.rtl ? d - 1 - k : k], Z(this, m, g, f, a, b); } break; } default: if (Z(this, m, q, f, a, b), n && 1 < e && p < e - 1) { - for (d = C(), g = this.S, f = q, k = Math.min(n + 1, e - p), d[f] = 1, h = 1; h < k; h++) { + for (d = C(), g = this.S, f = q, k = Math.min(n + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { if ((q = c[this.rtl ? e - 1 - p - h : p + h]) && !d[q]) { d[q] = 1; - const 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); + const v = this.score ? this.score(c, f, p, q, h - 1) : Wa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; + Z(this, l, u ? f : q, v, a, b, u ? q : f); } } } @@ -1495,10 +1502,10 @@ function Wa(a, c, b, e, d) { l = 1; } h || 0 === h || (h = m ? this.S : this.resolution); - for (let q, y; l < b; l++) { - if ((y = a[l]) && !k[y]) { - k[y] = 1; - q = Xa(this, y, m); + for (let q, v; l < b; l++) { + if ((v = a[l]) && !k[v]) { + k[v] = 1; + q = Xa(this, v, m); a: { f = q; var n = e, t = g, p = h; @@ -1509,9 +1516,9 @@ function Wa(a, c, b, e, d) { q = void 0; break a; } - for (let v = 0, z; v < p; v++) { - if (z = f[v]) { - u[v] = z; + for (let w = 0, z; w < p; w++) { + if (z = f[w]) { + u[w] = z; } } if (u.length) { @@ -1526,9 +1533,9 @@ function Wa(a, c, b, e, d) { e = q; break; } - m && (g && q && e.length || (m = y)); + m && (g && q && e.length || (m = v)); } - g && m && l === b - 1 && !e.length && (m = "", l = -1, k = C()); + g && m && l === b - 1 && !e.length && (h = this.resolution, m = "", l = -1, k = C()); } a: { a = e; @@ -1621,21 +1628,21 @@ function Za(a, c) { this.cache = (b = a.cache || null) && new Y(b); this.priority = a.priority || 4; } -w = O.prototype; -w.clear = function() { +x = O.prototype; +x.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); this.cache && this.cache.clear(); return this; }; -w.append = function(a, c) { +x.append = function(a, c) { return this.add(a, c, !0); }; -w.contain = function(a) { +x.contain = function(a) { return this.reg.has(a); }; -w.update = function(a, c) { +x.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; @@ -1653,7 +1660,7 @@ function $a(a) { } return c; } -w.cleanup = function() { +x.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -1661,8 +1668,8 @@ w.cleanup = function() { this.depth && $a(this.ctx); return this; }; -w.searchCache = La; -w.export = function(a, c, b = 0, e = 0) { +x.searchCache = La; +x.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: @@ -1686,7 +1693,7 @@ w.export = function(a, c, b = 0, e = 0) { } return U.call(this, a, c, d, f, b, e); }; -w.import = function(a, c) { +x.import = function(a, c) { if (c) { switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": @@ -1701,7 +1708,7 @@ w.import = function(a, c) { } } }; -w.serialize = function(a = !0) { +x.serialize = function(a = !0) { if (!this.reg.size) { return ""; } @@ -1752,7 +1759,7 @@ w.serialize = function(a = !0) { return a ? "function inject(index){" + c + e + d + "}" : c + e + d; }; ja(O.prototype); -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 : {}; +const ab = {Index:O, Charset:Ua, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, bb = self; let cb; (cb = bb.define) && cb.amd ? cb([], function() { return ab; diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index c1a4597..465ee56 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -1,24 +1,24 @@ /**! - * FlexSearch.js v0.8.117 (Bundle) + * FlexSearch.js v0.8.123 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function(self){'use strict';var v;function B(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function C(){return Object.create(null)}function D(a){return"string"===typeof a} +(function(self){'use strict';var x;function B(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function C(){return Object.create(null)}function D(a){return"string"===typeof a} function H(a){return"object"===typeof a}function I(a,c){if(D(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; +["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const ca=/[^\p{L}\p{N}]+/u,da=/(\d{3})/g,ea=/(\D)(\d{3})/g,fa=/(\d{3})(\D)/g,ha="".normalize&&/[\u0300-\u036f]/g;function K(a={}){if(!this||this.constructor!==K)return new K(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; this.numeric=B(a.numeric,e)}else{try{this.split=B(this.split,ca)}catch(d){this.split=/\s+/}this.numeric=B(a.numeric,B(this.numeric,!0))}this.prepare=B(a.prepare,null,this.prepare);this.finalize=B(a.finalize,null,this.finalize);ha||(this.mapper=new Map(ba));this.rtl=B(a.rtl,!1,this.rtl);this.dedupe=B(a.dedupe,!1,this.dedupe);this.filter=B((b=a.filter)&&new Set(b),null,this.filter);this.matcher=B((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=B((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer= B((b=a.stemmer)&&new Map(b),null,this.stemmer);this.replacer=B(a.replacer,null,this.replacer);this.minlength=B(a.minlength,1,this.minlength);this.maxlength=B(a.maxlength,0,this.maxlength);if(this.cache=b=B(a.cache,!0,this.cache))this.H=null,this.R="number"===typeof b?b:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.D="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.D+= -(this.D?"|":"")+d;return this};v.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.D+=(this.D?"|":"")+a;this.N=null;this.cache&&L(this);return this};v.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&L(this);return this};v.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this};v.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&L(this);return this}; -v.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this};x.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&L(this);return this}; +x.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),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 ka,la,Q;function ma(){ka=Q=0} @@ -26,44 +26,44 @@ function P(a){this[a+"Async"]=function(){const c=arguments;var b=c[c.length-1];l 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 ua(a,c,b,e,d,f,g,k){if(a=a[g])if(e===c.length-1){if(a.constructor===Array){if(b[e]){for(c=0;cb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} function 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 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&&1this.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"],["ph","f"],["pf","f"]]),Pa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\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:{split:/\s+/,normalize:!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;bv;f--){g=q.substring(v,f);u=this.rtl?d-1-v:v;var k=this.score?this.score(c,q,p,g,u):Wa(t,e,p,d,u); +Z(this,m,g,k,a,b)}break}case "reverse":if(1g?0:1),e,p,k-1,h-1),u=this.bidirectional&& +q>f;Z(this,l,u?f:q,v,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Wa(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};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 $a(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 f; 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); + for (let v = 0, u; v < d; v++) { + for (f = d; f > v; f--) { + g = q.substring(v, f); + u = this.rtl ? d - 1 - v : v; + var k = this.score ? this.score(c, q, p, g, u) : Xa(t, e, p, d, u); + Z(this, m, g, k, a, b); } } break; @@ -1425,24 +1430,26 @@ 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[this.rtl ? d - 1 - k : k] + g; + var h = this.score ? this.score(c, q, p, g, k) : Xa(t, e, p, d, k); + Z(this, m, g, h, a, b); } g = ""; } case "forward": if (1 < d) { for (k = 0; k < d; k++) { - g += q[k], Z(this, m, g, f, a, b); + g += q[this.rtl ? d - 1 - k : k], Z(this, m, g, f, a, b); } break; } default: if (Z(this, m, q, f, a, b), n && 1 < e && p < e - 1) { - for (d = C(), g = this.S, f = q, k = Math.min(n + 1, e - p), d[f] = 1, h = 1; h < k; h++) { + for (d = C(), g = this.S, f = q, k = Math.min(n + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { if ((q = c[this.rtl ? e - 1 - p - h : p + h]) && !d[q]) { d[q] = 1; - const 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); + const v = this.score ? this.score(c, f, p, q, h - 1) : Xa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; + Z(this, l, u ? f : q, v, a, b, u ? q : f); } } } @@ -1494,10 +1501,10 @@ function Xa(a, c, b, e, d) { l = 1; } h || 0 === h || (h = m ? this.S : this.resolution); - for (let q, y; l < b; l++) { - if ((y = a[l]) && !k[y]) { - k[y] = 1; - q = Ya(this, y, m); + for (let q, v; l < b; l++) { + if ((v = a[l]) && !k[v]) { + k[v] = 1; + q = Ya(this, v, m); a: { f = q; var n = e, t = g, p = h; @@ -1508,9 +1515,9 @@ function Xa(a, c, b, e, d) { q = void 0; break a; } - for (let v = 0, z; v < p; v++) { - if (z = f[v]) { - u[v] = z; + for (let w = 0, z; w < p; w++) { + if (z = f[w]) { + u[w] = z; } } if (u.length) { @@ -1525,9 +1532,9 @@ function Xa(a, c, b, e, d) { e = q; break; } - m && (g && q && e.length || (m = y)); + m && (g && q && e.length || (m = v)); } - g && m && l === b - 1 && !e.length && (m = "", l = -1, k = C()); + g && m && l === b - 1 && !e.length && (h = this.resolution, m = "", l = -1, k = C()); } a: { a = e; @@ -1620,21 +1627,21 @@ function Za(a, c) { this.cache = (b = a.cache || null) && new Y(b); this.priority = a.priority || 4; } -w = O.prototype; -w.clear = function() { +x = O.prototype; +x.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); this.cache && this.cache.clear(); return this; }; -w.append = function(a, c) { +x.append = function(a, c) { return this.add(a, c, !0); }; -w.contain = function(a) { +x.contain = function(a) { return this.reg.has(a); }; -w.update = function(a, c) { +x.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; @@ -1652,7 +1659,7 @@ function $a(a) { } return c; } -w.cleanup = function() { +x.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -1660,8 +1667,8 @@ w.cleanup = function() { this.depth && $a(this.ctx); return this; }; -w.searchCache = La; -w.export = function(a, c, b = 0, e = 0) { +x.searchCache = La; +x.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { case 0: @@ -1685,7 +1692,7 @@ w.export = function(a, c, b = 0, e = 0) { } return U.call(this, a, c, d, f, b, e); }; -w.import = function(a, c) { +x.import = function(a, c) { if (c) { switch("string" === typeof c && (c = JSON.parse(c)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), 3 === a.length && a.shift(), a = 1 < a.length ? a[1] : a[0], a) { case "reg": @@ -1700,7 +1707,7 @@ w.import = function(a, c) { } } }; -w.serialize = function(a = !0) { +x.serialize = function(a = !0) { if (!this.reg.size) { return ""; } diff --git a/dist/flexsearch.compact.module.min.js b/dist/flexsearch.compact.module.min.js index c881e0f..b10d0c1 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -1,24 +1,24 @@ /**! - * FlexSearch.js v0.8.117 (Bundle) + * FlexSearch.js v0.8.123 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var v;function B(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function C(){return Object.create(null)}function D(a){return"string"===typeof a} +var x;function B(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function C(){return Object.create(null)}function D(a){return"string"===typeof a} function H(a){return"object"===typeof a}function I(a,c){if(D(c))a=a[c];else for(let b=0;a&&b"a1a".split(b).length; +["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const ca=/[^\p{L}\p{N}]+/u,da=/(\d{3})/g,ea=/(\D)(\d{3})/g,fa=/(\d{3})(\D)/g,ha="".normalize&&/[\u0300-\u036f]/g;function K(a={}){if(!this||this.constructor!==K)return new K(...arguments);if(arguments.length)for(a=0;a"a1a".split(b).length; this.numeric=B(a.numeric,e)}else{try{this.split=B(this.split,ca)}catch(d){this.split=/\s+/}this.numeric=B(a.numeric,B(this.numeric,!0))}this.prepare=B(a.prepare,null,this.prepare);this.finalize=B(a.finalize,null,this.finalize);ha||(this.mapper=new Map(ba));this.rtl=B(a.rtl,!1,this.rtl);this.dedupe=B(a.dedupe,!1,this.dedupe);this.filter=B((b=a.filter)&&new Set(b),null,this.filter);this.matcher=B((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=B((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer= B((b=a.stemmer)&&new Map(b),null,this.stemmer);this.replacer=B(a.replacer,null,this.replacer);this.minlength=B(a.minlength,1,this.minlength);this.maxlength=B(a.maxlength,0,this.maxlength);if(this.cache=b=B(a.cache,!0,this.cache))this.H=null,this.R="number"===typeof b?b:2E5,this.F=new Map,this.G=new Map,this.L=this.K=128;this.h="";this.M=null;this.D="";this.N=null;if(this.matcher)for(const d of this.matcher.keys())this.h+=(this.h?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.D+= -(this.D?"|":"")+d;return this};v.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.D+=(this.D?"|":"")+a;this.N=null;this.cache&&L(this);return this};v.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&L(this);return this};v.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this};v.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&L(this);return this}; -v.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.h+=(this.h?"|":"")+a;this.M=null;this.cache&&L(this);return this};x.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&L(this);return this}; +x.encode=function(a){if(this.cache&&a.length<=this.K)if(this.H){if(this.F.has(a))return this.F.get(a)}else this.H=setTimeout(L,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=ha?a.normalize("NFKD").replace(ha,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(h)),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 ka,la,Q;function ma(){ka=Q=0} @@ -26,45 +26,45 @@ function P(a){this[a+"Async"]=function(){const c=arguments;var b=c[c.length-1];l 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 ua(a,c,b,e,d,f,g,k){if(a=a[g])if(e===c.length-1){if(a.constructor===Array){if(b[e]){for(c=0;cb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} function 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 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&&1this.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"],["ph","f"],["pf","f"]]),Pa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\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:{split:/\s+/,normalize:!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;bv;f--){g=q.substring(v,f);u=this.rtl?d-1-v:v;var k=this.score?this.score(c,q,p,g,u):Xa(t,e,p,d,u); +Z(this,m,g,k,a,b)}break}case "reverse":if(1g?0:1),e,p,k-1,h-1),u=this.bidirectional&& +q>f;Z(this,l,u?f:q,v,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Xa(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};O.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else 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 $a(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 n; q--) { - p = l.substring(n, q); - var t = this.score ? this.score(b, l, k, p, n) : Jb(h, d, k, m, n); - Kb(this, f, p, t, a, c); + n = 0; + for (var q; n < m; n++) { + for (var r = m; r > n; r--) { + p = l.substring(n, r), q = this.rtl ? m - 1 - n : n, q = this.score ? this.score(b, l, k, p, q) : Jb(h, d, k, m, q), Kb(this, f, p, q, a, c); } } break; } 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) : Jb(h, d, k, m, q), Kb(this, f, p, t, a, c); + for (r = m - 1; 0 < r; r--) { + p = l[this.rtl ? m - 1 - r : r] + p, q = this.score ? this.score(b, l, k, p, r) : Jb(h, d, k, m, r), Kb(this, f, p, q, a, c); } p = ""; } case "forward": if (1 < m) { - for (q = 0; q < m; q++) { - p += l[q], Kb(this, f, p, n, a, c); + for (r = 0; r < m; r++) { + p += l[this.rtl ? m - 1 - r : r], Kb(this, f, p, n, a, c); } break; } default: 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]) { + for (m = J(), p = this.da, n = l, r = Math.min(g + 1, this.rtl ? k + 1 : d - k), q = m[n] = 1; q < r; q++) { + if ((l = b[this.rtl ? d - 1 - k - q : k + q]) && !m[l]) { m[l] = 1; - var 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); + var x = this.score ? this.score(b, n, k, l, q - 1) : Jb(p + (d / 2 > p ? 0 : 1), d, k, r - 1, q - 1), t = this.bidirectional && l > n; + Kb(this, e, t ? n : l, x, a, c, t ? l : n); } } } @@ -2823,12 +2827,12 @@ function Jb(a, b, c, d, e) { if (2 === q && g && !h) { return Mb.call(this, p[0], p[1], b, e, f, k, n); } - var t = J(), x = 0; + var r = J(), x = 0; if (1 < q && g) { - var r = p[0]; + var t = p[0]; x = 1; } - m || 0 === m || (m = r ? this.da : this.resolution); + m || 0 === m || (m = t ? this.da : this.resolution); if (this.db) { if (this.db.search && (a = this.db.search(this, p, b, e, h, f, k, n), !1 !== a)) { return a; @@ -2846,12 +2850,12 @@ function Jb(a, b, c, d, e) { break; } v = p[x]; - if (!v || t[v]) { + if (!v || r[v]) { y.h = 5; break; } - t[v] = 1; - return E(y, Nb(A, v, r, 0, 0, !1, !1), 6); + r[v] = 1; + return E(y, Nb(A, v, t, 0, 0, !1, !1), 6); case 6: z = y.D; if (z = Ob(z, d, h, m)) { @@ -2859,9 +2863,9 @@ function Jb(a, b, c, d, e) { y.h = 4; break; } - r && (h && z && d.length || (r = v)); + t && (h && z && d.length || (t = v)); case 5: - h && r && x === q - 1 && !d.length && (r = "", x = -1, t = J()); + h && t && x === q - 1 && !d.length && (m = A.resolution, t = "", x = -1, r = J()); x++; y.h = 2; break; @@ -2872,16 +2876,16 @@ function Jb(a, b, c, d, e) { }(); } for (c = a = void 0; x < q; x++) { - if ((c = p[x]) && !t[c]) { - t[c] = 1; - a = Nb(this, c, r, 0, 0, !1, !1); + if ((c = p[x]) && !r[c]) { + r[c] = 1; + a = Nb(this, c, t, 0, 0, !1, !1); if (a = Ob(a, d, h, m)) { d = a; break; } - r && (h && a && d.length || (r = c)); + t && (h && a && d.length || (t = c)); } - h && r && x === q - 1 && !d.length && (r = "", x = -1, t = J()); + h && t && x === q - 1 && !d.length && (m = this.resolution, t = "", x = -1, r = J()); } return Pb(d, m, b, e, h, l, f); }; @@ -3149,8 +3153,8 @@ u.serialize = function(a) { n = 0; for (var p; n < l.length; n++) { p = l[n] || [""]; - for (var q = "", t = 0; t < p.length; t++) { - q += (q ? "," : "") + ("string" === c ? '"' + p[t] + '"' : p[t]); + for (var q = "", r = 0; r < p.length; r++) { + q += (q ? "," : "") + ("string" === c ? '"' + p[r] + '"' : p[r]); } q = "[" + q + "]"; m += (m ? "," : "") + q; @@ -3377,24 +3381,24 @@ u.commit = function(a, b, c) { 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; + var q = this.result, r; if (q && q.length) { - for (var x = Math.max(q.length, p.O.length), r = 0, A; r < x; r++) { - if ((A = p.O[r]) && A.length) { - if ((t = q[r]) && t.length) { + for (var x = Math.max(q.length, p.O.length), t = 0, A; t < x; t++) { + if ((A = p.O[t]) && A.length) { + if ((r = q[t]) && r.length) { for (var z = 0; z < A.length; z++) { - t.push(A[z]); + r.push(A[z]); } } else { - q[r] = A; + q[t] = A; } - t = 1; + r = 1; } } } else { - q = p.O, t = 1; + q = p.O, r = 1; } - t && k.put(q, p.Y); + r && k.put(q, p.Y); }; }(n)); } @@ -3406,26 +3410,26 @@ u.commit = function(a, b, c) { n.V = m[0]; m = w(m[1]); for (var p = m.next(), q = {}; !p.done; q = {P:void 0, Z:void 0}, p = m.next()) { - p = p.value, q.Z = p[0], q.P = p[1], q.P.length && (b ? k.put(q.P, n.V + ":" + q.Z) : k.get(n.V + ":" + q.Z).onsuccess = function(t, x) { + p = p.value, q.Z = p[0], q.P = p[1], q.P.length && (b ? k.put(q.P, n.V + ":" + q.Z) : k.get(n.V + ":" + q.Z).onsuccess = function(r, x) { return function() { - var r = this.result, A; - if (r && r.length) { - for (var z = Math.max(r.length, t.P.length), v = 0, y; v < z; v++) { - if ((y = t.P[v]) && y.length) { - if ((A = r[v]) && A.length) { + var t = this.result, A; + if (t && t.length) { + for (var z = Math.max(t.length, r.P.length), v = 0, y; v < z; v++) { + if ((y = r.P[v]) && y.length) { + if ((A = t[v]) && A.length) { for (var D = 0; D < y.length; D++) { A.push(y[D]); } } else { - r[v] = y; + t[v] = y; } A = 1; } } } else { - r = t.P, A = 1; + t = r.P, A = 1; } - A && k.put(r, x.V + ":" + t.Z); + A && k.put(t, x.V + ":" + r.Z); }; }(q, n)); } @@ -3529,7 +3533,7 @@ function Vb(a) { a = null; }); } -;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; +;var Zb = {Index:S, Charset:Hb, Encoder:Ga, Document:W, Worker:Ra, Resolver:Y, IndexedDB:Ub, Language:{}}, $b = self, ac; (ac = $b.define) && ac.amd ? ac([], function() { return Zb; }) : "object" === typeof $b.exports ? $b.exports = Zb : $b.FlexSearch = Zb; diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js index a90a7f1..42a924d 100644 --- a/dist/flexsearch.es5.min.js +++ b/dist/flexsearch.es5.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.117 (ES5) + * FlexSearch.js v0.8.123 (ES5) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -41,7 +41,7 @@ function J(){return Object.create(null)}function K(a){return"string"===typeof a} "i"],["\u01d2","o"],["\u01d4","u"],["\u01d6","u"],["\u01d8","u"],["\u01da","u"],["\u01dc","u"],["\u01df","a"],["\u01e1","a"],["\u01e3","ae"],["\u00e6","ae"],["\u01fd","ae"],["\u01e7","g"],["\u01e9","k"],["\u01eb","o"],["\u01ed","o"],["\u01ef","\u0292"],["\u01f0","j"],["\u01f3","dz"],["\u01f5","g"],["\u01f9","n"],["\u01fb","a"],["\u01ff","\u00f8"],["\u0201","a"],["\u0203","a"],["\u0205","e"],["\u0207","e"],["\u0209","i"],["\u020b","i"],["\u020d","o"],["\u020f","o"],["\u0211","r"],["\u0213","r"],["\u0215", "u"],["\u0217","u"],["\u0219","s"],["\u021b","t"],["\u021f","h"],["\u0227","a"],["\u0229","e"],["\u022b","o"],["\u022d","o"],["\u022f","o"],["\u0231","o"],["\u0233","y"],["\u02b0","h"],["\u02b1","h"],["\u0266","h"],["\u02b2","j"],["\u02b3","r"],["\u02b4","\u0279"],["\u02b5","\u027b"],["\u02b6","\u0281"],["\u02b7","w"],["\u02b8","y"],["\u02e0","\u0263"],["\u02e1","l"],["\u02e2","s"],["\u02e3","x"],["\u02e4","\u0295"],["\u0390","\u03b9"],["\u03ac","\u03b1"],["\u03ad","\u03b5"],["\u03ae","\u03b7"],["\u03af", "\u03b9"],["\u03b0","\u03c5"],["\u03ca","\u03b9"],["\u03cb","\u03c5"],["\u03cc","\u03bf"],["\u03cd","\u03c5"],["\u03ce","\u03c9"],["\u03d0","\u03b2"],["\u03d1","\u03b8"],["\u03d2","\u03a5"],["\u03d3","\u03a5"],["\u03d4","\u03a5"],["\u03d5","\u03c6"],["\u03d6","\u03c0"],["\u03f0","\u03ba"],["\u03f1","\u03c1"],["\u03f2","\u03c2"],["\u03f5","\u03b5"],["\u0439","\u0438"],["\u0450","\u0435"],["\u0451","\u0435"],["\u0453","\u0433"],["\u0457","\u0456"],["\u045c","\u043a"],["\u045d","\u0438"],["\u045e","\u0443"], -["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];var Ba=/[^\p{L}\p{N}]+/u,Ca=/(\d{3})/g,Da=/(\D)(\d{3})/g,Ea=/(\d{3})(\D)/g,Fa="".normalize&&/[\u0300-\u036f]/g;function Ga(a){if(!this||this.constructor!==Ga){var b=Function.prototype.bind,c=b.apply,d=[null],e=d.concat;if(arguments instanceof Array)var g=arguments;else{g=w(arguments);for(var f,h=[];!(f=g.next()).done;)h.push(f.value);g=h}return new (c.call(b,Ga,e.call(d,g)))}for(b=0;b"a1a".split(c).length; this.numeric=H(a.numeric,e)}else{try{this.split=H(this.split,Ba)}catch(g){this.split=/\s+/}this.numeric=H(a.numeric,H(this.numeric,!0))}this.prepare=H(a.prepare,null,this.prepare);this.finalize=H(a.finalize,null,this.finalize);Fa||(this.mapper=new Map(Aa));this.rtl=H(a.rtl,!1,this.rtl);this.dedupe=H(a.dedupe,!1,this.dedupe);this.filter=H((c=a.filter)&&new Set(c),null,this.filter);this.matcher=H((c=a.matcher)&&new Map(c),null,this.matcher);this.mapper=H((c=a.mapper)&&new Map(c),null,this.mapper);this.stemmer= H((c=a.stemmer)&&new Map(c),null,this.stemmer);this.replacer=H(a.replacer,null,this.replacer);this.minlength=H(a.minlength,1,this.minlength);this.maxlength=H(a.maxlength,0,this.maxlength);if(this.cache=c=H(a.cache,!0,this.cache))this.D=null,this.T="number"===typeof c?c:2E5,this.B=new Map,this.C=new Map,this.H=this.G=128;this.h="";this.M=null;this.A="";this.N=null;if(this.matcher)for(a=w(this.matcher.keys()),b=a.next();!b.done;b=a.next())this.h+=(this.h?"|":"")+b.value;if(this.stemmer)for(a=w(this.stemmer.keys()), @@ -58,7 +58,7 @@ function Ma(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if("fu 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} @@ -88,8 +88,8 @@ if(n){if(this.db){y.tag=n;var Ja=v.db.support_tag_search;y.field=m}Ja||(y.enrich D.push(L);else if(!p)return h?e:new Y(e)}}if(G){v=kb(v,D,h);y=v.length;if(!y&&!p)return h?v:new Y(v);G--}}if(y)g[f]=z,e.push(v),f++;else if(1===m.length)return h?e:new Y(e)}if(t){if(this.db&&n&&n.length&&!Ja)for(q=0;qc||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 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}; +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"],["ph","f"],["pf","f"]]),Cb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\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:{split:/\s+/,normalize:!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;r--)p=l.substring(n,r),q=this.rtl?m-1-n:n,q=this.score?this.score(b,l,k,p,q):Jb(h,d,k,m,q),Kb(this,g,p, +q,a,c);break}case "reverse":if(1p?0:1),d,k,r-1,q-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;dm&&!g&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(g=1),0<=m)if(e=1,1 "a1a".split(b).length; } - this.numeric = r(a.numeric, f); + this.numeric = u(a.numeric, f); } else { try { - this.split = r(this.split, y); + this.split = u(this.split, y); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } - this.numeric = r(a.numeric, r(this.numeric, !0)); + this.numeric = u(a.numeric, u(this.numeric, !0)); } - this.prepare = r(a.prepare, null, this.prepare); - this.finalize = r(a.finalize, null, this.finalize); - this.rtl = r(a.rtl, !1, this.rtl); - this.dedupe = r(a.dedupe, !1, this.dedupe); - this.filter = r((b = a.filter) && new Set(b), null, this.filter); - this.matcher = r((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = r((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = r((b = a.stemmer) && new Map(b), null, this.stemmer); - this.replacer = r(a.replacer, null, this.replacer); - this.minlength = r(a.minlength, 1, this.minlength); - this.maxlength = r(a.maxlength, 0, this.maxlength); - if (this.cache = b = r(a.cache, !0, this.cache)) { + this.prepare = u(a.prepare, null, this.prepare); + this.finalize = u(a.finalize, null, this.finalize); + this.rtl = u(a.rtl, !1, this.rtl); + this.dedupe = u(a.dedupe, !1, this.dedupe); + this.filter = u((b = a.filter) && new Set(b), null, this.filter); + this.matcher = u((b = a.matcher) && new Map(b), null, this.matcher); + this.mapper = u((b = a.mapper) && new Map(b), null, this.mapper); + this.stemmer = u((b = a.stemmer) && new Map(b), null, this.stemmer); + this.replacer = u(a.replacer, null, this.replacer); + this.minlength = u(a.minlength, 1, this.minlength); + this.maxlength = u(a.maxlength, 0, this.maxlength); + if (this.cache = b = u(a.cache, !0, this.cache)) { this.l = null, this.A = "number" === typeof b ? b : 2e5, this.i = new Map(), this.j = new Map(), this.o = this.m = 128; } this.g = ""; @@ -120,7 +124,7 @@ q.assign = function(a) { } return this; }; -q.addStemmer = function(a, c) { +r.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, c); this.h += (this.h ? "|" : "") + a; @@ -128,13 +132,13 @@ q.addStemmer = function(a, c) { this.cache && G(this); return this; }; -q.addFilter = function(a) { +r.addFilter = function(a) { this.filter || (this.filter = new Set()); this.filter.add(a); this.cache && G(this); return this; }; -q.addMapper = function(a, c) { +r.addMapper = function(a, c) { if ("object" === typeof a) { return this.addReplacer(a, c); } @@ -146,7 +150,7 @@ q.addMapper = function(a, c) { this.cache && G(this); return this; }; -q.addMatcher = function(a, c) { +r.addMatcher = function(a, c) { if ("object" === typeof a) { return this.addReplacer(a, c); } @@ -160,7 +164,7 @@ q.addMatcher = function(a, c) { this.cache && G(this); return this; }; -q.addReplacer = function(a, c) { +r.addReplacer = function(a, c) { if ("string" === typeof a) { return this.addMatcher(a, c); } @@ -169,7 +173,7 @@ q.addReplacer = function(a, c) { this.cache && G(this); return this; }; -q.encode = function(a) { +r.encode = function(a) { if (this.cache && a.length <= this.m) { if (this.l) { if (this.i.has(a)) { @@ -204,8 +208,8 @@ q.encode = function(a) { this.stemmer && 2 < e.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), e = e.replace(this.u, k => this.stemmer.get(k)), e.length < this.minlength || this.filter && this.filter.has(e)) && (e = ""); if (e && (this.mapper || this.dedupe && 1 < e.length)) { d = ""; - for (let k = 0, n = "", m, u; k < e.length; k++) { - m = e.charAt(k), m === n && this.dedupe || ((u = this.mapper && this.mapper.get(m)) || "" === u ? u === n && this.dedupe || !(n = u) || (d += u) : d += n = m); + for (let k = 0, n = "", m, v; k < e.length; k++) { + m = e.charAt(k), m === n && this.dedupe || ((v = this.mapper && this.mapper.get(m)) || "" === v ? v === n && this.dedupe || !(n = v) || (d += v) : d += n = m); } e = d; } @@ -288,7 +292,7 @@ I.prototype.clear = function() { const J = {normalize:function(a) { return a.toLowerCase(); }}; -const K = {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 K = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; L.prototype.add = function(a, c, b, f) { if (c && (a || 0 === a)) { if (!f && !b && this.reg.has(a)) { @@ -296,20 +300,21 @@ L.prototype.add = function(a, c, b, f) { } c = this.encoder.encode(c); if (f = c.length) { - const n = w(), m = w(), u = this.depth, C = this.resolution; + const n = w(), m = w(), v = this.depth, C = this.resolution; for (let p = 0; p < f; p++) { let l = c[this.rtl ? f - 1 - p : p]; var d = l.length; - if (d && (u || !m[l])) { + if (d && (v || !m[l])) { var g = this.score ? this.score(c, l, p, null, 0) : M(C, f, p), e = ""; switch(this.tokenize) { case "full": if (2 < d) { - for (g = 0; g < d; g++) { - for (var h = d; h > g; h--) { - e = l.substring(g, h); - var k = this.score ? this.score(c, l, p, e, g) : M(C, f, p, d, g); - N(this, m, e, k, a, b); + for (let q = 0, t; q < d; q++) { + for (g = d; g > q; g--) { + e = l.substring(q, g); + t = this.rtl ? d - 1 - q : q; + var h = this.score ? this.score(c, l, p, e, t) : M(C, f, p, d, t); + N(this, m, e, h, a, b); } } break; @@ -317,24 +322,26 @@ L.prototype.add = function(a, c, b, f) { case "reverse": if (1 < d) { for (h = d - 1; 0 < h; h--) { - e = l[h] + e, k = this.score ? this.score(c, l, p, e, h) : M(C, f, p, d, h), N(this, m, e, k, a, b); + e = l[this.rtl ? d - 1 - h : h] + e; + var k = this.score ? this.score(c, l, p, e, h) : M(C, f, p, d, h); + N(this, m, e, k, a, b); } e = ""; } case "forward": if (1 < d) { for (h = 0; h < d; h++) { - e += l[h], N(this, m, e, g, a, b); + e += l[this.rtl ? d - 1 - h : h], N(this, m, e, g, a, b); } break; } default: - if (N(this, m, l, g, a, b), u && 1 < f && p < f - 1) { - for (d = w(), e = this.v, g = l, h = Math.min(u + 1, f - p), d[g] = 1, k = 1; k < h; k++) { + if (N(this, m, l, g, a, b), v && 1 < f && p < f - 1) { + for (d = w(), e = this.v, g = l, h = Math.min(v + 1, this.rtl ? p + 1 : f - p), d[g] = 1, k = 1; k < h; k++) { if ((l = c[this.rtl ? f - 1 - p - k : p + k]) && !d[l]) { d[l] = 1; - const v = this.score ? this.score(c, g, p, l, k) : M(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; - N(this, n, t ? g : l, v, a, b, t ? l : g); + const q = this.score ? this.score(c, g, p, l, k - 1) : M(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; + N(this, n, t ? g : l, q, a, b, t ? l : g); } } } @@ -386,17 +393,17 @@ function M(a, c, b, f, d) { n = 1; } k || 0 === k || (k = m ? this.v : this.resolution); - for (let l, v; n < b; n++) { - if ((v = a[n]) && !h[v]) { - h[v] = 1; - l = O(this, v, m); + for (let l, q; n < b; n++) { + if ((q = a[n]) && !h[q]) { + h[q] = 1; + l = O(this, q, m); a: { g = l; - var u = f, C = e, p = k; + var v = f, C = e, p = k; let t = []; if (g && g.length) { if (g.length <= p) { - u.push(g); + v.push(g); l = void 0; break a; } @@ -406,7 +413,7 @@ function M(a, c, b, f, d) { } } if (t.length) { - u.push(t); + v.push(t); l = void 0; break a; } @@ -417,9 +424,9 @@ function M(a, c, b, f, d) { f = l; break; } - m && (e && l && f.length || (m = v)); + m && (e && l && f.length || (m = q)); } - e && m && n === b - 1 && !f.length && (m = "", n = -1, h = w()); + e && m && n === b - 1 && !f.length && (k = this.resolution, m = "", n = -1, h = w()); } a: { a = f; @@ -431,11 +438,11 @@ function M(a, c, b, f, d) { m = a.length; e = []; b = w(); - for (let l = 0, v, t, x, E; l < k; l++) { + for (let l = 0, q, t, x, E; l < k; l++) { for (n = 0; n < m; n++) { - if (x = a[n], l < x.length && (v = x[l])) { - for (g = 0; g < v.length; g++) { - t = v[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), E = e[h] || (e[h] = []), E.push(t); + if (x = a[n], l < x.length && (q = x[l])) { + for (g = 0; g < q.length; g++) { + t = q[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), E = e[h] || (e[h] = []), E.push(t); } } } @@ -563,21 +570,21 @@ function P(a, c) { this.rtl = d.rtl || a.rtl || !1; this.cache = (b = a.cache || null) && new I(b); } -q = L.prototype; -q.clear = function() { +r = L.prototype; +r.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); this.cache && this.cache.clear(); return this; }; -q.append = function(a, c) { +r.append = function(a, c) { return this.add(a, c, !0); }; -q.contain = function(a) { +r.contain = function(a) { return this.reg.has(a); }; -q.update = function(a, c) { +r.update = function(a, c) { const b = this, f = this.remove(a); return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); }; @@ -595,7 +602,7 @@ function Q(a) { } return c; } -q.cleanup = function() { +r.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -603,7 +610,7 @@ q.cleanup = function() { this.depth && Q(this.ctx); return this; }; -q.searchCache = function(a, c, b) { +r.searchCache = function(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new I()); let f = this.cache.get(a); @@ -620,7 +627,7 @@ q.searchCache = function(a, c, b) { } return f; }; -const R = {Index:L, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, S = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : "undefined" !== typeof window ? window : {}; +const R = {Index:L, Charset:null, Encoder:F, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, S = self; let T; (T = S.define) && T.amd ? T([], function() { return R; diff --git a/dist/flexsearch.light.min.js b/dist/flexsearch.light.min.js index 0db6021..7667e11 100644 --- a/dist/flexsearch.light.min.js +++ b/dist/flexsearch.light.min.js @@ -1,27 +1,27 @@ /**! - * FlexSearch.js v0.8.117 (Light) + * FlexSearch.js v0.8.123 (Light) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -(function(self){'use strict';var q;function r(a,c,b){const f=typeof b,d=typeof a;if("undefined"!==f){if("undefined"!==d){if(b){if("function"===d&&f===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(c===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===d?c:a}function w(){return Object.create(null)};const y=/[^\p{L}\p{N}]+/u,z=/(\d{3})/g,A=/(\D)(\d{3})/g,B=/(\d{3})(\D)/g,D="".normalize&&/[\u0300-\u036f]/g;function F(a){if(!this||this.constructor!==F)return new F(...arguments);for(let c=0;c"a1a".split(b).length; -this.numeric=r(a.numeric,f)}else{try{this.split=r(this.split,y)}catch(d){this.split=/\s+/}this.numeric=r(a.numeric,r(this.numeric,!0))}this.prepare=r(a.prepare,null,this.prepare);this.finalize=r(a.finalize,null,this.finalize);this.rtl=r(a.rtl,!1,this.rtl);this.dedupe=r(a.dedupe,!1,this.dedupe);this.filter=r((b=a.filter)&&new Set(b),null,this.filter);this.matcher=r((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=r((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=r((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=r(a.replacer,null,this.replacer);this.minlength=r(a.minlength,1,this.minlength);this.maxlength=r(a.maxlength,0,this.maxlength);if(this.cache=b=r(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const d of this.matcher.keys())this.g+=(this.g?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.h+=(this.h?"|":"")+d;return this}; -q.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};q.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&G(this);return this};q.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this};q.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; -q.encode=function(a){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=D?a.normalize("NFKD").replace(D,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3"a1a".split(b).length; +this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,y)}catch(d){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);this.rtl=u(a.rtl,!1,this.rtl);this.dedupe=u(a.dedupe,!1,this.dedupe);this.filter=u((b=a.filter)&&new Set(b),null,this.filter);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,0,this.maxlength);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const d of this.matcher.keys())this.g+=(this.g?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.h+=(this.h?"|":"")+d;return this}; +r.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&G(this);return this};r.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this};r.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; +r.encode=function(a){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=D?a.normalize("NFKD").replace(D,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),e.lengththis.matcher.get(k)));if(e&&this.replacer)for(d=0;e&&dthis.A&& +if(e&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(e&&this.replacer)for(d=0;e&&dthis.A&& (this.j.clear(),this.o=this.o/1.1|0));e&&b.push(e)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.m&&(this.i.set(a,b),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return b};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,c,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let f=[];for(let d=0,g,e;d=e){b-=e;continue}bc&&(g=g.slice(0,c),e=c);if(!f.length&&e>=c)return g;f.push(g);c-=e;if(!c)break}return f=1this.limit&&this.cache.delete(this.cache.keys().next().value)};I.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};I.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}}; -I.prototype.clear=function(){this.cache.clear();this.g=""};const J={normalize:function(a){return a.toLowerCase()}};const K={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};L.prototype.add=function(a,c,b,f){if(c&&(a||0===a)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(f=c.length){const n=w(),m=w(),u=this.depth,C=this.resolution;for(let p=0;pg;h--){e=l.substring(g,h);var k=this.score?this.score(c,l,p,e,g):M(C,f,p,d,g);N(this,m,e,k,a,b)}break}case "reverse":if(1< -d){for(h=d-1;0e?0:1),f,p,h-1,k-1),t=this.bidirectional&&l>g;N(this,n,t?g:l,v,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function N(a,c,b,f,d,g,e){let h=e?a.ctx:a.map,k;if(!c[b]||e&&!(k=c[b])[e])e?(c=k||(c[b]=w()),c[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function M(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}m=e}else if(1===f){c=H.call(null,a[0],c,d);break a}c=m}return c}; +I.prototype.clear=function(){this.cache.clear();this.g=""};const J={normalize:function(a){return a.toLowerCase()}};const K={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};L.prototype.add=function(a,c,b,f){if(c&&(a||0===a)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(f=c.length){const n=w(),m=w(),v=this.depth,C=this.resolution;for(let p=0;pq;g--){e=l.substring(q,g);t=this.rtl?d-1-q:q;var h=this.score?this.score(c,l,p,e,t):M(C,f,p,d,t);N(this, +m,e,h,a,b)}break}case "reverse":if(1e?0:1),f,p,h-1,k-1),t=this.bidirectional&& +l>g;N(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function N(a,c,b,f,d,g,e){let h=e?a.ctx:a.map,k;if(!c[b]||e&&!(k=c[b])[e])e?(c=k||(c[b]=w()),c[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function M(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}m=e}else if(1===f){c=H.call(null,a[0],c,d);break a}c=m}return c}; function O(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};L.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let f=0,d;fd.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else P(this.map,a),this.depth&&P(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; function P(a,c){let b=0;if(a.constructor===Array)for(let f=0,d,g;fb.add(a,c)):this.add(a,c)}; -function Q(a){let c=0;if(a.constructor===Array)for(let b=0,f;bb.add(a,c)):this.add(a,c)}; +function Q(a){let c=0;if(a.constructor===Array)for(let b=0,f;b "a1a".split(b).length; } - this.numeric = r(a.numeric, f); + this.numeric = u(a.numeric, f); } else { try { - this.split = r(this.split, y); + this.split = u(this.split, y); } catch (d) { console.warn("This platform does not support unicode regex. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/; } - this.numeric = r(a.numeric, r(this.numeric, !0)); + this.numeric = u(a.numeric, u(this.numeric, !0)); } - this.prepare = r(a.prepare, null, this.prepare); - this.finalize = r(a.finalize, null, this.finalize); - this.rtl = r(a.rtl, !1, this.rtl); - this.dedupe = r(a.dedupe, !1, this.dedupe); - this.filter = r((b = a.filter) && new Set(b), null, this.filter); - this.matcher = r((b = a.matcher) && new Map(b), null, this.matcher); - this.mapper = r((b = a.mapper) && new Map(b), null, this.mapper); - this.stemmer = r((b = a.stemmer) && new Map(b), null, this.stemmer); - this.replacer = r(a.replacer, null, this.replacer); - this.minlength = r(a.minlength, 1, this.minlength); - this.maxlength = r(a.maxlength, 0, this.maxlength); - if (this.cache = b = r(a.cache, !0, this.cache)) { + this.prepare = u(a.prepare, null, this.prepare); + this.finalize = u(a.finalize, null, this.finalize); + this.rtl = u(a.rtl, !1, this.rtl); + this.dedupe = u(a.dedupe, !1, this.dedupe); + this.filter = u((b = a.filter) && new Set(b), null, this.filter); + this.matcher = u((b = a.matcher) && new Map(b), null, this.matcher); + this.mapper = u((b = a.mapper) && new Map(b), null, this.mapper); + this.stemmer = u((b = a.stemmer) && new Map(b), null, this.stemmer); + this.replacer = u(a.replacer, null, this.replacer); + this.minlength = u(a.minlength, 1, this.minlength); + this.maxlength = u(a.maxlength, 0, this.maxlength); + if (this.cache = b = u(a.cache, !0, this.cache)) { this.l = null, this.A = "number" === typeof b ? b : 2e5, this.i = new Map(), this.j = new Map(), this.o = this.m = 128; } this.g = ""; @@ -119,7 +123,7 @@ q.assign = function(a) { } return this; }; -q.addStemmer = function(a, c) { +r.addStemmer = function(a, c) { this.stemmer || (this.stemmer = new Map()); this.stemmer.set(a, c); this.h += (this.h ? "|" : "") + a; @@ -127,13 +131,13 @@ q.addStemmer = function(a, c) { this.cache && G(this); return this; }; -q.addFilter = function(a) { +r.addFilter = function(a) { this.filter || (this.filter = new Set()); this.filter.add(a); this.cache && G(this); return this; }; -q.addMapper = function(a, c) { +r.addMapper = function(a, c) { if ("object" === typeof a) { return this.addReplacer(a, c); } @@ -145,7 +149,7 @@ q.addMapper = function(a, c) { this.cache && G(this); return this; }; -q.addMatcher = function(a, c) { +r.addMatcher = function(a, c) { if ("object" === typeof a) { return this.addReplacer(a, c); } @@ -159,7 +163,7 @@ q.addMatcher = function(a, c) { this.cache && G(this); return this; }; -q.addReplacer = function(a, c) { +r.addReplacer = function(a, c) { if ("string" === typeof a) { return this.addMatcher(a, c); } @@ -168,7 +172,7 @@ q.addReplacer = function(a, c) { this.cache && G(this); return this; }; -q.encode = function(a) { +r.encode = function(a) { if (this.cache && a.length <= this.m) { if (this.l) { if (this.i.has(a)) { @@ -203,8 +207,8 @@ q.encode = function(a) { this.stemmer && 2 < e.length && (this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$")), e = e.replace(this.u, k => this.stemmer.get(k)), e.length < this.minlength || this.filter && this.filter.has(e)) && (e = ""); if (e && (this.mapper || this.dedupe && 1 < e.length)) { d = ""; - for (let k = 0, n = "", m, u; k < e.length; k++) { - m = e.charAt(k), m === n && this.dedupe || ((u = this.mapper && this.mapper.get(m)) || "" === u ? u === n && this.dedupe || !(n = u) || (d += u) : d += n = m); + for (let k = 0, n = "", m, v; k < e.length; k++) { + m = e.charAt(k), m === n && this.dedupe || ((v = this.mapper && this.mapper.get(m)) || "" === v ? v === n && this.dedupe || !(n = v) || (d += v) : d += n = m); } e = d; } @@ -287,7 +291,7 @@ I.prototype.clear = function() { const J = {normalize:function(a) { return a.toLowerCase(); }}; -const K = {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 K = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; L.prototype.add = function(a, c, b, f) { if (c && (a || 0 === a)) { if (!f && !b && this.reg.has(a)) { @@ -295,20 +299,21 @@ L.prototype.add = function(a, c, b, f) { } c = this.encoder.encode(c); if (f = c.length) { - const n = w(), m = w(), u = this.depth, C = this.resolution; + const n = w(), m = w(), v = this.depth, C = this.resolution; for (let p = 0; p < f; p++) { let l = c[this.rtl ? f - 1 - p : p]; var d = l.length; - if (d && (u || !m[l])) { + if (d && (v || !m[l])) { var g = this.score ? this.score(c, l, p, null, 0) : M(C, f, p), e = ""; switch(this.tokenize) { case "full": if (2 < d) { - for (g = 0; g < d; g++) { - for (var h = d; h > g; h--) { - e = l.substring(g, h); - var k = this.score ? this.score(c, l, p, e, g) : M(C, f, p, d, g); - N(this, m, e, k, a, b); + for (let q = 0, t; q < d; q++) { + for (g = d; g > q; g--) { + e = l.substring(q, g); + t = this.rtl ? d - 1 - q : q; + var h = this.score ? this.score(c, l, p, e, t) : M(C, f, p, d, t); + N(this, m, e, h, a, b); } } break; @@ -316,24 +321,26 @@ L.prototype.add = function(a, c, b, f) { case "reverse": if (1 < d) { for (h = d - 1; 0 < h; h--) { - e = l[h] + e, k = this.score ? this.score(c, l, p, e, h) : M(C, f, p, d, h), N(this, m, e, k, a, b); + e = l[this.rtl ? d - 1 - h : h] + e; + var k = this.score ? this.score(c, l, p, e, h) : M(C, f, p, d, h); + N(this, m, e, k, a, b); } e = ""; } case "forward": if (1 < d) { for (h = 0; h < d; h++) { - e += l[h], N(this, m, e, g, a, b); + e += l[this.rtl ? d - 1 - h : h], N(this, m, e, g, a, b); } break; } default: - if (N(this, m, l, g, a, b), u && 1 < f && p < f - 1) { - for (d = w(), e = this.v, g = l, h = Math.min(u + 1, f - p), d[g] = 1, k = 1; k < h; k++) { + if (N(this, m, l, g, a, b), v && 1 < f && p < f - 1) { + for (d = w(), e = this.v, g = l, h = Math.min(v + 1, this.rtl ? p + 1 : f - p), d[g] = 1, k = 1; k < h; k++) { if ((l = c[this.rtl ? f - 1 - p - k : p + k]) && !d[l]) { d[l] = 1; - const v = this.score ? this.score(c, g, p, l, k) : M(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; - N(this, n, t ? g : l, v, a, b, t ? l : g); + const q = this.score ? this.score(c, g, p, l, k - 1) : M(e + (f / 2 > e ? 0 : 1), f, p, h - 1, k - 1), t = this.bidirectional && l > g; + N(this, n, t ? g : l, q, a, b, t ? l : g); } } } @@ -385,17 +392,17 @@ function M(a, c, b, f, d) { n = 1; } k || 0 === k || (k = m ? this.v : this.resolution); - for (let l, v; n < b; n++) { - if ((v = a[n]) && !h[v]) { - h[v] = 1; - l = O(this, v, m); + for (let l, q; n < b; n++) { + if ((q = a[n]) && !h[q]) { + h[q] = 1; + l = O(this, q, m); a: { g = l; - var u = f, C = e, p = k; + var v = f, C = e, p = k; let t = []; if (g && g.length) { if (g.length <= p) { - u.push(g); + v.push(g); l = void 0; break a; } @@ -405,7 +412,7 @@ function M(a, c, b, f, d) { } } if (t.length) { - u.push(t); + v.push(t); l = void 0; break a; } @@ -416,9 +423,9 @@ function M(a, c, b, f, d) { f = l; break; } - m && (e && l && f.length || (m = v)); + m && (e && l && f.length || (m = q)); } - e && m && n === b - 1 && !f.length && (m = "", n = -1, h = w()); + e && m && n === b - 1 && !f.length && (k = this.resolution, m = "", n = -1, h = w()); } a: { a = f; @@ -430,11 +437,11 @@ function M(a, c, b, f, d) { m = a.length; e = []; b = w(); - for (let l = 0, v, t, x, E; l < k; l++) { + for (let l = 0, q, t, x, E; l < k; l++) { for (n = 0; n < m; n++) { - if (x = a[n], l < x.length && (v = x[l])) { - for (g = 0; g < v.length; g++) { - t = v[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), E = e[h] || (e[h] = []), E.push(t); + if (x = a[n], l < x.length && (q = x[l])) { + for (g = 0; g < q.length; g++) { + t = q[g], (h = b[t]) ? b[t]++ : (h = 0, b[t] = 1), E = e[h] || (e[h] = []), E.push(t); } } } @@ -562,21 +569,21 @@ function P(a, c) { this.rtl = d.rtl || a.rtl || !1; this.cache = (b = a.cache || null) && new I(b); } -q = L.prototype; -q.clear = function() { +r = L.prototype; +r.clear = function() { this.map.clear(); this.ctx.clear(); this.reg.clear(); this.cache && this.cache.clear(); return this; }; -q.append = function(a, c) { +r.append = function(a, c) { return this.add(a, c, !0); }; -q.contain = function(a) { +r.contain = function(a) { return this.reg.has(a); }; -q.update = function(a, c) { +r.update = function(a, c) { const b = this, f = this.remove(a); return f && f.then ? f.then(() => b.add(a, c)) : this.add(a, c); }; @@ -594,7 +601,7 @@ function Q(a) { } return c; } -q.cleanup = function() { +r.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } @@ -602,7 +609,7 @@ q.cleanup = function() { this.depth && Q(this.ctx); return this; }; -q.searchCache = function(a, c, b) { +r.searchCache = function(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new I()); let f = this.cache.get(a); diff --git a/dist/flexsearch.light.module.min.js b/dist/flexsearch.light.module.min.js index 197e8e1..db8cd10 100644 --- a/dist/flexsearch.light.module.min.js +++ b/dist/flexsearch.light.module.min.js @@ -1,28 +1,28 @@ /**! - * FlexSearch.js v0.8.117 (Bundle) + * FlexSearch.js v0.8.123 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var q;function r(a,c,b){const f=typeof b,d=typeof a;if("undefined"!==f){if("undefined"!==d){if(b){if("function"===d&&f===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var e of a)g.set(e[0],e[1]);return g}if(c===Set){e=new Set(b);for(g of a.values())e.add(g);return e}}}return a}return b}return"undefined"===d?c:a}function w(){return Object.create(null)};const y=/[^\p{L}\p{N}]+/u,z=/(\d{3})/g,A=/(\D)(\d{3})/g,B=/(\d{3})(\D)/g,D="".normalize&&/[\u0300-\u036f]/g;function F(a){if(!this||this.constructor!==F)return new F(...arguments);for(let c=0;c"a1a".split(b).length; -this.numeric=r(a.numeric,f)}else{try{this.split=r(this.split,y)}catch(d){this.split=/\s+/}this.numeric=r(a.numeric,r(this.numeric,!0))}this.prepare=r(a.prepare,null,this.prepare);this.finalize=r(a.finalize,null,this.finalize);this.rtl=r(a.rtl,!1,this.rtl);this.dedupe=r(a.dedupe,!1,this.dedupe);this.filter=r((b=a.filter)&&new Set(b),null,this.filter);this.matcher=r((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=r((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=r((b=a.stemmer)&&new Map(b), -null,this.stemmer);this.replacer=r(a.replacer,null,this.replacer);this.minlength=r(a.minlength,1,this.minlength);this.maxlength=r(a.maxlength,0,this.maxlength);if(this.cache=b=r(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const d of this.matcher.keys())this.g+=(this.g?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.h+=(this.h?"|":"")+d;return this}; -q.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};q.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&G(this);return this};q.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this};q.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; -q.encode=function(a){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=D?a.normalize("NFKD").replace(D,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3"a1a".split(b).length; +this.numeric=u(a.numeric,f)}else{try{this.split=u(this.split,y)}catch(d){this.split=/\s+/}this.numeric=u(a.numeric,u(this.numeric,!0))}this.prepare=u(a.prepare,null,this.prepare);this.finalize=u(a.finalize,null,this.finalize);this.rtl=u(a.rtl,!1,this.rtl);this.dedupe=u(a.dedupe,!1,this.dedupe);this.filter=u((b=a.filter)&&new Set(b),null,this.filter);this.matcher=u((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=u((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=u((b=a.stemmer)&&new Map(b), +null,this.stemmer);this.replacer=u(a.replacer,null,this.replacer);this.minlength=u(a.minlength,1,this.minlength);this.maxlength=u(a.maxlength,0,this.maxlength);if(this.cache=b=u(a.cache,!0,this.cache))this.l=null,this.A="number"===typeof b?b:2E5,this.i=new Map,this.j=new Map,this.o=this.m=128;this.g="";this.s=null;this.h="";this.u=null;if(this.matcher)for(const d of this.matcher.keys())this.g+=(this.g?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.h+=(this.h?"|":"")+d;return this}; +r.addStemmer=function(a,c){this.stemmer||(this.stemmer=new Map);this.stemmer.set(a,c);this.h+=(this.h?"|":"")+a;this.u=null;this.cache&&G(this);return this};r.addFilter=function(a){this.filter||(this.filter=new Set);this.filter.add(a);this.cache&&G(this);return this};r.addMapper=function(a,c){if("object"===typeof a)return this.addReplacer(a,c);if(1a.length&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this};r.addReplacer=function(a,c){if("string"===typeof a)return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; +r.encode=function(a){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&("function"===typeof this.normalize?a=this.normalize(a):a=D?a.normalize("NFKD").replace(D,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(k)),e.lengththis.matcher.get(k)));if(e&&this.replacer)for(d=0;e&&dthis.A&& +if(e&&(this.mapper||this.dedupe&&1this.matcher.get(k)));if(e&&this.replacer)for(d=0;e&&dthis.A&& (this.j.clear(),this.o=this.o/1.1|0));e&&b.push(e)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.m&&(this.i.set(a,b),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return b};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,c,b){if(!a.length)return a;if(1===a.length)return a=a[0],a=b||a.length>c?c?a.slice(b,b+c):a.slice(b):a;let f=[];for(let d=0,g,e;d=e){b-=e;continue}bc&&(g=g.slice(0,c),e=c);if(!f.length&&e>=c)return g;f.push(g);c-=e;if(!c)break}return f=1this.limit&&this.cache.delete(this.cache.keys().next().value)};I.prototype.get=function(a){const c=this.cache.get(a);c&&this.g!==a&&(this.cache.delete(a),this.cache.set(this.g=a,c));return c};I.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}}; -I.prototype.clear=function(){this.cache.clear();this.g=""};const J={normalize:function(a){return a.toLowerCase()}};const K={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};L.prototype.add=function(a,c,b,f){if(c&&(a||0===a)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(f=c.length){const n=w(),m=w(),u=this.depth,C=this.resolution;for(let p=0;pg;h--){e=l.substring(g,h);var k=this.score?this.score(c,l,p,e,g):M(C,f,p,d,g);N(this,m,e,k,a,b)}break}case "reverse":if(1< -d){for(h=d-1;0e?0:1),f,p,h-1,k-1),t=this.bidirectional&&l>g;N(this,n,t?g:l,v,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function N(a,c,b,f,d,g,e){let h=e?a.ctx:a.map,k;if(!c[b]||e&&!(k=c[b])[e])e?(c=k||(c[b]=w()),c[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function M(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}m=e}else if(1===f){c=H.call(null,a[0],c,d);break a}c=m}return c}; +I.prototype.clear=function(){this.cache.clear();this.g=""};const J={normalize:function(a){return a.toLowerCase()}};const K={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};L.prototype.add=function(a,c,b,f){if(c&&(a||0===a)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(f=c.length){const n=w(),m=w(),v=this.depth,C=this.resolution;for(let p=0;pq;g--){e=l.substring(q,g);t=this.rtl?d-1-q:q;var h=this.score?this.score(c,l,p,e,t):M(C,f,p,d,t);N(this, +m,e,h,a,b)}break}case "reverse":if(1e?0:1),f,p,h-1,k-1),t=this.bidirectional&& +l>g;N(this,n,t?g:l,q,a,b,t?l:g)}}}}this.fastupdate||this.reg.add(a)}}return this};function N(a,c,b,f,d,g,e){let h=e?a.ctx:a.map,k;if(!c[b]||e&&!(k=c[b])[e])e?(c=k||(c[b]=w()),c[e]=1,(k=h.get(e))?h=k:h.set(e,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[f]||(h[f]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function M(a,c,b,f,d){return b&&1c||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}m=e}else if(1===f){c=H.call(null,a[0],c,d);break a}c=m}return c}; function O(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};L.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let f=0,d;fd.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else P(this.map,a),this.depth&&P(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; function P(a,c){let b=0;if(a.constructor===Array)for(let f=0,d,g;fb.add(a,c)):this.add(a,c)}; -function Q(a){let c=0;if(a.constructor===Array)for(let b=0,f;bb.add(a,c)):this.add(a,c)}; +function Q(a){let c=0;if(a.constructor===Array)for(let b=0,f;b} */ Document.prototype.contain = function (id) { - if (this.db) { return this.index.get(this.field[0]).db.has(id); } diff --git a/dist/module-debug/document/search.js b/dist/module-debug/document/search.js index fc8751c..f16d0ce 100644 --- a/dist/module-debug/document/search.js +++ b/dist/module-debug/document/search.js @@ -418,7 +418,7 @@ Document.prototype.search = function (query, limit, options, _promises) { for (let j = 0; j < promises.length; j++) { result[j].result = promises[j]; } - return merge ? merge_fields(result, limit, offset) : highlight ? highlight_fields(result, query, self.index, self.field, self.tree, highlight, limit, offset) : result; + return merge ? merge_fields(result, /** @type {number} */limit, offset) : highlight ? highlight_fields(result, query, self.index, self.field, self.tree, highlight, limit, offset) : result; }); } @@ -511,7 +511,14 @@ function highlight_fields(result, query, index, field, tree, template) { // be found at least by one field to get a valid match without // using suggestion explicitly +/** + * @param {DocumentSearchResults} fields + * @param {number=} limit + * @param {number=} offset + * @return {MergedDocumentSearchResults} + */ function merge_fields(fields, limit) { + /** @type {MergedDocumentSearchResults} */ const final = [], set = create_object(); @@ -520,6 +527,12 @@ function merge_fields(fields, limit) { res = field.result; for (let j = 0, id, entry, tmp; j < res.length; j++) { entry = res[j]; + // upgrade flat results + if ("object" != typeof entry) { + entry = { + id: entry + }; + } id = entry.id; tmp = set[id]; if (!tmp) { diff --git a/dist/module-debug/encoder.js b/dist/module-debug/encoder.js index 7978b83..5cc15e7 100644 --- a/dist/module-debug/encoder.js +++ b/dist/module-debug/encoder.js @@ -64,7 +64,7 @@ const whitespace = /[^\p{L}\p{N}]+/u, * @constructor */ -export default function Encoder() { +export default function Encoder(options = {}) { if (!this || this.constructor !== Encoder) { // let args = Array.prototype.slice.call(arguments); @@ -73,8 +73,12 @@ export default function Encoder() { return new Encoder(...arguments); } - for (let i = 0; i < arguments.length; i++) { - this.assign(arguments[i]); + if (arguments.length) { + for (let i = 0; i < arguments.length; i++) { + this.assign(arguments[i]); + } + } else { + this.assign(options); } } @@ -87,7 +91,9 @@ Encoder.prototype.assign = function (options) { * pre-processing string input * @type {Function|boolean} */ - this.normalize = /** @type {Function|boolean} */merge_option(options.normalize, /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */ /* skip deletion */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/, this.normalize); + this.normalize = /** @type {Function|boolean} */merge_option(options.normalize, /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */ /* skip deletion */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ + + /*await rows.hasNext()*/, this.normalize); // { // letter: true, @@ -410,8 +416,6 @@ Encoder.prototype.encode = function (str) { this.timer = setTimeout(clear, 50, this); } } - - // apply stemmer after matcher if (this.stemmer && 2 < word.length) { // for(const item of this.stemmer){ // const key = item[0]; diff --git a/dist/module-debug/index/add.js b/dist/module-debug/index/add.js index 387a1bd..211c72c 100644 --- a/dist/module-debug/index/add.js +++ b/dist/module-debug/index/add.js @@ -49,9 +49,10 @@ Index.prototype.add = function (id, content, _append, _skip_update) { term_length = term.length; + // todo check context search + // this check also wasn't applied on search, so it's useless here // skip dupes will break the context chain - - if (term_length /*&& (term_length >= this.minlength)*/ && (depth || !dupes[term])) { + if (term_length && (depth || !dupes[term])) { let score = this.score ? this.score(content, term, i, null, 0) : get_score(resolution, word_length, i), token = ""; @@ -60,14 +61,12 @@ Index.prototype.add = function (id, content, _append, _skip_update) { case "full": if (2 < term_length) { - for (let x = 0; x < term_length; x++) { + for (let x = 0, _x; x < term_length; x++) { for (let y = term_length; y > x; y--) { - - //if((y - x) >= this.minlength){ token = term.substring(x, y); - const partial_score = this.score ? this.score(content, term, i, token, x) : get_score(resolution, word_length, i, term_length, x); + _x = this.rtl ? term_length - 1 - x : x; + const partial_score = this.score ? this.score(content, term, i, token, _x) : get_score(resolution, word_length, i, term_length, _x); this.push_index(dupes, token, partial_score, id, _append); - //} } } break; @@ -77,11 +76,9 @@ Index.prototype.add = function (id, content, _append, _skip_update) { // skip last round (this token exist already in "forward") if (1 < term_length) { for (let x = term_length - 1; 0 < x; x--) { - token = term[x] + token; - //if(token.length >= this.minlength){ + token = term[this.rtl ? term_length - 1 - x : x] + token; const partial_score = this.score ? this.score(content, term, i, token, x) : get_score(resolution, word_length, i, term_length, x); this.push_index(dupes, token, partial_score, id, _append); - //} } token = ""; } @@ -90,25 +87,16 @@ Index.prototype.add = function (id, content, _append, _skip_update) { case "forward": if (1 < term_length) { for (let x = 0; x < term_length; x++) { - token += term[x]; - //if(token.length >= this.minlength){ + token += term[this.rtl ? term_length - 1 - x : x]; this.push_index(dupes, token, score, id, _append); - //} } break; } // fallthrough to next case when token has a length of 1 default: - // case "strict": - - // todo move boost to search - // if(this.boost){ - // score = Math.min((score / this.boost(content, term, i)) | 0, resolution - 1); - // } - + // "strict": this.push_index(dupes, term, score, id, _append); - // context is just supported by tokenizer "strict" if (depth) { @@ -118,7 +106,7 @@ Index.prototype.add = function (id, content, _append, _skip_update) { const dupes_inner = create_object(), resolution = this.resolution_ctx, keyword = term, - size = Math.min(depth + 1, word_length - i); + size = Math.min(depth + 1, this.rtl ? i + 1 : word_length - i); dupes_inner[keyword] = 1; @@ -127,11 +115,10 @@ Index.prototype.add = function (id, content, _append, _skip_update) { term = content[this.rtl ? word_length - 1 - i - x : i + x]; - if (term /*&& (term.length >= this.minlength)*/ && !dupes_inner[term]) { + if (term && !dupes_inner[term]) { dupes_inner[term] = 1; - - const context_score = this.score ? this.score(content, keyword, i, term, x) : get_score(resolution + (word_length / 2 > resolution ? 0 : 1), word_length, i, size - 1, x - 1), + const context_score = this.score ? this.score(content, keyword, i, term, x - 1) : get_score(resolution + (word_length / 2 > resolution ? 0 : 1), word_length, i, size - 1, x - 1), swap = this.bidirectional && term > keyword; this.push_index(dupes_ctx, swap ? keyword : term, context_score, id, _append, swap ? term : keyword); diff --git a/dist/module-debug/index/search.js b/dist/module-debug/index/search.js index c03a771..2fcd863 100644 --- a/dist/module-debug/index/search.js +++ b/dist/module-debug/index/search.js @@ -57,8 +57,7 @@ Index.prototype.search = function (query, limit, options) { offset = options.offset || 0; context = options.context; suggest = options.suggest; - resolve = /*global_resolve &&*/ /* suggest */ /* append: */ /* enrich */ - !1 !== options.resolve; + resolve = /*global_resolve &&*/ /* suggest */ /* append: */ /* enrich */!1 !== options.resolve; //resolve || (global_resolve = 0); enrich = resolve && options.enrich; boost = options.boost; @@ -251,6 +250,7 @@ Index.prototype.search = function (query, limit, options) { // fallback to non-contextual search when no result was found if (suggest && keyword && index == length - 1) { if (!result.length) { + resolution = self.resolution; keyword = ""; index = -1; dupes = create_object(); @@ -293,6 +293,7 @@ Index.prototype.search = function (query, limit, options) { // fallback to non-contextual search when no result was found if (suggest && keyword && index == length - 1) { if (!result.length) { + resolution = this.resolution; keyword = ""; index = -1; dupes = create_object(); diff --git a/dist/module-debug/preset.js b/dist/module-debug/preset.js index 550657e..18fd7d2 100644 --- a/dist/module-debug/preset.js +++ b/dist/module-debug/preset.js @@ -6,7 +6,6 @@ import { IndexOptions } from "./type.js"; * @type {Object} * @const */ - const presets = { memory: { @@ -14,12 +13,12 @@ const presets = { }, performance: { - resolution: 6, + resolution: 3, fastupdate: /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */ /* skip deletion */ // splice: !0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/, context: { depth: 1, - resolution: 3 + resolution: 1 } }, @@ -31,7 +30,7 @@ const presets = { resolution: 9, context: { depth: 2, - resolution: 9 + resolution: 3 } } }; diff --git a/dist/module-debug/type.js b/dist/module-debug/type.js index da6a70e..23342fd 100644 --- a/dist/module-debug/type.js +++ b/dist/module-debug/type.js @@ -213,7 +213,7 @@ export let EncoderSplitOptions = {}; * dedupe: (boolean|undefined), * include: (EncoderSplitOptions|undefined), * exclude: (EncoderSplitOptions|undefined), - * split: (string|boolean|undefined), + * split: (string|boolean|RegExp|undefined), * numeric: (boolean|undefined), * normalize: (boolean|(function(string):string)|undefined), * prepare: ((function(string):string)|undefined), diff --git a/dist/module-debug/worker.js b/dist/module-debug/worker.js index 332abbf..48abcdd 100644 --- a/dist/module-debug/worker.js +++ b/dist/module-debug/worker.js @@ -141,15 +141,19 @@ function register(key) { function create(factory, is_node_js, worker_path) { let worker = is_node_js ? + // if anyone would ask me what JS has delivered the past 10 years, + // those are the lines I definitively show up first ^^ + "undefined" != typeof module // This eval will be removed when compiling - "undefined" != typeof module ? (0, eval)('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")') - //: (0,eval)('new ((await import("worker_threads"))["Worker"])(import.meta.dirname + "/worker/node.mjs")') - //: (0,eval)('new ((await import("worker_threads"))["Worker"])((1,eval)(\"import.meta.dirname\") + "/node/node.mjs")') - : (0, eval)('import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)(\"import.meta.dirname\") + "/node/node.mjs"); })') - //: import("worker_threads").then(function(worker){ return new worker["Worker"](import.meta.dirname + "/worker/node.mjs"); }) - - //eval('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")') - : factory ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + handler.toString()], { type: "text/javascript" }))) : new window.Worker("string" == typeof worker_path ? worker_path : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js") /*"worker/worker.js"*/ + // The issue is that this will not build by Closure Compiler + ? (0,eval)('new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js")') + // this will need to remove in CommonJS builds, + // otherwise the module is treated as ESM by Node.js automatic detection + // the path src/worker/node.mjs is located at dist/node/node.mjs + // The issue is that this will not build by Babel Compiler + : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/../node/node.mjs")}) : factory ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + handler.toString()], { type: "text/javascript" }))) : new window.Worker("string" == typeof worker_path ? worker_path + // when loaded from /src/ folder the worker file is located at /worker/worker.js + : (1, eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js") /*"worker/worker.js"*/ , { type: "module" }); return worker; diff --git a/dist/module-debug/worker/handler.js b/dist/module-debug/worker/handler.js index 09af4fb..b019b56 100644 --- a/dist/module-debug/worker/handler.js +++ b/dist/module-debug/worker/handler.js @@ -26,7 +26,7 @@ export default (async function (data) { options = options; // will be replaced after build with the line below because // there is an issue with closure compiler dynamic import - options = (await import(filepath))["default"]; + options=(await import(filepath))["default"]; } const factory = data.factory; diff --git a/dist/module-min/bundle.js b/dist/module-min/bundle.js index 0b1671d..4b57439 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,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 +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:{}};{const a=self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}export default FlexSearch;export{Index,Document,Encoder,Charset,WorkerIndex as Worker,Resolver,IdxDB as IndexedDB}; \ No newline at end of file diff --git a/dist/module-min/charset/arabic/default.js b/dist/module-min/charset/arabic/default.js index c81f2ae..703f825 100644 --- a/dist/module-min/charset/arabic/default.js +++ b/dist/module-min/charset/arabic/default.js @@ -1 +1 @@ -import{EncoderOptions}from"../../type.js";const regex=/[\x00-\x7F]+/g,split=/\s+/,options={rtl:!0,normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(regex," ")}};export default options; \ No newline at end of file +import{EncoderOptions}from"../../type.js";const regex=/[\x00-\x7F]+/g,split=/\s+/,options={normalize:!1,dedupe:!0,prepare:function(a){return(""+a).replace(regex," ")}};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/latin/advanced.js b/dist/module-min/charset/latin/advanced.js index c4968e2..59a7fa6 100644 --- a/dist/module-min/charset/latin/advanced.js +++ b/dist/module-min/charset/latin/advanced.js @@ -1 +1 @@ -import{EncoderOptions}from"../../type.js";import{soundex}from"./balance.js";export const matcher=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]);export const replacer=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const options={normalize:!0,dedupe:!0,mapper:soundex,matcher:matcher,replacer:replacer};export default options; \ No newline at end of file +import{EncoderOptions}from"../../type.js";import{soundex}from"./balance.js";export const matcher=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]);export const replacer=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const options={normalize:!0,dedupe:!0,mapper:soundex,matcher:matcher,replacer:replacer};export default options; \ No newline at end of file diff --git a/dist/module-min/charset/latin/exact.js b/dist/module-min/charset/latin/exact.js index 9999f54..d842cb3 100644 --- a/dist/module-min/charset/latin/exact.js +++ b/dist/module-min/charset/latin/exact.js @@ -1 +1 @@ -import{EncoderOptions}from"../../type.js";const options={normalize:!1,dedupe:!1};export default options; \ No newline at end of file +import{EncoderOptions}from"../../type.js";const options={split:/\s+/,normalize:!1};export default options; \ No newline at end of file diff --git a/dist/module-min/document/search.js b/dist/module-min/document/search.js index ab27dab..e728b11 100644 --- a/dist/module-min/document/search.js +++ b/dist/module-min/document/search.js @@ -1 +1 @@ -import{DocumentSearchOptions,DocumentSearchResults,EnrichedDocumentSearchResults,MergedDocumentSearchResults,EnrichedSearchResults,SearchResults,IntermediateSearchResults}from"../type.js";import{create_object,is_array,is_object,is_string,parse_simple}from"../common.js";import{intersect_union}from"../intersect.js";import Document from"../document.js";import Index from"../index.js";import Resolver from"../resolver.js";import tick from"../profiler.js";Document.prototype.search=function(a,b,c,d){!1,c||(!b&&is_object(a)?(c=a,a=""):is_object(b)&&(c=b,b=0));let e,f,g,h,j,k,l,m,n=[],o=[],p=0,q=!0;if(c){if(is_array(c)&&(c={index:c}),a=c.query||a,e=c.pluck,g=c.merge,j=e||c.field||(j=c.index)&&(j.index?null:j),k=this.tag&&c.tag,h=c.suggest,q=!1!==c.resolve,(q||e||(j=j||this.field,j&&(is_string(j)?e=j:(is_array(j)&&1===j.length&&(j=j[0]),e=j.field||j.index))),!1,f=this.store&&c.enrich&&q,m=c.highlight&&f,b=c.limit||b,l=c.offset||0,b||(b=100),k&&(!this.db||!d))){!1,k.constructor!==Array&&(k=[k]);let c=[];for(let a,b=0;b"a1a".split(d).length;this.numeric=merge_option(a.numeric,b)}else{try{this.split=merge_option(this.split,whitespace)}catch(a){!1,this.split=/\s+/}this.numeric=merge_option(a.numeric,merge_option(this.numeric,!0))}if(this.prepare=merge_option(a.prepare,null,this.prepare),this.finalize=merge_option(a.finalize,null,this.finalize),!normalize&&(this.mapper=new Map(normalize_polyfill)),this.rtl=merge_option(a.rtl,!1,this.rtl),this.dedupe=merge_option(a.dedupe,!1,this.dedupe),this.filter=merge_option((d=a.filter)&&new Set(d),null,this.filter),this.matcher=merge_option((d=a.matcher)&&new Map(d),null,this.matcher),this.mapper=merge_option((d=a.mapper)&&new Map(d),null,this.mapper),this.stemmer=merge_option((d=a.stemmer)&&new Map(d),null,this.stemmer),this.replacer=merge_option(a.replacer,null,this.replacer),this.minlength=merge_option(a.minlength,1,this.minlength),this.maxlength=merge_option(a.maxlength,0,this.maxlength),this.cache=d=merge_option(a.cache,!0,this.cache),d&&(this.timer=null,this.cache_size="number"==typeof d?d:2e5,this.cache_enc=new Map,this.cache_term=new Map,this.cache_enc_length=128,this.cache_term_length=128),this.matcher_str="",this.matcher_test=null,this.stemmer_str="",this.stemmer_test=null,this.matcher)for(const a of this.matcher.keys())this.matcher_str+=(this.matcher_str?"|":"")+a;if(this.stemmer)for(const a of this.stemmer.keys())this.stemmer_str+=(this.stemmer_str?"|":"")+a;return this},Encoder.prototype.addStemmer=function(a,b){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(a,b),this.stemmer_str+=(this.stemmer_str?"|":"")+a,this.stemmer_test=null,this.cache&&clear(this),this},Encoder.prototype.addFilter=function(a){return this.filter||(this.filter=new Set),this.filter.add(a),this.cache&&clear(this),this},Encoder.prototype.addMapper=function(a,b){return"object"==typeof a?this.addReplacer(a,b):1a.length&&(this.dedupe||this.mapper)?this.addMapper(a,b):(this.matcher||(this.matcher=new Map),this.matcher.set(a,b),this.matcher_str+=(this.matcher_str?"|":"")+a,this.matcher_test=null,this.cache&&clear(this),this)},Encoder.prototype.addReplacer=function(a,b){return"string"==typeof a?this.addMatcher(a,b):(this.replacer||(this.replacer=[]),this.replacer.push(a,b),this.cache&&clear(this),this)},Encoder.prototype.encode=function(a){if(this.cache&&a.length<=this.cache_enc_length)if(!this.timer)this.timer=setTimeout(clear,50,this);else if(this.cache_enc.has(a))return this.cache_enc.get(a);this.normalize&&("function"==typeof this.normalize?a=this.normalize(a):normalize?a=a.normalize("NFKD").replace(normalize,"").toLowerCase():a=a.toLowerCase()),this.prepare&&(a=this.prepare(a)),this.numeric&&3this.stemmer.get(a)),(e.lengththis.matcher.get(a))),e&&this.replacer)for(let a=0;e&&athis.cache_size&&(this.cache_term.clear(),this.cache_term_length=0|this.cache_term_length/1.1)),e&&c.push(e)}}return this.finalize&&(c=this.finalize(c)||c),this.cache&&a.length<=this.cache_enc_length&&(this.cache_enc.set(a,c),this.cache_enc.size>this.cache_size&&(this.cache_enc.clear(),this.cache_enc_length=0|this.cache_enc_length/1.1)),c};function clear(a){a.timer=null,a.cache_enc.clear(),a.cache_term.clear()} \ No newline at end of file +import{merge_option}from"./common.js";import normalize_polyfill from"./charset/normalize.js";import{EncoderOptions}from"./type.js";const whitespace=/[^\p{L}\p{N}]+/u,numeric_split_length=/(\d{3})/g,numeric_split_prev_char=/(\D)(\d{3})/g,numeric_split_next_char=/(\d{3})(\D)/g,normalize=/[\u0300-\u036f]/g;export default function Encoder(a={}){if(!this||this.constructor!==Encoder)return new Encoder(...arguments);if(arguments.length)for(let a=0;a"a1a".split(d).length;this.numeric=merge_option(a.numeric,b)}else{try{this.split=merge_option(this.split,whitespace)}catch(a){!1,this.split=/\s+/}this.numeric=merge_option(a.numeric,merge_option(this.numeric,!0))}if(this.prepare=merge_option(a.prepare,null,this.prepare),this.finalize=merge_option(a.finalize,null,this.finalize),!normalize&&(this.mapper=new Map(normalize_polyfill)),this.rtl=merge_option(a.rtl,!1,this.rtl),this.dedupe=merge_option(a.dedupe,!1,this.dedupe),this.filter=merge_option((d=a.filter)&&new Set(d),null,this.filter),this.matcher=merge_option((d=a.matcher)&&new Map(d),null,this.matcher),this.mapper=merge_option((d=a.mapper)&&new Map(d),null,this.mapper),this.stemmer=merge_option((d=a.stemmer)&&new Map(d),null,this.stemmer),this.replacer=merge_option(a.replacer,null,this.replacer),this.minlength=merge_option(a.minlength,1,this.minlength),this.maxlength=merge_option(a.maxlength,0,this.maxlength),this.cache=d=merge_option(a.cache,!0,this.cache),d&&(this.timer=null,this.cache_size="number"==typeof d?d:2e5,this.cache_enc=new Map,this.cache_term=new Map,this.cache_enc_length=128,this.cache_term_length=128),this.matcher_str="",this.matcher_test=null,this.stemmer_str="",this.stemmer_test=null,this.matcher)for(const a of this.matcher.keys())this.matcher_str+=(this.matcher_str?"|":"")+a;if(this.stemmer)for(const a of this.stemmer.keys())this.stemmer_str+=(this.stemmer_str?"|":"")+a;return this},Encoder.prototype.addStemmer=function(a,b){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(a,b),this.stemmer_str+=(this.stemmer_str?"|":"")+a,this.stemmer_test=null,this.cache&&clear(this),this},Encoder.prototype.addFilter=function(a){return this.filter||(this.filter=new Set),this.filter.add(a),this.cache&&clear(this),this},Encoder.prototype.addMapper=function(a,b){return"object"==typeof a?this.addReplacer(a,b):1a.length&&(this.dedupe||this.mapper)?this.addMapper(a,b):(this.matcher||(this.matcher=new Map),this.matcher.set(a,b),this.matcher_str+=(this.matcher_str?"|":"")+a,this.matcher_test=null,this.cache&&clear(this),this)},Encoder.prototype.addReplacer=function(a,b){return"string"==typeof a?this.addMatcher(a,b):(this.replacer||(this.replacer=[]),this.replacer.push(a,b),this.cache&&clear(this),this)},Encoder.prototype.encode=function(a){if(this.cache&&a.length<=this.cache_enc_length)if(!this.timer)this.timer=setTimeout(clear,50,this);else if(this.cache_enc.has(a))return this.cache_enc.get(a);this.normalize&&("function"==typeof this.normalize?a=this.normalize(a):normalize?a=a.normalize("NFKD").replace(normalize,"").toLowerCase():a=a.toLowerCase()),this.prepare&&(a=this.prepare(a)),this.numeric&&3this.stemmer.get(a)),(e.lengththis.matcher.get(a))),e&&this.replacer)for(let a=0;e&&athis.cache_size&&(this.cache_term.clear(),this.cache_term_length=0|this.cache_term_length/1.1)),e&&c.push(e)}}return this.finalize&&(c=this.finalize(c)||c),this.cache&&a.length<=this.cache_enc_length&&(this.cache_enc.set(a,c),this.cache_enc.size>this.cache_size&&(this.cache_enc.clear(),this.cache_enc_length=0|this.cache_enc_length/1.1)),c};function clear(a){a.timer=null,a.cache_enc.clear(),a.cache_term.clear()} \ No newline at end of file diff --git a/dist/module-min/index/add.js b/dist/module-min/index/add.js index 61e4087..929a81a 100644 --- a/dist/module-min/index/add.js +++ b/dist/module-min/index/add.js @@ -1 +1 @@ -import{create_object}from"../common.js";import Index,{autoCommit}from"../index.js";import default_compress from"../compress.js";import{KeystoreArray}from"../keystore.js";Index.prototype.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.reg.has(a))return this.update(a,b);b=this.encoder.encode(b);const e=b.length;if(e){const d=create_object(),f=create_object(),g=this.depth,h=this.resolution;for(let j=0;jd;g--){m=i.substring(d,g);const l=this.score?this.score(b,i,j,m,d):get_score(h,e,j,k,d);this.push_index(f,m,l,a,c)}break}case"reverse":if(1h?0:1),e,j,l-1,g-1),n=this.bidirectional&&i>k;this.push_index(d,n?k:i,m,a,c,n?i:k)}}}}}this.fastupdate||this.reg.add(a)}else b=""}return this.db&&(b||this.commit_task.push({del:a}),this.commit_auto&&autoCommit(this)),this},Index.prototype.push_index=function(a,b,c,d,e,f){let g,h=f?this.ctx:this.map;if((!a[b]||f&&!(g=a[b])[f])&&(f?(a=g||(a[b]=create_object()),a[f]=1,this.compress&&(f=default_compress(f)),g=h.get(f),g?h=g:h.set(f,h=new Map)):a[b]=1,this.compress&&(b=default_compress(b)),g=h.get(b),g?h=g:h.set(b,h=g=[]),h=h[c]||(h[c]=[]),!e||!h.includes(d))){if(2147483647===h.length){const a=new KeystoreArray(h);if(this.fastupdate)for(let b of this.reg.values())b.includes(h)&&(b[b.indexOf(h)]=a);g[c]=h=a}if(h.push(d),this.fastupdate){const a=this.reg.get(d);a?a.push(h):this.reg.set(d,[h])}}};function get_score(a,b,c,d,e){return c&&1g;l--){m=i.substring(g,l),d=this.rtl?k-1-g:g;const n=this.score?this.score(b,i,j,m,d):get_score(h,e,j,k,d);this.push_index(f,m,n,a,c)}break}case"reverse":if(1h?0:1),e,j,l-1,g-1),n=this.bidirectional&&i>k;this.push_index(d,n?k:i,m,a,c,n?i:k)}}}}}this.fastupdate||this.reg.add(a)}else b=""}return this.db&&(b||this.commit_task.push({del:a}),this.commit_auto&&autoCommit(this)),this},Index.prototype.push_index=function(a,b,c,d,e,f){let g,h=f?this.ctx:this.map;if((!a[b]||f&&!(g=a[b])[f])&&(f?(a=g||(a[b]=create_object()),a[f]=1,this.compress&&(f=default_compress(f)),g=h.get(f),g?h=g:h.set(f,h=new Map)):a[b]=1,this.compress&&(b=default_compress(b)),g=h.get(b),g?h=g:h.set(b,h=g=[]),h=h[c]||(h[c]=[]),!e||!h.includes(d))){if(2147483647===h.length){const a=new KeystoreArray(h);if(this.fastupdate)for(let b of this.reg.values())b.includes(h)&&(b[b.indexOf(h)]=a);g[c]=h=a}if(h.push(d),this.fastupdate){const a=this.reg.get(d);a?a.push(h):this.reg.set(d,[h])}}};function get_score(a,b,c,d,e){return c&&1b,i&&(i=b,b=a,a=i)),this.compress&&(a=default_compress(a),b&&(b=default_compress(b))),this.db)?this.db.get(a,b,c,d,e,f,g):(b?(h=this.ctx.get(b),h=h&&h.get(a)):h=this.map.get(a),h)}; \ No newline at end of file +import{SearchOptions,SearchResults,EnrichedSearchResults,IntermediateSearchResults}from"../type.js";import{create_object,is_object,sort_by_length_down}from"../common.js";import Index from"../index.js";import default_compress from"../compress.js";import Resolver from"../resolver.js";import{intersect}from"../intersect.js";import resolve_default from"../resolve/default.js";Index.prototype.search=function(a,b,c){c||(!b&&is_object(a)?(c=a,a=""):is_object(b)&&(c=b,b=0));let d,e,f,g,h,i,j,k,l=[],m=0;c?(a=c.query||a,b=c.limit||b,m=c.offset||0,e=c.context,f=c.suggest,g=!1!==c.resolve,k=g&&c.enrich,i=c.boost,j=c.resolution,h=this.db&&c.tag):g=this.resolve;let n=this.encoder.encode(a);if(d=n.length,b=b||(g?100:0),1===d)return single_term_query.call(this,n[0],"",b,m,g,k,h);if(e=this.depth&&!1!==e,2===d&&e&&!f)return single_term_query.call(this,n[0],n[1],b,m,g,k,h);let o,p=create_object(),q=0;if(1b,i&&(i=b,b=a,a=i)),this.compress&&(a=default_compress(a),b&&(b=default_compress(b))),this.db)?this.db.get(a,b,c,d,e,f,g):(b?(h=this.ctx.get(b),h=h&&h.get(a)):h=this.map.get(a),h)}; \ No newline at end of file diff --git a/dist/module-min/preset.js b/dist/module-min/preset.js index f39c3ee..a2e2adc 100644 --- a/dist/module-min/preset.js +++ b/dist/module-min/preset.js @@ -1 +1 @@ -import{is_string}from"./common.js";import{IndexOptions}from"./type.js";const presets={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};export default function apply_preset(a){const b=is_string(a)?a:a.preset;return b&&(!1,a=Object.assign({},presets[b],a)),a} \ No newline at end of file +import{is_string}from"./common.js";import{IndexOptions}from"./type.js";const presets={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};export default function apply_preset(a){const b=is_string(a)?a:a.preset;return b&&(!1,a=Object.assign({},presets[b],a)),a} \ No newline at end of file diff --git a/dist/module-min/worker.js b/dist/module-min/worker.js index e36f9a9..d2b8d1e 100644 --- a/dist/module-min/worker.js +++ b/dist/module-min/worker.js @@ -1 +1 @@ -import{IndexOptions}from"./type.js";import{create_object}from"./common.js";import handler from"./worker/handler.js";import apply_async from"./async.js";let pid=0;export default function WorkerIndex(a={}){function b(b){function f(a){a=a.data||a;const b=a.id,c=b&&e.resolver[b];c&&(c(a.msg),delete e.resolver[b])}if(this.worker=b,this.resolver=create_object(),!!this.worker)return(d?this.worker.on("message",f):this.worker.onmessage=f,a.config)?new Promise(function(b){e.resolver[++pid]=function(){b(e),1e9} */ Document.prototype.contain = function (id) { - if (this.db) { return this.index.get(this.field[0]).db.has(id); } diff --git a/dist/module/document/search.js b/dist/module/document/search.js index 928ed60..6918b33 100644 --- a/dist/module/document/search.js +++ b/dist/module/document/search.js @@ -398,7 +398,7 @@ Document.prototype.search = function (query, limit, options, _promises) { for (let j = 0; j < promises.length; j++) { result[j].result = promises[j]; } - return merge ? merge_fields(result, limit, offset) : highlight ? highlight_fields(result, query, self.index, self.field, self.tree, highlight, limit, offset) : result; + return merge ? merge_fields(result, /** @type {number} */limit, offset) : highlight ? highlight_fields(result, query, self.index, self.field, self.tree, highlight, limit, offset) : result; }); } @@ -491,7 +491,14 @@ function highlight_fields(result, query, index, field, tree, template) { // be found at least by one field to get a valid match without // using suggestion explicitly +/** + * @param {DocumentSearchResults} fields + * @param {number=} limit + * @param {number=} offset + * @return {MergedDocumentSearchResults} + */ function merge_fields(fields, limit) { + /** @type {MergedDocumentSearchResults} */ const final = [], set = create_object(); @@ -500,6 +507,12 @@ function merge_fields(fields, limit) { res = field.result; for (let j = 0, id, entry, tmp; j < res.length; j++) { entry = res[j]; + // upgrade flat results + if ("object" != typeof entry) { + entry = { + id: entry + }; + } id = entry.id; tmp = set[id]; if (!tmp) { diff --git a/dist/module/encoder.js b/dist/module/encoder.js index 3a730c6..a2fe6a3 100644 --- a/dist/module/encoder.js +++ b/dist/module/encoder.js @@ -64,7 +64,7 @@ const whitespace = /[^\p{L}\p{N}]+/u, * @constructor */ -export default function Encoder() { +export default function Encoder(options = {}) { if (!this || this.constructor !== Encoder) { // let args = Array.prototype.slice.call(arguments); @@ -73,8 +73,12 @@ export default function Encoder() { return new Encoder(...arguments); } - for (let i = 0; i < arguments.length; i++) { - this.assign(arguments[i]); + if (arguments.length) { + for (let i = 0; i < arguments.length; i++) { + this.assign(arguments[i]); + } + } else { + this.assign(options); } } @@ -87,7 +91,9 @@ Encoder.prototype.assign = function (options) { * pre-processing string input * @type {Function|boolean} */ - this.normalize = /** @type {Function|boolean} */merge_option(options.normalize, /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */ /* skip deletion */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/, this.normalize); + this.normalize = /** @type {Function|boolean} */merge_option(options.normalize, /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */ /* skip deletion */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ + + /*await rows.hasNext()*/, this.normalize); // { // letter: true, @@ -408,8 +414,6 @@ Encoder.prototype.encode = function (str) { this.timer = setTimeout(clear, 50, this); } } - - // apply stemmer after matcher if (this.stemmer && 2 < word.length) { // for(const item of this.stemmer){ // const key = item[0]; diff --git a/dist/module/index/add.js b/dist/module/index/add.js index 387a1bd..211c72c 100644 --- a/dist/module/index/add.js +++ b/dist/module/index/add.js @@ -49,9 +49,10 @@ Index.prototype.add = function (id, content, _append, _skip_update) { term_length = term.length; + // todo check context search + // this check also wasn't applied on search, so it's useless here // skip dupes will break the context chain - - if (term_length /*&& (term_length >= this.minlength)*/ && (depth || !dupes[term])) { + if (term_length && (depth || !dupes[term])) { let score = this.score ? this.score(content, term, i, null, 0) : get_score(resolution, word_length, i), token = ""; @@ -60,14 +61,12 @@ Index.prototype.add = function (id, content, _append, _skip_update) { case "full": if (2 < term_length) { - for (let x = 0; x < term_length; x++) { + for (let x = 0, _x; x < term_length; x++) { for (let y = term_length; y > x; y--) { - - //if((y - x) >= this.minlength){ token = term.substring(x, y); - const partial_score = this.score ? this.score(content, term, i, token, x) : get_score(resolution, word_length, i, term_length, x); + _x = this.rtl ? term_length - 1 - x : x; + const partial_score = this.score ? this.score(content, term, i, token, _x) : get_score(resolution, word_length, i, term_length, _x); this.push_index(dupes, token, partial_score, id, _append); - //} } } break; @@ -77,11 +76,9 @@ Index.prototype.add = function (id, content, _append, _skip_update) { // skip last round (this token exist already in "forward") if (1 < term_length) { for (let x = term_length - 1; 0 < x; x--) { - token = term[x] + token; - //if(token.length >= this.minlength){ + token = term[this.rtl ? term_length - 1 - x : x] + token; const partial_score = this.score ? this.score(content, term, i, token, x) : get_score(resolution, word_length, i, term_length, x); this.push_index(dupes, token, partial_score, id, _append); - //} } token = ""; } @@ -90,25 +87,16 @@ Index.prototype.add = function (id, content, _append, _skip_update) { case "forward": if (1 < term_length) { for (let x = 0; x < term_length; x++) { - token += term[x]; - //if(token.length >= this.minlength){ + token += term[this.rtl ? term_length - 1 - x : x]; this.push_index(dupes, token, score, id, _append); - //} } break; } // fallthrough to next case when token has a length of 1 default: - // case "strict": - - // todo move boost to search - // if(this.boost){ - // score = Math.min((score / this.boost(content, term, i)) | 0, resolution - 1); - // } - + // "strict": this.push_index(dupes, term, score, id, _append); - // context is just supported by tokenizer "strict" if (depth) { @@ -118,7 +106,7 @@ Index.prototype.add = function (id, content, _append, _skip_update) { const dupes_inner = create_object(), resolution = this.resolution_ctx, keyword = term, - size = Math.min(depth + 1, word_length - i); + size = Math.min(depth + 1, this.rtl ? i + 1 : word_length - i); dupes_inner[keyword] = 1; @@ -127,11 +115,10 @@ Index.prototype.add = function (id, content, _append, _skip_update) { term = content[this.rtl ? word_length - 1 - i - x : i + x]; - if (term /*&& (term.length >= this.minlength)*/ && !dupes_inner[term]) { + if (term && !dupes_inner[term]) { dupes_inner[term] = 1; - - const context_score = this.score ? this.score(content, keyword, i, term, x) : get_score(resolution + (word_length / 2 > resolution ? 0 : 1), word_length, i, size - 1, x - 1), + const context_score = this.score ? this.score(content, keyword, i, term, x - 1) : get_score(resolution + (word_length / 2 > resolution ? 0 : 1), word_length, i, size - 1, x - 1), swap = this.bidirectional && term > keyword; this.push_index(dupes_ctx, swap ? keyword : term, context_score, id, _append, swap ? term : keyword); diff --git a/dist/module/index/search.js b/dist/module/index/search.js index c03a771..2fcd863 100644 --- a/dist/module/index/search.js +++ b/dist/module/index/search.js @@ -57,8 +57,7 @@ Index.prototype.search = function (query, limit, options) { offset = options.offset || 0; context = options.context; suggest = options.suggest; - resolve = /*global_resolve &&*/ /* suggest */ /* append: */ /* enrich */ - !1 !== options.resolve; + resolve = /*global_resolve &&*/ /* suggest */ /* append: */ /* enrich */!1 !== options.resolve; //resolve || (global_resolve = 0); enrich = resolve && options.enrich; boost = options.boost; @@ -251,6 +250,7 @@ Index.prototype.search = function (query, limit, options) { // fallback to non-contextual search when no result was found if (suggest && keyword && index == length - 1) { if (!result.length) { + resolution = self.resolution; keyword = ""; index = -1; dupes = create_object(); @@ -293,6 +293,7 @@ Index.prototype.search = function (query, limit, options) { // fallback to non-contextual search when no result was found if (suggest && keyword && index == length - 1) { if (!result.length) { + resolution = this.resolution; keyword = ""; index = -1; dupes = create_object(); diff --git a/dist/module/preset.js b/dist/module/preset.js index ebb4208..4fbf451 100644 --- a/dist/module/preset.js +++ b/dist/module/preset.js @@ -6,7 +6,6 @@ import { IndexOptions } from "./type.js"; * @type {Object} * @const */ - const presets = { memory: { @@ -14,12 +13,12 @@ const presets = { }, performance: { - resolution: 6, + resolution: 3, fastupdate: /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */ /* skip deletion */ // splice: !0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/, context: { depth: 1, - resolution: 3 + resolution: 1 } }, @@ -31,7 +30,7 @@ const presets = { resolution: 9, context: { depth: 2, - resolution: 9 + resolution: 3 } } }; diff --git a/dist/module/type.js b/dist/module/type.js index da6a70e..23342fd 100644 --- a/dist/module/type.js +++ b/dist/module/type.js @@ -213,7 +213,7 @@ export let EncoderSplitOptions = {}; * dedupe: (boolean|undefined), * include: (EncoderSplitOptions|undefined), * exclude: (EncoderSplitOptions|undefined), - * split: (string|boolean|undefined), + * split: (string|boolean|RegExp|undefined), * numeric: (boolean|undefined), * normalize: (boolean|(function(string):string)|undefined), * prepare: ((function(string):string)|undefined), diff --git a/dist/module/worker.js b/dist/module/worker.js index 332abbf..48abcdd 100644 --- a/dist/module/worker.js +++ b/dist/module/worker.js @@ -141,15 +141,19 @@ function register(key) { function create(factory, is_node_js, worker_path) { let worker = is_node_js ? + // if anyone would ask me what JS has delivered the past 10 years, + // those are the lines I definitively show up first ^^ + "undefined" != typeof module // This eval will be removed when compiling - "undefined" != typeof module ? (0, eval)('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")') - //: (0,eval)('new ((await import("worker_threads"))["Worker"])(import.meta.dirname + "/worker/node.mjs")') - //: (0,eval)('new ((await import("worker_threads"))["Worker"])((1,eval)(\"import.meta.dirname\") + "/node/node.mjs")') - : (0, eval)('import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)(\"import.meta.dirname\") + "/node/node.mjs"); })') - //: import("worker_threads").then(function(worker){ return new worker["Worker"](import.meta.dirname + "/worker/node.mjs"); }) - - //eval('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")') - : factory ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + handler.toString()], { type: "text/javascript" }))) : new window.Worker("string" == typeof worker_path ? worker_path : import.meta.url.replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js") /*"worker/worker.js"*/ + // The issue is that this will not build by Closure Compiler + ? (0,eval)('new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js")') + // this will need to remove in CommonJS builds, + // otherwise the module is treated as ESM by Node.js automatic detection + // the path src/worker/node.mjs is located at dist/node/node.mjs + // The issue is that this will not build by Babel Compiler + : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/../node/node.mjs")}) : factory ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + handler.toString()], { type: "text/javascript" }))) : new window.Worker("string" == typeof worker_path ? worker_path + // when loaded from /src/ folder the worker file is located at /worker/worker.js + : (1, eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js", "module/worker/worker.js") /*"worker/worker.js"*/ , { type: "module" }); return worker; diff --git a/dist/module/worker/handler.js b/dist/module/worker/handler.js index 2957005..a911533 100644 --- a/dist/module/worker/handler.js +++ b/dist/module/worker/handler.js @@ -26,7 +26,7 @@ export default (async function (data) { options = options; // will be replaced after build with the line below because // there is an issue with closure compiler dynamic import - options = (await import(filepath))["default"]; + options=(await import(filepath))["default"]; } const factory = data.factory; diff --git a/doc/async.md b/doc/async.md index ea07443..9c0bf81 100644 --- a/doc/async.md +++ b/doc/async.md @@ -22,11 +22,11 @@ const index = new Index({ }); ``` -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). +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 ~45ms). 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. +A priority value of `9` will cycle the event loop on every ~250ms 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: diff --git a/index.d.ts b/index.d.ts index f2b513e..87fca40 100644 --- a/index.d.ts +++ b/index.d.ts @@ -117,6 +117,7 @@ declare module "flexsearch" { exclude?: EncoderSplitOptions; split?: string|RegExp|""|false; numeric?: boolean; + normalize?: boolean|((str: string) => string); prepare?: (str: string) => string; finalize?: (terms: string[]) => string[]; filter?: Set; diff --git a/package-lock.json b/package-lock.json index d161da6..ad91fb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "flexsearch", - "version": "0.8.117", + "version": "0.8.123", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "flexsearch", - "version": "0.8.117", + "version": "0.8.123", "funding": [ { "type": "github", @@ -52,10 +52,162 @@ "babel-plugin-transform-property-literals": "^6.9.4", "babel-plugin-transform-simplify-comparison-operators": "^6.9.4", "babel-plugin-transform-undefined-to-void": "^6.9.4", + "c8": "^10.1.3", + "chai": "^5.2.0", "google-closure-compiler": "^20240317.0.0", + "mocha": "^11.1.0", "rollup": "^4.35.0" } }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.35.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.35.0.tgz", @@ -309,6 +461,21 @@ "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", "dev": true }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true + }, + "node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -433,6 +600,12 @@ "node": ">=0.10.0" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "node_modules/arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", @@ -473,6 +646,15 @@ "node": ">=0.10.0" } }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", @@ -1089,6 +1271,45 @@ "node": ">=0.10.0" } }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "node_modules/c8": { + "version": "10.1.3", + "resolved": "https://registry.npmjs.org/c8/-/c8-10.1.3.tgz", + "integrity": "sha512-LvcyrOAaOnrrlMpW22n690PUvxiq4Uf9WMhQwNJ9vgagkL/ph1+D4uvjvDA5XCbykrc0sx+ay6pVi9YZ1GnhyA==", + "dev": true, + "dependencies": { + "@bcoe/v8-coverage": "^1.0.1", + "@istanbuljs/schema": "^0.1.3", + "find-up": "^5.0.0", + "foreground-child": "^3.1.1", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.1.6", + "test-exclude": "^7.0.1", + "v8-to-istanbul": "^9.0.0", + "yargs": "^17.7.2", + "yargs-parser": "^21.1.1" + }, + "bin": { + "c8": "bin/c8.js" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "monocart-coverage-reports": "^2" + }, + "peerDependenciesMeta": { + "monocart-coverage-reports": { + "optional": true + } + } + }, "node_modules/cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -1110,6 +1331,34 @@ "node": ">=0.10.0" } }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.0.tgz", + "integrity": "sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw==", + "dev": true, + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -1126,6 +1375,15 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true, + "engines": { + "node": ">= 16" + } + }, "node_modules/chokidar": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", @@ -1227,6 +1485,41 @@ "node": ">=0.10.0" } }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/clone": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", @@ -1340,6 +1633,49 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "dev": true, + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", @@ -1350,6 +1686,15 @@ "node": ">=0.10" } }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", @@ -1376,6 +1721,36 @@ "node": ">=0.10.0" } }, + "node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -1623,6 +1998,31 @@ "node": ">=0.10.0" } }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "bin": { + "flat": "cli.js" + } + }, "node_modules/for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -1646,6 +2046,22 @@ "node": ">=0.10.0" } }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -1690,6 +2106,15 @@ "node": ">= 4.0" } }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, "node_modules/get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -1887,6 +2312,15 @@ "node": ">=0.10.0" } }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, "node_modules/home-or-tmp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", @@ -1900,6 +2334,12 @@ "node": ">=0.10.0" } }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -2071,6 +2511,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-glob": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", @@ -2097,6 +2546,15 @@ "node": ">=0.10.0" } }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -2130,6 +2588,18 @@ "node": ">=0.10.0" } }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -2146,6 +2616,12 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, "node_modules/isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", @@ -2156,12 +2632,75 @@ "node": ">=0.10.0" } }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -2175,12 +2714,43 @@ "node": ">=0.10.0" } }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -2193,6 +2763,33 @@ "loose-envify": "cli.js" } }, + "node_modules/loupe": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz", + "integrity": "sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==", + "dev": true + }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -2303,6 +2900,15 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -2342,6 +2948,304 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/mocha": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.1.0.tgz", + "integrity": "sha512-8uJR5RTC2NgpY3GrYcgpZrsEd9zKbPDpob1RezyR2upGHRQtHWofmzTMzTMSV6dru3tj5Ukt0+Vnq1qhFEEwAg==", + "dev": true, + "dependencies": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^10.4.5", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^17.7.2", + "yargs-parser": "^21.1.1", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/mocha/node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/mocha/node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mocha/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/mocha/node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mocha/node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/mocha/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mocha/node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mocha/node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/mocha/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/mocha/node_modules/glob/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mocha/node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/mocha/node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/mocha/node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/mocha/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/mocha/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/mocha/node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, "node_modules/nan": { "version": "2.14.2", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", @@ -2588,6 +3492,42 @@ "object-assign": "^4.1.0" } }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true + }, "node_modules/parse-glob": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", @@ -2614,12 +3554,67 @@ "node": ">=0.10.0" } }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "dev": true, + "engines": { + "node": ">= 14.16" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -2690,6 +3685,15 @@ "node": ">=0.10.0" } }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, "node_modules/readable-stream": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", @@ -2827,6 +3831,15 @@ "node": ">= 0.10" } }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -2913,6 +3926,27 @@ "ret": "~0.1.10" } }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, "node_modules/set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", @@ -2929,6 +3963,39 @@ "node": ">=0.10.0" } }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -3234,6 +4301,77 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -3246,6 +4384,40 @@ "node": ">=0.10.0" } }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -3258,6 +4430,64 @@ "node": ">=8" } }, + "node_modules/test-exclude": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", + "integrity": "sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^10.4.1", + "minimatch": "^9.0.4" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/test-exclude/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/test-exclude/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", @@ -3441,6 +4671,26 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "node_modules/v8-to-istanbul": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", + "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + }, "node_modules/v8flags": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", @@ -3479,14 +4729,281 @@ "source-map": "^0.5.1" } }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } }, "dependencies": { + "@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true + }, + "@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "requires": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true + }, + "ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true + }, + "emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "requires": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + } + }, + "strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "requires": { + "ansi-regex": "^6.0.1" + } + }, + "wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "requires": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + } + } + } + }, + "@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true + }, + "@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true + }, + "@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "optional": true + }, "@rollup/rollup-android-arm-eabi": { "version": "4.35.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.35.0.tgz", @@ -3626,6 +5143,18 @@ "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", "dev": true }, + "@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true + }, + "ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -3725,6 +5254,12 @@ } } }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", @@ -3753,6 +5288,12 @@ "dev": true, "optional": true }, + "assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true + }, "assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", @@ -4326,6 +5867,31 @@ "to-regex": "^3.0.1" } }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "c8": { + "version": "10.1.3", + "resolved": "https://registry.npmjs.org/c8/-/c8-10.1.3.tgz", + "integrity": "sha512-LvcyrOAaOnrrlMpW22n690PUvxiq4Uf9WMhQwNJ9vgagkL/ph1+D4uvjvDA5XCbykrc0sx+ay6pVi9YZ1GnhyA==", + "dev": true, + "requires": { + "@bcoe/v8-coverage": "^1.0.1", + "@istanbuljs/schema": "^0.1.3", + "find-up": "^5.0.0", + "foreground-child": "^3.1.1", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.1.6", + "test-exclude": "^7.0.1", + "v8-to-istanbul": "^9.0.0", + "yargs": "^17.7.2", + "yargs-parser": "^21.1.1" + } + }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -4344,6 +5910,25 @@ "unset-value": "^1.0.0" } }, + "camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true + }, + "chai": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.0.tgz", + "integrity": "sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw==", + "dev": true, + "requires": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + } + }, "chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -4354,6 +5939,12 @@ "supports-color": "^7.1.0" } }, + "check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true + }, "chokidar": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", @@ -4438,6 +6029,34 @@ } } }, + "cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, "clone": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", @@ -4534,6 +6153,32 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "dev": true, + "requires": { + "ms": "^2.1.3" + } + }, + "decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true + }, "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", @@ -4541,6 +6186,12 @@ "dev": true, "optional": true }, + "deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true + }, "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", @@ -4561,6 +6212,30 @@ "repeating": "^2.0.0" } }, + "diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "dev": true + }, + "eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -4771,6 +6446,22 @@ "to-regex-range": "^2.1.0" } }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -4788,6 +6479,16 @@ "for-in": "^1.0.1" } }, + "foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + } + }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -4821,6 +6522,12 @@ "nan": "^2.12.1" } }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -4962,6 +6669,12 @@ } } }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, "home-or-tmp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", @@ -4972,6 +6685,12 @@ "os-tmpdir": "^1.0.1" } }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -5110,6 +6829,12 @@ "integrity": "sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==", "dev": true }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, "is-glob": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", @@ -5130,6 +6855,12 @@ "kind-of": "^3.0.2" } }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -5154,6 +6885,12 @@ "dev": true, "optional": true }, + "is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -5167,6 +6904,12 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", @@ -5174,12 +6917,58 @@ "dev": true, "optional": true }, + "istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true + }, + "istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + } + }, + "istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, + "jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "requires": { + "@isaacs/cliui": "^8.0.2", + "@pkgjs/parseargs": "^0.11.0" + } + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + } + }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -5190,12 +6979,31 @@ "is-buffer": "^1.1.5" } }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + } + }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -5205,6 +7013,27 @@ "js-tokens": "^3.0.0 || ^4.0.0" } }, + "loupe": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz", + "integrity": "sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==", + "dev": true + }, + "lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true + }, + "make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "requires": { + "semver": "^7.5.3" + } + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -5296,6 +7125,12 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, + "minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true + }, "mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -5328,6 +7163,220 @@ "minimist": "^1.2.5" } }, + "mocha": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.1.0.tgz", + "integrity": "sha512-8uJR5RTC2NgpY3GrYcgpZrsEd9zKbPDpob1RezyR2upGHRQtHWofmzTMzTMSV6dru3tj5Ukt0+Vnq1qhFEEwAg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^10.4.5", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^17.7.2", + "yargs-parser": "^21.1.1", + "yargs-unparser": "^2.0.0" + }, + "dependencies": { + "anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "requires": { + "fill-range": "^7.1.1" + } + }, + "chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "optional": true + }, + "glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "requires": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "dependencies": { + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + } + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, "nan": { "version": "2.14.2", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", @@ -5529,6 +7578,30 @@ "object-assign": "^4.1.0" } }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true + }, "parse-glob": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", @@ -5549,12 +7622,46 @@ "dev": true, "optional": true }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "requires": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + } + }, + "pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "dev": true + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -5609,6 +7716,15 @@ } } }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, "readable-stream": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", @@ -5721,6 +7837,12 @@ "integrity": "sha512-yD5BHCe7quCgBph4rMQ+0KkIRKwWCrHDOX1p1Gp6HwjPM5kVoCdKGNhN7ydqqsX6lJEnQDKZ/tFMiEdQ1dvPEw==", "dev": true }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true + }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -5789,6 +7911,21 @@ "ret": "~0.1.10" } }, + "semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "dev": true + }, + "serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, "set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", @@ -5802,6 +7939,27 @@ "split-string": "^3.0.1" } }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -6065,6 +8223,62 @@ "safe-buffer": "~5.1.0" } }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, + "string-width-cjs": { + "version": "npm:string-width@4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -6074,6 +8288,29 @@ "ansi-regex": "^2.0.0" } }, + "strip-ansi-cjs": { + "version": "npm:strip-ansi@6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + } + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -6083,6 +8320,51 @@ "has-flag": "^4.0.0" } }, + "test-exclude": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", + "integrity": "sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^10.4.1", + "minimatch": "^9.0.4" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "requires": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + } + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } + } + }, "to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", @@ -6229,6 +8511,25 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "v8-to-istanbul": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", + "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "dependencies": { + "convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + } + } + }, "v8flags": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", @@ -6261,11 +8562,127 @@ "source-map": "^0.5.1" } }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, + "wrap-ansi-cjs": { + "version": "npm:wrap-ansi@7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true + }, + "yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "requires": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + } + }, + "yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true + }, + "yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "requires": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + } + }, + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true } } } diff --git a/package.json b/package.json index 1ca426a..dcc1ac7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "public": true, "preferGlobal": false, "name": "flexsearch", - "version": "0.8.117", + "version": "0.8.123", "description": "Next-Generation full-text search library for Browser and Node.js", "homepage": "https://github.com/nextapps-de/flexsearch/", "author": "Thomas Wilkerling", @@ -83,8 +83,9 @@ "build:module:light:debug": "node task/build RELEASE=light.module DEBUG=true PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CHARSET=false SUPPORT_CACHE=true SUPPORT_ASYNC=false SUPPORT_STORE=false SUPPORT_TAGS=false SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=false SUPPORT_DOCUMENT=false POLYFILL=false SUPPORT_PERSISTENT=false SUPPORT_RESOLVER=false SUPPORT_KEYSTORE=false SUPPORT_COMPRESSION=false FORMATTING=PRETTY_PRINT", "build:all": "npm version --no-git-tag-version patch && npm run build:bundle && npm run build:bundle:debug && npm run build:light && npm run build:light:debug && npm run build:compact && npm run build:compact:debug && npm run build:module && npm run build:module:debug && npm run build:module:min && npm run build:module:bundle && npm run build:module:bundle:debug && npm run build:module:light && npm run build:module:light:debug && npm run build:module:compact && npm run build:module:compact:debug && npm run build:es5 && npm run build:es5:debug && npm run build:lang && npm run build:db", "build:custom": "node task/build RELEASE=custom", - "test": "cd test && npm install && npm run test && cd ..", - "test:all": "npm run test && cd test && npm run test:all && cd .." + "test": "mocha test/*.js", + "test:coverage": "c8 -c test/.c8rc.json mocha test/*.js", + "test:all": "npx mocha test/*.js module/bundle && npx mocha test/*.js module-debug/bundle && npx mocha test/*.js module-min/bundle && npx mocha test/*.js flexsearch.bundle.debug && npx mocha test/*.js flexsearch.bundle.min && npx mocha test/*.js flexsearch.bundle.module.debug && npx mocha test/*.js flexsearch.bundle.module.min && npx mocha test/*.js flexsearch.compact.debug && npx mocha test/*.js flexsearch.compact.min && npx mocha test/*.js flexsearch.compact.module.debug && npx mocha test/*.js flexsearch.compact.module.min && npx mocha test/*.js flexsearch.es5.debug && npx mocha test/*.js flexsearch.es5.min && npx mocha test/*.js flexsearch.light.debug && npx mocha test/*.js flexsearch.light.min && npx mocha test/*.js flexsearch.light.module.debug && npx mocha test/*.js flexsearch.light.module.min" }, "files": [ "dist/**", @@ -114,7 +115,10 @@ "babel-plugin-transform-simplify-comparison-operators": "^6.9.4", "babel-plugin-transform-undefined-to-void": "^6.9.4", "google-closure-compiler": "^20240317.0.0", - "rollup": "^4.35.0" + "rollup": "^4.35.0", + "c8": "^10.1.3", + "chai": "^5.2.0", + "mocha": "^11.1.0" }, "funding": [ { diff --git a/src/bundle.js b/src/bundle.js index 309ff06..5ee4f0a 100644 --- a/src/bundle.js +++ b/src/bundle.js @@ -313,11 +313,13 @@ if(RELEASE !== "bundle.module" && RELEASE !== "compact.module" && RELEASE !== "custom.module"){ - FlexSearch["Language"] = {}; + // When it is not a module, the package is for Node.js or legacy Browser + // Here there exists this or self + // const root = typeof self !== "undefined" ? self : + // typeof global !== "undefined" ? global : + // typeof window !== "undefined" ? window : {}; - const root = typeof self !== "undefined" ? self : - typeof global !== "undefined" ? global : - typeof window !== "undefined" ? window : {}; + const root = self; let prop; // AMD (RequireJS) diff --git a/src/charset/arabic/default.js b/src/charset/arabic/default.js index 218a7c4..2d71351 100644 --- a/src/charset/arabic/default.js +++ b/src/charset/arabic/default.js @@ -5,7 +5,8 @@ const split = /\s+/; /** @type EncoderOptions */ const options = { - rtl: true, + // the string is already encoded as RTL by default + //rtl: true, normalize: false, dedupe: true, prepare: function(str){ diff --git a/src/charset/latin/advanced.js b/src/charset/latin/advanced.js index a6d01ba..145a9ea 100644 --- a/src/charset/latin/advanced.js +++ b/src/charset/latin/advanced.js @@ -10,14 +10,17 @@ export const matcher = new Map([ //["ch", "c"], // before soundex ["kh", "k"], // after soundex ["th", "t"], // replacer "h" - //["ph", "f"], - ["pf", "f"] + ["ph", "f"], // replacer "h" + ["pf", "f"], + //["ps", "s"], + //["ts", "s"], + ]); export const replacer = [ /([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", - /([^0-9])\1+/g, "$1" + /(.)\1+/g, "$1" // /([^0-9])\1+/g, "$1" ]; /** @type EncoderOptions */ diff --git a/src/charset/latin/exact.js b/src/charset/latin/exact.js index 522c04c..aefdb18 100644 --- a/src/charset/latin/exact.js +++ b/src/charset/latin/exact.js @@ -2,7 +2,8 @@ import { EncoderOptions } from "../../type.js"; /** @type EncoderOptions */ const options = { + split: /\s+/, normalize: false, - dedupe: false + //dedupe: false }; export default options; \ No newline at end of file diff --git a/src/config.js b/src/config.js index 0782c7f..a599317 100644 --- a/src/config.js +++ b/src/config.js @@ -47,7 +47,7 @@ export const SUPPORT_PERSISTENT = true; export const SUPPORT_KEYSTORE = true; /** @define {boolean} */ -export const SUPPORT_COMPRESSION = true; +export const SUPPORT_COMPRESSION = false; /** @define {boolean} */ export const SUPPORT_RESOLVER = true; \ No newline at end of file diff --git a/src/document.js b/src/document.js index c12ebf3..9552cea 100644 --- a/src/document.js +++ b/src/document.js @@ -58,6 +58,7 @@ export default function Document(options){ keystore = SUPPORT_KEYSTORE && (options.keystore || 0); keystore && (this.keystore = keystore); this.fastupdate = !!options.fastupdate; + // Shared Registry this.reg = this.fastupdate && (!SUPPORT_WORKER || !options.worker) && (!SUPPORT_PERSISTENT || !options.db) ? (keystore && SUPPORT_KEYSTORE ? new KeystoreMap(keystore) : new Map()) : (keystore && SUPPORT_KEYSTORE ? new KeystoreSet(keystore) : new Set()); diff --git a/src/document/search.js b/src/document/search.js index a876f9c..3c09a0f 100644 --- a/src/document/search.js +++ b/src/document/search.js @@ -14,6 +14,7 @@ import { DocumentSearchResults, EnrichedDocumentSearchResults, MergedDocumentSearchResults, + MergedDocumentSearchEntry, EnrichedSearchResults, SearchResults, IntermediateSearchResults @@ -472,7 +473,7 @@ Document.prototype.search = function(query, limit, options, _promises){ result[j]["result"] = promises[j]; } return merge - ? merge_fields(result, limit, offset) + ? merge_fields(result, /** @type {number} */ (limit), offset) : highlight ? highlight_fields(result, query, self.index, self.field, self.tree, highlight, limit, offset) : result; @@ -573,7 +574,14 @@ function highlight_fields(result, query, index, field, tree, template, limit, of // be found at least by one field to get a valid match without // using suggestion explicitly +/** + * @param {DocumentSearchResults} fields + * @param {number=} limit + * @param {number=} offset + * @return {MergedDocumentSearchResults} + */ function merge_fields(fields, limit, offset){ + /** @type {Array} */ const final = []; const set = create_object(); for(let i = 0, field, res; i < fields.length; i++){ @@ -581,6 +589,12 @@ function merge_fields(fields, limit, offset){ res = field.result; for(let j = 0, id, entry, tmp; j < res.length; j++){ entry = res[j]; + // upgrade flat results + if(typeof entry !== "object"){ + entry = { + "id": entry + }; + } id = entry.id; tmp = set[id]; if(!tmp){ @@ -595,7 +609,7 @@ function merge_fields(fields, limit, offset){ return final; } entry.field = set[id] = [field.field]; - final.push(entry); + final.push(/** @type {MergedDocumentSearchEntry} */ (entry)); } else{ tmp.push(field.field); diff --git a/src/encoder.js b/src/encoder.js index af3efe8..155e0dc 100644 --- a/src/encoder.js +++ b/src/encoder.js @@ -67,7 +67,7 @@ const normalize = "".normalize && /[\u0300-\u036f]/g; // '´`’ʼ., * @constructor */ -export default function Encoder(options){ +export default function Encoder(options = {}){ if(!this || this.constructor !== Encoder){ // let args = Array.prototype.slice.call(arguments); @@ -76,8 +76,13 @@ export default function Encoder(options){ return new Encoder(...arguments); } - for(let i = 0; i < arguments.length; i++){ - this.assign(arguments[i]); + if(arguments.length){ + for(let i = 0; i < arguments.length; i++){ + this.assign(arguments[i]); + } + } + else{ + this.assign(options); } }; diff --git a/src/index/add.js b/src/index/add.js index cbd799f..1a7b0fd 100644 --- a/src/index/add.js +++ b/src/index/add.js @@ -54,9 +54,10 @@ Index.prototype.add = function(id, content, _append, _skip_update){ let term = content[this.rtl ? word_length - 1 - i : i]; let term_length = term.length; + // todo check context search + // this check also wasn't applied on search, so it's useless here // skip dupes will break the context chain - - if(term_length /*&& (term_length >= this.minlength)*/ && (depth || !dupes[term])){ + if(term_length && (depth || !dupes[term])){ let score = this.score ? this.score(content, term, i, null, 0) @@ -67,16 +68,14 @@ Index.prototype.add = function(id, content, _append, _skip_update){ case "full": if(term_length > 2){ - for(let x = 0; x < term_length; x++){ + for(let x = 0, _x; x < term_length; x++){ for(let y = term_length; y > x; y--){ - - //if((y - x) >= this.minlength){ token = term.substring(x, y); + _x = this.rtl ? term_length - 1 - x : x; const partial_score = this.score - ? this.score(content, term, i, token, x) - : get_score(resolution, word_length, i, term_length, x); + ? this.score(content, term, i, token, _x) + : get_score(resolution, word_length, i, term_length, _x); this.push_index(dupes, token, partial_score, id, _append); - //} } } break; @@ -86,13 +85,15 @@ Index.prototype.add = function(id, content, _append, _skip_update){ // skip last round (this token exist already in "forward") if(term_length > 1){ for(let x = term_length - 1; x > 0; x--){ - token = term[x] + token; - //if(token.length >= this.minlength){ + token = term[ + this.rtl + ? term_length - 1 - x + : x + ] + token; const partial_score = this.score ? this.score(content, term, i, token, x) : get_score(resolution, word_length, i, term_length, x); this.push_index(dupes, token, partial_score, id, _append); - //} } token = ""; } @@ -101,25 +102,19 @@ Index.prototype.add = function(id, content, _append, _skip_update){ case "forward": if(term_length > 1){ for(let x = 0; x < term_length; x++){ - token += term[x]; - //if(token.length >= this.minlength){ + token += term[ + this.rtl + ? term_length - 1 - x + : x + ]; this.push_index(dupes, token, score, id, _append); - //} } break; } // fallthrough to next case when token has a length of 1 - default: - // case "strict": - - // todo move boost to search - // if(this.boost){ - // score = Math.min((score / this.boost(content, term, i)) | 0, resolution - 1); - // } - + default: // "strict": this.push_index(dupes, term, score, id, _append); - // context is just supported by tokenizer "strict" if(depth){ @@ -129,23 +124,38 @@ Index.prototype.add = function(id, content, _append, _skip_update){ const dupes_inner = create_object(); const resolution = this.resolution_ctx; const keyword = term; - const size = Math.min(depth + 1, word_length - i); + const size = Math.min( + depth + 1, + this.rtl + ? i + 1 + : word_length - i + ); dupes_inner[keyword] = 1; for(let x = 1; x < size; x++){ - term = content[this.rtl ? word_length - 1 - i - x : i + x]; + term = content[ + this.rtl + ? word_length - 1 - i - x + : i + x + ]; - if(term /*&& (term.length >= this.minlength)*/ && !dupes_inner[term]){ + if(term && !dupes_inner[term]){ dupes_inner[term] = 1; - const context_score = this.score - ? this.score(content, keyword, i, term, x) + ? this.score(content, keyword, i, term, x - 1) : get_score(resolution + ((word_length / 2) > resolution ? 0 : 1), word_length, i, size - 1, x - 1); const swap = this.bidirectional && (term > keyword); - this.push_index(dupes_ctx, swap ? keyword : term, context_score, id, _append, swap ? term : keyword); + this.push_index( + dupes_ctx, + swap ? keyword : term, + context_score, + id, + _append, + swap ? term : keyword + ); } } } diff --git a/src/index/search.js b/src/index/search.js index 967d426..7283502 100644 --- a/src/index/search.js +++ b/src/index/search.js @@ -274,6 +274,7 @@ Index.prototype.search = function(query, limit, options){ // fallback to non-contextual search when no result was found if(suggest && keyword && (index === length - 1)){ if(!result.length){ + resolution = self.resolution; keyword = ""; index = -1; dupes = create_object(); @@ -323,6 +324,7 @@ Index.prototype.search = function(query, limit, options){ // fallback to non-contextual search when no result was found if(suggest && keyword && (index === length - 1)){ if(!result.length){ + resolution = this.resolution; keyword = ""; index = -1; dupes = create_object(); diff --git a/src/preset.js b/src/preset.js index 5a127eb..44cddc7 100644 --- a/src/preset.js +++ b/src/preset.js @@ -8,7 +8,6 @@ import { IndexOptions } from "./type.js"; * @type {Object} * @const */ - const presets = { "memory": { @@ -16,11 +15,11 @@ const presets = { }, "performance": { - resolution: 6, + resolution: 3, fastupdate: true, context: { depth: 1, - resolution: 3 + resolution: 1 } }, @@ -32,7 +31,7 @@ const presets = { resolution: 9, context: { depth: 2, - resolution: 9 + resolution: 3 } } }; diff --git a/src/type.js b/src/type.js index 5a7c8d2..a8dbacb 100644 --- a/src/type.js +++ b/src/type.js @@ -185,13 +185,19 @@ export let DocumentSearchResults = []; */ export let EnrichedDocumentSearchResults = []; + /** - * @typedef Array<{ + * @typedef {{ * id: (number|string), * doc: (Object|null), * field: (Array|undefined), * tag: (Array|undefined) - * }> + * }} + */ +export let MergedDocumentSearchEntry = {}; + +/** + * @typedef Array */ export let MergedDocumentSearchResults = []; @@ -213,7 +219,7 @@ export let EncoderSplitOptions = {}; * dedupe: (boolean|undefined), * include: (EncoderSplitOptions|undefined), * exclude: (EncoderSplitOptions|undefined), - * split: (string|boolean|undefined), + * split: (string|boolean|RegExp|undefined), * numeric: (boolean|undefined), * normalize: (boolean|(function(string):string)|undefined), * prepare: ((function(string):string)|undefined), diff --git a/src/worker.js b/src/worker.js index 1ce926b..40d1ca7 100644 --- a/src/worker.js +++ b/src/worker.js @@ -155,15 +155,17 @@ function create(factory, is_node_js, worker_path){ let worker worker = is_node_js ? - // This eval will be removed when compiling + // if anyone would ask me what JS has delivered the past 10 years, + // those are the lines I definitively show up first ^^ typeof module !== "undefined" - ? (0,eval)('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")') - //: (0,eval)('new ((await import("worker_threads"))["Worker"])(import.meta.dirname + "/worker/node.mjs")') - //: (0,eval)('new ((await import("worker_threads"))["Worker"])((1,eval)(\"import.meta.dirname\") + "/node/node.mjs")') - : (0,eval)('import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)(\"import.meta.dirname\") + "/node/node.mjs"); })') - //: import("worker_threads").then(function(worker){ return new worker["Worker"](import.meta.dirname + "/worker/node.mjs"); }) - - //eval('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")') + // This eval will be removed when compiling + // The issue is that this will not build by Closure Compiler + ? (0,eval)('new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js")') + // this will need to remove in CommonJS builds, + // otherwise the module is treated as ESM by Node.js automatic detection + // the path src/worker/node.mjs is located at dist/node/node.mjs + // The issue is that this will not build by Babel Compiler + : import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/worker/node.mjs")}) :( factory ? new window.Worker(URL.createObjectURL( @@ -176,6 +178,7 @@ function create(factory, is_node_js, worker_path){ new window.Worker( typeof worker_path === "string" ? worker_path + // when loaded from /src/ folder the worker file is located at /worker/worker.js : import.meta.url.replace("/worker.js", "/worker/worker.js") .replace("flexsearch.bundle.module.min.js", "module/worker/worker.js") /*"worker/worker.js"*/ , { type: "module" } diff --git a/src/worker/handler.js b/src/worker/handler.js index 4ab2a26..1bfd30c 100644 --- a/src/worker/handler.js +++ b/src/worker/handler.js @@ -28,7 +28,7 @@ export default async function(data) { options = options; // will be replaced after build with the line below because // there is an issue with closure compiler dynamic import - options = (await import(filepath))["default"]; + options=(await import(filepath))["default"]; } const factory = data["factory"]; diff --git a/task/babel.js b/task/babel.js index ddc899b..1804ee0 100644 --- a/task/babel.js +++ b/task/babel.js @@ -18,8 +18,13 @@ fs.existsSync("dist") || fs.mkdirSync("dist"); let src = fs.readFileSync("src/" + file, "utf8"); src = src.replace(/\/\/ COMPILER BLOCK -->(.*)<-- COMPILER BLOCK/gs, ""); if(file === "worker.js"){ - // add the eval wrapper + // add the eval wrapper #1 src = src.replace("import.meta.url", '(1,eval)("import.meta.url")'); + // add the eval wrapper #2 + src = src.replace( + /[: ]+import\("worker_threads"\)[^}]+}\)/g, + `: (0,eval)('import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)(\\"import.meta.dirname\\")+"/worker/node.mjs")})')` + ); } fs.writeFileSync("tmp/" + file, src); } @@ -61,7 +66,7 @@ fs.existsSync("dist") || fs.mkdirSync("dist"); src = src.replace(/\/\/ COMPILER BLOCK -->(.*)<-- COMPILER BLOCK/gs, ""); if(file === "handler.js"){ // add the eval wrapper - src = src.replace('options = (await import(filepath))["default"];', '//options = (await import(filepath))["default"];'); + src = src.replace('options=(await import(filepath))["default"];', '//options=(await import(filepath))["default"];'); } fs.writeFileSync("tmp/" + path + "/" + file, src); } @@ -72,7 +77,6 @@ fs.existsSync("dist") || fs.mkdirSync("dist"); content = content.replace(/import \{([^}]+)} from "\.\.\/type\.js";/, ''); fs.writeFileSync("tmp/db/interface.js", content); - //fs.copyFileSync("src/db/interface.js", "tmp/db/interface.js"); fs.copyFileSync("task/babel." + (debug ? "debug": (minify ? "min" : "bundle")) + ".json", "tmp/.babelrc"); fs.existsSync("dist/module" + (debug ? "-debug" : (minify ? "-min" : ""))) && fs.rmSync("dist/module" + (debug ? "-debug" : (minify ? "-min" : "")), { recursive: true }); @@ -83,12 +87,31 @@ fs.existsSync("dist") || fs.mkdirSync("dist"); // fix babel compiler dynamic import let content = fs.readFileSync("dist/module" + (debug ? "-debug" : (minify ? "-min" : "")) + "/worker/handler.js", "utf8"); - content = content.replace('//options = (await import(filepath))["default"];', 'options = (await import(filepath))["default"];'); + content = content.replace('//options=(await import(filepath))["default"];', 'options=(await import(filepath))["default"];'); fs.writeFileSync("dist/module" + (debug ? "-debug" : (minify ? "-min" : "")) + "/worker/handler.js", content); // fix babel compiler dynamic import content = fs.readFileSync("dist/module" + (debug ? "-debug" : (minify ? "-min" : "")) + "/worker.js", "utf8"); - content = content.replace('(1, eval)("import.meta.url")', 'import.meta.url'); + // replace the eval wrapper + content = content.replace(/\(0, eval\)/g, "(0,eval)"); + content = content.replace( + `(0,eval)('import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)(\\"import.meta.dirname\\")+"/worker/node.mjs")})')`, + `import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/../node/node.mjs")})` + ); + content = content.replace( + `(0,eval)("import(\\"worker_threads\\").then(function(worker){return new worker[\\"Worker\\"]((1,eval)(\\"import.meta.dirname\\")+\\"/worker/node.mjs\\")})")`, + `import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/../node/node.mjs")})` + ); + content = content.replace( + `(0,eval)("new(require(\\"worker_threads\\")[\\"Worker\\"])(__dirname+\\"/worker/node.js\\")")`, + `new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js")` + ); + //content = content.replace(/\(1,eval\)\('([^']+)'\)/g, "import.meta.dirname"); + content = content.replace('(1,eval)("import.meta.url")', 'import.meta.url'); + content = content.replace('(1,eval)("import.meta.url")', 'import.meta.url'); + content = content.replace('(0,eval)("import.meta.url")', 'import.meta.url'); + content = content.replace('(0,eval)("import.meta.url")', 'import.meta.url'); + content = content.replace('(1,eval)("import.meta.dirname")', 'import.meta.dirname'); fs.writeFileSync("dist/module" + (debug ? "-debug" : (minify ? "-min" : "")) + "/worker.js", content); }); }()); diff --git a/task/build.js b/task/build.js index a67aafb..862661d 100644 --- a/task/build.js +++ b/task/build.js @@ -314,9 +314,14 @@ else (async function(){ else if(file === "worker.js"){ let content = fs.readFileSync("src/" + file, "utf8"); - // add the eval wrapper + // add the eval wrapper #1 content = content.replace("import.meta.url", '(1,eval)("import.meta.url")'); - fs.writeFileSync("tmp/worker.js", content); + // add the eval wrapper #2 + content = content.replace( + /[: ]+import\("worker_threads"\)[^}]+}\)/g, + `: (0,eval)('import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)(\\"import.meta.dirname\\")+"/node/node.mjs")})')` + ); + fs.writeFileSync("tmp/worker.js", content) } else{ @@ -338,7 +343,7 @@ else (async function(){ // add the eval wrapper let content = fs.readFileSync("tmp/worker/handler.js", "utf8"); - content = content.replace('options = (await import(filepath))["default"];', '//options = (await import(filepath))["default"];'); + content = content.replace('options=(await import(filepath))["default"];', '//options=(await import(filepath))["default"];'); fs.writeFileSync("tmp/worker/handler.js", content); const filename = "dist/flexsearch." + (release + (custom ? "." + custom : "")) + (options["DEBUG"] ? ".debug" : ".min") + ".js"; @@ -409,10 +414,23 @@ else (async function(){ // replace the eval wrapper build = build.replace(/\(1,eval\)\('([^']+)'\)/g, "import.meta.dirname"); build = build.replace('(0,eval)("import.meta.url")', 'import.meta.url'); + build = build.replace('(1,eval)("import.meta.url")', 'import.meta.url'); build = build.replace('(1,eval)("import.meta.dirname")', 'import.meta.dirname'); + build = build.replace( + `: (0,eval)('import("worker_threads").then(function(worker){return new worker["Worker"]((1,eval)(\\"import.meta.dirname\\")+"/node/node.mjs")})')`, + `: import("worker_threads").then(function(worker){return new worker["Worker"](import.meta.dirname+"/node/node.mjs")})` + ); //build = build.replace(/\(function\(self\)\{/, "const FlexSearch=(function(self){"); } + else{ + + // add the eval wrapper #3 + build = build.replace( + `(0,eval)('new(require("worker_threads")["Worker"])(__dirname+"/worker/node.js")')`, + `new(require("worker_threads")["Worker"])(__dirname+"/node/node.js")` + ); + } // fix closure compiler dynamic import build = build.replace(/\(([a-z])=([a-z]).config\)&&\(([a-z])=([a-z])\)/, "($1=$2.config)&&($3=(await import($4))[\"default\"])"); diff --git a/test/.c8rc.json b/test/.c8rc.json new file mode 100644 index 0000000..b01b2a0 --- /dev/null +++ b/test/.c8rc.json @@ -0,0 +1,19 @@ +{ + "reporter": "text", + "reports-dir": "./test/report/", + "branches": 80, + "functions": 80, + "lines": 80, + "statements": 80, + "exclude": [ + "src/compress.js", + "src/db/indexeddb/**" + ], + "src": [ + "src" + ], + "include": [ + "test/*.js", + "src/**" + ] +} \ No newline at end of file diff --git a/test/async.js b/test/async.js new file mode 100644 index 0000000..c3d0f60 --- /dev/null +++ b/test/async.js @@ -0,0 +1,97 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +console.log("--RELEASE-------------"); +console.log(env ? "dist/" + env + ".js" : "src/bundle.js") +console.log("----------------------"); +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +if(!build_light) describe("Add (Async)", function(){ + + it("Should have been added asynchronously to the index", async function(){ + + const index = new Index(/*{ priority: 4 }*/); + let duration = 0; + let time = Date.now(); + + setTimeout(function(){ + duration = Date.now() - time; + }); + + for(let i = 0; i < 1000; i++){ + await index.addAsync(i, "foo"); + if(duration) break; + } + + expect(duration).to.equal(0); + + for(let i = 0; i < 999999999; i++){ + await index.addAsync(i, "foo"); + if(duration){ + break; + } + } + + expect(duration).to.closeTo(50, 5); + }); + + it("Should have been added asynchronously to the index (priority: 1)", async function(){ + + const index = new Index({ priority: 1 }); + let duration = 0; + let time = Date.now(); + + setTimeout(function(){ + duration = Date.now() - time; + }); + + for(let i = 0; i < 1000; i++){ + await index.addAsync(i, "foo"); + if(duration) break; + } + + expect(duration).to.equal(0); + + for(let i = 0; i < 999999999; i++){ + await index.addAsync(i, "foo"); + if(duration){ + break; + } + } + + expect(duration).to.closeTo(4, 2); + }); + + it("Should have been added asynchronously to the index (priority: 9)", async function(){ + + const index = new Index({ priority: 9 }); + let duration = 0; + let time = Date.now(); + + setTimeout(function(){ + duration = Date.now() - time; + }); + + for(let i = 0; i < 1000; i++){ + await index.addAsync(i, "foo"); + if(duration) break; + } + + expect(duration).to.equal(0); + + for(let i = 0; i < 999999999; i++){ + await index.addAsync(i, "foo"); + if(duration){ + break; + } + } + expect(duration).to.closeTo(250, 25); + }); +}); diff --git a/test/basic.js b/test/basic.js new file mode 100644 index 0000000..f15d64a --- /dev/null +++ b/test/basic.js @@ -0,0 +1,958 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +// console.log("--------------"); +// console.log(env ? "dist/" + env + ".js" : "src/bundle.js") +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +// global.FlexSearch = { Index, Document, Worker, Charset, Encoder, Resolver }; +// global.build = { build_light, build_compact, build_esm }; + +describe("Initialize", function(){ + + const index = new Index(); + + it("Should have proper constructor", function(){ + + expect(index).to.be.an.instanceOf(Index); + }); + + it("Should have all provided methods", function(){ + + expect(index).to.respondTo("search"); + expect(index).to.respondTo("add"); + expect(index).to.respondTo("append"); + expect(index).to.respondTo("update"); + expect(index).to.respondTo("remove"); + expect(index).to.respondTo("clear"); + + expect(index).to.hasOwnProperty("map"); + expect(index).to.hasOwnProperty("ctx"); + expect(index).to.hasOwnProperty("reg"); + + if(!build_light){ + expect(index).to.respondTo("searchAsync"); + expect(index).to.respondTo("addAsync"); + expect(index).to.respondTo("appendAsync"); + expect(index).to.respondTo("updateAsync"); + expect(index).to.respondTo("removeAsync"); + expect(index).to.respondTo("export"); + expect(index).to.respondTo("import"); + expect(index).to.respondTo("serialize"); + } + }); + + it("Should have the default options", function(){ + + expect(index.resolution).to.equal(9); + expect(index.depth).to.equal(0); + expect(index.fastupdate).to.equal(false); + }); + + it("Should have the default Encoder", function(){ + + const encoder = new Encoder(Charset.LatinDefault); + expect(index.tokenize).to.equal("strict"); + expect(typeof index.encoder.normalize).to.equal(typeof encoder.normalize); + index.encoder.normalize = encoder.normalize; + expect(index.encoder).to.eql(encoder); + expect(index.encoder.minlength).to.equal(1); + expect(index.encoder.maxlength).to.equal(0); + expect(index.encoder.rtl).to.equal(false); + expect(index.encoder.numeric).to.equal(true); + expect(index.encoder.dedupe).to.equal(false); + }); +}); + +describe("Add", function(){ + + it("Should have been properly added to the index", function(){ + + const index = new Index(); + + index.add(0, "foo"); + index.add(2, "bar"); + index.add(1, "FooBar"); + index.add(3, "Some 'short' content."); + + expect(index.reg.keys()).to.have.members([0, 1, 2, 3]); + expect(index.map.keys()).to.have.members(["foo", "bar", "foobar", "some", "short", "content"]); + expect(index.ctx.size).to.equal(0); + expect(index.reg.size).to.equal(4); + }); + + build_light || it("Should have been numeric content properly added to the index (Triplets)", function(){ + + const index = new Index(); + + index.add(0, "TEST-123456789123456789"); + index.add(1, "T10030"); + index.add(2, "T10030T10030"); + index.add(3, "1443-AB14345-1778"); + + expect(index.reg.keys()).to.have.members([0, 1, 2, 3]); + expect(index.map.keys()).to.have.members([ + "test", "123", "456", "789", + "t", "100", "30", + // id 2 was already completely added, split: "t", "100", "30", "t", "100", "30" + "144", "3", "ab", "143", "45", "177", "8" + ]); + expect(index.ctx.size).to.equal(0); + expect(index.reg.size).to.equal(4); + }); + + it("Should not have been added to the index (Parameter)", function(){ + + const index = new Index(); + + index.add("foo"); + index.add(3); + index.add(null, "foobar"); + index.add(void 0, "foobar"); + index.add(3, null); + index.add(3, false); + + expect(index.reg.size).to.equal(0); + }); + + it("Should not have been added to the index (Empty)", function(){ + + const index = new Index(); + + index.add(1, ""); + index.add(2, " "); + index.add(3, " "); + index.add(4, " - "); + index.add(5, ` ... + - : , + <-- `); + + expect(index.reg.size).to.equal(0); + }); +}); + +describe("Search (Sync)", function(){ + + it("Should have been matched properly", function(){ + + const index = new Index(); + + index.add(0, "foo"); + index.add(1, "bar"); + index.add(2, "FooBar"); + index.add(3, "Some 'short' content."); + index.add(4, "Foo Bar"); + + expect(index.search("foo")).to.have.members([0, 4]); + expect(index.search("bar")).to.include(1, 4); + expect(index.search("foobar")).to.include(2); + expect(index.search("short 'content'")).to.include(3); + expect(index.search("foo foo")).to.have.members([0, 4]); + expect(index.search("foo foo bar foo bar")).to.have.members([4]); + }); + + it("Should have been applied limit/offset properly", function(){ + + const index = new Index(); + + for(let i = 0; i < 10; i++){ + index.add(i, "foo"); + } + + expect(index.search("foo", 99)).to.have.members([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + expect(index.search("foo", 3)).to.have.members([0, 1, 2]); + expect(index.search("foo", { limit: 3 })).to.have.members([0, 1, 2]); + expect(index.search("foo", { limit: 3, offset: 3 })).to.have.members([3, 4, 5]); + expect(index.search("foo", { limit: 3, offset: 9 })).to.have.members([9]); + expect(index.search("foo", { limit: 3, offset: 10 })).to.have.members([]); + expect(index.search({ query: "foo", limit: 1 })).to.include(0); + }); +}); + +describe("Search Scoring", function(){ + + it("Should have been matched properly", function(){ + + const index = new Index(); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let result = index.search("cats cute"); + expect(result.length).to.equal(7); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = index.search("cute cats"); + expect(result.length).to.equal(7); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = index.search("cute dogs cats"); + expect(result.length).to.equal(1); + expect(result).to.eql([1]); + + result = index.search("cute cat"); + expect(result.length).to.equal(0); + }); +}); + +describe("Tokenizer", function(){ + + it("Should have been \"forward\" tokenized properly", function(){ + + const index = new Index({ tokenize: "forward" }); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let result = index.search("cat cute"); + expect(result.length).to.equal(7); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = index.search("cute cat"); + expect(result.length).to.equal(7); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + }); + + it("Should have been \"reverse\" tokenized properly", function(){ + + const index = new Index({ tokenize: "reverse", resolution: 12 }); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let result = index.search("ats ute"); + expect(result.length).to.equal(7); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = index.search("ute ats"); + expect(result.length).to.equal(7); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + }); + + it("Should have been \"full\" tokenized properly", function(){ + + const index = new Index({ tokenize: "full", resolution: 12 }); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let result = index.search("at ut"); + expect(result.length).to.equal(7); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = index.search("ut at"); + expect(result.length).to.equal(7); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + }); +}); + +describe("Search: Suggestion", function(){ + + it("Should have been provide suggestions properly", function(){ + + const index = new Index({ tokenize: "forward" }); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', // <-- dogs + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let result = index.search("cute dog or cute cat or nothing", { suggest: true }); + expect(result.length).to.equal(7); + expect(result).to.eql([1, 6, 5, 4, 3, 2, 0]); + + result = index.search("nothing or cute cat or cute dog", { suggest: true }); + expect(result.length).to.equal(7); + expect(result).to.eql([1, 6, 5, 4, 3, 2, 0]); + }); +}); + +describe("Update (Sync)", function(){ + + it("Should have been updated to the index", function(){ + + const index = new Index({ tokenize: "full" }); + index.add(1, "foo"); + index.add(2, "bar"); + index.add(3, "foobar"); + + index.update(1, "bar"); + index.update(2, "foobar"); + index.update(3, "foo"); + + expect(index.reg.size).to.equal(3); + expect(index.search("foo")).to.have.members([2, 3]); + expect(index.search("bar")).to.have.members([1, 2]); + expect(index.search("bar")).to.not.include(3); + expect(index.search("foobar")).to.have.members([2]); + + index.update(1, "bar"); + index.update(2, "foobar"); + index.update(3, "foo"); + + expect(index.reg.size).to.equal(3); + expect(index.search("foo")).to.have.members([2, 3]); + expect(index.search("bar")).to.have.members([1, 2]); + expect(index.search("bar")).to.not.include(3); + expect(index.search("foobar")).to.have.members([2]); + }); + + it("Should not have been updated to the index", function(){ + + const index = new Index({ tokenize: "full" }); + index.add(1, "bar"); + index.add(2, "foobar"); + index.add(3, "foo"); + + index.update("foo"); + // todo + // index.update(1); + index.update(null, "foobar"); + index.update(void 0, "foobar"); + // index.update(1, null); + // index.update(2, false); + index.update(4, "new"); + + expect(index.reg.size).to.equal(4); + expect(index.search("foo")).to.have.members([2, 3]); + expect(index.search("bar")).to.have.members([1, 2]); + expect(index.search("bar")).to.not.include(3); + expect(index.search("foobar")).to.have.members([2]); + }); +}); + +describe("Remove (Sync)", function(){ + + it("Should have been removed from the index", function(){ + + const index = new Index({ tokenize: "full" }); + index.add(1, "bar"); + index.add(2, "foobar"); + index.add(3, "foo"); + + index.remove(2); + index.remove(1); + index.remove(3); + index.remove(4); + + expect(index.reg.size).to.equal(0); + expect(index.search("foo")).to.have.lengthOf(0); + expect(index.search("bar")).to.have.lengthOf(0); + expect(index.search("foobar")).to.have.lengthOf(0); + }); +}); + +// if(env !== "light") describe("Operators", function(){ +// +// var data = [{ +// id: 2, +// title: "Title 3", +// body: "Body 3", +// blacklist: "x1" +// },{ +// id: 1, +// title: "Title 2", +// body: "Body 2", +// blacklist: "x2" +// },{ +// id: 0, +// title: "Title 1", +// body: "Body 1", +// blacklist: "x3" +// }]; +// +// var index = new FlexSearch({ +// tokenize: "forward", +// doc: { +// id: "id", +// field: ["title", "body", "blacklist"] +// } +// }); +// +// it("Should have been properly applied logic", function(){ +// +// index.add(data); +// +// expect(index.search([{ +// field: "title", +// query: "title", +// bool: "and" +// },{ +// field: "body", +// query: "body", +// bool: "and" +// },{ +// field: "blacklist", +// query: "xxx", +// bool: "not" +// }])).to.have.members(data); +// +// expect(index.search([{ +// field: "title", +// query: "title", +// bool: "and" +// },{ +// field: "body", +// query: "title", +// bool: "and" +// },{ +// field: "blacklist", +// query: "xxx", +// bool: "not" +// }])).to.have.length(0); +// +// expect(index.search([{ +// field: "title", +// query: "title", +// bool: "and" +// },{ +// field: "body", +// query: "title", +// bool: "or" +// },{ +// field: "blacklist", +// query: "xxx", +// bool: "not" +// }])).to.have.members(data); +// +// expect(index.search([{ +// field: "title", +// query: "title", +// bool: "and" +// },{ +// field: "body", +// query: "title", +// bool: "or" +// }])).to.have.members(data); +// +// expect(index.search([{ +// field: "title", +// query: "title", +// bool: "and" +// },{ +// field: "body", +// query: "title", +// bool: "or" +// },{ +// field: "blacklist", +// query: "x1", +// bool: "not" +// }])).to.have.members([data[1], data[2]]); +// +// expect(index.search([{ +// field: "title", +// query: "body", +// bool: "or" +// },{ +// field: "body", +// query: "title", +// bool: "or" +// },{ +// field: "blacklist", +// query: "x1", +// bool: "not" +// }])).to.have.length(0); +// +// expect(index.search([{ +// field: "blacklist", +// query: "x1", +// bool: "not" +// },{ +// field: "title", +// query: "title", +// bool: "or" +// },{ +// field: "body", +// query: "body", +// bool: "or" +// }])).to.have.members([data[1], data[2]]); +// +// expect(index.search([{ +// field: "title", +// query: "body", +// bool: "or" +// },{ +// field: "body", +// query: "body", +// bool: "and" +// },{ +// field: "blacklist", +// query: "x2", +// bool: "not" +// }])).to.have.members([data[0], data[2]]); +// +// expect(index.search([{ +// field: "blacklist", +// query: "x2", +// bool: "not" +// },{ +// field: "title", +// query: "body", +// bool: "or" +// },{ +// field: "body", +// query: "body", +// bool: "and" +// }])).to.have.members([data[0], data[2]]); +// +// expect(index.search([{ +// field: "title", +// query: "body", +// bool: "or" +// },{ +// field: "blacklist", +// query: "x2", +// bool: "not" +// },{ +// field: "body", +// query: "body", +// bool: "and" +// }])).to.have.members([data[0], data[2]]); +// +// expect(index.search([{ +// field: "title", +// query: "title", +// bool: "and" +// },{ +// field: "body", +// query: "body", +// bool: "and" +// },{ +// field: "blacklist", +// query: "x", +// bool: "not" +// }])).to.have.length(0); +// +// expect(index.search([{ +// field: "title", +// query: "title", +// bool: "not" +// },{ +// field: "body", +// query: "body", +// bool: "not" +// },{ +// field: "blacklist", +// query: "x", +// bool: "not" +// }])).to.have.length(0); +// }); +// }); +// +// describe("Reserved Words", function(){ +// +// it("Should have been indexed properly", function(){ +// +// var index = new FlexSearch({ +// encode: function(str){ return [str]; }, +// tokenize: "strict", +// threshold: 0, +// depth: 3 +// }); +// +// var array = Object.getOwnPropertyNames({}.__proto__); +// array = array.concat(Object.getOwnPropertyNames(index)); +// +// array.push("prototype"); +// array.push("constructor"); +// array.push("__proto__"); +// +// if(env !== "min"){ +// +// array.push("concat"); +// array.push("hasOwnProperty"); +// array.push("length"); +// } +// +// for(var i = 0; i < array.length; i++){ +// +// index.add(array[i], array[i]); +// } +// +// for(var i = 0; i < array.length; i++){ +// +// // TODO: this word is reserved and can't be indexed +// if(array[i] === "_ctx"){ +// +// continue; +// } +// +// expect(index.search(array[i])).to.have.members([array[i]]); +// } +// }); +// }); +// +// // ------------------------------------------------------------------------ +// // Export / Import +// // ------------------------------------------------------------------------ +// +// if(env !== "light") describe("Export / Import", function(){ +// +// var data; +// +// it("Should have been exported properly", function(){ +// +// var index = new FlexSearch("match"); +// +// index.add(0, "foo"); +// index.add(1, "bar"); +// index.add(2, "foobar"); +// +// data = index.export(); +// +// if(env === ""){ +// +// expect(data).to.equal(JSON.stringify( +// [ +// index._map, +// index._ctx, +// Object.keys(index._ids) +// ] +// )); +// } +// }); +// +// it("Should have been imported properly", function(){ +// +// var index = new FlexSearch("match"); +// +// index.import(data); +// +// expect(index.length).to.equal(3); +// +// expect(index.search("foo")).to.have.lengthOf(2); +// expect(index.search("bar")).to.have.lengthOf(2); +// expect(index.search("foobar")).to.have.lengthOf(1); +// expect(index.search("foobar")[0]).to.equal(2); +// }); +// +// it("Should have been exported properly (documents)", function(){ +// +// var index = new FlexSearch({ +// +// tokenize: "strict", +// threshold: 1, +// resolution: 3, +// depth: 1, +// doc: { +// id: "id", +// field: ["title", "content"] +// } +// }); +// +// var docs = [{ +// id: 1, +// title: "Title 2", +// content: "foobar" +// },{ +// id: 0, +// title: "Title 1", +// content: "foo" +// },{ +// id: 2, +// title: "Title 3", +// content: "bar" +// }]; +// +// index.add(docs); +// data = index.export(); +// +// if(env === ""){ +// +// expect(index.doc.index["title"].length).to.equal(3); +// expect(data).to.equal(JSON.stringify([ +// [ +// index.doc.index["title"]._map, +// index.doc.index["title"]._ctx, +// Object.keys(index.doc.index["title"]._ids) +// ], +// [ +// index.doc.index["content"]._map, +// index.doc.index["content"]._ctx, +// Object.keys(index.doc.index["content"]._ids) +// ], +// index._doc +// ])); +// } +// }); +// +// it("Should have been imported properly (documents)", function(){ +// +// var index = new FlexSearch({ +// +// tokenize: "strict", +// threshold: 1, +// resolution: 3, +// depth: 1, +// doc: { +// id: "id", +// field: ["title", "content"] +// } +// }); +// +// index.import(data); +// +// if(env === ""){ +// +// expect(index.doc.index["title"].length).to.equal(3); +// expect(index.doc.index["content"].length).to.equal(3); +// } +// +// expect(index.search("foo")).to.have.lengthOf(1); +// expect(index.search("bar")).to.have.lengthOf(1); +// expect(index.search("foobar")).to.have.lengthOf(1); +// expect(index.search("foobar")[0].id).to.equal(1); +// }); +// }); +// +// // ------------------------------------------------------------------------ +// // Presets +// // ------------------------------------------------------------------------ +// +// describe("Presets", function(){ +// +// it("Should have been properly initialized", function(){ +// +// expect(FlexSearch("memory").length).to.equal(0); +// expect(FlexSearch("speed").length).to.equal(0); +// expect(FlexSearch("match").length).to.equal(0); +// expect(FlexSearch("score").length).to.equal(0); +// expect(FlexSearch("balance").length).to.equal(0); +// expect(FlexSearch("fast").length).to.equal(0); +// }); +// +// it("Should have been properly extended", function(){ +// +// var index = FlexSearch("fast"); +// index.add(0, "foobar"); +// expect(index.search("bar")).to.have.lengthOf(0); +// +// index = FlexSearch({preset: "speed", id: "test", tokenize: "reverse"}); +// expect(index.id).to.equal("test"); +// index.add(0, "foobar"); +// expect(index.search("bar")).to.have.lengthOf(1); +// expect(index.search("bar")).to.have.members([0]) +// }); +// }); +// +// // ------------------------------------------------------------------------ +// // Feature Tests +// // ------------------------------------------------------------------------ +// +// describe("Add Matchers", function(){ +// +// it("Should have been added properly", function(){ +// +// flexsearch_forward.init({ +// +// tokenize: "forward", +// matcher: { +// +// "1": "a", +// "2": "b", +// "3": "c", +// "7": "e", +// "8": "f", +// "[456]": "d" +// } +// +// }).add(0, "12345678"); +// +// expect(flexsearch_forward.search("12345678")).to.include(0); +// expect(flexsearch_forward.search("abcd")).to.include(0); +// expect(flexsearch_forward.encode("12345678")).to.eql(["abcdddef"]); +// }); +// }); +// +// // ------------------------------------------------------------------------ +// // Caching +// // ------------------------------------------------------------------------ +// +// if(env !== "light"){ +// +// describe("Caching", function(){ +// +// it("Should have been cached properly", function(){ +// +// flexsearch_cache.add(0, "foo") +// .add(1, "bar") +// .add(2, "foobar"); +// // fetch: +// expect(flexsearch_cache.search("foo")).to.have.members([0, 2]); +// expect(flexsearch_cache.search("bar")).to.have.members([1, 2]); +// expect(flexsearch_cache.search("foobar")).to.include(2); +// +// // cache: +// expect(flexsearch_cache.search("foo")).to.have.members([0, 2]); +// expect(flexsearch_cache.search("bar")).to.have.members([1, 2]); +// expect(flexsearch_cache.search("foobar")).to.include(2); +// +// // update: +// flexsearch_cache.remove(2).update(1, "foo").add(3, "foobar"); +// +// // fetch: +// expect(flexsearch_cache.search("foo")).to.have.members([0, 1, 3]); +// expect(flexsearch_cache.search("bar")).to.include(3); +// expect(flexsearch_cache.search("foobar")).to.include(3); +// +// // cache: +// expect(flexsearch_cache.search("foo")).to.have.members([0, 1, 3]); +// expect(flexsearch_cache.search("bar")).to.include(3); +// expect(flexsearch_cache.search("foobar")).to.include(3); +// }); +// }); +// } +// +// // ------------------------------------------------------------------------ +// // Debug Information +// // ------------------------------------------------------------------------ +// +// if(env !== "light" && env !== "min"){ +// +// describe("Debug", function(){ +// +// it("Should have been debug mode activated", function(){ +// +// var info = flexsearch_cache.info(); +// +// expect(info).to.have.keys([ +// +// "id", +// //"chars", +// "cache", +// "items", +// "matcher", +// //"memory", +// //"sequences", +// "resolution", +// "worker", +// "contextual", +// "depth", +// "threshold" +// ]); +// }); +// }); +// } +// +// // ------------------------------------------------------------------------ +// // Destroy +// // ------------------------------------------------------------------------ +// +// describe("Destroy", function(){ +// +// it("Should have been destroyed properly", function(){ +// +// var index = FlexSearch() +// .add(0, "foo") +// .add(1, "bar"); +// +// expect(index.search("foo")).to.include(0); +// expect(index.search("bar")).to.include(1); +// +// index.destroy(); +// +// expect(index.search("foo")).to.have.lengthOf(0); +// expect(index.search("bar")).to.have.lengthOf(0); +// }); +// +// if(env !== "light") it("Should have been destroyed properly (documents)", function(){ +// +// var data = [{id: 0, title: "foo"}, {id: 1, title: "bar"}]; +// +// var index = FlexSearch({doc: {id: "id", field: "title"}}) +// .add(data) +// .add(data); +// +// expect(index.search("foo")).to.have.members([data[0]]); +// expect(index.search("bar")).to.have.members([data[1]]); +// +// index.destroy(); +// +// expect(index.search("foo")).to.have.lengthOf(0); +// expect(index.search("bar")).to.have.lengthOf(0); +// }); +// }); +// +// // ------------------------------------------------------------------------ +// // Chaining +// // ------------------------------------------------------------------------ +// +// describe("Chaining", function(){ +// +// it("Should have been chained properly", function(){ +// +// var index = FlexSearch({tokenize: "forward", matcher: {"â": "a"}}) +// .add(0, "foo") +// .add(1, "bar"); +// +// expect(index.search("foo")).to.include(0); +// expect(index.search("bar")).to.include(1); +// expect(index.encode("bâr")).to.eql(["bar"]); +// +// index.remove(0).update(1, "foo").add(2, "foobâr"); +// +// expect(index.search("foo")).to.have.members([1, 2]); +// expect(index.search("bar")).to.have.lengthOf(0); +// expect(index.search("foobar")).to.include(2); +// +// index.clear().add(0, "foo").add(1, "bar"); +// +// expect(index.search("foo")).to.include(0); +// expect(index.search("bar")).to.include(1); +// expect(index.search("foobar")).to.have.lengthOf(0); +// +// flexsearch_cache.destroy().init().add(0, "foo").add(1, "bar"); +// +// expect(flexsearch_cache.search("foo")).to.include(0); +// expect(flexsearch_cache.search("bar")).to.include(1); +// expect(flexsearch_cache.search("foobar")).to.have.lengthOf(0); +// }); +// }); +//} + +/* Test Helpers */ + +function test_encoder(str){ + + return "-[" + str.toUpperCase() + "]-"; +} \ No newline at end of file diff --git a/test/context.js b/test/context.js new file mode 100644 index 0000000..67026f7 --- /dev/null +++ b/test/context.js @@ -0,0 +1,56 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +describe("Context", function(){ + + it("Should have been added properly to the context", function(){ + + let index = new Index({ + tokenize: "strict", + context: { + depth: 2 + } + }); + + index.add(0, "zero one two three four five six seven eight nine ten"); + + expect(index.reg.size).to.equal(1); + expect(index.search("zero one")).to.include(0); + expect(index.search("zero two")).to.include(0); + expect(index.search("zero three").length).to.equal(0); + expect(index.search("three seven").length).to.equal(0); + expect(index.search("three five seven")).to.include(0); + expect(index.search("eight six four")).to.include(0); + expect(index.search("seven five three")).to.include(0); + expect(index.search("three foobar seven").length).to.equal(0); + expect(index.search("seven foobar three").length).to.equal(0); + expect(index.search("eight ten")).to.include(0); + expect(index.search("ten nine seven eight six five three four two zero one")).to.include(0); + + index.add(1, "1 2 3 1 4 2 5 1"); + + expect(index.search("1")).to.include(1); + expect(index.search("1 5")).to.include(1); + expect(index.search("2 4 1")).to.include(1); + + index = new Index({ + tokenize: "strict", + context: { + depth: 2, + bidirectional: false + } + }); + + index.add(0, "zero one two three four five six seven eight nine ten"); + expect(index.search("ten nine seven eight six five three four two zero one").length).to.equal(0); + }); +}); diff --git a/test/document.js b/test/document.js new file mode 100644 index 0000000..2e98b66 --- /dev/null +++ b/test/document.js @@ -0,0 +1,404 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +if(!build_light) describe("Document (Multi-Field Search)", function(){ + + const data = [{ + id: 2, + data: { title: "Title 3", body: "Body 3" } + },{ + id: 1, + data: { title: "Title 2", body: "Body 2" } + },{ + id: 0, + data: { title: "Title 1", body: "Body 1" } + }]; + + const update = [{ + id: 0, + data: { title: "Foo 1", body: "Bar 1" } + },{ + id: 1, + data: { title: "Foo 2", body: "Bar 2" } + },{ + id: 2, + data: { title: "Foo 3", body: "Bar 3" } + }]; + + it("Should have been indexed properly", function(){ + + const document = new Document({ + document: { + id: "id", + field: [ + "data:title", + "data:body" + ] + } + }); + + const document_with_store = new Document({ + document: { + store: true, + id: "id", + field: [ + "data:title", + "data:body" + ] + } + }); + + for(let i = 0; i < data.length; i++){ + document.add(data[i]); + document_with_store.add(data[i]); + } + + expect(document.index.size).to.equal(2); + expect(document.reg.size).to.equal(3); + // Registry Sharing + expect(document.index.get("data:title").reg).to.equal(document.reg); + expect(document.index.get("data:title").reg).to.not.equal(document_with_store.reg); + + expect(document.search({ + query: "title" + })).to.eql([{ + field: "data:title", + result: [2, 1, 0] + }]); + + expect(document.search({ + query: "title", + field: "data:title" + })).to.eql([{ + field: "data:title", + result: [2, 1, 0] + }]); + + expect(document_with_store.search({ + query: "title", + pluck: "data:title", + enrich: true + }).map(res => res.doc)).to.eql(data); + + expect(document.search({ + field: "data:body", + query: "title" + })).to.have.lengthOf(0) + + expect(document.search({ + field: "data:title", + query: "body" + })).to.have.lengthOf(0); + + expect(document.search({ + field: "data:body", + query: "body" + })).to.eql([{ + field: "data:body", + result: [2, 1, 0] + }]); + + expect(document.search({ + field: ["data:title"], + query: "title" + })).to.eql([{ + field: "data:title", + result: [2, 1, 0] + }]); + + expect(document.search({ + field: ["data:title", "data:body"], + query: "body" + })).to.eql([{ + field: "data:body", + result: [2, 1, 0] + }]); + + expect(document.search({ + field: ["data:body", "data:title"], + query: "title" + })).to.eql([{ + field: "data:title", + result: [2, 1, 0] + }]); + + expect(document.search({ + field: ["data:title", "data:body"], + query: "body" + })).to.eql([{ + field: "data:body", + result: [2, 1, 0] + }]); + + expect(document.search({ + field: ["data:body", "data:title"], + query: "title" + })).to.eql([{ + field: "data:title", + result: [2, 1, 0] + }]); + + expect(document.search("body", { + field: "data:body" + })).to.eql([{ + field: "data:body", + result: [2, 1, 0] + }]); + + expect(document.search("title", { + field: ["data:title"] + })).to.eql([{ + field: "data:title", + result: [2, 1, 0] + }]); + + expect(document.search({ + query: "body" + })).to.eql([{ + field: "data:body", + result: [2, 1, 0] + }]); + + expect(document.search("title")).to.eql([{ + field: "data:title", + result: [2, 1, 0] + }]); + + expect(document.search([{ + field: "data:title", + query: "body" + },{ + field: "data:body", + query: "body" + }])).to.eql([{ + field: "data:body", + result: [2, 1, 0] + }]); + + // --------------------------------------- + + for(let i = 0; i < update.length; i++){ + document.add(update[i]); + document_with_store.add(update[i]); + } + + expect(document.search("foo")).to.eql([{ + field: "data:title", + result: [0, 1, 2] + }]); + + expect(document.search("bar")).to.eql([{ + field: "data:body", + result: [0, 1, 2] + }]); + + expect(document.search("foo bar", { suggest: true })).to.eql([{ + field: "data:title", + result: [0, 1, 2] + },{ + field: "data:body", + result: [0, 1, 2] + }]); + + expect(document.search("foo bar", { suggest: true, merge: true })).to.eql([ + { id: 0, field: [ 'data:title', 'data:body' ] }, + { id: 1, field: [ 'data:title', 'data:body' ] }, + { id: 2, field: [ 'data:title', 'data:body' ] } + ]); + + expect(document_with_store.search({ + query: "foo", + pluck: "data:title", + enrich: true + }).map(res => res.doc)).to.eql(update); + + expect(document_with_store.search({ + query: "bar", + pluck: "data:body", + enrich: true + }).map(res => res.doc)).to.eql(update); + + // --------------------------------------- + + for(let i = 0; i < update.length; i++){ + document.remove(update[i]); + document_with_store.remove(update[i]); + } + + expect(document.reg.size).to.equal(0); + expect(document.index.get("data:title").reg.size).to.equal(0); + expect(document.index.get("data:body").reg.size).to.equal(0); + expect(document.index.get("data:title").map.size).to.equal(0); + expect(document.index.get("data:body").map.size).to.equal(0); + expect(document_with_store.store.size).to.equal(0); + + expect(document_with_store.search({ + query: "foo", + })).to.eql([]); + + expect(document_with_store.search({ + query: "bar" + })).to.eql([]); + }); + + + it("Should have been unique results", function(){ + + const document = new Document({ + document: { + id: "id", + field: ["field1", "field2"] + } + }); + + const data = [{ + id: 1, + field1: "phrase", + field2: "phrase next" + },{ + id: 2, + field1: "phrase next", + field2: "phrase" + }]; + + for(let i = 0; i < data.length; i++){ + document.add(data[i]); + } + + expect(document.search("phrase")).to.eql([{ + field: "field1", + result: [1, 2] + },{ + field: "field2", + result: [1, 2] + }]); + + expect(document.search("phrase", { suggest: true })).to.eql([{ + field: "field1", + result: [1, 2] + },{ + field: "field2", + result: [1, 2] + }]); + }); + + it("Should have been sorted properly by number of field count matches", function(){ + + const document = new Document({ + document: { + id: "id", + field: ["field1", "field2"] + } + }); + + const data = [{ + id: 1, + field1: "phrase", + field2: "phrase next" + },{ + id: 2, + field1: "phrase next", + field2: "phrase" + }]; + + for(let i = 0; i < data.length; i++){ + document.add(data[i]); + } + + expect(document.search("phrase", { suggest: true, merge: true })).to.eql([ + { id: 1, field: [ 'field1', 'field2' ] }, + { id: 2, field: [ 'field1', 'field2' ] } + ]); + + expect(document.search("phrase next", { suggest: true, merge: true })).to.eql([ + { id: 2, field: [ 'field1', 'field2' ] }, + { id: 1, field: [ 'field1', 'field2' ] } + ]); + }); + + it("Should not have been shared the Encoder", function(){ + + const document = new Document({ + document: { + id: "id", + field: ["field1", "field2"] + } + }); + + expect(document.index.get("field1").encoder).not.to.equal( + document.index.get("field2").encoder + ); + }); + + it("Should have been shared the Encoder", function(){ + + const document = new Document({ + encoder: new Encoder(), + document: { + id: "id", + field: ["field1", "field2"] + } + }); + + expect(document.index.get("field1").encoder).to.equal( + document.index.get("field2").encoder + ); + }); + + it("Should have been applied limit/offset properly", function(){ + + const document = new Document({ + document: { + store: true, + id: "id", + field: [ + "data:title", + "data:body" + ] + } + }); + + for(let i = 0; i < data.length; i++){ + document.add(data[i]); + } + + expect(document.search({ + query: "title", + pluck: "data:title", + enrich: true, + suggest: true, + limit: 2 + }).map(res => res.doc)).to.eql([data[0], data[1]]); + + expect(document.search({ + query: "body", + pluck: "data:body", + enrich: true, + suggest: true, + limit: 1, + offset: 1 + }).map(res => res.doc)).to.eql([data[1]]); + + expect(document.search({ + query: "title", + suggest: true, + limit: 1, + offset: 3 + })).to.eql([]); + + expect(document.search({ + query: "title", + suggest: true, + offset: 3 + })).to.eql([]); + }); +}); diff --git a/test/document.tag.js b/test/document.tag.js new file mode 100644 index 0000000..ffad3fa --- /dev/null +++ b/test/document.tag.js @@ -0,0 +1,204 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +if(!build_light) describe("Documents: Tag-Search", function(){ + + const data = [{ + id: 2, + data: { title: "Title 3", body: "Body 3", cat: "A" } + },{ + id: 1, + data: { title: "Title 2", body: "Body 2", cat: "B" } + },{ + id: 0, + data: { title: "Title 1", body: "Body 1", cat: "A" } + }]; + + const update = [{ + id: 0, + data: { title: "Foo 1", body: "Bar 1", cat: "B" } + },{ + id: 1, + data: { title: "Foo 2", body: "Bar 2", cat: "A" } + },{ + id: 2, + data: { title: "Foo 3", body: "Bar 3", cat: "B" } + }]; + + it("Should have been indexed properly (tag)", function(){ + + const document = new Document({ + document: { + id: "id", + field: ["data:body", "data:title"], + tag: "data:cat" + } + }); + + const document_with_store = new Document({ + document: { + store: true, + id: "id", + field: ["data:body", "data:title"], + tag: "data:cat" + } + }); + + for(let i = 0; i < data.length; i++){ + document.add(data[i]); + document_with_store.add(data[i]); + } + + expect(document.index.size).to.equal(2); + expect(document.tag.size).to.equal(1); + expect(document.reg.size).to.equal(3); + expect(document_with_store.store.size).to.equal(3); + + expect(document.search({ + query: "title" + })).to.eql([{ + field: "data:title", + result: [2, 1, 0] + }]); + + expect(document.search({ + query: "title", + tag: { "data:cat": "A" } + })).to.eql([{ + field: "data:title", + result: [2, 0] + }]); + + expect(document.search({ + query: "body", + tag: { "data:cat": "B" } + })).to.eql([{ + field: "data:body", + result: [1] + }]); + + expect(document.search({ + query: "title", + tag: [ + { "data:cat": "A" }, + { "data:cat": "B" } + ] + })).to.eql([{ + field: "data:title", + result: [2, 1, 0] + }]); + + expect(document.search({ + query: "body title", + suggest: true, + tag: [ + { "data:cat": "A" }, + { "data:cat": "B" } + ] + })).to.eql([{ + field: "data:body", + result: [2, 1, 0] + },{ + field: "data:title", + result: [2, 1, 0] + }]); + + // todo suggestions should return all results like one below + expect(document.search({ + query: "body title", + suggest: true, + tag: [ + { "data:cat": "C" }, // not exists + { "data:cat": "B" } + ] + })).to.eql([{ + field: "data:body", + result: [1] + },{ + field: "data:title", + result: [1] + }]); + + // suggestions on + expect(document.search({ + query: "body title", + suggest: true, + tag: [ + { "data:cat": "C" } // not exists + ] + })).to.eql([{ + field: "data:body", + result: [2, 1, 0] + },{ + field: "data:title", + result: [2, 1, 0] + }]); + + // suggestions off + expect(document.search({ + query: "body title", + tag: [ + { "data:cat": "C" } // not exists + ] + })).to.eql([]); + + // --------------------------------------- + + for(let i = 0; i < update.length; i++){ + document.add(update[i]); + document_with_store.add(update[i]); + } + + expect(document.search("foo")).to.eql([{ + field: "data:title", + result: [0, 1, 2] + }]); + + expect(document.search({ + query: "foo", + tag: { "data:cat": "A" } + })).to.eql([{ + field: "data:title", + result: [1] + }]); + + expect(document.search({ + query: "bar", + tag: { "data:cat": "B" } + })).to.eql([{ + field: "data:body", + result: [0, 2] + }]); + + // --------------------------------------- + + for(let i = 0; i < update.length; i++){ + document.remove(update[i]); + document_with_store.remove(update[i]); + } + + expect(document.reg.size).to.equal(0); + expect(document.index.get("data:title").reg.size).to.equal(0); + expect(document.index.get("data:body").reg.size).to.equal(0); + expect(document.index.get("data:title").map.size).to.equal(0); + expect(document.index.get("data:body").map.size).to.equal(0); + expect(document_with_store.store.size).to.equal(0); + + expect(document_with_store.search({ + query: "foo", + })).to.eql([]); + + expect(document_with_store.search({ + query: "bar" + })).to.eql([]); + }); +}); diff --git a/test/encoder.js b/test/encoder.js new file mode 100644 index 0000000..949a760 --- /dev/null +++ b/test/encoder.js @@ -0,0 +1,338 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +describe("Encoder", function(){ + + it("Should have been properly added a custom encoder", function(){ + + const encode = str => str.toLowerCase().split(/\s+/); + const index = new Index({ encoder: encode }); + expect(index.encoder.encode).to.eql(encode); + }); + + it("Should have been properly added a custom encode (alternative)", function(){ + + const encode = str => str.toLowerCase().split(/\s+/); + const index = new Index({ encode }); + expect(index.encoder.encode).to.eql(encode); + }); +}); + +describe("Encoder: Latin Charset", function(){ + + it("Should have been encoded properly: LatinDefault", function(){ + + const index = new Index({ encoder: Charset.LatinDefault }); + expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql(["björn", "phillipp", "mayer"]); + }); + + if(env !== "light"){ + + it("Should have been encoded properly: LatinExact", function(){ + + const index = new Index({ encoder: Charset.LatinExact }); + expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql(["Björn-Phillipp", "Mayer"]); + }); + + it("Should have been encoded properly: LatinSimple", function(){ + + const index = new Index({ encoder: Charset.LatinSimple }); + expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql(index.encoder.encode("bjorn/phillipp mayer")); + }); + + it("Should have been encoded properly: LatinBalance", function(){ + + const index = new Index({ encoder: Charset.LatinBalance }); + expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql(index.encoder.encode("bjorn philip mair")); + }); + + it("Should have been encoded properly: LatinAdvanced", function(){ + + const index = new Index({ encoder: Charset.LatinAdvanced }); + expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql(index.encoder.encode("bjoern filip mair")); + }); + + it("Should have been encoded properly: LatinExtra", function(){ + + const index = new Index({ encoder: Charset.LatinExtra }); + expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql(index.encoder.encode("bjorm filib mayr")); + }); + + it("Should have been encoded properly: LatinSoundex", function(){ + + const index = new Index({ encoder: Charset.LatinSoundex }); + expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql(index.encoder.encode("bjoernsen philippo mayr")); + }); + } + + it("Should have been encoded properly: Custom Encoder", function(){ + + function test_encoder(str){ + return "-[" + str.toUpperCase() + "]-"; + } + + const index = new Index({ encoder: test_encoder }); + expect(index.encoder.encode("Björn-Phillipp Mayer")).to.eql("-[BJÖRN-PHILLIPP MAYER]-"); + }); +}); + +describe("Encoder: CJK Word Break", function(){ + + it("Should have been tokenized properly", function(){ + + const index = Index({ + encoder: Charset.CjkDefault, + tokenize: "forward" + }); + + index.add(0, "서울시가 잠이 든 시간에 아무 말, 미뤄, 미뤄"); + expect(index.search("든")).to.include(0); + expect(index.search("시간에")).to.include(0); + + index.add(1, "一个单词"); + expect(index.search("一个")).to.include(1); + }); +}); + +describe("Encoder: Cyrillic Word Break", function(){ + + it("Should have been tokenized properly", function(){ + + const index = Index({ + encoder: Charset.CyrillicDefault, + tokenize: "forward" + }); + + index.add(0, "Фообар"); + expect(index.search("Фообар")).to.include(0); + expect(index.search("Фоо")).to.include(0); + }); +}); + +describe("Encoder: Arabic Word Break", function(){ + + it("Should have been tokenized properly", function(){ + + let index = Index({ + encoder: Charset.ArabicDefault, + tokenize: "forward" + }); + + index.add(0, "لكن لا بد أن أوضح لك أن كل"); + expect(index.search("بد أن")).to.include(0); + expect(index.search("أو")).to.include(0); + index = Index({ + encoder: Charset.ArabicDefault, + tokenize: "reverse" + }); + + index.add(0, "لكن لا بد أن أوضح لك أن كل"); + expect(index.search("ضح")).to.include(0); + }); +}); + +describe("Encoder: Right-to-Left", function(){ + + it("Should have been scored properly", function(){ + + let index = new Index({ + tokenize: "forward", + rtl: true + }); + + index.add(0, "54321 4 3 2 0"); + index.add(1, "0 2 3 4 54321"); + index.add(2, "0 2 3 4 12345"); + + expect(index.search("5")).to.eql([2]); + expect(index.search("1")).to.eql([1, 0]); + + index = new Index({ + tokenize: "reverse", + rtl: true + }); + + index.add(0, "54321 4 3 2 1 0"); + index.add(1, "0 1 2 3 4 54321"); + index.add(2, "0 1 2 3 4 12345"); + + expect(index.search("5")).to.eql([2, 1, 0]); + }); +}); + +describe("Filter", function(){ + + it("Should have been filtered properly", function(){ + + let encoder = new Encoder({ + filter: ["in", "the"] + }); + let index = new Index({ + tokenize: "strict", + encoder: encoder + }); + + index.add(0, "Today in the morning."); + + expect(index.search("today in the morning.")).to.include(0); + expect(index.search("today morning")).to.include(0); + expect(index.search("in the")).to.have.length(0); + + index = new Index({ + tokenize: "strict", + encoder: encoder, + context: true + }); + + index.add(0, "Today in the morning."); + expect(index.search("today morning")).to.include(0); + + encoder = new Encoder(); + encoder.addFilter("in"); + index = new Index({ + tokenize: "strict", + encoder: encoder + }); + index.encoder.addFilter("the"); + + index.add(0, "Today in the morning."); + expect(index.search("in the")).to.have.length(0); + }); + + it("Should have been filtered properly (custom function)", function(){ + + const encoder = new Encoder({ + filter: ["in", "the"], + finalize: function(word){ + return word.filter(t => t.length > 3); + } + }); + const index = new Index({ + tokenize: "strict", + encoder: encoder + }); + + index.add(0, "Today in the morning."); + + expect(index.search("today in the morning.")).to.include(0); + expect(index.search("today morning")).to.include(0); + expect(index.search("in the")).to.have.length(0); + }); + + it("Should have been filtered properly (minlength)", function(){ + + const encoder = new Encoder({ + filter: ["in", "the"], + minlength: 4 + }); + const index = new Index({ + tokenize: "strict", + encoder: encoder + }); + + index.add(0, "Today in the morning."); + + expect(index.search("today in the morning.")).to.include(0); + expect(index.search("today morning")).to.include(0); + expect(index.search("in the")).to.have.length(0); + }); +}); + +describe("Stemmer", function(){ + + it("Should have been stemmed properly", function(){ + + const encoder = new Encoder({ + stemmer: new Map([ + ["ization", "ize"], + ["tional", "tion"] + ]) + }); + const index = new Index({ + tokenize: "strict", + encoder: encoder + }); + + index.add(0, "Just a multinational colonization."); + + expect(index.search("Just a multinational colonization.")).to.include(0); + expect(index.search("multinational colonization")).to.include(0); + expect(index.search("tional tion")).to.have.length(0); + }); + +// it("Should have been stemmed properly (custom function)", function(){ +// +// var stems = { +// "ization": "ize", +// "tional": "tion" +// }; +// +// var index = new FlexSearch({ +// tokenize: "strict", +// stemmer: function(word){ +// return stems[word] || word; +// } +// }); +// +// index.add(0, "Just a multinational colonization."); +// +// expect(index.length).to.equal(1); +// expect(index.search("Just a multinational colonization.")).to.include(0); +// expect(index.search("multinational colonization")).to.include(0); +// expect(index.search("tional tion")).to.have.length(0); +// }); +// }); +// +// +// describe("Custom Language", function(){ +// +// it("Should have been applied properly", function(){ +// +// var index = new FlexSearch({ +// tokenize: "reverse", +// filter: ["a", "an"], +// stemmer: { +// "ization": "ize", +// "tional": "tion" +// } +// }); +// +// index.add(0, "Just a multinational colonization."); +// +// expect(index.length).to.equal(1); +// expect(index.search("Just a multinational colonization.")).to.include(0); +// expect(index.search("Just an multinational colonization.")).to.include(0); +// expect(index.search("multinational colonization")).to.include(0); +// expect(index.search("tional tion")).to.have.length(0); +// +// FlexSearch.registerLanguage("custom", { +// filter: ["a", "an"], +// stemmer: { +// "ization": "ize", +// "tional": "tion" +// } +// }); +// +// index = new FlexSearch({ +// tokenize: "reverse", +// lang: "custom" +// }); +// +// index.add(0, "Just a multinational colonization."); +// +// expect(index.length).to.equal(1); +// expect(index.search("Just a multinational colonization.")).to.include(0); +// expect(index.search("Just an multinational colonization.")).to.include(0); +// expect(index.search("multinational colonization")).to.include(0); +// expect(index.search("tional tion")).to.have.length(0); +// }); +}); diff --git a/test/issues.js b/test/issues.js new file mode 100644 index 0000000..65e14b7 --- /dev/null +++ b/test/issues.js @@ -0,0 +1,90 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +describe("Github Issues", function(){ + + if(!build_light && !build_compact) it("#48", async function(){ + + const fs = await new Document({ + encoder: Charset.LatinExtra, + resolution: 9, + context: { + depth: 4 + }, + worker: true, + cache: true, + doc: { + id: "id", + field: [ "intent", "text" ] + } + }); + + const doc = [{ + id: 0, + intent: "intent", + text: "text" + },{ + id: 1, + intent: "intent", + text: "howdy - how are you doing" + }]; + + for(let i = 0; i < doc.length; i++){ + await fs.add(doc[i]); + } + + expect(await fs.search("howdy")).to.eql([{ + field: "text", + result: [1] + }]); + expect(await fs.search("howdy -")).to.eql([{ + field: "text", + result: [1] + }]); + + // terminate workers + fs.index.get("intent").worker.terminate(); + fs.index.get("text").worker.terminate(); + }); + + if(!build_light) it("#54", function(){ + + const index = new Document({ + doc: { + id: "id", + field: ["title", "content"] + } + }); + + const docs = [{ + id: 1, + title: "Roaming Inquiry", + content: "Some content" + }, { + id: 2, + title: "New Service", + content: "This is not roaming-inquiry" + }]; + + for(let i = 0; i < docs.length; i++){ + index.add(docs[i]); + } + + expect(index.search("roaming")).to.eql([{ + field: "title", + result: [1] + },{ + field: "content", + result: [2] + }]); + }); +}); diff --git a/test/misc/reporter.js b/test/misc/reporter.js new file mode 100644 index 0000000..67a623b --- /dev/null +++ b/test/misc/reporter.js @@ -0,0 +1,21 @@ +const libCoverage = require('istanbul-lib-coverage'); +const { createReporter } = require('istanbul-api'); + +const coverage_1 = require('./.nyc_output/coverage.json'); +const coverage_2 = require('./.nyc_output/coverage2.json'); + +const normalizeJestCoverage = (obj) => { + const result = obj; + Object.entries(result).forEach(([k, v]) => { + if (v.data) result[k] = v.data; + }); + return result; +}; + +const map = libCoverage.createCoverageMap(); +map.merge(normalizeJestCoverage(coverage_1)); +map.merge(normalizeJestCoverage(coverage_2)); + +const reporter = createReporter(); +reporter.addAll(['html', 'json', 'lcov', 'text']); +reporter.write(map); \ No newline at end of file diff --git a/test/misc/runner.js b/test/misc/runner.js new file mode 100644 index 0000000..e69de29 diff --git a/test/persistent.js b/test/persistent.js new file mode 100644 index 0000000..9b174e8 --- /dev/null +++ b/test/persistent.js @@ -0,0 +1,11 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; diff --git a/test/resolver.js b/test/resolver.js new file mode 100644 index 0000000..23b0f6d --- /dev/null +++ b/test/resolver.js @@ -0,0 +1,431 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +if(!build_light && !build_compact) describe("Resolver", function(){ + + it("Should have been created a Resolver properly", function(){ + + const index = new Index({ tokenize: "reverse" }); + index.add(1, "foo"); + index.add(2, "bar"); + index.add(3, "FooBar"); + + let resolver = index.search("foo bar", { resolve: false, suggest: true }); + + expect(resolver).to.be.instanceof(Resolver); + expect(resolver).to.respondTo("and"); + expect(resolver).to.respondTo("or"); + expect(resolver).to.respondTo("xor"); + expect(resolver).to.respondTo("not"); + expect(resolver).to.respondTo("boost"); + expect(resolver).to.respondTo("limit"); + expect(resolver).to.respondTo("offset"); + expect(resolver).to.respondTo("resolve"); + + expect(resolver.result).to.eql([[3, 1, 2]]); + }); + + it("Should have been created a Resolver properly (alternative)", function(){ + + const index = new Index({ tokenize: "reverse" }); + index.add(1, "foo"); + index.add(2, "bar"); + index.add(3, "FooBar"); + + let resolver = new Resolver({ + index: index, + query: "foo bar", + suggest: true + }); + + expect(resolver).to.be.instanceof(Resolver); + expect(resolver.result).to.eql([[3, 1, 2]]); + }); + + it("Should have been resolved a Resolver properly", function(){ + + const index = new Index({ tokenize: "reverse" }); + index.add(1, "foo"); + index.add(2, "bar"); + index.add(3, "FooBar"); + + let result = new Resolver({ + index: index, + query: "foo bar", + suggest: true + }).resolve(); + + expect(result.length).to.equal(3); + expect(result).to.eql([3, 1, 2]); + + result = new Resolver({ + index: index, + query: "foo bar", + suggest: true + }).resolve({ + limit: 1, + offset: 1 + }); + + expect(result.length).to.equal(1); + expect(result).to.eql([1]); + + result = new Resolver({ + index: index, + query: "bar", + suggest: true + }).and({ + index: index, + query: "foo", + suggest: true, + resolve: true + }); + + expect(result.length).to.equal(3); + expect(result).to.eql([3, 2, 1]); + }); + + it("Should have been apply \"and\" properly", function(){ + + const index = new Index({ tokenize: "forward" }); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', // <-- dogs + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let resolver = new Resolver({ + index: index, + query: "cat" + }); + + expect(resolver.result).to.eql([[0, 1, 2, 3, 4, 5, 6]]); + + resolver = resolver.and({ + index: index, + query: "cute" + }); + + expect(resolver.result).to.eql([ + void 0, + [6], + [5], + [4], + [3], + [2], + [1], + [0] + ]); + + resolver = resolver.and({ + index: index, + query: "dog" + }); + + expect(resolver.result).to.eql([ + void 0, + void 0, + void 0, + void 0, + void 0, + void 0, + [1] + ]); + + resolver = resolver.and({ + index: index, + query: "fish", + suggest: true + }); + + expect(resolver.result).to.eql([ + void 0, + void 0, + void 0, + void 0, + void 0, + void 0, + [1] + ]); + + resolver = resolver.and({ + index: index, + query: "bird" + }); + + expect(resolver.result).to.eql([]); + + resolver = resolver.and({ + index: index, + query: "dog", + suggest: true + }); + + expect(resolver.result).to.eql([ + void 0, + void 0, + void 0, + void 0, + void 0, + [1] + ]); + }); + + it("Should have been apply \"or\" properly", function(){ + + const index = new Index({ tokenize: "forward" }); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', // <-- dogs + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let resolver = new Resolver({ + index: index, + query: "cat" + }).or({ + index: index, + query: "cute" + }); + + expect(resolver.result).to.eql([[0, 1, 2, 3, 4, 5, 6]]); + + // todo + // resolver = resolver.or([{ + // index: index, + // query: "fish" + // },{ + // index: index, + // query: "dog" + // },{ + // index: index, + // query: "horse" + // }]); + + resolver = resolver.or({ + index: index, + query: "fish" + }).or({ + index: index, + query: "dog" + }).or({ + index: index, + query: "horse" + }).or({ + index: index, + query: "dog" + }).or({ + index: index, + query: "horse" + }) + // todo + /*.or({ + and: [{ + index: index, + query: "dog" + },{ + index: index, + query: "cute" + }] + })*/; + + expect(resolver.result).to.eql([[0, 1, 2, 3, 4, 5, 6]]); + }); + + it("Should have been apply \"xor\" properly", function(){ + + const index = new Index(); + index.add(1, "foo foo"); + index.add(2, "bar bar"); + index.add(3, "foo bar"); + index.add(4, "bar foo"); + + let resolver = new Resolver({ + index: index, + query: "foo" + }).xor({ + index: index, + query: "bar" + }); + + expect(resolver.result).to.eql([[1, 2]]); + + }); + + it("Should have been apply \"not\" properly", function(){ + + const index = new Index({ tokenize: "forward" }); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', // <-- dogs + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let resolver = new Resolver({ + index: index, + query: "cute" + }).not({ + index: index, + query: "cat" + }); + + expect(resolver.result).to.eql([]); + + resolver = new Resolver({ + index: index, + query: "cute" + }).not({ + index: index, + query: "dog" + }); + + expect(resolver.result).to.eql([ + void 0, + [6], + [5], + [4], + [3], + [2], + void 0, // dogs + [0] + ]); + + }); + + it("Should have been apply \"limit\" and \"offset\" properly", function(){ + + const index = new Index({ tokenize: "forward" }); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', // <-- dogs + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let resolver = new Resolver({ + index: index, + query: "cute" + }).limit(3); + + expect(resolver.result).to.eql([ + void 0, + [6], + [5], + [4] + ]); + + resolver = new Resolver({ + index: index, + query: "cute" + }).offset(3).limit(2); + + expect(resolver.result).to.eql([ + void 0, + void 0, // offset +1 + void 0, // offset +2 + void 0, // offset +3 + [3], + [2] + ]); + }); + + it("Should have been apply \"boost\" properly", function(){ + + const index = new Index({ tokenize: "forward" }); + [ 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', // <-- dogs + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ].forEach((item, id) => { + index.add(id, item); + }); + + let resolver = new Resolver({ + index: index, + query: "dog" + }).boost(0).or({ + index: index, + query: "cat" + }); + + expect(resolver.result).to.eql([ + [ 0, 2, 3, 4, 5, 6 ], + void 0, + [ 1 ] + ]); + + resolver = new Resolver({ + index: index, + query: "dog" + }).boost(1).or({ + index: index, + query: "cat" + }); + + expect(resolver.result).to.eql([ + void 0, + [ 0, 2, 3, 4, 5, 6 ], + [ 1 ] + ]); + + resolver = new Resolver({ + index: index, + query: "dog" + }).boost(2).or({ + index: index, + query: "cat" + }); + + expect(resolver.result).to.eql([ + void 0, + void 0, + [ 1, 0, 2, 3, 4, 5, 6 ] + ]); + + resolver = new Resolver({ + index: index, + query: "dog" + }).boost(3).or({ + index: index, + query: "cat" + }); + + expect(resolver.result).to.eql([ + void 0, + void 0, + [ 1 ], + [ 0, 2, 3, 4, 5, 6 ] + ]); + }); +}); diff --git a/test/scoring.js b/test/scoring.js new file mode 100644 index 0000000..6562878 --- /dev/null +++ b/test/scoring.js @@ -0,0 +1,118 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +describe("Scoring", function(){ + + it("Should have been sorted by relevance properly", function(){ + + let index = new Index({ + tokenize: "strict", + resolution: 10 + }); + + index.add(0, "1 2 3 2 4 1 5 3"); + index.add(1, "zero one two three four five six seven eight nine ten"); + index.add(2, "four two zero one three ten five seven eight six nine"); + + expect(index.search("1")).to.eql([0]); + expect(index.search("one")).to.eql([1, 2]); + expect(index.search("one two")).to.eql([1, 2]); + expect(index.search("four one")).to.eql([2, 1]); + + index = new Index({ + tokenize: "strict", + context: { + depth: 3, + bidirectional: false + } + }); + + index.add(0, "1 2 3 2 4 1 5 3"); + index.add(1, "zero one two three four five six seven eight nine ten"); + index.add(2, "four two zero one three ten five seven eight six nine"); + + expect(index.search("1")).to.eql([0]); + expect(index.search("one")).to.eql([1, 2]); + expect(index.search("one two")).to.eql([2]); // 1: no bi-directional + expect(index.search("four one")).to.eql([1]); // 2: no bi-directional + + index = new Index({ + tokenize: "strict", + context: { + depth: 3, + bidirectional: true + } + }); + + index.add(0, "1 2 3 2 4 1 5 3"); + index.add(1, "zero one two three four five six seven eight nine ten"); + index.add(2, "five two zero one three four ten seven eight six nine"); + + expect(index.search("1 3 4")).to.eql([0]); + expect(index.search("1 5 3 4")).to.eql([0]); + expect(index.search("1 3 4 7")).to.have.lengthOf(0); + expect(index.search("one")).to.eql([1, 2]); + expect(index.search("one three")).to.eql([1, 2]); + expect(index.search("three one")).to.eql([1, 2]); + expect(index.search("zero five one ten")).to.eql([2]); + expect(index.search("zero two one three two five")).to.eql([1]); + expect(index.search("one zero two one zero three")).to.eql([1, 2]); + // todo context chain + //expect(index.search("zero two one three two five")).to.eql([1, 2]); + }); +}); + +describe("Suggestions", function(){ + + it("Should have been suggested properly by relevance", function(){ + + let index = new Index({ tokenize: "strict" }); + + index.add(0, "1 2 3 2 4 1 5 3"); + index.add(1, "zero one two three four five six seven eight nine ten"); + index.add(2, "four two zero one three ten five seven eight six nine"); + + expect(index.search("1 3 4 7", { suggest: false })).to.have.lengthOf(0); + expect(index.search("1 3 4 7", { suggest: true })).to.eql([0]); + expect(index.search("1 3 9 7", { suggest: true })).to.eql([0]); + + expect(index.search("foobar one two", { suggest: true })).to.eql([1, 2]); + expect(index.search("foobar one four", { suggest: true })).to.eql([2, 1]); + expect(index.search("one foobar two", { suggest: true })).to.eql([1, 2]); + expect(index.search("one two foobar", { suggest: true })).to.eql([1, 2]); + expect(index.search("zero one foobar two foobar", { suggest: true })).to.eql([1, 2]); + }); + + it("Should have been suggested properly by context", function(){ + + let index = new Index({ + tokenize: "strict", + context: { + depth: 3, + bidirectional: true + } + }); + + index.add(1, "zero one two three four five six seven eight nine ten"); + index.add(2, "four two zero one three ten five seven eight six nine"); + + expect(index.search("foobar one", { suggest: true })).to.eql([1, 2]); + expect(index.search("foobar two", { suggest: true })).to.eql([2, 1]); + expect(index.search("foobar foobar foobar one foobar two foobar foobar", { suggest: true })).to.eql([1, 2]); + expect(index.search("foobar foobar foobar two foobar one foobar foobar", { suggest: true })).to.eql([1, 2]); + expect(index.search("foobar one two", { suggest: true })).to.eql([1, 2]); + expect(index.search("one foobar two", { suggest: true })).to.eql([1, 2]); + expect(index.search("one two foobar", { suggest: true })).to.eql([1, 2]); + expect(index.search("foobar one foobar two foobar", { suggest: true })).to.eql([1, 2]); + expect(index.search("zero one foobar two foobar", { suggest: true })).to.eql([1, 2]); + }); +}); diff --git a/test/serialize.js b/test/serialize.js new file mode 100644 index 0000000..9b174e8 --- /dev/null +++ b/test/serialize.js @@ -0,0 +1,11 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; diff --git a/test/tokenize.js b/test/tokenize.js new file mode 100644 index 0000000..4b47715 --- /dev/null +++ b/test/tokenize.js @@ -0,0 +1,57 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +describe("Tokenizer", function(){ + + it("Should have been added properly to the index: Strict", function(){ + + let index = new Index(/*{ tokenize: "strict" }*/); + index.add(0, "björn phillipp mayer"); + + expect(index.search("björn phillipp")).to.include(0); + expect(index.search("björn mayer")).to.include(0); + + index = new Index({ tokenize: "strict" }); + index.add(0, "björn phillipp mayer"); + + expect(index.search("björn phillipp")).to.include(0); + expect(index.search("björn mayer")).to.include(0); + }); + + it("Should have been added properly to the index: Forward", function(){ + + let index = new Index({ tokenize: "forward" }); + index.add(0, "björn phillipp mayer"); + + expect(index.search("bjö phil may")).to.have.lengthOf(1); + expect(index.search("bjö phil may")).to.include(0); + }); + + it("Should have been added properly to the index: Reverse", function(){ + + let index = new Index({ tokenize: "reverse" }); + index.add(0, "björn phillipp mayer"); + + expect(index.search("jörn phil er")).to.have.lengthOf(1); + expect(index.search("jörn lipp er")).to.have.lengthOf(1); + expect(index.search("jörn lipp er")).to.include(0); + }); + + it("Should have been added properly to the index: Full", function(){ + + let index = new Index({ tokenize: "full" }); + index.add(0, "björn phillipp mayer"); + + expect(index.search("jör illi may")).to.have.lengthOf(1); + expect(index.search("jör illi may")).to.include(0); + }); +}); diff --git a/test/worker.js b/test/worker.js new file mode 100644 index 0000000..ac5e30d --- /dev/null +++ b/test/worker.js @@ -0,0 +1,102 @@ +global.self = global; +const env = process.argv[3]; +import { expect } from "chai"; +let FlexSearch = await import(env ? "../dist/" + env + ".js" : "../src/bundle.js"); +if(FlexSearch.default) FlexSearch = FlexSearch.default; +if(FlexSearch.FlexSearch) FlexSearch = FlexSearch.FlexSearch; +const { Index, Document, Worker: WorkerIndex, Charset: _Charset, Encoder, Resolver } = FlexSearch; +const build_light = env && env.includes(".light"); +const build_compact = env && env.includes(".compact"); +const build_esm = !env || env.startsWith("module"); +const Charset = _Charset || (await import("../src/charset.js")).default; + +if(!build_light && !build_compact) describe("Worker", function(){ + + let index; + + afterEach(function() { + index && index.worker.terminate(); + }); + + it("Should have the proper basic functionality", async function(){ + + index = await new WorkerIndex({ + encoder: "LatinAdvanced", + tokenize: "forward" + }); + + const data = [ + 'cats abcd efgh ijkl mnop qrst uvwx cute', + 'cats abcd efgh ijkl mnop dogs cute', + 'cats abcd efgh ijkl mnop cute', + 'cats abcd efgh ijkl cute', + 'cats abcd efgh cute', + 'cats abcd cute', + 'cats cute' + ]; + + for(let i = 0; i < data.length; i++){ + await index.addAsync(i, data[i]); + } + + expect(index.reg).to.be.undefined; + expect(index.map).to.be.undefined; + + let result = await index.search("cat cute"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = await index.search("cute cat"); + expect(result).to.eql([6, 5, 4, 3, 2, 1, 0]); + + result = await index.search("cudi tok-kat"); + expect(result).to.eql([1]); + }); + + it("Should update the index contents properly", async function(){ + + index = await new WorkerIndex({ tokenize: "full" }); + + await index.add(1, "foo"); + await index.add(2, "bar"); + await index.add(3, "foobar"); + + await index.update(1, "bar"); + await index.update(2, "foobar"); + await index.update(3, "foo"); + + expect(await index.search("foo")).to.have.members([2, 3]); + expect(await index.search("bar")).to.have.members([1, 2]); + expect(await index.search("bar")).to.not.include(3); + expect(await index.search("foobar")).to.have.members([2]); + expect(await index.search("oba")).to.have.members([2]); + + await index.update(1, "bar"); + await index.update(2, "foobar"); + await index.update(3, "foo"); + + expect(await index.search("foo")).to.have.members([2, 3]); + expect(await index.search("bar")).to.have.members([1, 2]); + expect(await index.search("bar")).to.not.include(3); + expect(await index.search("foobar")).to.have.members([2]); + expect(await index.search("oba")).to.have.members([2]); + }); + + it("Should have been removed from the index", async function(){ + + index = await new WorkerIndex({ tokenize: "full" }); + await index.add(1, "bar"); + await index.add(2, "foobar"); + await index.add(3, "foo"); + + await index.remove(2); + await index.remove(1); + await index.remove(3); + await index.remove(4); + + expect(await index.search("foo")).to.have.lengthOf(0); + expect(await index.search("bar")).to.have.lengthOf(0); + expect(await index.search("foobar")).to.have.lengthOf(0); + }); +}); + +