=m.length){d-=m.length;continue}const p=c?d+Math.min(m.length-d,c):m.length;for(let n=d;n=f.length)return[];if(!b&&!c)return f;f=f.slice(c,c+b);return d?e.enrich(f):f})};
+v.enrich=function(a){"object"!==typeof a&&(a=[a]);const b=this.db.transaction("reg","readonly").objectStore("reg"),c=[];for(let d=0;d{e.onerror=h=>{this.h[a+":"+b]=null;e.abort();e=d=null;g(h)};e.oncomplete=h=>{e=d=this.h[a+":"+b]=null;f(h||!0)};return c.call(this,d)})};
+v.commit=async function(a,b,c){if(b)await this.clear(),a.commit_task=[];else{let d=a.commit_task;a.commit_task=[];for(let e=0,f;em&&!f&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(f=1),0<=m)if(e=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};export default {Index:K,Charset:Ma,Encoder:I,Document:T,Worker:N,Resolver:X,IndexedDB:cb,Language:{}};
-export const Index=K;export const Charset=Ma;export const Encoder=I;export const Document=T;export const Worker=N;export const Resolver=X;export const IndexedDB=cb;export const Language={};
\ No newline at end of file
+function db(a,b,c){const d=a.value;let e,f,g=0;for(let h=0,k;hm&&!f&&"string"===typeof p&&!isNaN(p)&&(m=k.indexOf(parseInt(p,10)))&&(f=1),0<=m)if(e=1,1{a.onsuccess=function(){b(this.result)};a.oncomplete=function(){b(this.result)};a.onerror=c;a=null})};export default {Index:L,Charset:Ma,Encoder:K,Document:T,Worker:N,Resolver:X,IndexedDB:cb,Language:{}};
+export const Index=L;export const Charset=Ma;export const Encoder=K;export const Document=T;export const Worker=N;export const Resolver=X;export const IndexedDB=cb;export const Language={};
\ No newline at end of file
diff --git a/dist/flexsearch.compact.debug.js b/dist/flexsearch.compact.debug.js
index 83b03bc..4f6ce03 100644
--- a/dist/flexsearch.compact.debug.js
+++ b/dist/flexsearch.compact.debug.js
@@ -6,8 +6,8 @@
* https://github.com/nextapps-de/flexsearch
*/
(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;
-var v;
-function y(a, c, b) {
+var x;
+function B(a, c, b) {
const e = typeof b, d = typeof a;
if ("undefined" !== e) {
if ("undefined" !== d) {
@@ -44,20 +44,20 @@ function y(a, c, b) {
}
return "undefined" === d ? c : a;
}
-function z() {
+function C() {
return Object.create(null);
}
function aa(a, c) {
return c.length - a.length;
}
-function A(a) {
+function D(a) {
return "string" === typeof a;
}
-function F(a) {
+function H(a) {
return "object" === typeof a;
}
-function G(a, c) {
- if (A(c)) {
+function I(a, c) {
+ if (D(c)) {
a = a[c];
} else {
for (let b = 0; a && b < c.length; b++) {
@@ -75,16 +75,16 @@ function G(a, c) {
"\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, J = "".normalize && /[\u0300-\u036f]/g;
-function K(a) {
+function L(a) {
if (!this) {
- return new K(...arguments);
+ return new L(...arguments);
}
for (let c = 0; c < arguments.length; c++) {
this.assign(arguments[c]);
}
}
-K.prototype.assign = function(a) {
- this.normalize = y(a.normalize, !0, this.normalize);
+L.prototype.assign = function(a) {
+ this.normalize = B(a.normalize, !0, this.normalize);
let c = a.include, b = c || a.exclude || a.split;
if ("object" === typeof b) {
let e = !c, d = "";
@@ -105,25 +105,25 @@ K.prototype.assign = function(a) {
this.numeric = e;
} else {
try {
- this.split = y(b, ca, this.split);
+ this.split = B(b, ca, this.split);
} catch (e) {
this.split = /\s+/;
}
- this.numeric = y(this.numeric, !0);
+ this.numeric = B(this.numeric, !0);
}
- this.prepare = y(a.prepare, null, this.prepare);
- this.finalize = y(a.finalize, null, this.finalize);
+ this.prepare = B(a.prepare, null, this.prepare);
+ this.finalize = B(a.finalize, null, this.finalize);
J || (this.mapper = new Map(ba));
this.rtl = a.rtl || !1;
- this.dedupe = y(a.dedupe, !0, this.dedupe);
- this.filter = y((b = a.filter) && new Set(b), null, this.filter);
- this.matcher = y((b = a.matcher) && new Map(b), null, this.matcher);
- this.mapper = y((b = a.mapper) && new Map(b), null, this.mapper);
- this.stemmer = y((b = a.stemmer) && new Map(b), null, this.stemmer);
- this.replacer = y(a.replacer, null, this.replacer);
- this.minlength = y(a.minlength, 1, this.minlength);
- this.maxlength = y(a.maxlength, 0, this.maxlength);
- if (this.cache = b = y(a.cache, !0, this.cache)) {
+ this.dedupe = B(a.dedupe, !0, 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.J = null, this.O = "number" === typeof b ? b : 2e5, this.F = new Map(), this.H = new Map(), this.D = this.h = 128;
}
this.K = "";
@@ -142,7 +142,7 @@ K.prototype.assign = function(a) {
}
return this;
};
-K.prototype.encode = function(a) {
+L.prototype.encode = function(a) {
if (this.cache && a.length <= this.h) {
if (this.J) {
if (this.F.has(a)) {
@@ -211,13 +211,13 @@ function ha(a) {
a.H.clear();
}
;function ia(a) {
- L.call(a, "add");
- L.call(a, "append");
- L.call(a, "search");
- L.call(a, "update");
- L.call(a, "remove");
+ M.call(a, "add");
+ M.call(a, "append");
+ M.call(a, "search");
+ M.call(a, "update");
+ M.call(a, "remove");
}
-function L(a) {
+function M(a) {
this[a + "Async"] = function() {
var c = arguments;
const b = c[c.length - 1];
@@ -233,8 +233,8 @@ function L(a) {
c.export(a, c, b, d, f + 1, h);
}) : c.export(a, c, b, d, f + 1, h);
}
-;M.prototype.add = function(a, c, b) {
- F(a) && (c = a, a = G(c, this.key));
+;N.prototype.add = function(a, c, b) {
+ H(a) && (c = a, a = I(c, this.key));
if (c && (a || 0 === a)) {
if (!b && this.reg.has(a)) {
return this.update(a, c);
@@ -247,7 +247,7 @@ function L(a) {
d && e.add(a, d, !1, !0);
} else {
if (d = k.G, !d || d(c)) {
- k.constructor === String ? k = ["" + k] : A(k) && (k = [k]), N(c, k, this.I, 0, e, a, k[0], b);
+ k.constructor === String ? k = ["" + k] : D(k) && (k = [k]), O(c, k, this.I, 0, e, a, k[0], b);
}
}
}
@@ -255,7 +255,7 @@ function L(a) {
for (e = 0; e < this.B.length; e++) {
var f = this.B[e], g = this.R[e];
d = this.tag.get(g);
- let h = z();
+ let h = C();
if ("function" === typeof f) {
if (f = f(c), !f) {
continue;
@@ -266,10 +266,10 @@ function L(a) {
continue;
}
f.constructor === String && (f = "" + f);
- f = G(c, f);
+ f = I(c, f);
}
if (d && f) {
- A(f) && (f = [f]);
+ D(f) && (f = [f]);
for (let k = 0, l, m; k < f.length; k++) {
l = f[k], h[l] || (h[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), b && m.includes(a) || (m.push(a), this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m]))));
}
@@ -281,7 +281,7 @@ function L(a) {
if (this.store && (!b || !this.store.has(a))) {
let h;
if (this.A) {
- h = z();
+ h = C();
for (let k = 0, l; k < this.A.length; k++) {
l = this.A[k];
if ((b = l.G) && !b(c)) {
@@ -294,11 +294,11 @@ function L(a) {
continue;
}
l = [l.S];
- } else if (A(l) || l.constructor === String) {
+ } else if (D(l) || l.constructor === String) {
h[l] = c[l];
continue;
}
- O(c, h, l, 0, l[0], m);
+ P(c, h, l, 0, l[0], m);
}
}
this.store.set(a, h || c);
@@ -306,21 +306,21 @@ function L(a) {
}
return this;
};
-function O(a, c, b, e, d, f) {
+function P(a, c, b, e, d, f) {
a = a[d];
if (e === b.length - 1) {
c[d] = f || a;
} else if (a) {
if (a.constructor === Array) {
for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) {
- O(a, c, b, e, d);
+ P(a, c, b, e, d);
}
} else {
- c = c[d] || (c[d] = z()), d = b[++e], O(a, c, b, e, d);
+ c = c[d] || (c[d] = C()), d = b[++e], P(a, c, b, e, d);
}
}
}
-function N(a, c, b, e, d, f, g, h) {
+function O(a, c, b, e, d, f, g, h) {
if (a = a[g]) {
if (e === c.length - 1) {
if (a.constructor === Array) {
@@ -336,16 +336,16 @@ function N(a, c, b, e, d, f, g, h) {
} else {
if (a.constructor === Array) {
for (g = 0; g < a.length; g++) {
- N(a, c, b, e, d, f, g, h);
+ O(a, c, b, e, d, f, g, h);
}
} else {
- g = c[++e], N(a, c, b, e, d, f, g, h);
+ g = c[++e], O(a, c, b, e, d, f, g, h);
}
}
}
}
;function ka(a, c) {
- const b = z(), e = [];
+ const b = C(), e = [];
for (let d = 0, f; d < c.length; d++) {
f = c[d];
for (let g = 0; g < f.length; g++) {
@@ -357,17 +357,17 @@ function N(a, c, b, e, d, f, g, h) {
}
return e;
}
-;M.prototype.search = function(a, c, b, e) {
- b || (!c && F(a) ? (b = a, a = "") : F(c) && (b = c, c = 0));
+;N.prototype.search = function(a, c, b, e) {
+ b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0));
let d = [];
var f = [];
let g, h, k, l, m, n, t = 0, p;
if (b) {
b.constructor === Array && (b = {index:b});
a = b.query || a;
- var q = b.pluck;
+ var r = b.pluck;
h = b.merge;
- l = q || b.field || b.index;
+ l = r || b.field || b.index;
m = this.tag && b.tag;
g = this.store && b.enrich;
k = b.suggest;
@@ -378,29 +378,29 @@ function N(a, c, b, e, d, f, g, h) {
if (m) {
m.constructor !== Array && (m = [m]);
var u = [];
- for (let x = 0, r; x < m.length; x++) {
- r = m[x];
- if (A(r)) {
+ for (let w = 0, q; w < m.length; w++) {
+ q = m[w];
+ if (D(q)) {
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
}
- if (r.field && r.tag) {
- var w = r.tag;
- if (w.constructor === Array) {
- for (var B = 0; B < w.length; B++) {
- u.push(r.field, w[B]);
+ if (q.field && q.tag) {
+ var v = q.tag;
+ if (v.constructor === Array) {
+ for (var y = 0; y < v.length; y++) {
+ u.push(q.field, v[y]);
}
} else {
- u.push(r.field, w);
+ u.push(q.field, v);
}
} else {
- w = Object.keys(r);
- for (let D = 0, E, C; D < w.length; D++) {
- if (E = w[D], C = r[E], C.constructor === Array) {
- for (B = 0; B < C.length; B++) {
- u.push(E, C[B]);
+ v = Object.keys(q);
+ for (let E = 0, A, z; E < v.length; E++) {
+ if (A = v[E], z = q[A], z.constructor === Array) {
+ for (y = 0; y < z.length; y++) {
+ u.push(A, z[y]);
}
} else {
- u.push(E, C);
+ u.push(A, z);
}
}
}
@@ -413,114 +413,137 @@ function N(a, c, b, e, d, f, g, h) {
e = [];
if (u.length) {
for (f = 0; f < u.length; f += 2) {
- q = la.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:q});
+ r = la.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:r});
}
}
- 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(w) {
+ for (let q = 0; q < w.length; q++) {
+ d[q].result = w[q];
}
return d;
}) : d;
}
}
- A(l) && (l = [l]);
+ D(l) && (l = [l]);
}
l || (l = this.field);
u = !e && (this.worker || this.db) && [];
- for (let x = 0, r, D, E; x < l.length; x++) {
- D = l[x];
- let C;
- A(D) || (C = D, D = C.field, a = C.query || a, c = C.limit || c, n = C.offset || n, k = C.suggest || k, g = this.store && (C.enrich || g));
+ for (let w = 0, q, E, A; w < l.length; w++) {
+ E = l[w];
+ let z;
+ D(E) || (z = E, E = z.field, a = z.query || a, c = z.limit || c, n = z.offset || n, k = z.suggest || k, g = this.store && (z.enrich || g));
if (e) {
- r = e[x];
+ q = e[w];
} else {
- if (w = C || b, B = this.index.get(D), m && (w.enrich = !1), u) {
- u[x] = B.search(a, c, w);
- w && g && (w.enrich = g);
+ if (v = z || b, y = this.index.get(E), m && (v.enrich = !1), u) {
+ u[w] = y.search(a, c, v);
+ v && g && (v.enrich = g);
continue;
} else {
- r = B.search(a, c, w), w && g && (w.enrich = g);
+ q = y.search(a, c, v), v && g && (v.enrich = g);
}
}
- E = r && r.length;
- if (m && E) {
- w = [];
- B = 0;
- for (let H = 0, I, ya; H < m.length; H += 2) {
- I = this.tag.get(m[H]);
- if (!I) {
- if (console.warn("Tag '" + m[H] + ":" + m[H + 1] + "' will be skipped because there is no field '" + m[H] + "'."), k) {
+ A = q && q.length;
+ if (m && A) {
+ v = [];
+ y = 0;
+ for (let G = 0, F, K; G < m.length; G += 2) {
+ F = this.tag.get(m[G]);
+ if (!F) {
+ if (console.warn("Tag '" + m[G] + ":" + m[G + 1] + "' will be skipped because there is no field '" + m[G] + "'."), k) {
continue;
} else {
return d;
}
}
- if (ya = (I = I && I.get(m[H + 1])) && I.length) {
- B++, w.push(I);
+ if (K = (F = F && F.get(m[G + 1])) && F.length) {
+ y++, v.push(F);
} else if (!k) {
return d;
}
}
- if (B) {
- r = ka(r, w);
- E = r.length;
- if (!E && !k) {
+ if (y) {
+ q = ka(q, v);
+ A = q.length;
+ if (!A && !k) {
return d;
}
- B--;
+ y--;
}
}
- if (E) {
- f[t] = D, d.push(r), t++;
+ if (A) {
+ f[t] = E, d.push(q), t++;
} else if (1 === l.length) {
return d;
}
}
if (u) {
- const x = this;
- return Promise.all(u).then(function(r) {
- return r.length ? x.search(a, c, b, r) : r;
+ const w = this;
+ return Promise.all(u).then(function(q) {
+ return q.length ? w.search(a, c, b, q) : q;
});
}
if (!t) {
return d;
}
- if (q && (!g || !this.store)) {
+ if (r && (!g || !this.store)) {
return d[0];
}
u = [];
- for (let x = 0, r; x < f.length; x++) {
- r = d[x];
- g && r.length && !r[0].doc && r.length && (r = ma.call(this, r));
- if (q) {
- return r;
+ for (let w = 0, q; w < f.length; w++) {
+ q = d[w];
+ g && q.length && !q[0].doc && q.length && (q = ma.call(this, q));
+ if (r) {
+ return q;
}
- d[x] = {field:f[x], result:r};
+ d[w] = {field:f[w], result:q};
}
- return h ? na(d, c) : p ? oa(d, a, this.index, this.C, p) : d;
+ return h ? na(d, c) : p ? oa(d, a, this.index, this.field, this.C, p) : d;
};
-function oa(a, c, b, e, d) {
- let f;
- for (let g = 0, h, k, l, m; g < a.length; g++) {
- h = a[g].result;
- k = a[g].field;
- l = b.get(k).encoder;
- m = e[k.indexOf(k)];
- l !== f && (f = l, f.encode(c));
- for (let n = 0; n < h.length; n++) {
- let t = "", p = G(h[n].doc, m), q = f.encode(p);
- for (let u = 0; u < q.length; u++) {
- t += q[u].replace(new RegExp("(" + q[u] + ")", "g"), d.replace("$1", p));
+function oa(a, c, b, e, d, f) {
+ let g, h, k;
+ for (let m = 0, n, t, p, r, u; m < a.length; m++) {
+ n = a[m].result;
+ t = a[m].field;
+ r = b.get(t);
+ p = r.encoder;
+ k = r.tokenize;
+ u = d[e.indexOf(t)];
+ p !== g && (g = p, h = g.encode(c));
+ for (let v = 0; v < n.length; v++) {
+ let y = "";
+ var l = I(n[v].doc, u);
+ let w = g.encode(l);
+ l = l.split(g.split);
+ for (let q = 0, E, A; q < w.length; q++) {
+ E = w[q];
+ A = l[q];
+ let z;
+ for (let G = 0, F; G < h.length; G++) {
+ if (F = h[G], "strict" === k) {
+ if (E === F) {
+ y += (y ? " " : "") + f.replace("$1", A);
+ z = !0;
+ break;
+ }
+ } else {
+ const K = E.indexOf(F);
+ if (-1 < K) {
+ y += (y ? " " : "") + A.substring(0, K) + f.replace("$1", A.substring(K, F.length)) + A.substring(K + F.length);
+ z = !0;
+ break;
+ }
+ }
+ }
+ z || (y += (y ? " " : "") + l[q]);
}
- console.log(a, b, d);
- h[n].T = t;
+ n[v].T = y;
}
}
return a;
}
function na(a, c) {
- const b = [], e = z();
+ const b = [], e = C();
for (let d = 0, f, g; d < a.length; d++) {
f = a[d];
g = f.result;
@@ -558,32 +581,32 @@ function ma(a) {
}
return c;
}
-;function M(a) {
+;function N(a) {
if (!this) {
- return new M(a);
+ return new N(a);
}
const c = a.document || a.doc || a;
var b;
this.C = [];
this.field = [];
this.I = [];
- this.key = (b = c.key || c.id) && P(b, this.I) || "id";
+ this.key = (b = c.key || c.id) && Q(b, this.I) || "id";
this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set();
this.A = (b = c.store || null) && !0 !== b && [];
this.store = b && new Map();
- this.cache = (b = a.cache || null) && new Q(b);
+ this.cache = (b = a.cache || null) && new R(b);
a.cache = !1;
b = new Map();
let e = c.index || c.field || c;
- A(e) && (e = [e]);
+ D(e) && (e = [e]);
for (let d = 0, f, g; d < e.length; d++) {
- f = e[d], A(f) || (g = f, f = f.field), g = F(g) ? Object.assign({}, a, g) : a, b.set(f, new R(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = P(f, this.I), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].G = g.filter)), this.field[d] = f;
+ f = e[d], D(f) || (g = f, f = f.field), g = H(g) ? Object.assign({}, a, g) : a, b.set(f, new S(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Q(f, this.I), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].G = g.filter)), this.field[d] = f;
}
if (this.A) {
a = c.store;
- A(a) && (a = [a]);
+ D(a) && (a = [a]);
for (let d = 0, f, g; d < a.length; d++) {
- f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.S = g) : (this.A[d] = P(g, this.I), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].G = f.filter));
+ f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.S = g) : (this.A[d] = Q(g, this.I), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].G = f.filter));
}
}
this.index = b;
@@ -599,14 +622,14 @@ function ma(a) {
if (!g) {
throw Error("The tag field from the document descriptor is undefined.");
}
- f.custom ? this.B[d] = f.custom : (this.B[d] = P(g, this.I), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].G = f.filter));
+ f.custom ? this.B[d] = f.custom : (this.B[d] = Q(g, this.I), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].G = f.filter));
this.R[d] = g;
this.tag.set(g, new Map());
}
}
}
}
-function P(a, c) {
+function Q(a, c) {
const b = a.split(":");
let e = 0;
for (let d = 0; d < b.length; d++) {
@@ -615,15 +638,15 @@ function P(a, c) {
e < b.length && (b.length = e);
return 1 < e ? b : b[0];
}
-v = M.prototype;
-v.append = function(a, c) {
+x = N.prototype;
+x.append = function(a, c) {
return this.add(a, c, !0);
};
-v.update = function(a, c) {
+x.update = function(a, c) {
return this.remove(a).add(a, c);
};
-v.remove = function(a) {
- F(a) && (a = G(a, this.key));
+x.remove = function(a) {
+ H(a) && (a = I(a, this.key));
for (var c of this.index.values()) {
c.remove(a, !0);
}
@@ -643,7 +666,7 @@ v.remove = function(a) {
this.cache && this.cache.remove(a);
return this;
};
-v.clear = function() {
+x.clear = function() {
for (const a of this.index.values()) {
a.clear();
}
@@ -655,24 +678,24 @@ v.clear = function() {
this.store && this.store.clear();
return this;
};
-v.contain = function(a) {
+x.contain = function(a) {
return this.reg.has(a);
};
-v.cleanup = function() {
+x.cleanup = function() {
for (const a of this.index.values()) {
a.cleanup();
}
return this;
};
-v.get = function(a) {
+x.get = function(a) {
return this.store.get(a);
};
-v.set = function(a, c) {
+x.set = function(a, c) {
this.store.set(a, c);
return this;
};
-v.searchCache = pa;
-v.export = function(a, c, b, e, d, f) {
+x.searchCache = pa;
+x.export = function(a, c, b, e, d, f) {
let g;
"undefined" === typeof f && (g = new Promise(k => {
f = k;
@@ -704,9 +727,9 @@ v.export = function(a, c, b, e, d, f) {
}
return g;
};
-v.import = function(a, c) {
+x.import = function(a, c) {
if (c) {
- switch(A(c) && (c = JSON.parse(c)), a) {
+ switch(D(c) && (c = JSON.parse(c)), a) {
case "tag":
this.D = c;
break;
@@ -728,7 +751,7 @@ v.import = function(a, c) {
}
}
};
-ia(M.prototype);
+ia(N.prototype);
function pa(a, c, b) {
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
let e = this.cache.get(a);
@@ -745,40 +768,40 @@ function pa(a, c, b) {
}
return e;
}
-function Q(a) {
+function R(a) {
this.limit = a && !0 !== a ? a : 1000;
this.cache = new Map();
this.h = "";
}
-Q.prototype.set = function(a, c) {
+R.prototype.set = function(a, c) {
this.cache.set(this.h = a, c);
this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value);
};
-Q.prototype.get = function(a) {
+R.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;
};
-Q.prototype.remove = function(a) {
+R.prototype.remove = function(a) {
for (const c of this.cache) {
const b = c[0];
c[1].includes(a) && this.cache.delete(b);
}
};
-Q.prototype.clear = function() {
+R.prototype.clear = function() {
this.cache.clear();
this.h = "";
};
const qa = {normalize:function(a) {
return a.toLowerCase();
}, dedupe:!1};
-const S = 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 T = 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 ra = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), sa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"];
const ta = {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 ua = /[\x00-\x7F]+/g;
const va = /[\x00-\x7F]+/g;
const wa = /[\x00-\x7F]+/g;
-var xa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:qa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:S}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:S, matcher:ra, replacer:sa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:S, replacer:sa.concat([/(?!^)[aeo]/g, ""]), matcher:ra}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) {
+var xa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:qa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:T}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:T, matcher:ra, replacer:sa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:T, replacer:sa.concat([/(?!^)[aeo]/g, ""]), matcher:ra}, 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 = ta[e];
@@ -793,29 +816,29 @@ var xa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:qa, LatinSimple:{no
}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) {
return ("" + a).replace(wa, " ");
}}};
-const za = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
-z();
-R.prototype.add = function(a, c, b, e) {
+const ya = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
+C();
+S.prototype.add = function(a, c, b, e) {
if (c && (a || 0 === a)) {
if (!e && !b && this.reg.has(a)) {
return this.update(a, c);
}
c = this.encoder.encode(c);
if (e = c.length) {
- const l = z(), m = z(), n = this.depth, t = this.resolution;
+ const l = C(), m = C(), n = this.depth, t = this.resolution;
for (let p = 0; p < e; p++) {
- let q = c[this.rtl ? e - 1 - p : p];
- var d = q.length;
- if (d && (n || !m[q])) {
- var f = this.score ? this.score(c, q, p, null, 0) : T(t, e, p), g = "";
+ let r = c[this.rtl ? e - 1 - p : p];
+ var d = r.length;
+ if (d && (n || !m[r])) {
+ var f = this.score ? this.score(c, r, p, null, 0) : U(t, e, p), g = "";
switch(this.tokenize) {
case "full":
if (2 < d) {
for (f = 0; f < d; f++) {
for (var h = d; h > f; h--) {
- g = q.substring(f, h);
- var k = this.score ? this.score(c, q, p, g, f) : T(t, e, p, d, f);
- U(this, m, g, k, a, b);
+ g = r.substring(f, h);
+ var k = this.score ? this.score(c, r, p, g, f) : U(t, e, p, d, f);
+ V(this, m, g, k, a, b);
}
}
break;
@@ -823,24 +846,24 @@ R.prototype.add = function(a, c, b, e) {
case "reverse":
if (1 < d) {
for (h = d - 1; 0 < h; h--) {
- g = q[h] + g, k = this.score ? this.score(c, q, p, g, h) : T(t, e, p, d, h), U(this, m, g, k, a, b);
+ g = r[h] + g, k = this.score ? this.score(c, r, p, g, h) : U(t, e, p, d, h), V(this, m, g, k, a, b);
}
g = "";
}
case "forward":
if (1 < d) {
for (h = 0; h < d; h++) {
- g += q[h], U(this, m, g, f, a, b);
+ g += r[h], V(this, m, g, f, a, b);
}
break;
}
default:
- if (U(this, m, q, f, a, b), n && 1 < e && p < e - 1) {
- for (d = z(), g = this.P, f = q, h = Math.min(n + 1, e - p), d[f] = 1, k = 1; k < h; k++) {
- if ((q = c[this.rtl ? e - 1 - p - k : p + k]) && !d[q]) {
- d[q] = 1;
- const u = this.score ? this.score(c, f, p, q, k) : T(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), w = this.bidirectional && q > f;
- U(this, l, w ? f : q, u, a, b, w ? q : f);
+ if (V(this, m, r, f, a, b), n && 1 < e && p < e - 1) {
+ for (d = C(), g = this.P, f = r, h = Math.min(n + 1, e - p), d[f] = 1, k = 1; k < h; k++) {
+ if ((r = c[this.rtl ? e - 1 - p - k : p + k]) && !d[r]) {
+ d[r] = 1;
+ const u = this.score ? this.score(c, f, p, r, k) : U(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), v = this.bidirectional && r > f;
+ V(this, l, v ? f : r, u, a, b, v ? r : f);
}
}
}
@@ -852,16 +875,16 @@ R.prototype.add = function(a, c, b, e) {
}
return this;
};
-function U(a, c, b, e, d, f, g) {
+function V(a, c, b, e, d, f, g) {
let h = g ? a.ctx : a.map, k;
if (!c[b] || g && !(k = c[b])[g]) {
- g ? (c = k || (c[b] = z()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h])));
+ g ? (c = k || (c[b] = C()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h])));
}
}
-function T(a, c, b, e, d) {
+function U(a, c, b, e, d) {
return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0;
}
-;function Aa(a, c, b) {
+;function za(a, c, b) {
if (1 === a.length) {
return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a;
}
@@ -891,8 +914,8 @@ function T(a, c, b, e, d) {
}
return e.length ? e = 1 < e.length ? [].concat.apply([], e) : e[0] : e;
}
-;R.prototype.search = function(a, c, b) {
- b || (!c && F(a) ? (b = a, a = "") : F(c) && (b = c, c = 0));
+;S.prototype.search = function(a, c, b) {
+ b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0));
var e = [], d = 0;
if (b) {
a = b.query || a;
@@ -905,26 +928,26 @@ function T(a, c, b, e, d) {
b = a.length;
c || (c = 100);
if (1 === b) {
- return V.call(this, a[0], "", c, d);
+ return W.call(this, a[0], "", c, d);
}
f = this.depth && !1 !== f;
if (2 === b && f && !g) {
- return V.call(this, a[0], a[1], c, d);
+ return W.call(this, a[0], a[1], c, d);
}
var h = 0, k = 0;
if (1 < b) {
- var l = z();
+ var l = C();
const n = [];
for (let t = 0, p; t < b; t++) {
if ((p = a[t]) && !l[p]) {
- if (g || W(this, p)) {
+ if (g || X(this, p)) {
n.push(p), l[p] = 1;
} else {
return e;
}
- const q = p.length;
- h = Math.max(h, q);
- k = k ? Math.min(k, q) : q;
+ const r = p.length;
+ h = Math.max(h, r);
+ k = k ? Math.min(k, r) : r;
}
}
a = n;
@@ -935,10 +958,10 @@ function T(a, c, b, e, d) {
}
l = 0;
if (1 === b) {
- return V.call(this, a[0], "", c, d);
+ return W.call(this, a[0], "", c, d);
}
if (2 === b && f && !g) {
- return V.call(this, a[0], a[1], c, d);
+ return W.call(this, a[0], a[1], c, d);
}
if (1 < b) {
if (f) {
@@ -950,7 +973,7 @@ function T(a, c, b, e, d) {
}
for (let n, t; l < b; l++) {
t = a[l];
- m ? (n = W(this, t, m), n = Ba(n, e, g, this.P), g && !1 === n && e.length || (m = t)) : (n = W(this, t, ""), n = Ba(n, e, g, this.resolution));
+ m ? (n = X(this, t, m), n = Aa(n, e, g, this.P), g && !1 === n && e.length || (m = t)) : (n = X(this, t, ""), n = Aa(n, e, g, this.resolution));
if (n) {
return n;
}
@@ -965,74 +988,69 @@ function T(a, c, b, e, d) {
return e;
}
if (1 === f) {
- return Aa(e[0], c, d);
+ return za(e[0], c, d);
}
}
}
a: {
a = e;
e = this.resolution;
- m = a.length;
- b = [];
- f = z();
- for (let n = 0, t, p, q, u; n < e; n++) {
- for (k = 0; k < m; k++) {
- if (q = a[k], n < q.length && (t = q[n])) {
+ m = g;
+ b = a.length;
+ g = [];
+ f = C();
+ for (let n = 0, t, p, r, u; n < e; n++) {
+ for (k = 0; k < b; k++) {
+ if (r = a[k], n < r.length && (t = r[n])) {
for (l = 0; l < t.length; l++) {
- p = t[l], (h = f[p]) ? f[p]++ : (h = 0, f[p] = 1), u = b[h] || (b[h] = []), u.push(p);
+ p = t[l], (h = f[p]) ? f[p]++ : (h = 0, f[p] = 1), u = g[h] || (g[h] = []), u.push(p);
}
}
}
}
- if (a = b.length) {
- if (g) {
- if (1 < b.length) {
+ if (a = g.length) {
+ if (m) {
+ if (1 < g.length) {
b: {
- g = b;
- a = [];
- e = z();
- m = g.length;
- for (h = m - 1; 0 <= h; h--) {
+ for (a = [], e = C(), m = g.length, h = m - 1; 0 <= h; h--) {
for (m = g[h], f = m.length, k = 0; k < f; k++) {
if (b = m[k], !e[b]) {
if (e[b] = 1, d) {
d--;
} else {
if (a.push(b), a.length === c) {
- c = a;
break b;
}
}
}
}
}
- c = a;
}
} else {
- c = b[0];
+ a = (g = g[0]).length > c || d ? g.slice(d, c + d) : g;
}
- b = c;
+ g = a;
} else {
- if (a < m) {
+ if (a < b) {
e = [];
break a;
}
- b = b[a - 1];
+ g = g[a - 1];
if (c || d) {
- if (b.length > c || d) {
- b = b.slice(d, c + d);
+ if (g.length > c || d) {
+ g = g.slice(d, c + d);
}
}
}
}
- e = b;
+ e = g;
}
return e;
};
-function V(a, c, b, e) {
- return (a = W(this, a, c)) && a.length ? Aa(a, b, e) : [];
+function W(a, c, b, e) {
+ return (a = X(this, a, c)) && a.length ? za(a, b, e) : [];
}
-function Ba(a, c, b, e) {
+function Aa(a, c, b, e) {
let d = [];
if (a) {
e = Math.min(a.length, e);
@@ -1046,13 +1064,13 @@ function Ba(a, c, b, e) {
}
return !b && d;
}
-function W(a, c, b) {
+function X(a, c, b) {
let e;
b && (e = a.bidirectional && c > b);
a = b ? (a = a.ctx.get(e ? c : b)) && a.get(e ? b : c) : a.map.get(c);
return a;
}
-;R.prototype.remove = function(a, c) {
+;S.prototype.remove = function(a, c) {
const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a));
if (b) {
if (this.fastupdate) {
@@ -1067,14 +1085,14 @@ function W(a, c, b) {
}
}
} else {
- X(this.map, a), this.depth && X(this.ctx, a);
+ Y(this.map, a), this.depth && Y(this.ctx, a);
}
c || this.reg.delete(a);
}
this.cache && this.cache.remove(a);
return this;
};
-function X(a, c) {
+function Y(a, c) {
let b = 0;
if (a.constructor === Array) {
for (let e = 0, d, f; e < a.length; e++) {
@@ -1089,25 +1107,25 @@ function X(a, c) {
}
} else {
for (let e of a) {
- const d = e[0], f = X(e[1], c);
+ const d = e[0], f = Y(e[1], c);
f ? b += f : a.delete(d);
}
}
return b;
}
-;function R(a, c) {
+;function S(a, c) {
if (!this) {
- return new R(a);
+ return new S(a);
}
if (a) {
- var b = A(a) ? a : a.preset;
- b && (za[b] || console.warn("Preset not found: " + b), a = Object.assign({}, za[b], a));
+ var b = D(a) ? a : a.preset;
+ b && (ya[b] || console.warn("Preset not found: " + b), a = Object.assign({}, ya[b], a));
} else {
a = {};
}
b = a.context || {};
- const e = A(a.encoder) ? xa[a.encoder] : a.encode || a.encoder || qa;
- this.encoder = e.encode ? e : "object" === typeof e ? new K(e) : {encode:e};
+ const e = D(a.encoder) ? xa[a.encoder] : a.encode || a.encoder || qa;
+ this.encoder = e.encode ? e : "object" === typeof e ? new L(e) : {encode:e};
let d;
this.resolution = a.resolution || 9;
this.tokenize = d = a.tokenize || "strict";
@@ -1121,27 +1139,27 @@ function X(a, c) {
this.reg = c || (this.fastupdate ? new Map() : new Set());
this.P = b.resolution || 1;
this.rtl = e.rtl || a.rtl || !1;
- this.cache = (d = a.cache || null) && new Q(d);
+ this.cache = (d = a.cache || null) && new R(d);
}
-v = R.prototype;
-v.clear = function() {
+x = S.prototype;
+x.clear = function() {
this.map.clear();
this.ctx.clear();
this.reg.clear();
this.cache && this.cache.clear();
return this;
};
-v.append = function(a, c) {
+x.append = function(a, c) {
return this.add(a, c, !0);
};
-v.contain = function(a) {
+x.contain = function(a) {
return this.reg.has(a);
};
-v.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);
};
-function Y(a) {
+function Ba(a) {
let c = 0;
if (a.constructor === Array) {
for (let b = 0, e; b < a.length; b++) {
@@ -1149,22 +1167,22 @@ function Y(a) {
}
} else {
for (const b of a) {
- const e = b[0], d = Y(b[1]);
+ const e = b[0], d = Ba(b[1]);
d ? c += d : a.delete(e);
}
}
return c;
}
-v.cleanup = function() {
+x.cleanup = function() {
if (!this.fastupdate) {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
- Y(this.map);
- this.depth && Y(this.ctx);
+ Ba(this.map);
+ this.depth && Ba(this.ctx);
return this;
};
-v.searchCache = pa;
-v.export = function(a, c, b, e, d, f) {
+x.searchCache = pa;
+x.export = function(a, c, b, e, d, f) {
let g = !0;
"undefined" === typeof f && (g = new Promise(l => {
f = l;
@@ -1174,7 +1192,7 @@ v.export = function(a, c, b, e, d, f) {
case 0:
h = "reg";
if (this.fastupdate) {
- k = z();
+ k = C();
for (let l of this.reg.keys()) {
k[l] = 1;
}
@@ -1201,9 +1219,9 @@ v.export = function(a, c, b, e, d, f) {
ja(a, c || this, b, h, e, d, k, f);
return g;
};
-v.import = function(a, c) {
+x.import = function(a, c) {
if (c) {
- switch(A(c) && (c = JSON.parse(c)), a) {
+ switch(D(c) && (c = JSON.parse(c)), a) {
case "cfg":
this.h = !!c.opt;
break;
@@ -1219,7 +1237,7 @@ v.import = function(a, c) {
}
}
};
-v.serialize = function(a = !0) {
+x.serialize = function(a = !0) {
if (!this.reg.size) {
return "";
}
@@ -1255,8 +1273,8 @@ v.serialize = function(a = !0) {
for (let t = 0, p; t < h.length; t++) {
p = h[t] || [""];
l = "";
- for (let q = 0; q < p.length; q++) {
- l += (l ? "," : "") + ("string" === b ? '"' + p[q] + '"' : p[q]);
+ for (let r = 0; r < p.length; r++) {
+ l += (l ? "," : "") + ("string" === b ? '"' + p[r] + '"' : p[r]);
}
l = "[" + l + "]";
k += (k ? "," : "") + l;
@@ -1269,8 +1287,8 @@ v.serialize = function(a = !0) {
d = "index.ctx=new Map([" + d + "]);";
return a ? "function inject(index){" + c + e + d + "}" : c + e + d;
};
-ia(R.prototype);
-const Ca = {Index:R, Charset:xa, Encoder:K, Document:M, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, Z = self;
+ia(S.prototype);
+const Ca = {Index:S, Charset:xa, Encoder:L, Document:N, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, Z = self;
let Da;
(Da = Z.define) && Da.amd ? Da([], function() {
return Ca;
diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js
index 55051ea..736b2b5 100644
--- a/dist/flexsearch.compact.min.js
+++ b/dist/flexsearch.compact.min.js
@@ -5,48 +5,48 @@
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
-(function _f(self){'use strict';if(typeof module!=='undefined')self=module;else if(typeof process !== 'undefined')self=process;self._factory=_f;var v;function y(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function z(){return Object.create(null)}function aa(a,c){return c.length-a.length}
-function C(a){return"string"===typeof a}function F(a){return"object"===typeof a}function G(a,c){if(C(c))a=a[c];else for(let b=0;a&&bthis.stemmer.get(l)),k=1);g&&k&&(g.length<
-this.minlength||this.filter&&this.filter.has(g))&&(g="");if(g&&(this.mapper||this.dedupe&&1this.matcher.get(l)));if(g&&this.replacer)for(d=0;g&&dthis.O&&(this.H.clear(),this.D=this.D/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.h&&(this.F.set(a,b),this.F.size>this.O&&(this.F.clear(),this.h=this.h/1.1|0));return b};function ha(a){a.J=null;a.F.clear();a.H.clear()};function ia(a){K.call(a,"add");K.call(a,"append");K.call(a,"search");K.call(a,"update");K.call(a,"remove")}function K(a){this[a+"Async"]=function(){var c=arguments;const b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);c=this[a].apply(this,c);e&&(c.then?c.then(e):e(c));return c}};function ja(a,c,b,e,d,f,g,h){(e=a(b?b+"."+e:e,JSON.stringify(g)))&&e.then?e.then(function(){c.export(a,c,b,d,f+1,h)}):c.export(a,c,b,d,f+1,h)};L.prototype.add=function(a,c,b){F(a)&&(c=a,a=G(c,this.key));if(c&&(a||0===a)){if(!b&&this.reg.has(a))return this.update(a,c);for(let h=0,k;hb||e)a=a.slice(e,e+b);d&&(a=ma.call(this,a));return a}}
-function ma(a){const c=Array(a.length);for(let b=0,e;b{f=k}));d||(d=0);e||(e=0);if(ethis.limit&&this.cache.delete(this.cache.keys().next().value)};
-Q.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};Q.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Q.prototype.clear=function(){this.cache.clear();this.h=""};const qa={normalize:function(a){return a.toLowerCase()},dedupe:!1};const S=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 ra=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),sa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const ta={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 ua=/[\x00-\x7F]+/g;const va=/[\x00-\x7F]+/g;const wa=/[\x00-\x7F]+/g;var ya={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:qa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:S},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:S,matcher:ra,replacer:sa},LatinExtra:{normalize:!0,dedupe:!0,mapper:S,replacer:sa.concat([/(?!^)[aeo]/g,""]),matcher:ra},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bf;h--){g=q.substring(f,h);var k=this.score?this.score(c,q,p,g,f):T(t,e,p,d,f);U(this,m,g,k,a,b)}break}case "reverse":if(1<
-d){for(h=d-1;0g?0:1),e,p,h-1,k-1),w=this.bidirectional&&q>f;U(this,l,w?f:q,u,a,b,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};
-function U(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])g?(c=k||(c[b]=z()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function T(a,c,b,e,d){return b&&1c?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}bc&&(f=f.slice(0,c),g=f.length),e.push(f);else{if(g>=c)return g>c&&(f=f.slice(0,c)),f;e=[f]}c-=g;if(!c)break}return e.length?e=1c||d)b=b.slice(d,c+d)}e=b}return e};
-function V(a,c,b,e){return(a=W(this,a,c))&&a.length?Aa(a,b,e):[]}function Ba(a,c,b,e){let d=[];if(a){e=Math.min(a.length,e);for(let f=0,g;fb);a=b?(a=a.ctx.get(e?c:b))&&a.get(e?b:c):a.map.get(c);return a};R.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 X(this.map,a),this.depth&&X(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
-function X(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};
-function Y(a){let c=0;if(a.constructor===Array)for(let b=0,e;b{f=l}));let h,k;switch(d||(d=0)){case 0:h="reg";if(this.fastupdate){k=z();for(let l of this.reg.keys())k[l]=1}else k=this.reg;break;case 1:h="cfg";k={doc:0,opt:this.h?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.ctx;break;default:"undefined"===typeof b&&f&&f();return}ja(a,c||this,b,h,e,d,k,f);return g};
-v.import=function(a,c){if(c)switch(C(c)&&(c=JSON.parse(c)),a){case "cfg":this.h=!!c.opt;break;case "reg":this.fastupdate=!1;this.reg=c;break;case "map":this.map=c;break;case "ctx":this.ctx=c}};
-v.serialize=function(a=!0){if(!this.reg.size)return"";let c="",b="";for(var e of this.reg.keys())b||(b=typeof e),c+=(c?",":"")+("string"===b?'"'+e+'"':e);c="index.reg=new Set(["+c+"]);";e="";for(var d of this.map.entries()){var f=d[0],g=d[1],h="";for(let m=0,n;mthis.stemmer.get(l)),k=1);f&&k&&(f.length<
+this.minlength||this.filter&&this.filter.has(f))&&(f="");if(f&&(this.mapper||this.dedupe&&1this.matcher.get(l)));if(f&&this.replacer)for(d=0;f&&dthis.O&&(this.H.clear(),this.D=this.D/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.h&&(this.F.set(a,b),this.F.size>this.O&&(this.F.clear(),this.h=this.h/1.1|0));return b};function ha(a){a.J=null;a.F.clear();a.H.clear()};function ia(a){M.call(a,"add");M.call(a,"append");M.call(a,"search");M.call(a,"update");M.call(a,"remove")}function M(a){this[a+"Async"]=function(){var c=arguments;const b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);c=this[a].apply(this,c);e&&(c.then?c.then(e):e(c));return c}};function ja(a,c,b,e,d,g,f,h){(e=a(b?b+"."+e:e,JSON.stringify(f)))&&e.then?e.then(function(){c.export(a,c,b,d,g+1,h)}):c.export(a,c,b,d,g+1,h)};N.prototype.add=function(a,c,b){H(a)&&(c=a,a=I(c,this.key));if(c&&(a||0===a)){if(!b&&this.reg.has(a))return this.update(a,c);for(let h=0,k;hb||e)a=a.slice(e,e+b);d&&(a=ma.call(this,a));return a}}
+function ma(a){const c=Array(a.length);for(let b=0,e;b{g=k}));d||(d=0);e||(e=0);if(ethis.limit&&this.cache.delete(this.cache.keys().next().value)};
+R.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};R.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};R.prototype.clear=function(){this.cache.clear();this.h=""};const qa={normalize:function(a){return a.toLowerCase()},dedupe:!1};const T=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 ra=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),sa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const ta={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 ua=/[\x00-\x7F]+/g;const va=/[\x00-\x7F]+/g;const wa=/[\x00-\x7F]+/g;var xa={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:qa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:T},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:T,matcher:ra,replacer:sa},LatinExtra:{normalize:!0,dedupe:!0,mapper:T,replacer:sa.concat([/(?!^)[aeo]/g,""]),matcher:ra},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bg;h--){f=r.substring(g,h);var k=this.score?this.score(c,r,p,f,g):U(t,e,p,d,g);V(this,m,f,k,a,b)}break}case "reverse":if(1<
+d){for(h=d-1;0f?0:1),e,p,h-1,k-1),u=this.bidirectional&&r>g;V(this,l,u?g:r,v,a,b,u?r:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
+function V(a,c,b,e,d,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=C()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function U(a,c,b,e,d){return b&&1c?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,g,f;d=f){b-=f;continue}bc&&(g=g.slice(0,c),f=g.length),e.push(g);else{if(f>=c)return f>c&&(g=g.slice(0,c)),g;e=[g]}c-=f;if(!c)break}return e.length?e=1c||d?f.slice(d,c+d):f;f=a}else{if(ac||d)f=f.slice(d,c+d)}e=f}return e};
+function W(a,c,b,e){return(a=X(this,a,c))&&a.length?za(a,b,e):[]}function Aa(a,c,b,e){let d=[];if(a){e=Math.min(a.length,e);for(let g=0,f;gb);a=b?(a=a.ctx.get(e?c:b))&&a.get(e?b:c):a.map.get(c);return a};S.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else Y(this.map,a),this.depth&&Y(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
+function Y(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,g;eb.add(a,c)):this.add(a,c)};
+function Ba(a){let c=0;if(a.constructor===Array)for(let b=0,e;b{g=l}));let h,k;switch(d||(d=0)){case 0:h="reg";if(this.fastupdate){k=C();for(let l of this.reg.keys())k[l]=1}else k=this.reg;break;case 1:h="cfg";k={doc:0,opt:this.h?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.ctx;break;default:"undefined"===typeof b&&g&&g();return}ja(a,c||this,b,h,e,d,k,g);return f};
+x.import=function(a,c){if(c)switch(E(c)&&(c=JSON.parse(c)),a){case "cfg":this.h=!!c.opt;break;case "reg":this.fastupdate=!1;this.reg=c;break;case "map":this.map=c;break;case "ctx":this.ctx=c}};
+x.serialize=function(a=!0){if(!this.reg.size)return"";let c="",b="";for(var e of this.reg.keys())b||(b=typeof e),c+=(c?",":"")+("string"===b?'"'+e+'"':e);c="index.reg=new Set(["+c+"]);";e="";for(var d of this.map.entries()){var g=d[0],f=d[1],h="";for(let m=0,n;m this.O && (this.F.clear(), this.h = this.h / 1.1 | 0));
return b;
};
-function L(a) {
+function ha(a) {
a.J = null;
a.F.clear();
a.H.clear();
}
-;function ha(a) {
+;function ia(a) {
M.call(a, "add");
M.call(a, "append");
M.call(a, "search");
@@ -227,13 +227,13 @@ function M(a) {
return c;
};
}
-;function ia(a, c, b, e, d, f, g, h) {
+;function ja(a, c, b, e, d, f, g, h) {
(e = a(b ? b + "." + e : e, JSON.stringify(g))) && e.then ? e.then(function() {
c.export(a, c, b, d, f + 1, h);
}) : c.export(a, c, b, d, f + 1, h);
}
;N.prototype.add = function(a, c, b) {
- F(a) && (c = a, a = G(c, this.key));
+ H(a) && (c = a, a = I(c, this.key));
if (c && (a || 0 === a)) {
if (!b && this.reg.has(a)) {
return this.update(a, c);
@@ -246,7 +246,7 @@ function M(a) {
d && e.add(a, d, !1, !0);
} else {
if (d = k.G, !d || d(c)) {
- k.constructor === String ? k = ["" + k] : A(k) && (k = [k]), O(c, k, this.I, 0, e, a, k[0], b);
+ k.constructor === String ? k = ["" + k] : D(k) && (k = [k]), O(c, k, this.I, 0, e, a, k[0], b);
}
}
}
@@ -254,7 +254,7 @@ function M(a) {
for (e = 0; e < this.B.length; e++) {
var f = this.B[e], g = this.R[e];
d = this.tag.get(g);
- let h = z();
+ let h = C();
if ("function" === typeof f) {
if (f = f(c), !f) {
continue;
@@ -265,10 +265,10 @@ function M(a) {
continue;
}
f.constructor === String && (f = "" + f);
- f = G(c, f);
+ f = I(c, f);
}
if (d && f) {
- A(f) && (f = [f]);
+ D(f) && (f = [f]);
for (let k = 0, l, m; k < f.length; k++) {
l = f[k], h[l] || (h[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), b && m.includes(a) || (m.push(a), this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m]))));
}
@@ -280,7 +280,7 @@ function M(a) {
if (this.store && (!b || !this.store.has(a))) {
let h;
if (this.A) {
- h = z();
+ h = C();
for (let k = 0, l; k < this.A.length; k++) {
l = this.A[k];
if ((b = l.G) && !b(c)) {
@@ -293,7 +293,7 @@ function M(a) {
continue;
}
l = [l.S];
- } else if (A(l) || l.constructor === String) {
+ } else if (D(l) || l.constructor === String) {
h[l] = c[l];
continue;
}
@@ -315,7 +315,7 @@ function P(a, c, b, e, d, f) {
P(a, c, b, e, d);
}
} else {
- c = c[d] || (c[d] = z()), d = b[++e], P(a, c, b, e, d);
+ c = c[d] || (c[d] = C()), d = b[++e], P(a, c, b, e, d);
}
}
}
@@ -343,8 +343,8 @@ function O(a, c, b, e, d, f, g, h) {
}
}
}
-;function ja(a, c) {
- const b = z(), e = [];
+;function ka(a, c) {
+ const b = C(), e = [];
for (let d = 0, f; d < c.length; d++) {
f = c[d];
for (let g = 0; g < f.length; g++) {
@@ -357,16 +357,16 @@ function O(a, c, b, e, d, f, g, h) {
return e;
}
;N.prototype.search = function(a, c, b, e) {
- b || (!c && F(a) ? (b = a, a = "") : F(c) && (b = c, c = 0));
+ b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0));
let d = [];
var f = [];
let g, h, k, l, m, n, t = 0, p;
if (b) {
b.constructor === Array && (b = {index:b});
a = b.query || a;
- var q = b.pluck;
+ var r = b.pluck;
h = b.merge;
- l = q || b.field || b.index;
+ l = r || b.field || b.index;
m = this.tag && b.tag;
g = this.store && b.enrich;
k = b.suggest;
@@ -377,29 +377,29 @@ function O(a, c, b, e, d, f, g, h) {
if (m) {
m.constructor !== Array && (m = [m]);
var u = [];
- for (let x = 0, r; x < m.length; x++) {
- r = m[x];
- if (A(r)) {
+ for (let w = 0, q; w < m.length; w++) {
+ q = m[w];
+ if (D(q)) {
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
}
- if (r.field && r.tag) {
- var w = r.tag;
- if (w.constructor === Array) {
- for (var B = 0; B < w.length; B++) {
- u.push(r.field, w[B]);
+ if (q.field && q.tag) {
+ var v = q.tag;
+ if (v.constructor === Array) {
+ for (var y = 0; y < v.length; y++) {
+ u.push(q.field, v[y]);
}
} else {
- u.push(r.field, w);
+ u.push(q.field, v);
}
} else {
- w = Object.keys(r);
- for (let D = 0, E, C; D < w.length; D++) {
- if (E = w[D], C = r[E], C.constructor === Array) {
- for (B = 0; B < C.length; B++) {
- u.push(E, C[B]);
+ v = Object.keys(q);
+ for (let E = 0, A, z; E < v.length; E++) {
+ if (A = v[E], z = q[A], z.constructor === Array) {
+ for (y = 0; y < z.length; y++) {
+ u.push(A, z[y]);
}
} else {
- u.push(E, C);
+ u.push(A, z);
}
}
}
@@ -412,114 +412,137 @@ function O(a, c, b, e, d, f, g, h) {
e = [];
if (u.length) {
for (f = 0; f < u.length; f += 2) {
- q = ka.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:q});
+ r = la.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:r});
}
}
- 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(w) {
+ for (let q = 0; q < w.length; q++) {
+ d[q].result = w[q];
}
return d;
}) : d;
}
}
- A(l) && (l = [l]);
+ D(l) && (l = [l]);
}
l || (l = this.field);
u = !e && (this.worker || this.db) && [];
- for (let x = 0, r, D, E; x < l.length; x++) {
- D = l[x];
- let C;
- A(D) || (C = D, D = C.field, a = C.query || a, c = C.limit || c, n = C.offset || n, k = C.suggest || k, g = this.store && (C.enrich || g));
+ for (let w = 0, q, E, A; w < l.length; w++) {
+ E = l[w];
+ let z;
+ D(E) || (z = E, E = z.field, a = z.query || a, c = z.limit || c, n = z.offset || n, k = z.suggest || k, g = this.store && (z.enrich || g));
if (e) {
- r = e[x];
+ q = e[w];
} else {
- if (w = C || b, B = this.index.get(D), m && (w.enrich = !1), u) {
- u[x] = B.search(a, c, w);
- w && g && (w.enrich = g);
+ if (v = z || b, y = this.index.get(E), m && (v.enrich = !1), u) {
+ u[w] = y.search(a, c, v);
+ v && g && (v.enrich = g);
continue;
} else {
- r = B.search(a, c, w), w && g && (w.enrich = g);
+ q = y.search(a, c, v), v && g && (v.enrich = g);
}
}
- E = r && r.length;
- if (m && E) {
- w = [];
- B = 0;
- for (let H = 0, I, va; H < m.length; H += 2) {
- I = this.tag.get(m[H]);
- if (!I) {
- if (console.warn("Tag '" + m[H] + ":" + m[H + 1] + "' will be skipped because there is no field '" + m[H] + "'."), k) {
+ A = q && q.length;
+ if (m && A) {
+ v = [];
+ y = 0;
+ for (let G = 0, F, K; G < m.length; G += 2) {
+ F = this.tag.get(m[G]);
+ if (!F) {
+ if (console.warn("Tag '" + m[G] + ":" + m[G + 1] + "' will be skipped because there is no field '" + m[G] + "'."), k) {
continue;
} else {
return d;
}
}
- if (va = (I = I && I.get(m[H + 1])) && I.length) {
- B++, w.push(I);
+ if (K = (F = F && F.get(m[G + 1])) && F.length) {
+ y++, v.push(F);
} else if (!k) {
return d;
}
}
- if (B) {
- r = ja(r, w);
- E = r.length;
- if (!E && !k) {
+ if (y) {
+ q = ka(q, v);
+ A = q.length;
+ if (!A && !k) {
return d;
}
- B--;
+ y--;
}
}
- if (E) {
- f[t] = D, d.push(r), t++;
+ if (A) {
+ f[t] = E, d.push(q), t++;
} else if (1 === l.length) {
return d;
}
}
if (u) {
- const x = this;
- return Promise.all(u).then(function(r) {
- return r.length ? x.search(a, c, b, r) : r;
+ const w = this;
+ return Promise.all(u).then(function(q) {
+ return q.length ? w.search(a, c, b, q) : q;
});
}
if (!t) {
return d;
}
- if (q && (!g || !this.store)) {
+ if (r && (!g || !this.store)) {
return d[0];
}
u = [];
- for (let x = 0, r; x < f.length; x++) {
- r = d[x];
- g && r.length && !r[0].doc && r.length && (r = la.call(this, r));
- if (q) {
- return r;
+ for (let w = 0, q; w < f.length; w++) {
+ q = d[w];
+ g && q.length && !q[0].doc && q.length && (q = ma.call(this, q));
+ if (r) {
+ return q;
}
- d[x] = {field:f[x], result:r};
+ d[w] = {field:f[w], result:q};
}
- return h ? ma(d, c) : p ? na(d, a, this.index, this.C, p) : d;
+ return h ? na(d, c) : p ? oa(d, a, this.index, this.field, this.C, p) : d;
};
-function na(a, c, b, e, d) {
- let f;
- for (let g = 0, h, k, l, m; g < a.length; g++) {
- h = a[g].result;
- k = a[g].field;
- l = b.get(k).encoder;
- m = e[k.indexOf(k)];
- l !== f && (f = l, f.encode(c));
- for (let n = 0; n < h.length; n++) {
- let t = "", p = G(h[n].doc, m), q = f.encode(p);
- for (let u = 0; u < q.length; u++) {
- t += q[u].replace(new RegExp("(" + q[u] + ")", "g"), d.replace("$1", p));
+function oa(a, c, b, e, d, f) {
+ let g, h, k;
+ for (let m = 0, n, t, p, r, u; m < a.length; m++) {
+ n = a[m].result;
+ t = a[m].field;
+ r = b.get(t);
+ p = r.encoder;
+ k = r.tokenize;
+ u = d[e.indexOf(t)];
+ p !== g && (g = p, h = g.encode(c));
+ for (let v = 0; v < n.length; v++) {
+ let y = "";
+ var l = I(n[v].doc, u);
+ let w = g.encode(l);
+ l = l.split(g.split);
+ for (let q = 0, E, A; q < w.length; q++) {
+ E = w[q];
+ A = l[q];
+ let z;
+ for (let G = 0, F; G < h.length; G++) {
+ if (F = h[G], "strict" === k) {
+ if (E === F) {
+ y += (y ? " " : "") + f.replace("$1", A);
+ z = !0;
+ break;
+ }
+ } else {
+ const K = E.indexOf(F);
+ if (-1 < K) {
+ y += (y ? " " : "") + A.substring(0, K) + f.replace("$1", A.substring(K, F.length)) + A.substring(K + F.length);
+ z = !0;
+ break;
+ }
+ }
+ }
+ z || (y += (y ? " " : "") + l[q]);
}
- console.log(a, b, d);
- h[n].T = t;
+ n[v].T = y;
}
}
return a;
}
-function ma(a, c) {
- const b = [], e = z();
+function na(a, c) {
+ const b = [], e = C();
for (let d = 0, f, g; d < a.length; d++) {
f = a[d];
g = f.result;
@@ -537,7 +560,7 @@ function ma(a, c) {
}
return b;
}
-function ka(a, c, b, e, d) {
+function la(a, c, b, e, d) {
let f = this.tag.get(a);
if (!f) {
return console.warn("Tag '" + a + "' was not found"), [];
@@ -546,11 +569,11 @@ function ka(a, c, b, e, d) {
if (a > b || e) {
f = f.slice(e, e + b);
}
- d && (f = la.call(this, f));
+ d && (f = ma.call(this, f));
return f;
}
}
-function la(a) {
+function ma(a) {
const c = Array(a.length);
for (let b = 0, e; b < a.length; b++) {
e = a[b], c[b] = {id:e, doc:this.store.get(e)};
@@ -574,13 +597,13 @@ function la(a) {
a.cache = !1;
b = new Map();
let e = c.index || c.field || c;
- A(e) && (e = [e]);
+ D(e) && (e = [e]);
for (let d = 0, f, g; d < e.length; d++) {
- f = e[d], A(f) || (g = f, f = f.field), g = F(g) ? Object.assign({}, a, g) : a, b.set(f, new S(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Q(f, this.I), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].G = g.filter)), this.field[d] = f;
+ f = e[d], D(f) || (g = f, f = f.field), g = H(g) ? Object.assign({}, a, g) : a, b.set(f, new S(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Q(f, this.I), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].G = g.filter)), this.field[d] = f;
}
if (this.A) {
a = c.store;
- A(a) && (a = [a]);
+ D(a) && (a = [a]);
for (let d = 0, f, g; d < a.length; d++) {
f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.S = g) : (this.A[d] = Q(g, this.I), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].G = f.filter));
}
@@ -614,15 +637,15 @@ function Q(a, c) {
e < b.length && (b.length = e);
return 1 < e ? b : b[0];
}
-v = N.prototype;
-v.append = function(a, c) {
+x = N.prototype;
+x.append = function(a, c) {
return this.add(a, c, !0);
};
-v.update = function(a, c) {
+x.update = function(a, c) {
return this.remove(a).add(a, c);
};
-v.remove = function(a) {
- F(a) && (a = G(a, this.key));
+x.remove = function(a) {
+ H(a) && (a = I(a, this.key));
for (var c of this.index.values()) {
c.remove(a, !0);
}
@@ -642,7 +665,7 @@ v.remove = function(a) {
this.cache && this.cache.remove(a);
return this;
};
-v.clear = function() {
+x.clear = function() {
for (const a of this.index.values()) {
a.clear();
}
@@ -654,24 +677,24 @@ v.clear = function() {
this.store && this.store.clear();
return this;
};
-v.contain = function(a) {
+x.contain = function(a) {
return this.reg.has(a);
};
-v.cleanup = function() {
+x.cleanup = function() {
for (const a of this.index.values()) {
a.cleanup();
}
return this;
};
-v.get = function(a) {
+x.get = function(a) {
return this.store.get(a);
};
-v.set = function(a, c) {
+x.set = function(a, c) {
this.store.set(a, c);
return this;
};
-v.searchCache = oa;
-v.export = function(a, c, b, e, d, f) {
+x.searchCache = pa;
+x.export = function(a, c, b, e, d, f) {
let g;
"undefined" === typeof f && (g = new Promise(k => {
f = k;
@@ -699,13 +722,13 @@ v.export = function(a, c, b, e, d, f) {
f();
return;
}
- ia(a, this, b, c, e, d, h, f);
+ ja(a, this, b, c, e, d, h, f);
}
return g;
};
-v.import = function(a, c) {
+x.import = function(a, c) {
if (c) {
- switch(A(c) && (c = JSON.parse(c)), a) {
+ switch(D(c) && (c = JSON.parse(c)), a) {
case "tag":
this.D = c;
break;
@@ -727,8 +750,8 @@ v.import = function(a, c) {
}
}
};
-ha(N.prototype);
-function oa(a, c, b) {
+ia(N.prototype);
+function pa(a, c, b) {
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
let e = this.cache.get(a);
if (!e) {
@@ -768,32 +791,32 @@ R.prototype.clear = function() {
this.cache.clear();
this.h = "";
};
-const pa = {normalize:function(a) {
+const qa = {normalize:function(a) {
return a.toLowerCase();
}, dedupe:!1};
const T = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]);
-const qa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), ra = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"];
-const sa = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6};
-const ta = /[\x00-\x7F]+/g;
+const ra = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), sa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"];
+const ta = {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 ua = /[\x00-\x7F]+/g;
+const va = /[\x00-\x7F]+/g;
const wa = /[\x00-\x7F]+/g;
-var xa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:pa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:T}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:T, matcher:qa, replacer:ra}, LatinExtra:{normalize:!0, dedupe:!0, mapper:T, replacer:ra.concat([/(?!^)[aeo]/g, ""]), matcher:qa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) {
+var xa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:qa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:T}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:T, matcher:ra, replacer:sa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:T, replacer:sa.concat([/(?!^)[aeo]/g, ""]), matcher:ra}, 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 = sa[e];
- for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = sa[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) {
+ let e = c.charAt(0), d = ta[e];
+ for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = ta[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) {
}
a[b] = e;
}
}}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) {
- return ("" + a).replace(ta, " ");
+ return ("" + a).replace(ua, " ");
}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) {
- return ("" + a).replace(ua, "");
+ return ("" + a).replace(va, "");
}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) {
return ("" + a).replace(wa, " ");
}}};
const ya = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
-z();
+C();
S.prototype.add = function(a, c, b, e) {
if (c && (a || 0 === a)) {
if (!e && !b && this.reg.has(a)) {
@@ -801,19 +824,19 @@ S.prototype.add = function(a, c, b, e) {
}
c = this.encoder.encode(c);
if (e = c.length) {
- const l = z(), m = z(), n = this.depth, t = this.resolution;
+ const l = C(), m = C(), n = this.depth, t = this.resolution;
for (let p = 0; p < e; p++) {
- let q = c[this.rtl ? e - 1 - p : p];
- var d = q.length;
- if (d && (n || !m[q])) {
- var f = this.score ? this.score(c, q, p, null, 0) : U(t, e, p), g = "";
+ let r = c[this.rtl ? e - 1 - p : p];
+ var d = r.length;
+ if (d && (n || !m[r])) {
+ var f = this.score ? this.score(c, r, p, null, 0) : U(t, e, p), g = "";
switch(this.tokenize) {
case "full":
if (2 < d) {
for (f = 0; f < d; f++) {
for (var h = d; h > f; h--) {
- g = q.substring(f, h);
- var k = this.score ? this.score(c, q, p, g, f) : U(t, e, p, d, f);
+ g = r.substring(f, h);
+ var k = this.score ? this.score(c, r, p, g, f) : U(t, e, p, d, f);
V(this, m, g, k, a, b);
}
}
@@ -822,24 +845,24 @@ S.prototype.add = function(a, c, b, e) {
case "reverse":
if (1 < d) {
for (h = d - 1; 0 < h; h--) {
- g = q[h] + g, k = this.score ? this.score(c, q, p, g, h) : U(t, e, p, d, h), V(this, m, g, k, a, b);
+ g = r[h] + g, k = this.score ? this.score(c, r, p, g, h) : U(t, e, p, d, h), V(this, m, g, k, a, b);
}
g = "";
}
case "forward":
if (1 < d) {
for (h = 0; h < d; h++) {
- g += q[h], V(this, m, g, f, a, b);
+ g += r[h], V(this, m, g, f, a, b);
}
break;
}
default:
- if (V(this, m, q, f, a, b), n && 1 < e && p < e - 1) {
- for (d = z(), g = this.P, f = q, h = Math.min(n + 1, e - p), d[f] = 1, k = 1; k < h; k++) {
- if ((q = c[this.rtl ? e - 1 - p - k : p + k]) && !d[q]) {
- d[q] = 1;
- const u = this.score ? this.score(c, f, p, q, k) : U(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), w = this.bidirectional && q > f;
- V(this, l, w ? f : q, u, a, b, w ? q : f);
+ if (V(this, m, r, f, a, b), n && 1 < e && p < e - 1) {
+ for (d = C(), g = this.P, f = r, h = Math.min(n + 1, e - p), d[f] = 1, k = 1; k < h; k++) {
+ if ((r = c[this.rtl ? e - 1 - p - k : p + k]) && !d[r]) {
+ d[r] = 1;
+ const u = this.score ? this.score(c, f, p, r, k) : U(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), v = this.bidirectional && r > f;
+ V(this, l, v ? f : r, u, a, b, v ? r : f);
}
}
}
@@ -854,7 +877,7 @@ S.prototype.add = function(a, c, b, e) {
function V(a, c, b, e, d, f, g) {
let h = g ? a.ctx : a.map, k;
if (!c[b] || g && !(k = c[b])[g]) {
- g ? (c = k || (c[b] = z()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h])));
+ g ? (c = k || (c[b] = C()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h])));
}
}
function U(a, c, b, e, d) {
@@ -891,7 +914,7 @@ function U(a, c, b, e, d) {
return e.length ? e = 1 < e.length ? [].concat.apply([], e) : e[0] : e;
}
;S.prototype.search = function(a, c, b) {
- b || (!c && F(a) ? (b = a, a = "") : F(c) && (b = c, c = 0));
+ b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0));
var e = [], d = 0;
if (b) {
a = b.query || a;
@@ -912,7 +935,7 @@ function U(a, c, b, e, d) {
}
var h = 0, k = 0;
if (1 < b) {
- var l = z();
+ var l = C();
const n = [];
for (let t = 0, p; t < b; t++) {
if ((p = a[t]) && !l[p]) {
@@ -921,9 +944,9 @@ function U(a, c, b, e, d) {
} else {
return e;
}
- const q = p.length;
- h = Math.max(h, q);
- k = k ? Math.min(k, q) : q;
+ const r = p.length;
+ h = Math.max(h, r);
+ k = k ? Math.min(k, r) : r;
}
}
a = n;
@@ -971,60 +994,55 @@ function U(a, c, b, e, d) {
a: {
a = e;
e = this.resolution;
- m = a.length;
- b = [];
- f = z();
- for (let n = 0, t, p, q, u; n < e; n++) {
- for (k = 0; k < m; k++) {
- if (q = a[k], n < q.length && (t = q[n])) {
+ m = g;
+ b = a.length;
+ g = [];
+ f = C();
+ for (let n = 0, t, p, r, u; n < e; n++) {
+ for (k = 0; k < b; k++) {
+ if (r = a[k], n < r.length && (t = r[n])) {
for (l = 0; l < t.length; l++) {
- p = t[l], (h = f[p]) ? f[p]++ : (h = 0, f[p] = 1), u = b[h] || (b[h] = []), u.push(p);
+ p = t[l], (h = f[p]) ? f[p]++ : (h = 0, f[p] = 1), u = g[h] || (g[h] = []), u.push(p);
}
}
}
}
- if (a = b.length) {
- if (g) {
- if (1 < b.length) {
+ if (a = g.length) {
+ if (m) {
+ if (1 < g.length) {
b: {
- g = b;
- a = [];
- e = z();
- m = g.length;
- for (h = m - 1; 0 <= h; h--) {
+ for (a = [], e = C(), m = g.length, h = m - 1; 0 <= h; h--) {
for (m = g[h], f = m.length, k = 0; k < f; k++) {
if (b = m[k], !e[b]) {
if (e[b] = 1, d) {
d--;
} else {
if (a.push(b), a.length === c) {
- c = a;
break b;
}
}
}
}
}
- c = a;
}
} else {
- c = b[0];
+ a = (g = g[0]).length > c || d ? g.slice(d, c + d) : g;
}
- b = c;
+ g = a;
} else {
- if (a < m) {
+ if (a < b) {
e = [];
break a;
}
- b = b[a - 1];
+ g = g[a - 1];
if (c || d) {
- if (b.length > c || d) {
- b = b.slice(d, c + d);
+ if (g.length > c || d) {
+ g = g.slice(d, c + d);
}
}
}
}
- e = b;
+ e = g;
}
return e;
};
@@ -1099,14 +1117,14 @@ function Y(a, c) {
return new S(a);
}
if (a) {
- var b = A(a) ? a : a.preset;
+ var b = D(a) ? a : a.preset;
b && (ya[b] || console.warn("Preset not found: " + b), a = Object.assign({}, ya[b], a));
} else {
a = {};
}
b = a.context || {};
- const e = A(a.encoder) ? xa[a.encoder] : a.encode || a.encoder || pa;
- this.encoder = e.encode ? e : "object" === typeof e ? new K(e) : {encode:e};
+ const e = D(a.encoder) ? xa[a.encoder] : a.encode || a.encoder || qa;
+ this.encoder = e.encode ? e : "object" === typeof e ? new L(e) : {encode:e};
let d;
this.resolution = a.resolution || 9;
this.tokenize = d = a.tokenize || "strict";
@@ -1122,21 +1140,21 @@ function Y(a, c) {
this.rtl = e.rtl || a.rtl || !1;
this.cache = (d = a.cache || null) && new R(d);
}
-v = S.prototype;
-v.clear = function() {
+x = S.prototype;
+x.clear = function() {
this.map.clear();
this.ctx.clear();
this.reg.clear();
this.cache && this.cache.clear();
return this;
};
-v.append = function(a, c) {
+x.append = function(a, c) {
return this.add(a, c, !0);
};
-v.contain = function(a) {
+x.contain = function(a) {
return this.reg.has(a);
};
-v.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);
};
@@ -1154,7 +1172,7 @@ function Z(a) {
}
return c;
}
-v.cleanup = function() {
+x.cleanup = function() {
if (!this.fastupdate) {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
@@ -1162,8 +1180,8 @@ v.cleanup = function() {
this.depth && Z(this.ctx);
return this;
};
-v.searchCache = oa;
-v.export = function(a, c, b, e, d, f) {
+x.searchCache = pa;
+x.export = function(a, c, b, e, d, f) {
let g = !0;
"undefined" === typeof f && (g = new Promise(l => {
f = l;
@@ -1173,7 +1191,7 @@ v.export = function(a, c, b, e, d, f) {
case 0:
h = "reg";
if (this.fastupdate) {
- k = z();
+ k = C();
for (let l of this.reg.keys()) {
k[l] = 1;
}
@@ -1197,12 +1215,12 @@ v.export = function(a, c, b, e, d, f) {
"undefined" === typeof b && f && f();
return;
}
- ia(a, c || this, b, h, e, d, k, f);
+ ja(a, c || this, b, h, e, d, k, f);
return g;
};
-v.import = function(a, c) {
+x.import = function(a, c) {
if (c) {
- switch(A(c) && (c = JSON.parse(c)), a) {
+ switch(D(c) && (c = JSON.parse(c)), a) {
case "cfg":
this.h = !!c.opt;
break;
@@ -1218,7 +1236,7 @@ v.import = function(a, c) {
}
}
};
-v.serialize = function(a = !0) {
+x.serialize = function(a = !0) {
if (!this.reg.size) {
return "";
}
@@ -1254,8 +1272,8 @@ v.serialize = function(a = !0) {
for (let t = 0, p; t < h.length; t++) {
p = h[t] || [""];
l = "";
- for (let q = 0; q < p.length; q++) {
- l += (l ? "," : "") + ("string" === b ? '"' + p[q] + '"' : p[q]);
+ for (let r = 0; r < p.length; r++) {
+ l += (l ? "," : "") + ("string" === b ? '"' + p[r] + '"' : p[r]);
}
l = "[" + l + "]";
k += (k ? "," : "") + l;
@@ -1268,7 +1286,7 @@ v.serialize = function(a = !0) {
d = "index.ctx=new Map([" + d + "]);";
return a ? "function inject(index){" + c + e + d + "}" : c + e + d;
};
-ha(S.prototype);
-export default {Index:S, Charset:xa, Encoder:K, Document:N, Worker:null, Resolver:null, IndexedDB:null, Language:{}};
+ia(S.prototype);
+export default {Index:S, Charset:xa, Encoder:L, Document:N, Worker:null, Resolver:null, IndexedDB:null, Language:{}};
-export const Index=S;export const Charset=xa;export const Encoder=K;export const Document=N;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={};
\ No newline at end of file
+export const Index=S;export const Charset=xa;export const Encoder=L;export const Document=N;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={};
\ No newline at end of file
diff --git a/dist/flexsearch.compact.module.min.js b/dist/flexsearch.compact.module.min.js
index cc662aa..b500242 100644
--- a/dist/flexsearch.compact.module.min.js
+++ b/dist/flexsearch.compact.module.min.js
@@ -5,49 +5,49 @@
* Hosted by Nextapps GmbH
* https://github.com/nextapps-de/flexsearch
*/
-var v;function y(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var f=new Map(b);for(var g of a)f.set(g[0],g[1]);return f}if(c===Set){g=new Set(b);for(f of a.values())g.add(f);return g}}}return a}return b}return"undefined"===d?c:a}function z(){return Object.create(null)}function aa(a,c){return c.length-a.length}
-function C(a){return"string"===typeof a}function F(a){return"object"===typeof a}function G(a,c){if(C(c))a=a[c];else for(let b=0;a&&bthis.stemmer.get(l)),k=1);g&&k&&(g.length<
-this.minlength||this.filter&&this.filter.has(g))&&(g="");if(g&&(this.mapper||this.dedupe&&1this.matcher.get(l)));if(g&&this.replacer)for(d=0;g&&dthis.O&&(this.H.clear(),this.D=this.D/1.1|0));g&&b.push(g)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.h&&(this.F.set(a,b),this.F.size>this.O&&(this.F.clear(),this.h=this.h/1.1|0));return b};function K(a){a.J=null;a.F.clear();a.H.clear()};function ha(a){L.call(a,"add");L.call(a,"append");L.call(a,"search");L.call(a,"update");L.call(a,"remove")}function L(a){this[a+"Async"]=function(){var c=arguments;const b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);c=this[a].apply(this,c);e&&(c.then?c.then(e):e(c));return c}};function ia(a,c,b,e,d,f,g,h){(e=a(b?b+"."+e:e,JSON.stringify(g)))&&e.then?e.then(function(){c.export(a,c,b,d,f+1,h)}):c.export(a,c,b,d,f+1,h)};M.prototype.add=function(a,c,b){F(a)&&(c=a,a=G(c,this.key));if(c&&(a||0===a)){if(!b&&this.reg.has(a))return this.update(a,c);for(let h=0,k;hb||e)a=a.slice(e,e+b);d&&(a=la.call(this,a));return a}}
-function la(a){const c=Array(a.length);for(let b=0,e;b{f=k}));d||(d=0);e||(e=0);if(ethis.limit&&this.cache.delete(this.cache.keys().next().value)};
-R.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};R.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};R.prototype.clear=function(){this.cache.clear();this.h=""};const pa={normalize:function(a){return a.toLowerCase()},dedupe:!1};const T=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const qa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),ra=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const sa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const ta=/[\x00-\x7F]+/g;const va=/[\x00-\x7F]+/g;const wa=/[\x00-\x7F]+/g;var xa={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:pa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:T},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:T,matcher:qa,replacer:ra},LatinExtra:{normalize:!0,dedupe:!0,mapper:T,replacer:ra.concat([/(?!^)[aeo]/g,""]),matcher:qa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bf;h--){g=q.substring(f,h);var k=this.score?this.score(c,q,p,g,f):U(t,e,p,d,f);V(this,m,g,k,a,b)}break}case "reverse":if(1<
-d){for(h=d-1;0g?0:1),e,p,h-1,k-1),w=this.bidirectional&&q>f;V(this,l,w?f:q,u,a,b,w?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};
-function V(a,c,b,e,d,f,g){let h=g?a.ctx:a.map,k;if(!c[b]||g&&!(k=c[b])[g])g?(c=k||(c[b]=z()),c[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),f&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function U(a,c,b,e,d){return b&&1c?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}bc&&(f=f.slice(0,c),g=f.length),e.push(f);else{if(g>=c)return g>c&&(f=f.slice(0,c)),f;e=[f]}c-=g;if(!c)break}return e.length?e=1c||d)b=b.slice(d,c+d)}e=b}return e};
-function W(a,c,b,e){return(a=X(this,a,c))&&a.length?za(a,b,e):[]}function Aa(a,c,b,e){let d=[];if(a){e=Math.min(a.length,e);for(let f=0,g;fb);a=b?(a=a.ctx.get(e?c:b))&&a.get(e?b:c):a.map.get(c);return a};S.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Y(this.map,a),this.depth&&Y(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
-function Y(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};
-function Z(a){let c=0;if(a.constructor===Array)for(let b=0,e;b{f=l}));let h,k;switch(d||(d=0)){case 0:h="reg";if(this.fastupdate){k=z();for(let l of this.reg.keys())k[l]=1}else k=this.reg;break;case 1:h="cfg";k={doc:0,opt:this.h?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.ctx;break;default:"undefined"===typeof b&&f&&f();return}ia(a,c||this,b,h,e,d,k,f);return g};
-v.import=function(a,c){if(c)switch(C(c)&&(c=JSON.parse(c)),a){case "cfg":this.h=!!c.opt;break;case "reg":this.fastupdate=!1;this.reg=c;break;case "map":this.map=c;break;case "ctx":this.ctx=c}};
-v.serialize=function(a=!0){if(!this.reg.size)return"";let c="",b="";for(var e of this.reg.keys())b||(b=typeof e),c+=(c?",":"")+("string"===b?'"'+e+'"':e);c="index.reg=new Set(["+c+"]);";e="";for(var d of this.map.entries()){var f=d[0],g=d[1],h="";for(let m=0,n;mthis.stemmer.get(l)),k=1);f&&k&&(f.length<
+this.minlength||this.filter&&this.filter.has(f))&&(f="");if(f&&(this.mapper||this.dedupe&&1this.matcher.get(l)));if(f&&this.replacer)for(d=0;f&&dthis.O&&(this.H.clear(),this.D=this.D/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.h&&(this.F.set(a,b),this.F.size>this.O&&(this.F.clear(),this.h=this.h/1.1|0));return b};function ha(a){a.J=null;a.F.clear();a.H.clear()};function ia(a){M.call(a,"add");M.call(a,"append");M.call(a,"search");M.call(a,"update");M.call(a,"remove")}function M(a){this[a+"Async"]=function(){var c=arguments;const b=c[c.length-1];let e;"function"===typeof b&&(e=b,delete c[c.length-1]);c=this[a].apply(this,c);e&&(c.then?c.then(e):e(c));return c}};function ja(a,c,b,e,d,g,f,h){(e=a(b?b+"."+e:e,JSON.stringify(f)))&&e.then?e.then(function(){c.export(a,c,b,d,g+1,h)}):c.export(a,c,b,d,g+1,h)};N.prototype.add=function(a,c,b){H(a)&&(c=a,a=I(c,this.key));if(c&&(a||0===a)){if(!b&&this.reg.has(a))return this.update(a,c);for(let h=0,k;hb||e)a=a.slice(e,e+b);d&&(a=ma.call(this,a));return a}}
+function ma(a){const c=Array(a.length);for(let b=0,e;b{g=k}));d||(d=0);e||(e=0);if(ethis.limit&&this.cache.delete(this.cache.keys().next().value)};
+R.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};R.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};R.prototype.clear=function(){this.cache.clear();this.h=""};const qa={normalize:function(a){return a.toLowerCase()},dedupe:!1};const T=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 ra=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),sa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const ta={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 ua=/[\x00-\x7F]+/g;const va=/[\x00-\x7F]+/g;const wa=/[\x00-\x7F]+/g;var xa={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:qa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:T},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:T,matcher:ra,replacer:sa},LatinExtra:{normalize:!0,dedupe:!0,mapper:T,replacer:sa.concat([/(?!^)[aeo]/g,""]),matcher:ra},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bg;h--){f=r.substring(g,h);var k=this.score?this.score(c,r,p,f,g):U(t,e,p,d,g);V(this,m,f,k,a,b)}break}case "reverse":if(1<
+d){for(h=d-1;0f?0:1),e,p,h-1,k-1),u=this.bidirectional&&r>g;V(this,l,u?g:r,v,a,b,u?r:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
+function V(a,c,b,e,d,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=C()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[e]||(h[e]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(h):a.reg.set(d,[h])))}function U(a,c,b,e,d){return b&&1c?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,g,f;d=f){b-=f;continue}bc&&(g=g.slice(0,c),f=g.length),e.push(g);else{if(f>=c)return f>c&&(g=g.slice(0,c)),g;e=[g]}c-=f;if(!c)break}return e.length?e=1c||d?f.slice(d,c+d):f;f=a}else{if(ac||d)f=f.slice(d,c+d)}e=f}return e};
+function W(a,c,b,e){return(a=X(this,a,c))&&a.length?za(a,b,e):[]}function Aa(a,c,b,e){let d=[];if(a){e=Math.min(a.length,e);for(let g=0,f;gb);a=b?(a=a.ctx.get(e?c:b))&&a.get(e?b:c):a.map.get(c);return a};S.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const g=d.indexOf(a);g===b.length-1?d.pop():d.splice(g,1)}}else Y(this.map,a),this.depth&&Y(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this};
+function Y(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,g;eb.add(a,c)):this.add(a,c)};
+function Z(a){let c=0;if(a.constructor===Array)for(let b=0,e;b{g=l}));let h,k;switch(d||(d=0)){case 0:h="reg";if(this.fastupdate){k=C();for(let l of this.reg.keys())k[l]=1}else k=this.reg;break;case 1:h="cfg";k={doc:0,opt:this.h?1:0};break;case 2:h="map";k=this.map;break;case 3:h="ctx";k=this.ctx;break;default:"undefined"===typeof b&&g&&g();return}ja(a,c||this,b,h,e,d,k,g);return f};
+x.import=function(a,c){if(c)switch(E(c)&&(c=JSON.parse(c)),a){case "cfg":this.h=!!c.opt;break;case "reg":this.fastupdate=!1;this.reg=c;break;case "map":this.map=c;break;case "ctx":this.ctx=c}};
+x.serialize=function(a=!0){if(!this.reg.size)return"";let c="",b="";for(var e of this.reg.keys())b||(b=typeof e),c+=(c?",":"")+("string"===b?'"'+e+'"':e);c="index.reg=new Set(["+c+"]);";e="";for(var d of this.map.entries()){var g=d[0],f=d[1],h="";for(let m=0,n;m>> 0) + "_", e = 0;
return b;
});
-C("Symbol.iterator", function(a) {
+E("Symbol.iterator", function(a) {
if (a) {
return a;
}
a = Symbol("Symbol.iterator");
for (var b = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), c = 0; c < b.length; c++) {
- var d = B[b[c]];
+ var d = C[b[c]];
"function" === typeof d && "function" != typeof d.prototype[a] && ba(d.prototype, a, {configurable:!0, writable:!0, value:function() {
return sa(aa(this));
}});
@@ -247,7 +247,7 @@ function sa(a) {
};
return a;
}
-C("Promise", function(a) {
+E("Promise", function(a) {
function b(f) {
this.A = 0;
this.B = void 0;
@@ -281,7 +281,7 @@ C("Promise", function(a) {
}
this.h.push(f);
};
- var e = B.setTimeout;
+ var e = C.setTimeout;
c.prototype.B = function(f) {
e(f, 0);
};
@@ -367,7 +367,7 @@ C("Promise", function(a) {
var f = this;
e(function() {
if (f.fa()) {
- var h = B.console;
+ var h = C.console;
"undefined" !== typeof h && h.error(f.B);
}
}, 1);
@@ -376,11 +376,11 @@ C("Promise", function(a) {
if (this.L) {
return !1;
}
- var f = B.CustomEvent, h = B.Event, k = B.dispatchEvent;
+ var f = C.CustomEvent, h = C.Event, k = C.dispatchEvent;
if ("undefined" === typeof k) {
return !0;
}
- "function" === typeof f ? f = new f("unhandledrejection", {cancelable:!0}) : "function" === typeof h ? f = new h("unhandledrejection", {cancelable:!0}) : (f = B.document.createEvent("CustomEvent"), f.initCustomEvent("unhandledrejection", !1, !0, f));
+ "function" === typeof f ? f = new f("unhandledrejection", {cancelable:!0}) : "function" === typeof h ? f = new h("unhandledrejection", {cancelable:!0}) : (f = C.document.createEvent("CustomEvent"), f.initCustomEvent("unhandledrejection", !1, !0, f));
f.promise = this;
f.reason = this.B;
return k(f);
@@ -451,13 +451,13 @@ C("Promise", function(a) {
};
b.race = function(f) {
return new b(function(h, k) {
- for (var l = w(f), m = l.next(); !m.done; m = l.next()) {
+ for (var l = y(f), m = l.next(); !m.done; m = l.next()) {
d(m.value).V(h, k);
}
});
};
b.all = function(f) {
- var h = w(f), k = h.next();
+ var h = y(f), k = h.next();
return k.done ? d([]) : new b(function(l, m) {
function n(r) {
return function(u) {
@@ -489,7 +489,7 @@ function ta(a, b) {
};
return e;
}
-C("Array.prototype.values", function(a) {
+E("Array.prototype.values", function(a) {
return a ? a : function() {
return ta(this, function(b, c) {
return c;
@@ -499,11 +499,11 @@ C("Array.prototype.values", function(a) {
function J(a, b) {
return Object.prototype.hasOwnProperty.call(a, b);
}
-C("WeakMap", function(a) {
+E("WeakMap", function(a) {
function b(k) {
this.h = (h += Math.random() + 1).toString();
if (k) {
- k = w(k);
+ k = y(k);
for (var l; !(l = k.next()).done;) {
l = l.value, this.set(l[0], l[1]);
}
@@ -576,7 +576,7 @@ C("WeakMap", function(a) {
};
return b;
});
-C("Map", function(a) {
+E("Map", function(a) {
function b() {
var h = {};
return h.K = h.next = h.head = h;
@@ -615,7 +615,7 @@ C("Map", function(a) {
this[1] = b();
this.size = 0;
if (h) {
- h = w(h);
+ h = y(h);
for (var k; !(k = h.next()).done;) {
k = k.value, this.set(k[0], k[1]);
}
@@ -626,7 +626,7 @@ C("Map", function(a) {
return !1;
}
try {
- var h = Object.seal({x:4}), k = new a(w([[h, "s"]]));
+ var h = Object.seal({x:4}), k = new a(y([[h, "s"]]));
if ("s" != k.get(h) || 1 != k.size || k.get({x:4}) || k.set({x:4}, "t") != k || 2 != k.size) {
return !1;
}
@@ -689,18 +689,18 @@ C("Map", function(a) {
var f = 0;
return e;
});
-C("Array.prototype.keys", function(a) {
+E("Array.prototype.keys", function(a) {
return a ? a : function() {
return ta(this, function(b) {
return b;
});
};
});
-C("Set", function(a) {
+E("Set", function(a) {
function b(c) {
this.h = new Map();
if (c) {
- c = w(c);
+ c = y(c);
for (var d; !(d = c.next()).done;) {
this.add(d.value);
}
@@ -712,7 +712,7 @@ C("Set", function(a) {
return !1;
}
try {
- var c = Object.seal({x:4}), d = new a(w([c]));
+ var c = Object.seal({x:4}), d = new a(y([c]));
if (!d.has(c) || 1 != d.size || d.add(c) != d || 1 != d.size || d.add({x:4}) != d || 2 != d.size) {
return !1;
}
@@ -762,19 +762,19 @@ C("Set", function(a) {
};
return b;
});
-C("Array.prototype.entries", function(a) {
+E("Array.prototype.entries", function(a) {
return a ? a : function() {
return ta(this, function(b, c) {
return [b, c];
});
};
});
-C("Object.is", function(a) {
+E("Object.is", function(a) {
return a ? a : function(b, c) {
return b === c ? 0 !== b || 1 / b === 1 / c : b !== b && c !== c;
};
});
-C("Array.prototype.includes", function(a) {
+E("Array.prototype.includes", function(a) {
return a ? a : function(b, c) {
var d = this;
d instanceof String && (d = String(d));
@@ -789,7 +789,7 @@ C("Array.prototype.includes", function(a) {
return !1;
};
});
-C("String.prototype.includes", function(a) {
+E("String.prototype.includes", function(a) {
return a ? a : function(b, c) {
if (null == this) {
throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");
@@ -811,10 +811,10 @@ var ua = "function" == typeof Object.assign ? Object.assign : function(a, b) {
}
return a;
};
-C("Object.assign", function(a) {
+E("Object.assign", function(a) {
return a || ua;
});
-C("Array.prototype.flat", function(a) {
+E("Array.prototype.flat", function(a) {
return a ? a : function(b) {
b = void 0 === b ? 1 : b;
var c = [];
@@ -841,7 +841,7 @@ function L(a, b, c) {
}
if (b === Map) {
b = new Map(c);
- d = w(a);
+ d = y(a);
for (e = d.next(); !e.done; e = d.next()) {
e = e.value, b.set(e[0], e[1]);
}
@@ -849,7 +849,7 @@ function L(a, b, c) {
}
if (b === Set) {
b = new Set(c);
- d = w(a.values());
+ d = y(a.values());
for (e = d.next(); !e.done; e = d.next()) {
b.add(e.value);
}
@@ -877,7 +877,7 @@ function O(a) {
}
function wa(a) {
var b = [];
- a = w(a.keys());
+ a = y(a.keys());
for (var c = a.next(); !c.done; c = a.next()) {
b.push(c.value);
}
@@ -907,26 +907,26 @@ function ya(a) {
["\u02b2", "j"], ["\u02b3", "r"], ["\u02b4", "\u0279"], ["\u02b5", "\u027b"], ["\u02b6", "\u0281"], ["\u02b7", "w"], ["\u02b8", "y"], ["\u02e0", "\u0263"], ["\u02e1", "l"], ["\u02e2", "s"], ["\u02e3", "x"], ["\u02e4", "\u0295"], ["\u0390", "\u03b9"], ["\u03ac", "\u03b1"], ["\u03ad", "\u03b5"], ["\u03ae", "\u03b7"], ["\u03af", "\u03b9"], ["\u03b0", "\u03c5"], ["\u03ca", "\u03b9"], ["\u03cb", "\u03c5"], ["\u03cc", "\u03bf"], ["\u03cd", "\u03c5"], ["\u03ce", "\u03c9"], ["\u03d0", "\u03b2"], ["\u03d1",
"\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db",
"\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]];
-var Aa = /[^\p{L}\p{N}]+/u, Ba = /(\d{3})/g, Ca = /(\D)(\d{3})/g, Da = /(\d{3})(\D)/g, Ea = "".normalize && /[\u0300-\u036f]/g;
-function Fa(a) {
+var Aa = /[^\p{L}\p{N}]+/u, Ba = /(\d{3})/g, Ca = /(\D)(\d{3})/g, Ea = /(\d{3})(\D)/g, Fa = "".normalize && /[\u0300-\u036f]/g;
+function Ga(a) {
if (!this) {
var b = Function.prototype.bind, c = b.apply, d = [null], e = d.concat;
if (arguments instanceof Array) {
var g = arguments;
} else {
- g = w(arguments);
+ g = y(arguments);
for (var f, h = []; !(f = g.next()).done;) {
h.push(f.value);
}
g = h;
}
- return new (c.call(b, Fa, e.call(d, g)))();
+ return new (c.call(b, Ga, e.call(d, g)))();
}
for (b = 0; b < arguments.length; b++) {
this.assign(arguments[b]);
}
}
-Fa.prototype.assign = function(a) {
+Ga.prototype.assign = function(a) {
this.normalize = L(a.normalize, !0, this.normalize);
var b = a.include, c = b || a.exclude || a.split;
if ("object" === typeof c) {
@@ -956,7 +956,7 @@ Fa.prototype.assign = function(a) {
}
this.prepare = L(a.prepare, null, this.prepare);
this.finalize = L(a.finalize, null, this.finalize);
- Ea || (this.mapper = new Map(za));
+ Fa || (this.mapper = new Map(za));
this.rtl = a.rtl || !1;
this.dedupe = L(a.dedupe, !0, this.dedupe);
this.filter = L((c = a.filter) && new Set(c), null, this.filter);
@@ -974,18 +974,18 @@ Fa.prototype.assign = function(a) {
this.C = "";
this.G = null;
if (this.matcher) {
- for (a = w(this.matcher.keys()), b = a.next(); !b.done; b = a.next()) {
+ for (a = y(this.matcher.keys()), b = a.next(); !b.done; b = a.next()) {
this.B += (this.B ? "|" : "") + b.value;
}
}
if (this.stemmer) {
- for (a = w(this.stemmer.keys()), b = a.next(); !b.done; b = a.next()) {
+ for (a = y(this.stemmer.keys()), b = a.next(); !b.done; b = a.next()) {
this.C += (this.C ? "|" : "") + b.value;
}
}
return this;
};
-Fa.prototype.encode = function(a) {
+Ga.prototype.encode = function(a) {
var b = this;
if (this.cache && a.length <= this.h) {
if (this.U) {
@@ -993,12 +993,12 @@ Fa.prototype.encode = function(a) {
return this.N.get(a);
}
} else {
- this.U = setTimeout(Ga, 50, this);
+ this.U = setTimeout(Ha, 50, this);
}
}
- this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : Ea ? a.normalize("NFKD").replace(Ea, "").toLowerCase() : a.toLowerCase());
+ this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : Fa ? a.normalize("NFKD").replace(Fa, "").toLowerCase() : a.toLowerCase());
this.prepare && (a = this.prepare(a));
- this.numeric && 3 < a.length && (a = a.replace(Ca, "$1 $2").replace(Da, "$1 $2").replace(Ba, "$1 "));
+ this.numeric && 3 < a.length && (a = a.replace(Ca, "$1 $2").replace(Ea, "$1 $2").replace(Ba, "$1 "));
for (var c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer), d = [], e = this.split || "" === this.split ? a.split(this.split) : a, g = 0, f = void 0, h = void 0; g < e.length; g++) {
if ((f = h = e[g]) && !(f.length < this.minlength)) {
if (c) {
@@ -1013,7 +1013,7 @@ Fa.prototype.encode = function(a) {
continue;
}
} else {
- this.U = setTimeout(Ga, 50, this);
+ this.U = setTimeout(Ha, 50, this);
}
}
k = void 0;
@@ -1046,12 +1046,12 @@ Fa.prototype.encode = function(a) {
this.cache && a.length <= this.h && (this.N.set(a, d), this.N.size > this.L && (this.N.clear(), this.h = this.h / 1.1 | 0));
return d;
};
-function Ga(a) {
+function Ha(a) {
a.U = null;
a.N.clear();
a.S.clear();
}
-;function Ha(a) {
+;function Ia(a) {
var b, c, d, e, g, f, h, k;
return I(function(l) {
a = a.data;
@@ -1071,8 +1071,8 @@ function Ga(a) {
l.h = 0;
});
}
-;var Ia = 0;
-function Ja(a) {
+;var Ja = 0;
+function Ka(a) {
function b(f) {
function h(k) {
k = k.data || k;
@@ -1085,10 +1085,10 @@ function Ja(a) {
d ? this.worker.on("message", h) : this.worker.onmessage = h;
if (a.config) {
return new Promise(function(k) {
- e.h[++Ia] = function() {
+ e.h[++Ja] = function() {
k(e);
};
- e.worker.postMessage({id:Ia, task:"init", factory:c, options:a});
+ e.worker.postMessage({id:Ja, task:"init", factory:c, options:a});
});
}
this.worker.postMessage({task:"init", factory:c, options:a});
@@ -1097,22 +1097,22 @@ function Ja(a) {
}
a = void 0 === a ? {} : a;
if (!this) {
- return new Ja(a);
+ return new Ka(a);
}
var c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null;
c && (c = c.toString());
- var d = "undefined" === typeof window, e = this, g = Ka(c, d, a.worker);
+ var d = "undefined" === typeof window, e = this, g = La(c, d, a.worker);
return g.then ? g.then(function(f) {
return b.call(e, f);
}) : b.call(this, g);
}
-La("add");
-La("append");
-La("search");
-La("update");
-La("remove");
-function La(a) {
- Ja.prototype[a] = Ja.prototype[a + "Async"] = function() {
+Ma("add");
+Ma("append");
+Ma("search");
+Ma("update");
+Ma("remove");
+function Ma(a) {
+ Ka.prototype[a] = Ka.prototype[a + "Async"] = function() {
var b = this, c = arguments, d, e, g, f, h;
return I(function(k) {
d = b;
@@ -1120,25 +1120,25 @@ function La(a) {
g = e[e.length - 1];
"function" === typeof g && (f = g, e.splice(e.length - 1, 1));
h = new Promise(function(l) {
- d.h[++Ia] = l;
- d.worker.postMessage({task:a, id:Ia, args:e});
+ d.h[++Ja] = l;
+ d.worker.postMessage({task:a, id:Ja, args:e});
});
return f ? (h.then(f), k.return(b)) : k.return(h);
});
};
}
-function Ka(a, b, c) {
- return b ? "undefined" !== typeof module ? new (require("worker_threads")["Worker"])(__dirname + "/node/node.js") : import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); }) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + Ha.toString()], {type:"text/javascript"}))) : new window.Worker(N(c) ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js",
+function La(a, b, c) {
+ return b ? "undefined" !== typeof module ? new (require("worker_threads")["Worker"])(__dirname + "/node/node.js") : import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); }) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + Ia.toString()], {type:"text/javascript"}))) : new window.Worker(N(c) ? c : (0,eval)("import.meta.url").replace("/worker.js", "/worker/worker.js").replace("flexsearch.bundle.module.min.js",
"module/worker/worker.js"), {type:"module"});
}
-;function Ma(a) {
- Na.call(a, "add");
- Na.call(a, "append");
- Na.call(a, "search");
- Na.call(a, "update");
- Na.call(a, "remove");
+;function Na(a) {
+ Oa.call(a, "add");
+ Oa.call(a, "append");
+ Oa.call(a, "search");
+ Oa.call(a, "update");
+ Oa.call(a, "remove");
}
-function Na(a) {
+function Oa(a) {
this[a + "Async"] = function() {
var b = arguments, c = b[b.length - 1];
if ("function" === typeof c) {
@@ -1150,12 +1150,12 @@ function Na(a) {
return b;
};
}
-;function Oa(a, b, c, d, e, g, f, h) {
+;function Pa(a, b, c, d, e, g, f, h) {
(d = a(c ? c + "." + d : d, JSON.stringify(f))) && d.then ? d.then(function() {
b.export(a, b, c, e, g + 1, h);
}) : b.export(a, b, c, e, g + 1, h);
}
-;function Pa(a, b, c, d) {
+;function Qa(a, b, c, d) {
for (var e = [], g = 0, f; g < a.index.length; g++) {
if (f = a.index[g], b >= f.length) {
b -= f.length;
@@ -1220,12 +1220,12 @@ function S(a) {
}
if ("slice" === d) {
return function(e, g) {
- return Pa(b, e || 0, g || b.length, !1);
+ return Qa(b, e || 0, g || b.length, !1);
};
}
if ("splice" === d) {
return function(e, g) {
- return Pa(b, e || 0, g || b.length, !0);
+ return Qa(b, e || 0, g || b.length, !0);
};
}
if ("constructor" === d) {
@@ -1257,7 +1257,7 @@ function T(a) {
this.index = M();
this.B = [];
this.size = 0;
- 32 < a ? (this.h = Qa, this.A = BigInt(a)) : (this.h = Ra, this.A = a);
+ 32 < a ? (this.h = Ra, this.A = BigInt(a)) : (this.h = Sa, this.A = a);
}
T.prototype.get = function(a) {
var b = this.h(a);
@@ -1274,53 +1274,27 @@ function U(a) {
}
this.index = M();
this.h = [];
- 32 < a ? (this.B = Qa, this.A = BigInt(a)) : (this.B = Ra, this.A = a);
+ 32 < a ? (this.B = Ra, this.A = BigInt(a)) : (this.B = Sa, this.A = a);
}
U.prototype.add = function(a) {
var b = this.B(a), c = this.index[b];
c ? (b = c.size, c.add(a), (b -= c.size) && this.size++) : (this.index[b] = c = new Set([a]), this.h.push(c));
};
-t = T.prototype;
-t.has = U.prototype.has = function(a) {
+v = T.prototype;
+v.has = U.prototype.has = function(a) {
var b = this.B(a);
return (b = this.index[b]) && b.has(a);
};
-t.delete = U.prototype.delete = function(a) {
+v.delete = U.prototype.delete = function(a) {
var b = this.B(a);
(b = this.index[b]) && b.delete(a) && this.size--;
};
-t.clear = U.prototype.clear = function() {
+v.clear = U.prototype.clear = function() {
this.index = M();
this.h = [];
this.size = 0;
};
-t.values = U.prototype.values = function Sa() {
- var b, c = this, d, e, g;
- return qa(Sa, function(f) {
- switch(f.h) {
- case 1:
- b = 0;
- case 2:
- if (!(b < c.h.length)) {
- f.h = 0;
- break;
- }
- d = w(c.h[b].values());
- e = d.next();
- case 5:
- if (e.done) {
- b++;
- f.h = 2;
- break;
- }
- g = e.value;
- return G(f, g, 6);
- case 6:
- e = d.next(), f.h = 5;
- }
- });
-};
-t.keys = U.prototype.keys = function Ta() {
+v.values = U.prototype.values = function Ta() {
var b, c = this, d, e, g;
return qa(Ta, function(f) {
switch(f.h) {
@@ -1331,7 +1305,7 @@ t.keys = U.prototype.keys = function Ta() {
f.h = 0;
break;
}
- d = w(c.h[b].keys());
+ d = y(c.h[b].values());
e = d.next();
case 5:
if (e.done) {
@@ -1346,7 +1320,7 @@ t.keys = U.prototype.keys = function Ta() {
}
});
};
-t.entries = U.prototype.entries = function Ua() {
+v.keys = U.prototype.keys = function Ua() {
var b, c = this, d, e, g;
return qa(Ua, function(f) {
switch(f.h) {
@@ -1357,7 +1331,7 @@ t.entries = U.prototype.entries = function Ua() {
f.h = 0;
break;
}
- d = w(c.h[b].entries());
+ d = y(c.h[b].keys());
e = d.next();
case 5:
if (e.done) {
@@ -1372,7 +1346,33 @@ t.entries = U.prototype.entries = function Ua() {
}
});
};
-function Ra(a) {
+v.entries = U.prototype.entries = function Va() {
+ var b, c = this, d, e, g;
+ return qa(Va, function(f) {
+ switch(f.h) {
+ case 1:
+ b = 0;
+ case 2:
+ if (!(b < c.h.length)) {
+ f.h = 0;
+ break;
+ }
+ d = y(c.h[b].entries());
+ e = d.next();
+ case 5:
+ if (e.done) {
+ b++;
+ f.h = 2;
+ break;
+ }
+ g = e.value;
+ return G(f, g, 6);
+ case 6:
+ e = d.next(), f.h = 5;
+ }
+ });
+};
+function Sa(a) {
var b = Math.pow(2, this.A) - 1;
if ("number" == typeof a) {
return a & b;
@@ -1382,7 +1382,7 @@ function Ra(a) {
}
return 32 === this.A ? c + Math.pow(2, 31) : c;
}
-function Qa() {
+function Ra() {
throw Error("The keystore is limited to 32 for EcmaScript5");
}
;V.prototype.add = function(a, b, c) {
@@ -1399,7 +1399,7 @@ function Qa() {
} else {
var f = e.R;
if (!f || f(b)) {
- e.constructor === String ? e = ["" + e] : N(e) && (e = [e]), Va(b, e, this.T, 0, g, a, e[0], c);
+ e.constructor === String ? e = ["" + e] : N(e) && (e = [e]), Wa(b, e, this.T, 0, g, a, e[0], c);
}
}
}
@@ -1432,7 +1432,7 @@ function Qa() {
if (k.length === Math.pow(2, 31) - 1) {
m = new S(k);
if (this.fastupdate) {
- for (var n = w(this.reg.values()), p = n.next(); !p.done; p = n.next()) {
+ for (var n = y(this.reg.values()), p = n.next(); !p.done; p = n.next()) {
p = p.value, p.includes(k) && (p[p.indexOf(k)] = m);
}
}
@@ -1464,7 +1464,7 @@ function Qa() {
q[d] = b[d];
continue;
}
- Wa(b, q, d, 0, d[0], g);
+ Xa(b, q, d, 0, d[0], g);
}
}
}
@@ -1473,21 +1473,21 @@ function Qa() {
}
return this;
};
-function Wa(a, b, c, d, e, g) {
+function Xa(a, b, c, d, e, g) {
a = a[e];
if (d === c.length - 1) {
b[e] = g || a;
} else if (a) {
if (a.constructor === Array) {
for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) {
- Wa(a, b, c, d, e);
+ Xa(a, b, c, d, e);
}
} else {
- b = b[e] || (b[e] = M()), e = c[++d], Wa(a, b, c, d, e);
+ b = b[e] || (b[e] = M()), e = c[++d], Xa(a, b, c, d, e);
}
}
}
-function Va(a, b, c, d, e, g, f, h) {
+function Wa(a, b, c, d, e, g, f, h) {
if (a = a[f]) {
if (d === b.length - 1) {
if (a.constructor === Array) {
@@ -1503,17 +1503,17 @@ function Va(a, b, c, d, e, g, f, h) {
} else {
if (a.constructor === Array) {
for (f = 0; f < a.length; f++) {
- Va(a, b, c, d, e, g, f, h);
+ Wa(a, b, c, d, e, g, f, h);
}
} else {
- f = b[++d], Va(a, b, c, d, e, g, f, h);
+ f = b[++d], Wa(a, b, c, d, e, g, f, h);
}
}
} else {
e.db && e.remove(g);
}
}
-;function Xa(a, b, c, d, e, g, f) {
+;function Ya(a, b, c, d, e, g, f) {
var h = a.length, k = [], l;
var m = M();
for (var n = 0, p = void 0, q; n < b; n++) {
@@ -1524,8 +1524,8 @@ function Va(a, b, c, d, e, g, f, h) {
(l = m[q]) ? m[q]++ : (l = 0, m[q] = 1);
l = k[l] || (k[l] = []);
if (!f) {
- var x = n + (r ? 0 : g || 0);
- l = l[x] || (l[x] = []);
+ var w = n + (r ? 0 : g || 0);
+ l = l[w] || (l[w] = []);
}
l.push(q);
}
@@ -1534,7 +1534,7 @@ function Va(a, b, c, d, e, g, f, h) {
}
if (a = k.length) {
if (e) {
- k = 1 < k.length ? Ya(k, d, c, f, 0) : k[0];
+ k = 1 < k.length ? Za(k, d, c, f, 0) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k;
} else {
if (a < h) {
return [];
@@ -1560,14 +1560,14 @@ function Va(a, b, c, d, e, g, f, h) {
}
}
}
- return 1 < e.length ? [].concat.apply([], e) : e[0];
+ k = 1 < e.length ? [].concat.apply([], e) : e[0];
}
}
}
}
return k;
}
-function Ya(a, b, c, d, e) {
+function Za(a, b, c, d, e) {
var g = [], f = M(), h = a.length, k = 0;
if (d) {
for (e = h - 1; 0 <= e; e--) {
@@ -1609,7 +1609,7 @@ function Ya(a, b, c, d, e) {
}
return g;
}
-function Za(a, b) {
+function $a(a, b) {
for (var c = M(), d = [], e = 0, g; e < b.length; e++) {
g = b[e];
for (var f = 0; f < g.length; f++) {
@@ -1639,30 +1639,30 @@ function Za(a, b) {
b || (b = 100);
if (m && (!this.db || !d)) {
m.constructor !== Array && (m = [m]);
- for (var u = [], x = 0, y = void 0; x < m.length; x++) {
- y = m[x];
- if (N(y)) {
+ for (var u = [], w = 0, x = void 0; w < m.length; w++) {
+ x = m[w];
+ if (N(x)) {
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
}
- if (y.field && y.tag) {
- var v = y.tag;
- if (v.constructor === Array) {
- for (var z = 0; z < v.length; z++) {
- u.push(y.field, v[z]);
+ if (x.field && x.tag) {
+ var t = x.tag;
+ if (t.constructor === Array) {
+ for (var z = 0; z < t.length; z++) {
+ u.push(x.field, t[z]);
}
} else {
- u.push(y.field, v);
+ u.push(x.field, t);
}
} else {
- v = Object.keys(y);
+ t = Object.keys(x);
z = 0;
- for (var A = void 0, D = void 0; z < v.length; z++) {
- if (A = v[z], D = y[A], D.constructor === Array) {
- for (var E = 0; E < D.length; E++) {
- u.push(A, D[E]);
+ for (var A = void 0, B = void 0; z < t.length; z++) {
+ if (A = t[z], B = x[A], B.constructor === Array) {
+ for (var D = 0; D < B.length; D++) {
+ u.push(A, B[D]);
}
} else {
- u.push(A, D);
+ u.push(A, B);
}
}
}
@@ -1701,76 +1701,76 @@ function Za(a, b) {
}
l || (l = this.field);
u = !d && (this.worker || this.db) && [];
- x = 0;
- for (z = y = v = void 0; x < l.length; x++) {
- if (y = l[x], !this.db || !this.tag || this.I[x]) {
- v = void 0;
- N(y) || (v = y, y = v.field, a = v.query || a, b = v.limit || b, r = v.offset || r, p = v.suggest || p, n = this.store && (v.enrich || n));
+ w = 0;
+ for (z = x = t = void 0; w < l.length; w++) {
+ if (x = l[w], !this.db || !this.tag || this.I[w]) {
+ t = void 0;
+ N(x) || (t = x, x = t.field, a = t.query || a, b = t.limit || b, r = t.offset || r, p = t.suggest || p, n = this.store && (t.enrich || n));
if (d) {
- v = d[x];
+ t = d[w];
} else {
- z = v || c;
- v = this.index.get(y);
+ z = t || c;
+ t = this.index.get(x);
if (m) {
if (this.db) {
z.tag = m;
- var F = v.db.support_tag_search;
+ var F = t.db.support_tag_search;
z.field = l;
}
F || (z.enrich = !1);
}
if (u) {
- u[x] = v.search(a, b, z);
+ u[w] = t.search(a, b, z);
z && n && (z.enrich = n);
continue;
} else {
- v = v.search(a, b, z), z && n && (z.enrich = n);
+ t = t.search(a, b, z), z && n && (z.enrich = n);
}
}
- z = v && v.length;
+ z = t && t.length;
if (m && z) {
A = [];
- D = 0;
+ B = 0;
if (this.db && d) {
if (!F) {
- for (E = l.length; E < d.length; E++) {
- var K = d[E];
+ for (D = l.length; D < d.length; D++) {
+ var K = d[D];
if (K && K.length) {
- D++, A.push(K);
+ B++, A.push(K);
} else if (!p) {
return e;
}
}
}
} else {
- E = 0;
- for (var Ib = K = void 0; E < m.length; E += 2) {
- K = this.tag.get(m[E]);
+ D = 0;
+ for (var Ib = K = void 0; D < m.length; D += 2) {
+ K = this.tag.get(m[D]);
if (!K) {
- if (console.warn("Tag '" + m[E] + ":" + m[E + 1] + "' will be skipped because there is no field '" + m[E] + "'."), p) {
+ if (console.warn("Tag '" + m[D] + ":" + m[D + 1] + "' will be skipped because there is no field '" + m[D] + "'."), p) {
continue;
} else {
return e;
}
}
- if (Ib = (K = K && K.get(m[E + 1])) && K.length) {
- D++, A.push(K);
+ if (Ib = (K = K && K.get(m[D + 1])) && K.length) {
+ B++, A.push(K);
} else if (!p) {
return e;
}
}
}
- if (D) {
- v = Za(v, A);
- z = v.length;
+ if (B) {
+ t = $a(t, A);
+ z = t.length;
if (!z && !p) {
return e;
}
- D--;
+ B--;
}
}
if (z) {
- g[f] = y, e.push(v), f++;
+ g[f] = x, e.push(t), f++;
} else if (1 === l.length) {
return e;
}
@@ -1812,24 +1812,43 @@ function Za(a, b) {
e[r] = {field:g[r], result:p};
}
if (n && this.db && u.length) {
- var $a = this;
+ var Da = this;
return Promise.all(u).then(function(P) {
for (var Q = 0; Q < P.length; Q++) {
e[Q].result = P[Q];
}
- return k ? cb(e, b) : q ? db(e, a, $a.index, $a.I, q) : e;
+ return k ? cb(e, b) : q ? db(e, a, Da.index, Da.field, Da.I, q) : e;
});
}
- return k ? cb(e, b) : q ? db(e, a, this.index, this.I, q) : e;
+ return k ? cb(e, b) : q ? db(e, a, this.index, this.field, this.I, q) : e;
};
-function db(a, b, c, d, e) {
- for (var g, f = 0, h, k, l; f < a.length; f++) {
- for (h = a[f].result, k = a[f].field, l = c.get(k).encoder, k = d[k.indexOf(k)], l !== g && (g = l, g.encode(b)), l = 0; l < h.length; l++) {
- for (var m = "", n = xa(h[l].doc, k), p = g.encode(n), q = 0; q < p.length; q++) {
- m += p[q].replace(new RegExp("(" + p[q] + ")", "g"), e.replace("$1", n));
+function db(a, b, c, d, e, g) {
+ for (var f, h, k, l = 0, m, n, p; l < a.length; l++) {
+ for (m = a[l].result, n = a[l].field, k = c.get(n), p = k.encoder, k = k.tokenize, n = e[d.indexOf(n)], p !== f && (f = p, h = f.encode(b)), p = 0; p < m.length; p++) {
+ var q = "", r = xa(m[p].doc, n), u = f.encode(r);
+ r = r.split(f.split);
+ for (var w = 0, x, t; w < u.length; w++) {
+ x = u[w];
+ t = r[w];
+ for (var z = void 0, A = 0, B; A < h.length; A++) {
+ if (B = h[A], "strict" === k) {
+ if (x === B) {
+ q += (q ? " " : "") + g.replace("$1", t);
+ z = !0;
+ break;
+ }
+ } else {
+ var D = x.indexOf(B);
+ if (-1 < D) {
+ q += (q ? " " : "") + t.substring(0, D) + g.replace("$1", t.substring(D, B.length)) + t.substring(D + B.length);
+ z = !0;
+ break;
+ }
+ }
+ }
+ z || (q += (q ? " " : "") + r[w]);
}
- console.log(a, c, e);
- h[l].na = m;
+ m[p].na = q;
}
}
return a;
@@ -1909,14 +1928,14 @@ function bb(a) {
}
if (this.worker) {
a = [];
- c = w(this.index.values());
+ c = y(this.index.values());
for (b = c.next(); !b.done; b = c.next()) {
b = b.value, b.then && a.push(b);
}
if (a.length) {
var g = this;
return Promise.all(a).then(function(f) {
- for (var h = 0, k = w(g.index.entries()), l = k.next(); !l.done; l = k.next()) {
+ for (var h = 0, k = y(g.index.entries()), l = k.next(); !l.done; l = k.next()) {
l = l.value;
var m = l[0];
l[1].then && g.index.set(m, f[h++]);
@@ -1928,8 +1947,8 @@ function bb(a) {
a.db && this.mount(a.db);
}
}
-t = V.prototype;
-t.mount = function(a) {
+v = V.prototype;
+v.mount = function(a) {
var b = this.field;
if (this.tag) {
for (var c = 0, d; c < this.$.length; c++) {
@@ -1956,12 +1975,12 @@ t.mount = function(a) {
this.db = !0;
return Promise.all(c);
};
-t.commit = function(a, b) {
+v.commit = function(a, b) {
var c = this, d, e, g, f;
return I(function(h) {
if (1 == h.h) {
d = [];
- e = w(c.index.values());
+ e = y(c.index.values());
for (g = e.next(); !g.done; g = e.next()) {
f = g.value, d.push(f.db.commit(f, a, b));
}
@@ -1971,8 +1990,8 @@ t.commit = function(a, b) {
h.h = 0;
});
};
-t.destroy = function() {
- for (var a = [], b = w(this.index.values()), c = b.next(); !c.done; c = b.next()) {
+v.destroy = function() {
+ for (var a = [], b = y(this.index.values()), c = b.next(); !c.done; c = b.next()) {
a.push(c.value.destroy());
}
return Promise.all(a);
@@ -1985,7 +2004,7 @@ function fb(a, b) {
N(g) || (f = g, g = g.field);
f = O(f) ? Object.assign({}, a, f) : a;
if (this.worker) {
- var h = new Ja(f);
+ var h = new Ka(f);
c.set(g, h);
}
this.worker || c.set(g, new R(f, this.reg));
@@ -2006,22 +2025,22 @@ function eb(a, b) {
d < c.length && (c.length = d);
return 1 < d ? c : c[0];
}
-t.append = function(a, b) {
+v.append = function(a, b) {
return this.add(a, b, !0);
};
-t.update = function(a, b) {
+v.update = function(a, b) {
return this.remove(a).add(a, b);
};
-t.remove = function(a) {
+v.remove = function(a) {
O(a) && (a = xa(a, this.key));
- for (var b = w(this.index.values()), c = b.next(); !c.done; c = b.next()) {
+ for (var b = y(this.index.values()), c = b.next(); !c.done; c = b.next()) {
c.value.remove(a, !0);
}
if (this.reg.has(a)) {
if (this.tag && !this.fastupdate) {
- for (b = w(this.tag.values()), c = b.next(); !c.done; c = b.next()) {
+ for (b = y(this.tag.values()), c = b.next(); !c.done; c = b.next()) {
c = c.value;
- for (var d = w(c), e = d.next(); !e.done; e = d.next()) {
+ for (var d = y(c), e = d.next(); !e.done; e = d.next()) {
var g = e.value;
e = g[0];
g = g[1];
@@ -2036,38 +2055,38 @@ t.remove = function(a) {
this.cache && this.cache.remove(a);
return this;
};
-t.clear = function() {
- for (var a = w(this.index.values()), b = a.next(); !b.done; b = a.next()) {
+v.clear = function() {
+ for (var a = y(this.index.values()), b = a.next(); !b.done; b = a.next()) {
b.value.clear();
}
if (this.tag) {
- for (a = w(this.tag.values()), b = a.next(); !b.done; b = a.next()) {
+ for (a = y(this.tag.values()), b = a.next(); !b.done; b = a.next()) {
b.value.clear();
}
}
this.store && this.store.clear();
return this;
};
-t.contain = function(a) {
+v.contain = function(a) {
return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a);
};
-t.cleanup = function() {
- for (var a = w(this.index.values()), b = a.next(); !b.done; b = a.next()) {
+v.cleanup = function() {
+ for (var a = y(this.index.values()), b = a.next(); !b.done; b = a.next()) {
b.value.cleanup();
}
return this;
};
-t.get = function(a) {
+v.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) {
+v.set = function(a, b) {
this.store.set(a, b);
return this;
};
-t.searchCache = gb;
-t.export = function(a, b, c, d, e, g) {
+v.searchCache = gb;
+v.export = function(a, b, c, d, e, g) {
var f;
"undefined" === typeof g && (f = new Promise(function(k) {
g = k;
@@ -2095,11 +2114,11 @@ t.export = function(a, b, c, d, e, g) {
g();
return;
}
- Oa(a, this, c, b, d, e, h, g);
+ Pa(a, this, c, b, d, e, h, g);
}
return f;
};
-t.import = function(a, b) {
+v.import = function(a, b) {
if (b) {
switch(N(b) && (b = JSON.parse(b)), a) {
case "tag":
@@ -2121,7 +2140,7 @@ t.import = function(a, b) {
}
}
};
-Ma(V.prototype);
+Na(V.prototype);
function gb(a, b, c) {
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
var d = this.cache.get(a);
@@ -2153,7 +2172,7 @@ W.prototype.get = function(a) {
return b;
};
W.prototype.remove = function(a) {
- for (var b = w(this.cache), c = b.next(); !c.done; c = b.next()) {
+ for (var b = y(this.cache), c = b.next(); !c.done; c = b.next()) {
c = c.value;
var d = c[0];
c[1].includes(a) && this.cache.delete(d);
@@ -2229,8 +2248,8 @@ R.prototype.add = function(a, b, c, d) {
for (m = M(), p = this.aa, n = l, q = Math.min(f + 1, d - k), r = m[n] = 1; r < q; r++) {
if ((l = b[this.rtl ? d - 1 - k - r : k + r]) && !m[l]) {
m[l] = 1;
- var u = this.score ? this.score(b, n, k, l, r) : rb(p + (d / 2 > p ? 0 : 1), d, k, q - 1, r - 1), x = this.bidirectional && l > n;
- sb(this, e, x ? n : l, u, a, c, x ? l : n);
+ var u = this.score ? this.score(b, n, k, l, r) : rb(p + (d / 2 > p ? 0 : 1), d, k, q - 1, r - 1), w = this.bidirectional && l > n;
+ sb(this, e, w ? n : l, u, a, c, w ? l : n);
}
}
}
@@ -2252,7 +2271,7 @@ function sb(a, b, c, d, e, g, f) {
if (h.length === Math.pow(2, 31) - 1) {
b = new S(h);
if (a.fastupdate) {
- for (c = w(a.reg.values()), g = c.next(); !g.done; g = c.next()) {
+ for (c = y(a.reg.values()), g = c.next(); !g.done; g = c.next()) {
g = g.value, g.includes(h) && (g[g.indexOf(h)] = b);
}
}
@@ -2358,7 +2377,7 @@ function vb(a, b, c, d, e, g) {
return a;
}
"object" === typeof b && (c = b.offset || 0, d = b.enrich || !1, b = b.limit || 0);
- return 2 > a.length ? e ? X(a[0], b, c, d) : a[0] : Ya(a, c, b, e, g);
+ return 2 > a.length ? e ? X(a[0], b, c, d) : a[0] : Za(a, c, b, e, g);
}
;Y.prototype.and = function() {
if (this.result.length) {
@@ -2422,7 +2441,7 @@ function wb(a, b, c, d, e, g) {
var f = [];
M();
var h = ya(a);
- return h ? Xa(a, h, b, c, g, e, d) : f;
+ return h ? Ya(a, h, b, c, g, e, d) : f;
}
;Y.prototype.xor = function() {
var a = this, b = arguments, c = b[0];
@@ -2673,16 +2692,16 @@ R.prototype.search = function(a, b, c) {
}
var p = c = 0;
if (1 < n) {
- for (var q = M(), r = [], u = 0, x = void 0; u < n; u++) {
- if ((x = a[u]) && !q[x]) {
- if (h || this.db || Z(this, x)) {
- r.push(x), q[x] = 1;
+ for (var q = M(), r = [], u = 0, w = void 0; u < n; u++) {
+ if ((w = a[u]) && !q[w]) {
+ if (h || this.db || Z(this, w)) {
+ r.push(w), q[w] = 1;
} else {
return g ? d : new Y(d);
}
- x = x.length;
- c = Math.max(c, x);
- p = p ? Math.min(p, x) : x;
+ w = w.length;
+ c = Math.max(c, w);
+ p = p ? Math.min(p, w) : w;
}
}
a = r;
@@ -2691,7 +2710,7 @@ R.prototype.search = function(a, b, c) {
if (!n) {
return g ? d : new Y(d);
}
- var y = 0;
+ var x = 0;
if (1 === n) {
return Ab.call(this, a[0], "", b, e, g, k, m);
}
@@ -2700,8 +2719,8 @@ R.prototype.search = function(a, b, c) {
}
if (1 < n) {
if (f) {
- var v = a[0];
- y = 1;
+ var t = a[0];
+ x = 1;
} else {
9 < c && 3 < c / p && a.sort(va);
}
@@ -2712,66 +2731,66 @@ R.prototype.search = function(a, b, c) {
}
var z = this;
return function() {
- var A, D, E;
+ var A, B, D;
return I(function(F) {
switch(F.h) {
case 1:
- D = A = void 0;
+ B = A = void 0;
case 2:
- if (!(y < n)) {
+ if (!(x < n)) {
F.h = 4;
break;
}
- D = a[y];
- return v ? G(F, Z(z, D, v, 0, 0, !1, !1), 8) : G(F, Z(z, D, "", 0, 0, !1, !1), 7);
+ B = a[x];
+ return t ? G(F, Z(z, B, t, 0, 0, !1, !1), 8) : G(F, Z(z, B, "", 0, 0, !1, !1), 7);
case 7:
A = F.F;
A = Bb(A, d, h, z.resolution);
F.h = 6;
break;
case 8:
- A = F.F, A = Bb(A, d, h, z.aa), h && !1 === A && d.length || (v = D);
+ A = F.F, A = Bb(A, d, h, z.aa), h && !1 === A && d.length || (t = B);
case 6:
if (A) {
return F.return(A);
}
- if (h && y === n - 1) {
- E = d.length;
- if (!E) {
- if (v) {
- v = "";
- y = -1;
+ if (h && x === n - 1) {
+ D = d.length;
+ if (!D) {
+ if (t) {
+ t = "";
+ x = -1;
F.h = 3;
break;
}
return F.return(d);
}
- if (1 === E) {
+ if (1 === D) {
return F.return(g ? X(d[0], b, e) : new Y(d[0]));
}
}
case 3:
- y++;
+ x++;
F.h = 2;
break;
case 4:
- return F.return(g ? Xa(d, z.resolution, b, e, h, l, g) : new Y(d[0]));
+ return F.return(g ? Ya(d, z.resolution, b, e, h, l, g) : new Y(d[0]));
}
});
}();
}
- for (k = f = void 0; y < n; y++) {
- k = a[y];
- v ? (f = Z(this, k, v, 0, 0, !1, !1), f = Bb(f, d, h, this.aa), h && !1 === f && d.length || (v = k)) : (f = Z(this, k, "", 0, 0, !1, !1), f = Bb(f, d, h, this.resolution));
+ for (k = f = void 0; x < n; x++) {
+ k = a[x];
+ t ? (f = Z(this, k, t, 0, 0, !1, !1), f = Bb(f, d, h, this.aa), h && !1 === f && d.length || (t = k)) : (f = Z(this, k, "", 0, 0, !1, !1), f = Bb(f, d, h, this.resolution));
if (f) {
return f;
}
- if (h && y === n - 1) {
+ if (h && x === n - 1) {
f = d.length;
if (!f) {
- if (v) {
- v = "";
- y = -1;
+ if (t) {
+ t = "";
+ x = -1;
continue;
}
return d;
@@ -2781,7 +2800,7 @@ R.prototype.search = function(a, b, c) {
}
}
}
- d = Xa(d, this.resolution, b, e, h, l, g);
+ d = Ya(d, this.resolution, b, e, h, l, g);
return g ? d : new Y(d);
};
function Ab(a, b, c, d, e, g, f) {
@@ -2850,7 +2869,7 @@ function Cb(a, b) {
}
}
} else {
- for (d = w(a), e = d.next(); !e.done; e = d.next()) {
+ for (d = y(a), e = d.next(); !e.done; e = d.next()) {
g = e.value, e = g[0], (g = Cb(g[1], b)) ? c += g : a.delete(e);
}
}
@@ -2868,7 +2887,7 @@ function Cb(a, b) {
}
c = a.context || {};
var d = N(a.encoder) ? pb[a.encoder] : a.encode || a.encoder || hb;
- this.encoder = d.encode ? d : "object" === typeof d ? new Fa(d) : {encode:d};
+ this.encoder = d.encode ? d : "object" === typeof d ? new Ga(d) : {encode:d};
var e;
this.resolution = a.resolution || 9;
this.tokenize = e = a.tokenize || "strict";
@@ -2891,16 +2910,16 @@ function Cb(a, b) {
this.commit_task = [];
this.commit_timer = null;
}
-t = R.prototype;
-t.mount = function(a) {
+v = R.prototype;
+v.mount = function(a) {
this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null);
return a.mount(this);
};
-t.commit = function(a, b) {
+v.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() {
+v.destroy = function() {
this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null);
return this.db.destroy();
};
@@ -2910,7 +2929,7 @@ function tb(a) {
a.db.commit(a, void 0, void 0);
}, 0));
}
-t.clear = function() {
+v.clear = function() {
this.map.clear();
this.ctx.clear();
this.reg.clear();
@@ -2918,13 +2937,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) {
+v.append = function(a, b) {
return this.add(a, b, !0);
};
-t.contain = function(a) {
+v.contain = function(a) {
return this.db ? this.db.has(a) : this.reg.has(a);
};
-t.update = function(a, b) {
+v.update = function(a, b) {
var c = this, d = this.remove(a);
return d && d.then ? d.then(function() {
return c.add(a, b);
@@ -2937,7 +2956,7 @@ function Db(a) {
(d = a[c]) && (b += d.length);
}
} else {
- for (c = w(a), d = c.next(); !d.done; d = c.next()) {
+ for (c = y(a), d = c.next(); !d.done; d = c.next()) {
var e = d.value;
d = e[0];
(e = Db(e[1])) ? b += e : a.delete(d);
@@ -2945,7 +2964,7 @@ function Db(a) {
}
return b;
}
-t.cleanup = function() {
+v.cleanup = function() {
if (!this.fastupdate) {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
@@ -2953,8 +2972,8 @@ t.cleanup = function() {
this.depth && Db(this.ctx);
return this;
};
-t.searchCache = gb;
-t.export = function(a, b, c, d, e, g) {
+v.searchCache = gb;
+v.export = function(a, b, c, d, e, g) {
var f = !0;
"undefined" === typeof g && (f = new Promise(function(n) {
g = n;
@@ -2964,7 +2983,7 @@ t.export = function(a, b, c, d, e, g) {
var h = "reg";
if (this.fastupdate) {
var k = M();
- for (var l = w(this.reg.keys()), m = l.next(); !m.done; m = l.next()) {
+ for (var l = y(this.reg.keys()), m = l.next(); !m.done; m = l.next()) {
k[m.value] = 1;
}
} else {
@@ -2987,10 +3006,10 @@ t.export = function(a, b, c, d, e, g) {
"undefined" === typeof c && g && g();
return;
}
- Oa(a, b || this, c, h, d, e, k, g);
+ Pa(a, b || this, c, h, d, e, k, g);
return f;
};
-t.import = function(a, b) {
+v.import = function(a, b) {
if (b) {
switch(N(b) && (b = JSON.parse(b)), a) {
case "cfg":
@@ -3008,17 +3027,17 @@ t.import = function(a, b) {
}
}
};
-t.serialize = function(a) {
+v.serialize = function(a) {
a = void 0 === a ? !0 : a;
if (!this.reg.size) {
return "";
}
- for (var b = "", c = "", d = w(this.reg.keys()), e = d.next(); !e.done; e = d.next()) {
+ for (var b = "", c = "", d = y(this.reg.keys()), e = d.next(); !e.done; e = d.next()) {
e = e.value, c || (c = typeof e), b += (b ? "," : "") + ("string" === c ? '"' + e + '"' : e);
}
b = "index.reg=new Set([" + b + "]);";
d = "";
- e = w(this.map.entries());
+ e = y(this.map.entries());
for (var g = e.next(); !g.done; g = e.next()) {
var f = g.value;
g = f[0];
@@ -3036,9 +3055,9 @@ t.serialize = function(a) {
}
d = "index.map=new Map([" + d + "]);";
e = "";
- g = w(this.ctx.entries());
+ g = y(this.ctx.entries());
for (f = g.next(); !f.done; f = g.next()) {
- for (h = f.value, f = h[0], h = w(h[1].entries()), k = h.next(); !k.done; k = h.next()) {
+ for (h = f.value, f = h[0], h = y(h[1].entries()), k = h.next(); !k.done; k = h.next()) {
l = k.value;
k = l[0];
l = l[1];
@@ -3060,7 +3079,7 @@ t.serialize = function(a) {
e = "index.ctx=new Map([" + e + "]);";
return a ? "function inject(index){" + b + d + e + "}" : b + d + e;
};
-Ma(R.prototype);
+Na(R.prototype);
var Eb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Fb = ["map", "ctx", "tag", "reg", "cfg"];
function Gb(a, b) {
b = void 0 === b ? {} : b;
@@ -3075,15 +3094,15 @@ function Gb(a, b) {
this.db = null;
this.h = {};
}
-t = Gb.prototype;
-t.mount = function(a) {
+v = Gb.prototype;
+v.mount = function(a) {
if (!a.encoder) {
return a.mount(this);
}
a.db = this;
return this.open();
};
-t.open = function() {
+v.open = function() {
var a = this;
navigator.storage && navigator.storage.persist();
return this.db || new Promise(function(b, c) {
@@ -3111,20 +3130,20 @@ t.open = function() {
};
});
};
-t.close = function() {
+v.close = function() {
this.db.close();
this.db = null;
};
-t.destroy = function() {
+v.destroy = function() {
return Eb.deleteDatabase(this.id + (this.field ? ":" + this.field : ""));
};
-t.clear = function() {
+v.clear = function() {
for (var a = this.db.transaction(Fb, "readwrite"), b = 0; b < Fb.length; b++) {
a.objectStore(Fb[b]).clear();
}
return Hb(a);
};
-t.get = function(a, b, c, d, e, g) {
+v.get = function(a, b, c, d, e, g) {
c = void 0 === c ? 0 : c;
d = void 0 === d ? 0 : d;
e = void 0 === e ? !0 : e;
@@ -3160,7 +3179,7 @@ t.get = function(a, b, c, d, e, g) {
return h;
});
};
-t.tag = function(a, b, c, d) {
+v.tag = function(a, b, c, d) {
b = void 0 === b ? 0 : b;
c = void 0 === c ? 0 : c;
d = void 0 === d ? !1 : d;
@@ -3177,7 +3196,7 @@ t.tag = function(a, b, c, d) {
return d ? e.enrich(g) : g;
});
};
-t.enrich = function(a) {
+v.enrich = function(a) {
"object" !== typeof a && (a = [a]);
for (var b = this.db.transaction("reg", "readonly").objectStore("reg"), c = [], d = 0; d < a.length; d++) {
c[d] = Hb(b.get(a[d]));
@@ -3189,14 +3208,14 @@ t.enrich = function(a) {
return e;
});
};
-t.has = function(a) {
+v.has = function(a) {
a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a);
return Hb(a);
};
-t.search = null;
-t.info = function() {
+v.search = null;
+v.info = function() {
};
-t.transaction = function(a, b, c) {
+v.transaction = function(a, b, c) {
var d = this, e = this.h[a + ":" + b];
if (e) {
return c.call(this, e);
@@ -3217,7 +3236,7 @@ t.transaction = function(a, b, c) {
return c.call(d, e);
});
};
-t.commit = function(a, b, c) {
+v.commit = function(a, b, c) {
var d = this, e, g, f;
return I(function(h) {
switch(h.h) {
@@ -3268,19 +3287,19 @@ t.commit = function(a, b, c) {
a.commit_task = [];
case 3:
return a.reg.size ? G(h, d.transaction("map", "readwrite", function(k) {
- for (var l = w(a.map), m = l.next(), n = {}; !m.done; n = {O:void 0, Y:void 0}, m = l.next()) {
+ for (var l = y(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, r;
if (q && q.length) {
- for (var u = Math.max(q.length, p.O.length), x = 0, y; x < u; x++) {
- if ((y = p.O[x]) && y.length) {
- if ((r = q[x]) && r.length) {
- for (var v = 0; v < y.length; v++) {
- r.push(y[v]);
+ for (var u = Math.max(q.length, p.O.length), w = 0, x; w < u; w++) {
+ if ((x = p.O[w]) && x.length) {
+ if ((r = q[w]) && r.length) {
+ for (var t = 0; t < x.length; t++) {
+ r.push(x[t]);
}
} else {
- q[x] = y;
+ q[w] = x;
}
r = 1;
}
@@ -3295,31 +3314,31 @@ t.commit = function(a, b, c) {
}), 13) : h.return();
case 13:
return G(h, d.transaction("ctx", "readwrite", function(k) {
- for (var l = w(a.ctx), m = l.next(), n = {}; !m.done; n = {W:void 0}, m = l.next()) {
+ for (var l = y(a.ctx), m = l.next(), n = {}; !m.done; n = {W:void 0}, m = l.next()) {
m = m.value;
n.W = m[0];
- m = w(m[1]);
+ m = y(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.W + ":" + q.Z) : k.get(n.W + ":" + q.Z).onsuccess = function(r, u) {
return function() {
- var x = this.result, y;
- if (x && x.length) {
- for (var v = Math.max(x.length, r.P.length), z = 0, A; z < v; z++) {
+ var w = this.result, x;
+ if (w && w.length) {
+ for (var t = Math.max(w.length, r.P.length), z = 0, A; z < t; z++) {
if ((A = r.P[z]) && A.length) {
- if ((y = x[z]) && y.length) {
- for (var D = 0; D < A.length; D++) {
- y.push(A[D]);
+ if ((x = w[z]) && x.length) {
+ for (var B = 0; B < A.length; B++) {
+ x.push(A[B]);
}
} else {
- x[z] = A;
+ w[z] = A;
}
- y = 1;
+ x = 1;
}
}
} else {
- x = r.P, y = 1;
+ w = r.P, x = 1;
}
- y && k.put(x, u.W + ":" + r.Z);
+ x && k.put(w, u.W + ":" + r.Z);
};
}(q, n));
}
@@ -3328,7 +3347,7 @@ t.commit = function(a, b, c) {
case 14:
if (a.store) {
return G(h, d.transaction("reg", "readwrite", function(k) {
- for (var l = w(a.store), m = l.next(); !m.done; m = l.next()) {
+ for (var l = y(a.store), m = l.next(); !m.done; m = l.next()) {
var n = m.value;
m = n[0];
n = n[1];
@@ -3341,7 +3360,7 @@ t.commit = function(a, b, c) {
break;
}
return G(h, d.transaction("reg", "readwrite", function(k) {
- for (var l = w(a.reg.keys()), m = l.next(); !m.done; m = l.next()) {
+ for (var l = y(a.reg.keys()), m = l.next(); !m.done; m = l.next()) {
k.put(1, m.value);
}
}), 16);
@@ -3351,7 +3370,7 @@ t.commit = function(a, b, c) {
break;
}
return G(h, d.transaction("tag", "readwrite", function(k) {
- for (var l = w(a.tag), m = l.next(), n = {}; !m.done; n = {X:void 0, ba:void 0}, m = l.next()) {
+ for (var l = y(a.tag), m = l.next(), n = {}; !m.done; n = {X:void 0, ba:void 0}, m = l.next()) {
m = m.value, n.ba = m[0], n.X = m[1], n.X.length && (k.get(n.ba).onsuccess = function(p) {
return function() {
var q = this.result;
@@ -3388,7 +3407,7 @@ function Kb(a, b, c) {
f ? e && a.update(d) : a.delete();
a.continue();
}
-t.remove = function(a) {
+v.remove = function(a) {
"object" !== typeof a && (a = [a]);
return Promise.all([this.transaction("map", "readwrite", function(b) {
b.openCursor().onsuccess = function() {
@@ -3423,7 +3442,7 @@ function Hb(a) {
a = null;
});
}
-;var Lb = {Index:R, Charset:pb, Encoder:Fa, Document:V, Worker:Ja, Resolver:Y, IndexedDB:Gb, Language:{}}, Mb = self, Nb;
+;var Lb = {Index:R, Charset:pb, Encoder:Ga, Document:V, Worker:Ka, Resolver:Y, IndexedDB:Gb, Language:{}}, Mb = self, Nb;
(Nb = Mb.define) && Nb.amd ? Nb([], function() {
return Lb;
}) : "object" === typeof Mb.exports ? Mb.exports = Lb : Mb.FlexSearch = Lb;
diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js
index 4b60311..00b97ea 100644
--- a/dist/flexsearch.es5.min.js
+++ b/dist/flexsearch.es5.min.js
@@ -5,128 +5,130 @@
* 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 aa(a){var b=0;return function(){return b>>0)+"_",e=0;return b});
-C("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c>>0)+"_",e=0;return b});
+E("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;cc&&(c=Math.max(c+e,0));cc&&(c=Math.max(c+e,0));cthis.L&&(this.S.clear(),this.A=this.A/1.1|0));f&&d.push(f)}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.h&&(this.N.set(a,d),this.N.size>this.L&&(this.N.clear(),this.h=this.h/1.1|0));return d};function Ga(a){a.U=null;a.N.clear();a.S.clear()};function Ha(a){var b,c,d,e,h,f,g,k;return I(function(l){a=a.data;b=self._index;c=a.args;d=a.task;switch(d){case "init":e=a.options||{};(h=e.config)&&(e=(await import(h))["default"]);(f=a.factory)?(Function("return "+f)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new R(e);postMessage({id:a.id});break;default:g=a.id,k=b[d].apply(b,c),postMessage("search"===d?{id:g,msg:k}:{id:g})}l.h=0})};var Ia=0;
-function Ja(a){function b(f){function g(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=M();if(this.worker){d?this.worker.on("message",g):this.worker.onmessage=g;if(a.config)return new Promise(function(k){e.h[++Ia]=function(){k(e)};e.worker.postMessage({id:Ia,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}a=void 0===a?{}:a;if(!this)return new Ja(a);var c="undefined"!==typeof self?self._factory:"undefined"!==
-typeof window?window._factory:null;c&&(c=c.toString());var d="undefined"===typeof window,e=this,h=Ka(c,d,a.worker);return h.then?h.then(function(f){return b.call(e,f)}):b.call(this,h)}La("add");La("append");La("search");La("update");La("remove");
-function La(a){Ja.prototype[a]=Ja.prototype[a+"Async"]=function(){var b=this,c=arguments,d,e,h,f,g;return I(function(k){d=b;e=[].slice.call(c);h=e[e.length-1];"function"===typeof h&&(f=h,e.splice(e.length-1,1));g=new Promise(function(l){d.h[++Ia]=l;d.worker.postMessage({task:a,id:Ia,args:e})});return f?(g.then(f),k.return(b)):k.return(g)})}}
-function Ka(a,b,c){return b?"undefined"!==typeof module?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); }):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+Ha.toString()],{type:"text/javascript"}))):new window.Worker(N(c)?c:(0,eval)("import.meta.url").replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js",
-"module/worker/worker.js"),{type:"module"})};function Ma(a){Na.call(a,"add");Na.call(a,"append");Na.call(a,"search");Na.call(a,"update");Na.call(a,"remove")}function Na(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if("function"===typeof c){var d=c;delete b[b.length-1]}b=this[a].apply(this,b);d&&(b.then?b.then(d):d(b));return b}};function Oa(a,b,c,d,e,h,f,g){(d=a(c?c+"."+d:d,JSON.stringify(f)))&&d.then?d.then(function(){b.export(a,b,c,e,h+1,g)}):b.export(a,b,c,e,h+1,g)};function Pa(a,b,c,d){for(var e=[],h=0,f;h=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}
+this.replacer[k+1]);this.cache&&g.length<=this.A&&(this.S.set(g,f),this.S.size>this.L&&(this.S.clear(),this.A=this.A/1.1|0));f&&d.push(f)}this.finalize&&(d=this.finalize(d)||d);this.cache&&a.length<=this.h&&(this.N.set(a,d),this.N.size>this.L&&(this.N.clear(),this.h=this.h/1.1|0));return d};function Ha(a){a.U=null;a.N.clear();a.S.clear()};function Ia(a){var b,c,d,e,h,f,g,k;return I(function(l){a=a.data;b=self._index;c=a.args;d=a.task;switch(d){case "init":e=a.options||{};(h=e.config)&&(e=(await import(h))["default"]);(f=a.factory)?(Function("return "+f)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new R(e);postMessage({id:a.id});break;default:g=a.id,k=b[d].apply(b,c),postMessage("search"===d?{id:g,msg:k}:{id:g})}l.h=0})};var Ja=0;
+function Ka(a){function b(f){function g(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=M();if(this.worker){d?this.worker.on("message",g):this.worker.onmessage=g;if(a.config)return new Promise(function(k){e.h[++Ja]=function(){k(e)};e.worker.postMessage({id:Ja,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}a=void 0===a?{}:a;if(!this)return new Ka(a);var c="undefined"!==typeof self?self._factory:"undefined"!==
+typeof window?window._factory:null;c&&(c=c.toString());var d="undefined"===typeof window,e=this,h=La(c,d,a.worker);return h.then?h.then(function(f){return b.call(e,f)}):b.call(this,h)}Ma("add");Ma("append");Ma("search");Ma("update");Ma("remove");
+function Ma(a){Ka.prototype[a]=Ka.prototype[a+"Async"]=function(){var b=this,c=arguments,d,e,h,f,g;return I(function(k){d=b;e=[].slice.call(c);h=e[e.length-1];"function"===typeof h&&(f=h,e.splice(e.length-1,1));g=new Promise(function(l){d.h[++Ja]=l;d.worker.postMessage({task:a,id:Ja,args:e})});return f?(g.then(f),k.return(b)):k.return(g)})}}
+function La(a,b,c){return b?"undefined"!==typeof module?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); }):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+Ia.toString()],{type:"text/javascript"}))):new window.Worker(N(c)?c:(0,eval)("import.meta.url").replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js",
+"module/worker/worker.js"),{type:"module"})};function Na(a){Oa.call(a,"add");Oa.call(a,"append");Oa.call(a,"search");Oa.call(a,"update");Oa.call(a,"remove")}function Oa(a){this[a+"Async"]=function(){var b=arguments,c=b[b.length-1];if("function"===typeof c){var d=c;delete b[b.length-1]}b=this[a].apply(this,b);d&&(b.then?b.then(d):d(b));return b}};function Pa(a,b,c,d,e,h,f,g){(d=a(c?c+"."+d:d,JSON.stringify(f)))&&d.then?d.then(function(){b.export(a,b,c,e,h+1,g)}):b.export(a,b,c,e,h+1,g)};function Qa(a,b,c,d){for(var e=[],h=0,f;h=f.length)b-=f.length;else{b=f[d?"splice":"slice"](b,c);if(f=b.length)if(e=e.length?e.concat(b):b,c-=f,d&&(a.length-=f),!c)break;b=0}return e}
function S(a){if(!this)return new S(a);this.index=a?[a]:[];this.length=a?a.length:0;var b=this;return new Proxy([],{get:function(c,d){if("length"===d)return b.length;if("push"===d)return function(e){b.index[b.index.length-1].push(e);b.length++};if("pop"===d)return function(){if(b.length)return b.length--,b.index[b.index.length-1].pop()};if("indexOf"===d)return function(e){for(var h=0,f=0,g,k;fc||d)k=k.slice(d,c+d)}else{e=[];for(f=0;fd)d-=g.length;else{if(g.length>c||d)g=g.slice(d,
-c+d),c-=g.length,d&&(d-=g.length);e.push(g);if(!c)break}return 1c||d)a=a.slice(d,d+c);e&&(a=bb.call(this,a));return a}}function bb(a){for(var b=Array(a.length),c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)};
-W.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};W.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)}};W.prototype.clear=function(){this.cache.clear();this.h=""};var hb={normalize:function(a){return a.toLowerCase()},dedupe:!1};var ib=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 jb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),kb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];var lb={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 mb=/[\x00-\x7F]+/g;var nb=/[\x00-\x7F]+/g;var ob=/[\x00-\x7F]+/g;var pb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:hb,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:ib},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:ib,matcher:jb,replacer:kb},LatinExtra:{normalize:!0,dedupe:!0,mapper:ib,replacer:kb.concat([/(?!^)[aeo]/g,""]),matcher:jb},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(var b=0;bc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(f=0;fd)d-=g.length;
+else{if(g.length>c||d)g=g.slice(d,c+d),c-=g.length,d&&(d-=g.length);e.push(g);if(!c)break}k=1c||d)a=a.slice(d,d+c);e&&(a=bb.call(this,a));return a}}
+function bb(a){for(var b=Array(a.length),c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)};
+W.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};W.prototype.remove=function(a){for(var b=y(this.cache),c=b.next();!c.done;c=b.next()){c=c.value;var d=c[0];c[1].includes(a)&&this.cache.delete(d)}};W.prototype.clear=function(){this.cache.clear();this.h=""};var hb={normalize:function(a){return a.toLowerCase()},dedupe:!1};var ib=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 jb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),kb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];var lb={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 mb=/[\x00-\x7F]+/g;var nb=/[\x00-\x7F]+/g;var ob=/[\x00-\x7F]+/g;var pb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:hb,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:ib},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:ib,matcher:jb,replacer:kb},LatinExtra:{normalize:!0,dedupe:!0,mapper:ib,replacer:kb.concat([/(?!^)[aeo]/g,""]),matcher:jb},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):rb(g,d,k,m,n);sb(this,h,p,r,a,c)}break}case "reverse":if(1<
-m){for(q=m-1;0p?0:1),d,k,q-1,r-1),x=this.bidirectional&&l>n;sb(this,e,x?n:l,v,a,c,x?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&
+m){for(q=m-1;0p?0:1),d,k,q-1,r-1),w=this.bidirectional&&l>n;sb(this,e,w?n:l,v,a,c,w?l:n)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&&
(b||this.commit_task.push({del:a}),this.da&&tb(this));return this};
-function sb(a,b,c,d,e,h,f){var g=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])if(f?(b=k||(b[c]=M()),b[f]=1,(k=g.get(f))?g=k:g.set(f,g=new Map)):b[c]=1,(k=g.get(c))?g=k:g.set(c,g=k=[]),g=g[d]||(g[d]=[]),!h||!g.includes(e)){if(g.length===Math.pow(2,31)-1){b=new S(g);if(a.fastupdate)for(c=w(a.reg.values()),h=c.next();!h.done;h=c.next())h=h.value,h.includes(g)&&(h[h.indexOf(g)]=b);k[d]=g=b}g.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(g):a.reg.set(e,[g]))}}
+function sb(a,b,c,d,e,h,f){var g=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])if(f?(b=k||(b[c]=M()),b[f]=1,(k=g.get(f))?g=k:g.set(f,g=new Map)):b[c]=1,(k=g.get(c))?g=k:g.set(c,g=k=[]),g=g[d]||(g[d]=[]),!h||!g.includes(e)){if(g.length===Math.pow(2,31)-1){b=new S(g);if(a.fastupdate)for(c=y(a.reg.values()),h=c.next();!h.done;h=c.next())h=h.value,h.includes(g)&&(h[h.indexOf(g)]=b);k[d]=g=b}g.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(g):a.reg.set(e,[g]))}}
function rb(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?ub(a):a;for(var e=[],h=0,f=void 0,g=void 0;h=g){c-=g;continue}cb&&(f=f.slice(0,b),g=f.length),e.push(f);else{if(g>=b)return g>b&&(f=f.slice(0,b)),d?ub(f):f;e=[f]}b-=g;if(!b)break}if(!e.length)return e;e=1a.length?e?X(a[0],b,c,d):a[0]:Ya(a,c,b,e,h)};Y.prototype.and=function(){if(this.result.length){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.and.apply(a,b)});if(c[0]&&c[0].index)return this.and.apply(this,c);var d=[];c=[];for(var e=0,h=0,f,g,k=0,l=void 0;ka.length)return[];var f=[];M();var g=ya(a);return g?Xa(a,g,b,c,h,e,d):f};Y.prototype.xor=function(){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.xor.apply(a,b)});if(c[0]&&c[0].index)return this.xor.apply(this,c);var d=[];c=[];for(var e=0,h=0,f,g,k=0,l=void 0;ka.length?e?X(a[0],b,c,d):a[0]:Za(a,c,b,e,h)};Y.prototype.and=function(){if(this.result.length){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.and.apply(a,b)});if(c[0]&&c[0].index)return this.and.apply(this,c);var d=[];c=[];for(var e=0,h=0,f,g,k=0,l=void 0;ka.length)return[];var f=[];M();var g=ya(a);return g?Ya(a,g,b,c,h,e,d):f};Y.prototype.xor=function(){var a=this,b=arguments,c=b[0];if(c.then)return c.then(function(){return a.xor.apply(a,b)});if(c[0]&&c[0].index)return this.xor.apply(this,c);var d=[];c=[];for(var e=0,h=0,f,g,k=0,l=void 0;ka.length)return e?X(a[0],b,c,d):a[0];d=[];for(var f=M(),g=0,k=0,l;kc);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,h,f,g):a.db.get(b,"",d,e,h,f,g);a=c?(a=a.ctx.get(k?b:c))&&a.get(k?c: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 h=e.indexOf(a);h===c.length-1?e.pop():e.splice(h,1)}}else Cb(this.map,a),this.depth&&Cb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.da&&tb(this));this.cache&&this.cache.remove(a);return this};
-function Cb(a,b){var c=0;if(a.constructor===Array)for(var d=0,e=void 0,h;d=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length,p=d;p=h.length)return[];if(!b&&!c)return h;h=h.slice(c,c+b);return d?e.enrich(h):h})};
-t.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;d=m.length)d-=m.length;else{for(var n=c?d+Math.min(m.length-d,c):m.length,p=d;p=h.length)return[];if(!b&&!c)return h;h=h.slice(c,c+b);return d?e.enrich(h):h})};
+u.enrich=function(a){"object"!==typeof a&&(a=[a]);for(var b=this.db.transaction("reg","readonly").objectStore("reg"),c=[],d=0;dm&&!h&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(h=1),0<=m)if(e=1,1 this.stemmer.get(q)), k = 1);
+ this.stemmer && 2 < f.length && (this.u || (this.u = new RegExp("(?!^)(" + this.o + ")$")), f = f.replace(this.u, p => this.stemmer.get(p)), k = 1);
f && k && (f.length < this.minlength || this.filter && this.filter.has(f)) && (f = "");
if (f && (this.mapper || this.dedupe && 1 < f.length)) {
e = "";
- for (let q = 0, p = "", m, r; q < f.length; q++) {
- m = f.charAt(q), m === p && this.dedupe || ((r = this.mapper && this.mapper.get(m)) || "" === r ? r === p && this.dedupe || !(p = r) || (e += r) : e += p = m);
+ for (let p = 0, q = "", m, r; p < f.length; p++) {
+ m = f.charAt(p), m === q && this.dedupe || ((r = this.mapper && this.mapper.get(m)) || "" === r ? r === q && this.dedupe || !(q = r) || (e += r) : e += q = m);
}
f = e;
}
- this.matcher && 1 < f.length && (this.s || (this.s = new RegExp("(" + this.m + ")", "g")), f = f.replace(this.s, q => this.matcher.get(q)));
+ this.matcher && 1 < f.length && (this.s || (this.s = new RegExp("(" + this.m + ")", "g")), f = f.replace(this.s, p => this.matcher.get(p)));
if (f && this.replacer) {
for (e = 0; f && e < this.replacer.length; e += 2) {
f = f.replace(this.replacer[e], this.replacer[e + 1]);
@@ -220,11 +220,11 @@ H.prototype.add = function(a, c, b, d) {
}
c = this.encoder.encode(c);
if (d = c.length) {
- const q = u(), p = u(), m = this.depth, r = this.resolution;
+ const p = u(), q = u(), m = this.depth, r = this.resolution;
for (let l = 0; l < d; l++) {
let n = c[this.rtl ? d - 1 - l : l];
var e = n.length;
- if (e && (m || !p[n])) {
+ if (e && (m || !q[n])) {
var g = this.score ? this.score(c, n, l, null, 0) : I(r, d, l), f = "";
switch(this.tokenize) {
case "full":
@@ -233,7 +233,7 @@ H.prototype.add = function(a, c, b, d) {
for (var h = e; h > g; h--) {
f = n.substring(g, h);
var k = this.score ? this.score(c, n, l, f, g) : I(r, d, l, e, g);
- J(this, p, f, k, a, b);
+ J(this, q, f, k, a, b);
}
}
break;
@@ -241,24 +241,24 @@ H.prototype.add = function(a, c, b, d) {
case "reverse":
if (1 < e) {
for (h = e - 1; 0 < h; h--) {
- f = n[h] + f, k = this.score ? this.score(c, n, l, f, h) : I(r, d, l, e, h), J(this, p, f, k, a, b);
+ f = n[h] + f, k = this.score ? this.score(c, n, l, f, h) : I(r, d, l, e, h), J(this, q, f, k, a, b);
}
f = "";
}
case "forward":
if (1 < e) {
for (h = 0; h < e; h++) {
- f += n[h], J(this, p, f, g, a, b);
+ f += n[h], J(this, q, f, g, a, b);
}
break;
}
default:
- if (J(this, p, n, g, a, b), m && 1 < d && l < d - 1) {
+ if (J(this, q, n, g, a, b), m && 1 < d && l < d - 1) {
for (e = u(), f = this.A, g = n, h = Math.min(m + 1, d - l), e[g] = 1, k = 1; k < h; k++) {
if ((n = c[this.rtl ? d - 1 - l - k : l + k]) && !e[n]) {
e[n] = 1;
const A = this.score ? this.score(c, g, l, n, k) : I(f + (d / 2 > f ? 0 : 1), d, l, h - 1, k - 1), L = this.bidirectional && n > g;
- J(this, q, L ? g : n, A, a, b, L ? n : g);
+ J(this, p, L ? g : n, A, a, b, L ? n : g);
}
}
}
@@ -331,12 +331,12 @@ function I(a, c, b, d, e) {
}
var h = 0, k = 0;
if (1 < b) {
- var q = u();
+ var p = u();
const m = [];
for (let r = 0, l; r < b; r++) {
- if ((l = a[r]) && !q[l]) {
+ if ((l = a[r]) && !p[l]) {
if (f || N(this, l)) {
- m.push(l), q[l] = 1;
+ m.push(l), p[l] = 1;
} else {
return d;
}
@@ -351,7 +351,7 @@ function I(a, c, b, d, e) {
if (!b) {
return d;
}
- q = 0;
+ p = 0;
if (1 === b) {
return M.call(this, a[0], "", c, e);
}
@@ -360,24 +360,24 @@ function I(a, c, b, d, e) {
}
if (1 < b) {
if (g) {
- var p = a[0];
- q = 1;
+ var q = a[0];
+ p = 1;
} else {
9 < h && 3 < h / k && a.sort(v);
}
}
- for (let m, r; q < b; q++) {
- r = a[q];
- p ? (m = N(this, r, p), m = O(m, d, f, this.A), f && !1 === m && d.length || (p = r)) : (m = N(this, r, ""), m = O(m, d, f, this.resolution));
+ for (let m, r; p < b; p++) {
+ r = a[p];
+ q ? (m = N(this, r, q), m = O(m, d, f, this.A), f && !1 === m && d.length || (q = r)) : (m = N(this, r, ""), m = O(m, d, f, this.resolution));
if (m) {
return m;
}
- if (f && q === b - 1) {
+ if (f && p === b - 1) {
g = d.length;
if (!g) {
- if (p) {
- p = "";
- q = -1;
+ if (q) {
+ q = "";
+ p = -1;
continue;
}
return d;
@@ -390,60 +390,55 @@ function I(a, c, b, d, e) {
a: {
a = d;
d = this.resolution;
- p = a.length;
- b = [];
+ q = f;
+ b = a.length;
+ f = [];
g = u();
for (let m = 0, r, l, n, A; m < d; m++) {
- for (k = 0; k < p; k++) {
+ for (k = 0; k < b; k++) {
if (n = a[k], m < n.length && (r = n[m])) {
- for (q = 0; q < r.length; q++) {
- l = r[q], (h = g[l]) ? g[l]++ : (h = 0, g[l] = 1), A = b[h] || (b[h] = []), A.push(l);
+ for (p = 0; p < r.length; p++) {
+ l = r[p], (h = g[l]) ? g[l]++ : (h = 0, g[l] = 1), A = f[h] || (f[h] = []), A.push(l);
}
}
}
}
- if (a = b.length) {
- if (f) {
- if (1 < b.length) {
+ if (a = f.length) {
+ if (q) {
+ if (1 < f.length) {
b: {
- f = b;
- a = [];
- d = u();
- p = f.length;
- for (h = p - 1; 0 <= h; h--) {
- for (p = f[h], g = p.length, k = 0; k < g; k++) {
- if (b = p[k], !d[b]) {
+ for (a = [], d = u(), q = f.length, h = q - 1; 0 <= h; h--) {
+ for (q = f[h], g = q.length, k = 0; k < g; k++) {
+ if (b = q[k], !d[b]) {
if (d[b] = 1, e) {
e--;
} else {
if (a.push(b), a.length === c) {
- c = a;
break b;
}
}
}
}
}
- c = a;
}
} else {
- c = b[0];
+ a = (f = f[0]).length > c || e ? f.slice(e, c + e) : f;
}
- b = c;
+ f = a;
} else {
- if (a < p) {
+ if (a < b) {
d = [];
break a;
}
- b = b[a - 1];
+ f = f[a - 1];
if (c || e) {
- if (b.length > c || e) {
- b = b.slice(e, c + e);
+ if (f.length > c || e) {
+ f = f.slice(e, c + e);
}
}
}
}
- d = b;
+ d = f;
}
return d;
};
diff --git a/dist/flexsearch.light.min.js b/dist/flexsearch.light.min.js
index 8215363..bb17bd2 100644
--- a/dist/flexsearch.light.min.js
+++ b/dist/flexsearch.light.min.js
@@ -10,14 +10,14 @@ C.prototype.assign=function(a){this.normalize=t(a.normalize,!0,this.normalize);l
/\s+/}this.numeric=t(this.numeric,!0)}this.prepare=t(a.prepare,null,this.prepare);this.finalize=t(a.finalize,null,this.finalize);this.rtl=a.rtl||!1;this.dedupe=t(a.dedupe,!0,this.dedupe);this.filter=t((b=a.filter)&&new Set(b),null,this.filter);this.matcher=t((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=t((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=t((b=a.stemmer)&&new Map(b),null,this.stemmer);this.replacer=t(a.replacer,null,this.replacer);this.minlength=t(a.minlength,1,this.minlength);
this.maxlength=t(a.maxlength,0,this.maxlength);if(this.cache=b=t(a.cache,!0,this.cache))this.j=null,this.v="number"===typeof b?b:2E5,this.h=new Map,this.i=new Map,this.l=this.g=128;this.m="";this.s=null;this.o="";this.u=null;if(this.matcher)for(const d of this.matcher.keys())this.m+=(this.m?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.o+=(this.o?"|":"")+d;return this};
C.prototype.encode=function(a){if(this.cache&&a.length<=this.g)if(this.j){if(this.h.has(a))return this.h.get(a)}else this.j=setTimeout(D,50,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):B?a.normalize("NFKD").replace(B,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(q)),k=1);f&&k&&(f.lengththis.matcher.get(q)));if(f&&this.replacer)for(e=0;f&ðis.stemmer.get(p)),k=1);f&&k&&(f.lengththis.matcher.get(p)));if(f&&this.replacer)for(e=0;f&ðis.v&&(this.i.clear(),this.l=this.l/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.g&&(this.h.set(a,b),this.h.size>this.v&&(this.h.clear(),this.g=this.g/1.1|0));return b};function D(a){a.j=null;a.h.clear();a.i.clear()};function E(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.g=""}E.prototype.set=function(a,c){this.cache.set(this.g=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};E.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};E.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};
-E.prototype.clear=function(){this.cache.clear();this.g=""};const F={normalize:function(a){return a.toLowerCase()},dedupe:!1};const G={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};u();H.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const q=u(),p=u(),m=this.depth,r=this.resolution;for(let l=0;lg;h--){f=n.substring(g,h);var k=this.score?this.score(c,n,l,f,g):I(r,d,l,e,g);J(this,p,f,k,a,b)}break}case "reverse":if(1<
-e){for(h=e-1;0f?0:1),d,l,h-1,k-1),K=this.bidirectional&&n>g;J(this,q,K?g:n,A,a,b,K?n:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
-function J(a,c,b,d,e,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=u()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),g&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.reg.get(e))?c.push(h):a.reg.set(e,[h])))}function I(a,c,b,d,e){return b&&1c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,g,f;e=f){b-=f;continue}bc&&(g=g.slice(0,c),f=g.length),d.push(g);else{if(f>=c)return f>c&&(g=g.slice(0,c)),g;d=[g]}c-=f;if(!c)break}return d.length?d=1c||e)b=b.slice(e,c+e)}d=b}return d};
+E.prototype.clear=function(){this.cache.clear();this.g=""};const F={normalize:function(a){return a.toLowerCase()},dedupe:!1};const G={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};u();H.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const p=u(),q=u(),m=this.depth,r=this.resolution;for(let l=0;lg;h--){f=n.substring(g,h);var k=this.score?this.score(c,n,l,f,g):I(r,d,l,e,g);J(this,q,f,k,a,b)}break}case "reverse":if(1<
+e){for(h=e-1;0f?0:1),d,l,h-1,k-1),K=this.bidirectional&&n>g;J(this,p,K?g:n,A,a,b,K?n:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
+function J(a,c,b,d,e,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=u()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),g&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.reg.get(e))?c.push(h):a.reg.set(e,[h])))}function I(a,c,b,d,e){return b&&1c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,g,f;e=f){b-=f;continue}bc&&(g=g.slice(0,c),f=g.length),d.push(g);else{if(f>=c)return f>c&&(g=g.slice(0,c)),g;d=[g]}c-=f;if(!c)break}return d.length?d=1c||e?f.slice(e,c+e):f;f=a}else{if(ac||e)f=f.slice(e,c+e)}d=f}return d};
function M(a,c,b,d){return(a=N(this,a,c))&&a.length?L(a,b,d):[]}function O(a,c,b,d){let e=[];if(a){d=Math.min(a.length,d);for(let g=0,f;gb);a=b?(a=a.ctx.get(d?c:b))&&a.get(d?b:c):a.map.get(c);return a};H.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let d=0,e;de.length)e.pop();else{const g=e.indexOf(a);g===b.length-1?e.pop():e.splice(g,1)}}else 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 d=0,e,g;db.add(a,c)):this.add(a,c)};
diff --git a/dist/flexsearch.light.module.debug.js b/dist/flexsearch.light.module.debug.js
index a5d7579..44ea2dc 100644
--- a/dist/flexsearch.light.module.debug.js
+++ b/dist/flexsearch.light.module.debug.js
@@ -156,16 +156,16 @@ C.prototype.encode = function(a) {
}
}
let k;
- this.stemmer && 2 < f.length && (this.u || (this.u = new RegExp("(?!^)(" + this.o + ")$")), f = f.replace(this.u, q => this.stemmer.get(q)), k = 1);
+ this.stemmer && 2 < f.length && (this.u || (this.u = new RegExp("(?!^)(" + this.o + ")$")), f = f.replace(this.u, p => this.stemmer.get(p)), k = 1);
f && k && (f.length < this.minlength || this.filter && this.filter.has(f)) && (f = "");
if (f && (this.mapper || this.dedupe && 1 < f.length)) {
e = "";
- for (let q = 0, p = "", m, r; q < f.length; q++) {
- m = f.charAt(q), m === p && this.dedupe || ((r = this.mapper && this.mapper.get(m)) || "" === r ? r === p && this.dedupe || !(p = r) || (e += r) : e += p = m);
+ for (let p = 0, q = "", m, r; p < f.length; p++) {
+ m = f.charAt(p), m === q && this.dedupe || ((r = this.mapper && this.mapper.get(m)) || "" === r ? r === q && this.dedupe || !(q = r) || (e += r) : e += q = m);
}
f = e;
}
- this.matcher && 1 < f.length && (this.s || (this.s = new RegExp("(" + this.m + ")", "g")), f = f.replace(this.s, q => this.matcher.get(q)));
+ this.matcher && 1 < f.length && (this.s || (this.s = new RegExp("(" + this.m + ")", "g")), f = f.replace(this.s, p => this.matcher.get(p)));
if (f && this.replacer) {
for (e = 0; f && e < this.replacer.length; e += 2) {
f = f.replace(this.replacer[e], this.replacer[e + 1]);
@@ -219,11 +219,11 @@ H.prototype.add = function(a, c, b, d) {
}
c = this.encoder.encode(c);
if (d = c.length) {
- const q = u(), p = u(), m = this.depth, r = this.resolution;
+ const p = u(), q = u(), m = this.depth, r = this.resolution;
for (let l = 0; l < d; l++) {
let n = c[this.rtl ? d - 1 - l : l];
var e = n.length;
- if (e && (m || !p[n])) {
+ if (e && (m || !q[n])) {
var g = this.score ? this.score(c, n, l, null, 0) : J(r, d, l), f = "";
switch(this.tokenize) {
case "full":
@@ -232,7 +232,7 @@ H.prototype.add = function(a, c, b, d) {
for (var h = e; h > g; h--) {
f = n.substring(g, h);
var k = this.score ? this.score(c, n, l, f, g) : J(r, d, l, e, g);
- K(this, p, f, k, a, b);
+ K(this, q, f, k, a, b);
}
}
break;
@@ -240,24 +240,24 @@ H.prototype.add = function(a, c, b, d) {
case "reverse":
if (1 < e) {
for (h = e - 1; 0 < h; h--) {
- f = n[h] + f, k = this.score ? this.score(c, n, l, f, h) : J(r, d, l, e, h), K(this, p, f, k, a, b);
+ f = n[h] + f, k = this.score ? this.score(c, n, l, f, h) : J(r, d, l, e, h), K(this, q, f, k, a, b);
}
f = "";
}
case "forward":
if (1 < e) {
for (h = 0; h < e; h++) {
- f += n[h], K(this, p, f, g, a, b);
+ f += n[h], K(this, q, f, g, a, b);
}
break;
}
default:
- if (K(this, p, n, g, a, b), m && 1 < d && l < d - 1) {
+ if (K(this, q, n, g, a, b), m && 1 < d && l < d - 1) {
for (e = u(), f = this.A, g = n, h = Math.min(m + 1, d - l), e[g] = 1, k = 1; k < h; k++) {
if ((n = c[this.rtl ? d - 1 - l - k : l + k]) && !e[n]) {
e[n] = 1;
const A = this.score ? this.score(c, g, l, n, k) : J(f + (d / 2 > f ? 0 : 1), d, l, h - 1, k - 1), I = this.bidirectional && n > g;
- K(this, q, I ? g : n, A, a, b, I ? n : g);
+ K(this, p, I ? g : n, A, a, b, I ? n : g);
}
}
}
@@ -330,12 +330,12 @@ function J(a, c, b, d, e) {
}
var h = 0, k = 0;
if (1 < b) {
- var q = u();
+ var p = u();
const m = [];
for (let r = 0, l; r < b; r++) {
- if ((l = a[r]) && !q[l]) {
+ if ((l = a[r]) && !p[l]) {
if (f || N(this, l)) {
- m.push(l), q[l] = 1;
+ m.push(l), p[l] = 1;
} else {
return d;
}
@@ -350,7 +350,7 @@ function J(a, c, b, d, e) {
if (!b) {
return d;
}
- q = 0;
+ p = 0;
if (1 === b) {
return M.call(this, a[0], "", c, e);
}
@@ -359,24 +359,24 @@ function J(a, c, b, d, e) {
}
if (1 < b) {
if (g) {
- var p = a[0];
- q = 1;
+ var q = a[0];
+ p = 1;
} else {
9 < h && 3 < h / k && a.sort(v);
}
}
- for (let m, r; q < b; q++) {
- r = a[q];
- p ? (m = N(this, r, p), m = O(m, d, f, this.A), f && !1 === m && d.length || (p = r)) : (m = N(this, r, ""), m = O(m, d, f, this.resolution));
+ for (let m, r; p < b; p++) {
+ r = a[p];
+ q ? (m = N(this, r, q), m = O(m, d, f, this.A), f && !1 === m && d.length || (q = r)) : (m = N(this, r, ""), m = O(m, d, f, this.resolution));
if (m) {
return m;
}
- if (f && q === b - 1) {
+ if (f && p === b - 1) {
g = d.length;
if (!g) {
- if (p) {
- p = "";
- q = -1;
+ if (q) {
+ q = "";
+ p = -1;
continue;
}
return d;
@@ -389,60 +389,55 @@ function J(a, c, b, d, e) {
a: {
a = d;
d = this.resolution;
- p = a.length;
- b = [];
+ q = f;
+ b = a.length;
+ f = [];
g = u();
for (let m = 0, r, l, n, A; m < d; m++) {
- for (k = 0; k < p; k++) {
+ for (k = 0; k < b; k++) {
if (n = a[k], m < n.length && (r = n[m])) {
- for (q = 0; q < r.length; q++) {
- l = r[q], (h = g[l]) ? g[l]++ : (h = 0, g[l] = 1), A = b[h] || (b[h] = []), A.push(l);
+ for (p = 0; p < r.length; p++) {
+ l = r[p], (h = g[l]) ? g[l]++ : (h = 0, g[l] = 1), A = f[h] || (f[h] = []), A.push(l);
}
}
}
}
- if (a = b.length) {
- if (f) {
- if (1 < b.length) {
+ if (a = f.length) {
+ if (q) {
+ if (1 < f.length) {
b: {
- f = b;
- a = [];
- d = u();
- p = f.length;
- for (h = p - 1; 0 <= h; h--) {
- for (p = f[h], g = p.length, k = 0; k < g; k++) {
- if (b = p[k], !d[b]) {
+ for (a = [], d = u(), q = f.length, h = q - 1; 0 <= h; h--) {
+ for (q = f[h], g = q.length, k = 0; k < g; k++) {
+ if (b = q[k], !d[b]) {
if (d[b] = 1, e) {
e--;
} else {
if (a.push(b), a.length === c) {
- c = a;
break b;
}
}
}
}
}
- c = a;
}
} else {
- c = b[0];
+ a = (f = f[0]).length > c || e ? f.slice(e, c + e) : f;
}
- b = c;
+ f = a;
} else {
- if (a < p) {
+ if (a < b) {
d = [];
break a;
}
- b = b[a - 1];
+ f = f[a - 1];
if (c || e) {
- if (b.length > c || e) {
- b = b.slice(e, c + e);
+ if (f.length > c || e) {
+ f = f.slice(e, c + e);
}
}
}
}
- d = b;
+ d = f;
}
return d;
};
diff --git a/dist/flexsearch.light.module.min.js b/dist/flexsearch.light.module.min.js
index d685ac3..ac5fc78 100644
--- a/dist/flexsearch.light.module.min.js
+++ b/dist/flexsearch.light.module.min.js
@@ -10,14 +10,14 @@ C.prototype.assign=function(a){this.normalize=t(a.normalize,!0,this.normalize);l
/\s+/}this.numeric=t(this.numeric,!0)}this.prepare=t(a.prepare,null,this.prepare);this.finalize=t(a.finalize,null,this.finalize);this.rtl=a.rtl||!1;this.dedupe=t(a.dedupe,!0,this.dedupe);this.filter=t((b=a.filter)&&new Set(b),null,this.filter);this.matcher=t((b=a.matcher)&&new Map(b),null,this.matcher);this.mapper=t((b=a.mapper)&&new Map(b),null,this.mapper);this.stemmer=t((b=a.stemmer)&&new Map(b),null,this.stemmer);this.replacer=t(a.replacer,null,this.replacer);this.minlength=t(a.minlength,1,this.minlength);
this.maxlength=t(a.maxlength,0,this.maxlength);if(this.cache=b=t(a.cache,!0,this.cache))this.j=null,this.v="number"===typeof b?b:2E5,this.h=new Map,this.i=new Map,this.l=this.g=128;this.m="";this.s=null;this.o="";this.u=null;if(this.matcher)for(const d of this.matcher.keys())this.m+=(this.m?"|":"")+d;if(this.stemmer)for(const d of this.stemmer.keys())this.o+=(this.o?"|":"")+d;return this};
C.prototype.encode=function(a){if(this.cache&&a.length<=this.g)if(this.j){if(this.h.has(a))return this.h.get(a)}else this.j=setTimeout(D,50,this);this.normalize&&(a="function"===typeof this.normalize?this.normalize(a):B?a.normalize("NFKD").replace(B,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&3this.stemmer.get(q)),k=1);f&&k&&(f.lengththis.matcher.get(q)));if(f&&this.replacer)for(e=0;f&ðis.stemmer.get(p)),k=1);f&&k&&(f.lengththis.matcher.get(p)));if(f&&this.replacer)for(e=0;f&ðis.v&&(this.i.clear(),this.l=this.l/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.g&&(this.h.set(a,b),this.h.size>this.v&&(this.h.clear(),this.g=this.g/1.1|0));return b};function D(a){a.j=null;a.h.clear();a.i.clear()};function E(a){this.limit=a&&!0!==a?a:1E3;this.cache=new Map;this.g=""}E.prototype.set=function(a,c){this.cache.set(this.g=a,c);this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};E.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};E.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};
-E.prototype.clear=function(){this.cache.clear();this.g=""};const F={normalize:function(a){return a.toLowerCase()},dedupe:!1};const G={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};u();I.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const q=u(),p=u(),m=this.depth,r=this.resolution;for(let l=0;lg;h--){f=n.substring(g,h);var k=this.score?this.score(c,n,l,f,g):J(r,d,l,e,g);K(this,p,f,k,a,b)}break}case "reverse":if(1<
-e){for(h=e-1;0f?0:1),d,l,h-1,k-1),H=this.bidirectional&&n>g;K(this,q,H?g:n,A,a,b,H?n:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
-function K(a,c,b,d,e,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=u()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),g&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.reg.get(e))?c.push(h):a.reg.set(e,[h])))}function J(a,c,b,d,e){return b&&1c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,g,f;e=f){b-=f;continue}bc&&(g=g.slice(0,c),f=g.length),d.push(g);else{if(f>=c)return f>c&&(g=g.slice(0,c)),g;d=[g]}c-=f;if(!c)break}return d.length?d=1c||e)b=b.slice(e,c+e)}d=b}return d};
+E.prototype.clear=function(){this.cache.clear();this.g=""};const F={normalize:function(a){return a.toLowerCase()},dedupe:!1};const G={memory:{resolution:1},performance:{resolution:6,fastupdate:!0,context:{depth:1,resolution:3}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:9}}};u();I.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.reg.has(a))return this.update(a,c);c=this.encoder.encode(c);if(d=c.length){const p=u(),q=u(),m=this.depth,r=this.resolution;for(let l=0;lg;h--){f=n.substring(g,h);var k=this.score?this.score(c,n,l,f,g):J(r,d,l,e,g);K(this,q,f,k,a,b)}break}case "reverse":if(1<
+e){for(h=e-1;0f?0:1),d,l,h-1,k-1),H=this.bidirectional&&n>g;K(this,p,H?g:n,A,a,b,H?n:g)}}}}this.fastupdate||this.reg.add(a)}}return this};
+function K(a,c,b,d,e,g,f){let h=f?a.ctx:a.map,k;if(!c[b]||f&&!(k=c[b])[f])f?(c=k||(c[b]=u()),c[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):c[b]=1,(k=h.get(b))?h=k:h.set(b,h=[]),h=h[d]||(h[d]=[]),g&&h.includes(e)||(h.push(e),a.fastupdate&&((c=a.reg.get(e))?c.push(h):a.reg.set(e,[h])))}function J(a,c,b,d,e){return b&&1c?c?a.slice(b,b+c):a.slice(b):a;let d=[];for(let e=0,g,f;e=f){b-=f;continue}bc&&(g=g.slice(0,c),f=g.length),d.push(g);else{if(f>=c)return f>c&&(g=g.slice(0,c)),g;d=[g]}c-=f;if(!c)break}return d.length?d=1c||e?f.slice(e,c+e):f;f=a}else{if(ac||e)f=f.slice(e,c+e)}d=f}return d};
function M(a,c,b,d){return(a=N(this,a,c))&&a.length?L(a,b,d):[]}function O(a,c,b,d){let e=[];if(a){d=Math.min(a.length,d);for(let g=0,f;gb);a=b?(a=a.ctx.get(d?c:b))&&a.get(d?b:c):a.map.get(c);return a};I.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let d=0,e;de.length)e.pop();else{const g=e.indexOf(a);g===b.length-1?e.pop():e.splice(g,1)}}else 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 d=0,e,g;db.add(a,c)):this.add(a,c)};
diff --git a/dist/module-debug/document/search.js b/dist/module-debug/document/search.js
index bbf665e..e2e6caf 100644
--- a/dist/module-debug/document/search.js
+++ b/dist/module-debug/document/search.js
@@ -212,6 +212,7 @@ Document.prototype.search = function (query, limit, options, _promises) {
// just collect and continue
continue;
} else {
+
res = index.search(query, limit, opt);
// restore enrich state
opt && enrich && (opt.enrich = enrich);
@@ -362,7 +363,9 @@ Document.prototype.search = function (query, limit, options, _promises) {
};
}
- if (enrich && /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/ /*await rows.hasNext()*/ && this.db && promises.length) {
+ if (enrich && /* tag? */ /* stringify */ /* stringify */ /* single param */ /* skip update: */ /* append: */ /* skip update: */ /* skip_update: */!0 /*await rows.hasNext()*/ /*await rows.hasNext()*/
+ /*await rows.hasNext()*/
+ && this.db && promises.length) {
const self = this;
return Promise.all(promises).then(function (promises) {
for (let j = 0; j < promises.length; j++) {
@@ -377,8 +380,9 @@ Document.prototype.search = function (query, limit, options, _promises) {
/*
- some matching term
-
+ karmen or clown or not found
+[Carmen]cita
+ Le [clown] et ses chiens
*/
@@ -386,35 +390,66 @@ function highlight_fields(result, query, index, field, tree, template) {
// if(typeof template === "string"){
// template = new RegExp(template, "g");
- // }
-
- let encoder;
+ let encoder, query_enc, tokenize;
- for (let i = 0, res, field, enc, path; i < result.length; i++) {
+ for (let i = 0, res, res_field, enc, idx, path; i < result.length; i++) {
res = result[i].result;
- field = result[i].field;
- enc = index.get(field).encoder;
- path = tree[field.indexOf(field)];
+ res_field = result[i].field;
+ idx = index.get(res_field);
+ enc = idx.encoder;
+ tokenize = idx.tokenize;
+ path = tree[field.indexOf(res_field)];
if (enc !== encoder) {
encoder = enc;
- encoder.encode(query);
+ query_enc = encoder.encode(query);
}
for (let j = 0; j < res.length; j++) {
let str = "",
content = parse_simple(res[j].doc, path),
- split = encoder.encode(content);
+ doc_enc = encoder.encode(content),
+ doc_org = content.split(encoder.split);
- for (let k = 0; k < split.length; k++) {
- str += split[k].replace(new RegExp("(" + split[k] + ")", "g"), template.replace("$1", content));
+ for (let k = 0, doc_enc_cur, doc_org_cur; k < doc_enc.length; k++) {
+ doc_enc_cur = doc_enc[k];
+ doc_org_cur = doc_org[k];
+ let found;
+ for (let l = 0, query_enc_cur; l < query_enc.length; l++) {
+ query_enc_cur = query_enc[l];
+ // todo tokenize could be custom also when "strict" was used
+ if ("strict" === tokenize) {
+ if (doc_enc_cur === query_enc_cur) {
+ str += (str ? " " : "") + template.replace("$1", doc_org_cur);
+ found = !0;
+ break;
+ }
+ } else {
+ const position = doc_enc_cur.indexOf(query_enc_cur);
+ if (-1 < position) {
+ str += (str ? " " : "") +
+ // prefix
+ doc_org_cur.substring(0, position) +
+ // match
+ template.replace("$1", doc_org_cur.substring(position, query_enc_cur.length)) +
+ // suffix
+ doc_org_cur.substring(position + query_enc_cur.length);
+ found = !0;
+ break;
+ }
+ }
+
+ //str += doc_enc[k].replace(new RegExp("(" + doc_enc[k] + ")", "g"), template.replace("$1", content))
+ }
+
+ if (!found) {
+ str += (str ? " " : "") + doc_org[k];
+ }
}
- console.log(result, index, template);
-
res[j].highlight = str;
}
}
diff --git a/dist/module-debug/encoder.js b/dist/module-debug/encoder.js
index 11523b6..0a16586 100644
--- a/dist/module-debug/encoder.js
+++ b/dist/module-debug/encoder.js
@@ -163,8 +163,7 @@ Encoder.prototype.assign = function (options) {
// options
- this.rtl = options.rtl || /* suggest */ /* append: */
- /* enrich */!1;
+ this.rtl = options.rtl || /* suggest */ /* append: */ /* enrich */!1;
this.dedupe = parse_option(options.dedupe, !0, this.dedupe);
this.filter = parse_option((tmp = options.filter) && new Set(tmp), null, this.filter);
this.matcher = parse_option((tmp = options.matcher) && new Map(tmp), null, this.matcher);
diff --git a/dist/module-debug/intersect.js b/dist/module-debug/intersect.js
index b97dba7..f6e00a4 100644
--- a/dist/module-debug/intersect.js
+++ b/dist/module-debug/intersect.js
@@ -49,6 +49,11 @@ export function intersect(arrays, resolution, limit, offset, suggest, boost, res
id = ids[z];
+ // todo the persistent implementation will count term matches
+ // and also aggregate the score (group by id)
+ // min(score): suggestions off (already covered)
+ // sum(score): suggestions on (actually not covered)
+
if (count = check[id]) {
check[id]++;
// tmp.count++;
@@ -115,12 +120,14 @@ export function intersect(arrays, resolution, limit, offset, suggest, boost, res
break;
}
}
- return 1 < final.length ? concat(final) : final[0];
+ result = 1 < final.length ? concat(final) : final[0];
}
+
+ return result;
}
} else {
- result = 1 < result.length ? union(result, offset, limit, resolve, 0) : result[0];
+ result = 1 < result.length ? union(result, offset, limit, resolve, 0) : (result = result[0]).length > limit || offset ? result.slice(offset, limit + offset) : result;
}
}
diff --git a/dist/module-debug/type.js b/dist/module-debug/type.js
index a13ad73..c9d87a9 100644
--- a/dist/module-debug/type.js
+++ b/dist/module-debug/type.js
@@ -138,7 +138,8 @@ export const SearchOptions = {};
* field: Array|undefined,
* index: Array|undefined,
* pluck: boolean|undefined,
- * merge: [boolean=false]
+ * merge: [boolean=false],
+ * highlight: string|undefined
* }}
*/
export const DocumentSearchOptions = {};
@@ -147,7 +148,8 @@ export const DocumentSearchOptions = {};
* @typedef DocumentSearchResults Array<{{
* field: string|undefined,
* tag: string|undefined,
- * result: Array
+ * result: Array,
+ * highlight: string|undefined
* }}>
*/
export const DocumentSearchResults = {};
@@ -159,7 +161,8 @@ export const DocumentSearchResults = {};
* result: Array<{{
* id: number|string,
* doc: Object
- * }}>
+ * }}>,
+ * highlight: string|undefined
* }}>
*/
export const EnrichedDocumentSearchResults = {};
@@ -168,7 +171,8 @@ export const EnrichedDocumentSearchResults = {};
* @typedef MergedDocumentSearchResults Array<{{
* id: number|string,
* doc: Object|undefined,
- * field: Array
+ * field: Array,
+ * highlight: string|undefined
* }}>
*/
export const MergedDocumentSearchResults = {};
diff --git a/dist/module-min/document/search.js b/dist/module-min/document/search.js
index eb86ef7..970b616 100644
--- a/dist/module-min/document/search.js
+++ b/dist/module-min/document/search.js
@@ -1 +1 @@
-import{DocumentSearchOptions}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";let debug=!1;Document.prototype.search=function(a,b,c,d){debug,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;if(c){if(is_array(c)&&(c={index:c}),a=c.query||a,e=c.pluck,g=c.merge,j=e||c.field||c.index,k=this.tag&&c.tag,f=this.store&&c.enrich,h=c.suggest,m=c.highlight,b=c.limit||b,l=c.offset||0,b||(b=100),k&&(!this.db||!d)){debug,k.constructor!==Array&&(k=[k]);let c=[];for(let a,b=0;bc||d)&&(k=k.slice(d,c+d));else{const a=[];for(let b,e=0;ed){d-=b.length;continue}if((b.length>c||d)&&(b=b.slice(d,c+d),c-=b.length,d&&(d-=b.length)),a.push(b),!c)break}return 1c||d)&&(k=k.slice(d,c+d));else{const a=[];for(let b,e=0;ed){d-=b.length;continue}if((b.length>c||d)&&(b=b.slice(d,c+d),c-=b.length,d&&(d-=b.length)),a.push(b),!c)break}k=1c||d?k.slice(d,c+d):k;return k}export function union(a,b,c,d,e){const f=[],g=create_object();let h,l,m,n=a.length,o=0;if(!d){let d=get_max_len(a);for(let j=0;j limit || offset ? result.slice(offset, limit + offset) : result;
}
}
diff --git a/dist/module/type.js b/dist/module/type.js
index a13ad73..c9d87a9 100644
--- a/dist/module/type.js
+++ b/dist/module/type.js
@@ -138,7 +138,8 @@ export const SearchOptions = {};
* field: Array|undefined,
* index: Array|undefined,
* pluck: boolean|undefined,
- * merge: [boolean=false]
+ * merge: [boolean=false],
+ * highlight: string|undefined
* }}
*/
export const DocumentSearchOptions = {};
@@ -147,7 +148,8 @@ export const DocumentSearchOptions = {};
* @typedef DocumentSearchResults Array<{{
* field: string|undefined,
* tag: string|undefined,
- * result: Array
+ * result: Array,
+ * highlight: string|undefined
* }}>
*/
export const DocumentSearchResults = {};
@@ -159,7 +161,8 @@ export const DocumentSearchResults = {};
* result: Array<{{
* id: number|string,
* doc: Object
- * }}>
+ * }}>,
+ * highlight: string|undefined
* }}>
*/
export const EnrichedDocumentSearchResults = {};
@@ -168,7 +171,8 @@ export const EnrichedDocumentSearchResults = {};
* @typedef MergedDocumentSearchResults Array<{{
* id: number|string,
* doc: Object|undefined,
- * field: Array
+ * field: Array,
+ * highlight: string|undefined
* }}>
*/
export const MergedDocumentSearchResults = {};
diff --git a/example/browser-legacy/document-highlighting/index.html b/example/browser-legacy/document-highlighting/index.html
new file mode 100644
index 0000000..c0c4418
--- /dev/null
+++ b/example/browser-legacy/document-highlighting/index.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+ Example: browser-legacy-document-highlighting
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/browser-module/document-highlighting/index.html b/example/browser-module/document-highlighting/index.html
new file mode 100644
index 0000000..f430586
--- /dev/null
+++ b/example/browser-module/document-highlighting/index.html
@@ -0,0 +1,62 @@
+
+
+
+
+
+ Example: browser-module-document-highlighting
+
+
+
+
+
\ No newline at end of file
diff --git a/example/browser-module/document/index.html b/example/browser-module/document/index.html
index 32e2830..58e999b 100644
--- a/example/browser-module/document/index.html
+++ b/example/browser-module/document/index.html
@@ -66,7 +66,7 @@
index.add(data[i]);
}
- // perform a query
+ // perform a query + enrich results
const result = index.search({
query: "karmen",
tag: {
@@ -77,7 +77,6 @@
]
},
enrich: true,
- highlight: "$1"
});
// display results
diff --git a/example/nodejs-commonjs/basic-persistent/README.md b/example/nodejs-commonjs/basic-persistent/README.md
index 9a8d887..a4c3c16 100644
--- a/example/nodejs-commonjs/basic-persistent/README.md
+++ b/example/nodejs-commonjs/basic-persistent/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
npm install sqlite3@5.1.7
diff --git a/example/nodejs-commonjs/basic-resolver/README.md b/example/nodejs-commonjs/basic-resolver/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-commonjs/basic-resolver/README.md
+++ b/example/nodejs-commonjs/basic-resolver/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-commonjs/basic-suggestion/README.md b/example/nodejs-commonjs/basic-suggestion/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-commonjs/basic-suggestion/README.md
+++ b/example/nodejs-commonjs/basic-suggestion/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-commonjs/basic-worker/README.md b/example/nodejs-commonjs/basic-worker/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-commonjs/basic-worker/README.md
+++ b/example/nodejs-commonjs/basic-worker/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-commonjs/basic/README.md b/example/nodejs-commonjs/basic/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-commonjs/basic/README.md
+++ b/example/nodejs-commonjs/basic/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-commonjs/document-persistent/README.md b/example/nodejs-commonjs/document-persistent/README.md
index 9a8d887..a4c3c16 100644
--- a/example/nodejs-commonjs/document-persistent/README.md
+++ b/example/nodejs-commonjs/document-persistent/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
npm install sqlite3@5.1.7
diff --git a/example/nodejs-commonjs/document-worker-extern-config/README.md b/example/nodejs-commonjs/document-worker-extern-config/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-commonjs/document-worker-extern-config/README.md
+++ b/example/nodejs-commonjs/document-worker-extern-config/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-commonjs/document-worker/README.md b/example/nodejs-commonjs/document-worker/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-commonjs/document-worker/README.md
+++ b/example/nodejs-commonjs/document-worker/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-commonjs/document/README.md b/example/nodejs-commonjs/document/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-commonjs/document/README.md
+++ b/example/nodejs-commonjs/document/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-commonjs/language-pack/README.md b/example/nodejs-commonjs/language-pack/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-commonjs/language-pack/README.md
+++ b/example/nodejs-commonjs/language-pack/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-esm/basic-persistent/README.md b/example/nodejs-esm/basic-persistent/README.md
index 9a8d887..a4c3c16 100644
--- a/example/nodejs-esm/basic-persistent/README.md
+++ b/example/nodejs-esm/basic-persistent/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
npm install sqlite3@5.1.7
diff --git a/example/nodejs-esm/basic-resolver/README.md b/example/nodejs-esm/basic-resolver/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-esm/basic-resolver/README.md
+++ b/example/nodejs-esm/basic-resolver/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-esm/basic-suggestion/README.md b/example/nodejs-esm/basic-suggestion/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-esm/basic-suggestion/README.md
+++ b/example/nodejs-esm/basic-suggestion/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-esm/basic-worker-extern-config/README.md b/example/nodejs-esm/basic-worker-extern-config/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-esm/basic-worker-extern-config/README.md
+++ b/example/nodejs-esm/basic-worker-extern-config/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-esm/basic-worker/README.md b/example/nodejs-esm/basic-worker/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-esm/basic-worker/README.md
+++ b/example/nodejs-esm/basic-worker/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-esm/basic/README.md b/example/nodejs-esm/basic/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-esm/basic/README.md
+++ b/example/nodejs-esm/basic/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-esm/document-persistent/README.md b/example/nodejs-esm/document-persistent/README.md
index 9a8d887..a4c3c16 100644
--- a/example/nodejs-esm/document-persistent/README.md
+++ b/example/nodejs-esm/document-persistent/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
npm install sqlite3@5.1.7
diff --git a/example/nodejs-esm/document-worker-extern-config/README.md b/example/nodejs-esm/document-worker-extern-config/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-esm/document-worker-extern-config/README.md
+++ b/example/nodejs-esm/document-worker-extern-config/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-esm/document-worker/README.md b/example/nodejs-esm/document-worker/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-esm/document-worker/README.md
+++ b/example/nodejs-esm/document-worker/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/example/nodejs-esm/document/README.md b/example/nodejs-esm/document/README.md
index 9a8d887..a4c3c16 100644
--- a/example/nodejs-esm/document/README.md
+++ b/example/nodejs-esm/document/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
npm install sqlite3@5.1.7
diff --git a/example/nodejs-esm/language-pack/README.md b/example/nodejs-esm/language-pack/README.md
index 864ef27..24ee65e 100644
--- a/example/nodejs-esm/language-pack/README.md
+++ b/example/nodejs-esm/language-pack/README.md
@@ -1,5 +1,5 @@
```bash
-npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview
+npm install
```
```bash
diff --git a/src/document/search.js b/src/document/search.js
index b218954..6211f19 100644
--- a/src/document/search.js
+++ b/src/document/search.js
@@ -1,7 +1,7 @@
// COMPILER BLOCK -->
import {
DEBUG,
- SUPPORT_PERSISTENT,
+ SUPPORT_PERSISTENT, SUPPORT_RESOLVER,
SUPPORT_STORE,
SUPPORT_SUGGESTION,
SUPPORT_TAGS
@@ -9,7 +9,7 @@ import {
// <-- COMPILER BLOCK
import { DocumentSearchOptions } from "../type.js";
-import { create_object, is_array, is_object, is_string } from "../common.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";
@@ -19,13 +19,13 @@ let debug = false;
* @param {!string|DocumentSearchOptions} query
* @param {number|DocumentSearchOptions=} limit
* @param {DocumentSearchOptions=} options
- * @param {Array=} _resolve For internal use only.
+ * @param {Array=} _promises For internal use only.
* @returns {Promise|Array}
*/
-Document.prototype.search = function(query, limit, options, _resolve){
+Document.prototype.search = function(query, limit, options, _promises){
- debug && console.log("checkoint:search", !!_resolve);
+ debug && console.log("checkoint:search", !!_promises);
if(!options){
if(!limit && is_object(query)){
@@ -40,7 +40,7 @@ Document.prototype.search = function(query, limit, options, _resolve){
let result = [], result_field = [];
let pluck, enrich, merge, suggest;
- let field, tag, offset, count = 0;
+ let field, tag, offset, count = 0, resolve, highlight;
if(options){
@@ -57,11 +57,13 @@ Document.prototype.search = function(query, limit, options, _resolve){
tag = SUPPORT_TAGS && this.tag && options.tag;
enrich = SUPPORT_STORE && this.store && options.enrich;
suggest = SUPPORT_SUGGESTION && options.suggest;
+ highlight = options.highlight;
+ //resolve = !SUPPORT_RESOLVER || (options.resolve !== false);
limit = options.limit || limit;
offset = options.offset || 0;
limit || (limit = 100);
- if(tag && (!SUPPORT_PERSISTENT || !this.db || !_resolve)){
+ if(tag && (!SUPPORT_PERSISTENT || !this.db || !_promises)){
// Tag-Search
// -----------------------------
@@ -165,7 +167,7 @@ Document.prototype.search = function(query, limit, options, _resolve){
}
field || (field = this.field);
- let promises = !_resolve && (this.worker || this.db /*|| this.async*/) && [];
+ let promises = !_promises && (this.worker || this.db /*|| this.async*/) && [];
let db_tag_search;
// multi field search
@@ -189,13 +191,13 @@ Document.prototype.search = function(query, limit, options, _resolve){
key = field_options.field;
query = field_options.query || query;
limit = field_options.limit || limit;
- //offset = field_options.offset || offset;
+ offset = field_options.offset || offset;
suggest = SUPPORT_SUGGESTION && (field_options.suggest || suggest);
- //enrich = SUPPORT_STORE && this.store && (field_options.enrich || enrich);
+ enrich = SUPPORT_STORE && this.store && (field_options.enrich || enrich);
}
- if(_resolve){
- res = _resolve[i];
+ if(_promises){
+ res = _promises[i];
}
else{
debug && console.log("checkoint:search:get", key);
@@ -213,13 +215,14 @@ Document.prototype.search = function(query, limit, options, _resolve){
}
}
if(promises){
- promises[i] = index.searchAsync(query, limit, opt);
+ promises[i] = index.search/*Async*/(query, limit, opt);
// restore enrich state
opt && enrich && (opt.enrich = enrich);
// just collect and continue
continue;
}
else{
+
res = index.search(query, limit, opt);
// restore enrich state
opt && enrich && (opt.enrich = enrich);
@@ -236,13 +239,13 @@ Document.prototype.search = function(query, limit, options, _resolve){
let count = 0;
// tags are only applied in resolve phase when it's a db
- if(SUPPORT_PERSISTENT && this.db && _resolve){
+ if(SUPPORT_PERSISTENT && this.db && _promises){
if(!db_tag_search){
// retrieve tag results assigned to it's field
- for(let y = field.length; y < _resolve.length; y++){
+ for(let y = field.length; y < _promises.length; y++){
- let ids = _resolve[y];
+ let ids = _promises[y];
let len = ids && ids.length;
if(len){
@@ -344,7 +347,7 @@ Document.prototype.search = function(query, limit, options, _resolve){
// TODO unroll this recursion
return Promise.all(promises).then(function(result){
return result.length
- ? self.search(query, limit, options, /* resolve: */ result)
+ ? self.search(query, limit, options, /* promises: */ result)
: result;
});
}
@@ -370,6 +373,7 @@ Document.prototype.search = function(query, limit, options, _resolve){
}
else{
debug && console.log("checkoint:search:doc:get");
+ // the documents are stored on the first field
promises.push(res = this.index.get(this.field[0]).db.enrich(res));
}
}
@@ -385,20 +389,107 @@ Document.prototype.search = function(query, limit, options, _resolve){
}
if(enrich && SUPPORT_PERSISTENT && this.db && promises.length){
+ const self = this;
return Promise.all(promises).then(function(promises){
for(let j = 0; j < promises.length; j++){
- result[j].result = promises[j];
+ result[j]["result"] = promises[j];
}
return merge
? merge_fields(result, limit, offset)
- : result;
+ : highlight
+ ? highlight_fields(result, query, self.index, self.field, self.tree, highlight, limit, offset)
+ : result;
});
}
return merge
? merge_fields(result, limit, offset)
- : result;
-};
+ : highlight
+ ? highlight_fields(result, query, this.index, this.field, this.tree, highlight, limit, offset)
+ : result;
+}
+
+/*
+
+ karmen or clown or not found
+[Carmen]cita
+ Le [clown] et ses chiens
+
+ */
+
+function highlight_fields(result, query, index, field, tree, template, limit, offset){
+
+ // if(typeof template === "string"){
+ // template = new RegExp(template, "g");
+ // }
+
+ let encoder;
+ let query_enc;
+ let tokenize;
+
+ for(let i = 0, res, res_field, enc, idx, path; i < result.length; i++){
+
+ res = result[i].result;
+ res_field = result[i].field;
+ idx = index.get(res_field);
+ enc = idx.encoder;
+ tokenize = idx.tokenize;
+ path = tree[field.indexOf(res_field)];
+
+ if(enc !== encoder){
+ encoder = enc;
+ query_enc = encoder.encode(query);
+ }
+
+ for(let j = 0; j < res.length; j++){
+ let str = "";
+ let content = parse_simple(res[j].doc, path);
+ let doc_enc = encoder.encode(content);
+ let doc_org = content.split(encoder.split);
+
+ for(let k = 0, doc_enc_cur, doc_org_cur; k < doc_enc.length; k++){
+ doc_enc_cur = doc_enc[k];
+ doc_org_cur = doc_org[k];
+ let found;
+ for(let l = 0, query_enc_cur; l < query_enc.length; l++){
+ query_enc_cur = query_enc[l];
+ // todo tokenize could be custom also when "strict" was used
+ if(tokenize === "strict"){
+ if(doc_enc_cur === query_enc_cur){
+ str += (str ? " " : "") + template.replace("$1", doc_org_cur);
+ found = true;
+ break;
+ }
+ }
+ else{
+ const position = doc_enc_cur.indexOf(query_enc_cur);
+ if(position > -1){
+ str += (str ? " " : "") +
+ // prefix
+ doc_org_cur.substring(0, position) +
+ // match
+ template.replace("$1", doc_org_cur.substring(position, query_enc_cur.length)) +
+ // suffix
+ doc_org_cur.substring(position + query_enc_cur.length);
+ found = true;
+ break;
+ }
+ }
+
+ //str += doc_enc[k].replace(new RegExp("(" + doc_enc[k] + ")", "g"), template.replace("$1", content))
+ }
+
+ if(!found){
+ str += (str ? " " : "") + doc_org[k];
+ }
+ }
+
+ res[j].highlight = str;
+ }
+ }
+
+ return result;
+}
// todo support Resolver
// todo when searching through multiple fields each term should
diff --git a/src/intersect.js b/src/intersect.js
index 71011cd..125dfc2 100644
--- a/src/intersect.js
+++ b/src/intersect.js
@@ -50,6 +50,11 @@ export function intersect(arrays, resolution, limit, offset, suggest, boost, res
id = ids[z];
+ // todo the persistent implementation will count term matches
+ // and also aggregate the score (group by id)
+ // min(score): suggestions off (already covered)
+ // sum(score): suggestions on (actually not covered)
+
if((count = check[id])){
check[id]++;
// tmp.count++;
@@ -118,17 +123,21 @@ export function intersect(arrays, resolution, limit, offset, suggest, boost, res
break;
}
}
- return final.length > 1
+ result = final.length > 1
? concat(final)
: final[0];
}
+
+ return result;
}
}
else{
result = result.length > 1
? union(result, offset, limit, resolve, 0)
- : result[0];
+ : ((result = result[0]).length > limit) || offset
+ ? result.slice(offset, limit + offset)
+ : result;
}
}
diff --git a/src/type.js b/src/type.js
index a13ad73..c9d87a9 100644
--- a/src/type.js
+++ b/src/type.js
@@ -138,7 +138,8 @@ export const SearchOptions = {};
* field: Array|undefined,
* index: Array