1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-10-04 00:51:52 +02:00

chunked export/import

This commit is contained in:
Thomas Wilkerling
2025-03-15 16:08:56 +01:00
parent 76d089b27c
commit 41b55bead6
44 changed files with 2177 additions and 1716 deletions

View File

@@ -89,7 +89,7 @@ function ca(a) {
"\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]];
const ea = /[^\p{L}\p{N}]+/u, fa = /(\d{3})/g, ha = /(\D)(\d{3})/g, ia = /(\d{3})(\D)/g, ja = "".normalize && /[\u0300-\u036f]/g;
function K(a) {
if (this.constructor !== K) {
if (!this || this.constructor !== K) {
return new K(...arguments);
}
for (let b = 0; b < arguments.length; b++) {
@@ -263,7 +263,7 @@ function N(a = {}) {
return this;
}
}
if (this.constructor !== N) {
if (!this || this.constructor !== N) {
return new N(a);
}
let c = "undefined" !== typeof self ? self._factory : "undefined" !== typeof window ? window._factory : null;
@@ -313,37 +313,68 @@ function P(a) {
return b;
};
}
;function oa(a) {
const b = [];
for (const c of a.entries()) {
b.push(c);
;function oa(a, b = 0) {
let c = [], d = [];
b && (b = 250000 / b * 5000 | 0);
for (const e of a.entries()) {
d.push(e), d.length === b && (c.push(d), d = []);
}
d.length && c.push(d);
return c;
}
function pa(a, b) {
b || (b = new Map());
for (let c = 0, d; c < a.length; c++) {
d = a[c], b.set(d[0], d[1]);
}
return b;
}
function pa(a) {
const b = [];
for (const c of a.entries()) {
b.push(oa(c));
function qa(a, b = 0) {
let c = [], d = [];
b && (b = 250000 / b * 1000 | 0);
for (const e of a.entries()) {
d.push([e[0], oa(e[1])[0]]), d.length === b && (c.push(d), d = []);
}
d.length && c.push(d);
return c;
}
function ra(a, b) {
b || (b = new Map());
for (let c = 0, d, e; c < a.length; c++) {
d = a[c], e = b.get(d[0]), b.set(d[0], pa(d[1], e));
}
return b;
}
function qa(a) {
const b = [];
for (const c of a.keys()) {
b.push(c);
function sa(a) {
let b = [], c = [];
for (const d of a.keys()) {
c.push(d), 250000 === c.length && (b.push(c), c = []);
}
c.length && b.push(c);
return b;
}
function ta(a, b) {
b || (b = new Set());
for (let c = 0; c < a.length; c++) {
b.add(a[c]);
}
return b;
}
function ra(a, b, c, d, e, f) {
if ((c = a(b ? b + "." + c : c, JSON.stringify(f))) && c.then) {
const g = this;
return c.then(function() {
return g.export(a, b, d, e + 1);
function ua(a, b, c, d, e, f, g = 0) {
const h = d && d.constructor === Array;
var k = h ? d.shift() : d;
if (!k) {
return this.export(a, b, e, f + 1);
}
if ((k = a((b ? b + "." : "") + (g + 1) + "." + c, JSON.stringify(k))) && k.then) {
const l = this;
return k.then(function() {
return ua.call(l, a, b, c, h ? d : null, e, f, g + 1);
});
}
return this.export(a, b, d, e + 1);
return ua.call(this, a, b, c, h ? d : null, e, f, g + 1);
}
;function sa(a, b, c, d) {
;function va(a, b, c, d) {
let e = [];
for (let f = 0, g; f < a.index.length; f++) {
if (g = a.index[f], b >= g.length) {
@@ -409,12 +440,12 @@ function Q(a) {
}
if ("slice" === d) {
return function(e, f) {
return sa(b, e || 0, f || b.length, !1);
return va(b, e || 0, f || b.length, !1);
};
}
if ("splice" === d) {
return function(e, f) {
return sa(b, e || 0, f || b.length, !0);
return va(b, e || 0, f || b.length, !0);
};
}
if ("constructor" === d) {
@@ -445,7 +476,7 @@ function R(a = 8) {
this.index = B();
this.B = [];
this.size = 0;
32 < a ? (this.h = ta, this.A = BigInt(a)) : (this.h = ua, this.A = a);
32 < a ? (this.h = wa, this.A = BigInt(a)) : (this.h = xa, this.A = a);
}
R.prototype.get = function(a) {
const b = this.index[this.h(a)];
@@ -462,7 +493,7 @@ function S(a = 8) {
}
this.index = B();
this.h = [];
32 < a ? (this.B = ta, this.A = BigInt(a)) : (this.B = ua, this.A = a);
32 < a ? (this.B = wa, this.A = BigInt(a)) : (this.B = xa, this.A = a);
}
S.prototype.add = function(a) {
var b = this.B(a);
@@ -504,7 +535,7 @@ v.entries = S.prototype.entries = function*() {
}
}
};
function ua(a) {
function xa(a) {
let b = 2 ** this.A - 1;
if ("number" == typeof a) {
return a & b;
@@ -515,7 +546,7 @@ function ua(a) {
}
return 32 === this.A ? c + 2 ** 31 : c;
}
function ta(a) {
function wa(a) {
let b = BigInt(2) ** this.A - BigInt(1);
var c = typeof a;
if ("bigint" === c) {
@@ -545,7 +576,7 @@ function ta(a) {
e && d.add(a, e, !1, !0);
} else {
if (e = k.I, !e || e(b)) {
k.constructor === String ? k = ["" + k] : G(k) && (k = [k]), va(b, k, this.K, 0, d, a, k[0], c);
k.constructor === String ? k = ["" + k] : G(k) && (k = [k]), ya(b, k, this.K, 0, d, a, k[0], c);
}
}
}
@@ -608,7 +639,7 @@ function ta(a) {
h[l] = b[l];
continue;
}
wa(b, h, l, 0, l[0], m);
za(b, h, l, 0, l[0], m);
}
}
this.store.set(a, h || b);
@@ -616,21 +647,21 @@ function ta(a) {
}
return this;
};
function wa(a, b, c, d, e, f) {
function za(a, b, c, d, e, f) {
a = a[e];
if (d === c.length - 1) {
b[e] = f || a;
} else if (a) {
if (a.constructor === Array) {
for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) {
wa(a, b, c, d, e);
za(a, b, c, d, e);
}
} else {
b = b[e] || (b[e] = B()), e = c[++d], wa(a, b, c, d, e);
b = b[e] || (b[e] = B()), e = c[++d], za(a, b, c, d, e);
}
}
}
function va(a, b, c, d, e, f, g, h) {
function ya(a, b, c, d, e, f, g, h) {
if (a = a[g]) {
if (d === b.length - 1) {
if (a.constructor === Array) {
@@ -646,17 +677,17 @@ function va(a, b, c, d, e, f, g, h) {
} else {
if (a.constructor === Array) {
for (g = 0; g < a.length; g++) {
va(a, b, c, d, e, f, g, h);
ya(a, b, c, d, e, f, g, h);
}
} else {
g = b[++d], va(a, b, c, d, e, f, g, h);
g = b[++d], ya(a, b, c, d, e, f, g, h);
}
}
} else {
e.db && e.remove(f);
}
}
;function xa(a, b, c, d, e, f, g) {
;function Aa(a, b, c, d, e, f, g) {
const h = a.length;
let k = [], l;
var m;
@@ -672,7 +703,7 @@ function va(a, b, c, d, e, f, g, h) {
}
if (a = k.length) {
if (e) {
k = 1 < k.length ? ya(k, d, c, g, 0) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k;
k = 1 < k.length ? Ba(k, d, c, g, 0) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k;
} else {
if (a < h) {
return [];
@@ -705,7 +736,7 @@ function va(a, b, c, d, e, f, g, h) {
}
return k;
}
function ya(a, b, c, d, e) {
function Ba(a, b, c, d, e) {
const f = [], g = B();
let h;
var k = a.length;
@@ -748,7 +779,7 @@ function ya(a, b, c, d, e) {
}
return f;
}
function za(a, b) {
function Ca(a, b) {
const c = B(), d = [];
for (let e = 0, f; e < b.length; e++) {
f = b[e];
@@ -826,7 +857,7 @@ function za(a, b) {
}
t.push(d = d.db.tag(r[n + 1], b, l, q));
} else {
d = Aa.call(this, r[n], r[n + 1], b, l, q);
d = Da.call(this, r[n], r[n + 1], b, l, q);
}
e.push({field:r[n], tag:r[n + 1], result:d});
}
@@ -878,7 +909,7 @@ function za(a, b) {
}
}
} else {
for (let E = 0, F, cb; E < n.length; E += 2) {
for (let E = 0, F, fb; E < n.length; E += 2) {
F = this.tag.get(n[E]);
if (!F) {
if (console.warn("Tag '" + n[E] + ":" + n[E + 1] + "' will be skipped because there is no field '" + n[E] + "'."), t) {
@@ -887,7 +918,7 @@ function za(a, b) {
return e;
}
}
if (cb = (F = F && F.get(n[E + 1])) && F.length) {
if (fb = (F = F && F.get(n[E + 1])) && F.length) {
x++, u.push(F);
} else if (!t) {
return e;
@@ -895,7 +926,7 @@ function za(a, b) {
}
}
if (x) {
w = za(w, u);
w = Ca(w, u);
I = w.length;
if (!I && !t) {
return e;
@@ -937,7 +968,7 @@ function za(a, b) {
r = [];
for (let y = 0, w; y < f.length; y++) {
w = e[y];
q && w.length && !w[0].doc && (this.db ? r.push(w = this.index.get(this.field[0]).db.enrich(w)) : w.length && (w = Ba.call(this, w)));
q && w.length && !w[0].doc && (this.db ? r.push(w = this.index.get(this.field[0]).db.enrich(w)) : w.length && (w = Ea.call(this, w)));
if (g) {
return w;
}
@@ -949,12 +980,12 @@ function za(a, b) {
for (let A = 0; A < w.length; A++) {
e[A].result = w[A];
}
return h ? Ca(e, b) : p ? Da(e, a, y.index, y.field, y.D, p) : e;
return h ? Fa(e, b) : p ? Ga(e, a, y.index, y.field, y.D, p) : e;
});
}
return h ? Ca(e, b) : p ? Da(e, a, this.index, this.field, this.D, p) : e;
return h ? Fa(e, b) : p ? Ga(e, a, this.index, this.field, this.D, p) : e;
};
function Da(a, b, c, d, e, f) {
function Ga(a, b, c, d, e, f) {
let g, h, k;
for (let m = 0, p, n, q, t, r; m < a.length; m++) {
p = a[m].result;
@@ -996,7 +1027,7 @@ function Da(a, b, c, d, e, f) {
}
return a;
}
function Ca(a, b) {
function Fa(a, b) {
const c = [], d = B();
for (let e = 0, f, g; e < a.length; e++) {
f = a[e];
@@ -1015,7 +1046,7 @@ function Ca(a, b) {
}
return c;
}
function Aa(a, b, c, d, e) {
function Da(a, b, c, d, e) {
let f = this.tag.get(a);
if (!f) {
return console.warn("Tag '" + a + "' was not found"), [];
@@ -1024,11 +1055,11 @@ function Aa(a, b, c, d, e) {
if (a > c || d) {
f = f.slice(d, d + c);
}
e && (f = Ba.call(this, f));
e && (f = Ea.call(this, f));
return f;
}
}
function Ba(a) {
function Ea(a) {
const b = Array(a.length);
for (let c = 0, d; c < a.length; c++) {
d = a[c], b[c] = {id:d, doc:this.store.get(d)};
@@ -1036,7 +1067,7 @@ function Ba(a) {
return b;
}
;function T(a) {
if (this.constructor !== T) {
if (!this || this.constructor !== T) {
return new T(a);
}
const b = a.document || a.doc || a;
@@ -1044,7 +1075,7 @@ function Ba(a) {
this.D = [];
this.field = [];
this.K = [];
this.key = (c = b.key || b.id) && Ea(c, this.K) || "id";
this.key = (c = b.key || b.id) && Ha(c, this.K) || "id";
(d = a.keystore || 0) && (this.keystore = d);
this.reg = (this.fastupdate = !!a.fastupdate) ? d ? new R(d) : new Map() : d ? new S(d) : new Set();
this.C = (c = b.store || null) && !0 !== c && [];
@@ -1052,7 +1083,7 @@ function Ba(a) {
this.cache = (c = a.cache || null) && new U(c);
a.cache = !1;
this.worker = a.worker;
this.index = Fa.call(this, a, b);
this.index = Ia.call(this, a, b);
this.tag = null;
if (c = b.tag) {
if ("string" === typeof c && (c = [c]), c.length) {
@@ -1065,7 +1096,7 @@ function Ba(a) {
if (!g) {
throw Error("The tag field from the document descriptor is undefined.");
}
f.custom ? this.G[e] = f.custom : (this.G[e] = Ea(g, this.K), f.filter && ("string" === typeof this.G[e] && (this.G[e] = new String(this.G[e])), this.G[e].I = f.filter));
f.custom ? this.G[e] = f.custom : (this.G[e] = Ha(g, this.K), f.filter && ("string" === typeof this.G[e] && (this.G[e] = new String(this.G[e])), this.G[e].I = f.filter));
this.N[e] = g;
this.tag.set(g, new Map());
}
@@ -1133,7 +1164,7 @@ v.destroy = function() {
}
return Promise.all(a);
};
function Fa(a, b) {
function Ia(a, b) {
const c = new Map();
let d = b.index || b.field || b;
G(d) && (d = [d]);
@@ -1146,19 +1177,19 @@ function Fa(a, b) {
c.set(f, h);
}
this.worker || c.set(f, new L(g, this.reg));
g.custom ? this.D[e] = g.custom : (this.D[e] = Ea(f, this.K), g.filter && ("string" === typeof this.D[e] && (this.D[e] = new String(this.D[e])), this.D[e].I = g.filter));
g.custom ? this.D[e] = g.custom : (this.D[e] = Ha(f, this.K), g.filter && ("string" === typeof this.D[e] && (this.D[e] = new String(this.D[e])), this.D[e].I = g.filter));
this.field[e] = f;
}
if (this.C) {
a = b.store;
G(a) && (a = [a]);
for (let e = 0, f, g; e < a.length; e++) {
f = a[e], g = f.field || f, f.custom ? (this.C[e] = f.custom, f.custom.U = g) : (this.C[e] = Ea(g, this.K), f.filter && ("string" === typeof this.C[e] && (this.C[e] = new String(this.C[e])), this.C[e].I = f.filter));
f = a[e], g = f.field || f, f.custom ? (this.C[e] = f.custom, f.custom.U = g) : (this.C[e] = Ha(g, this.K), f.filter && ("string" === typeof this.C[e] && (this.C[e] = new String(this.C[e])), this.C[e].I = f.filter));
}
}
return c;
}
function Ea(a, b) {
function Ha(a, b) {
const c = a.split(":");
let d = 0;
for (let e = 0; e < c.length; e++) {
@@ -1224,28 +1255,28 @@ v.set = function(a, b) {
this.store.set(a, b);
return this;
};
v.searchCache = Ga;
v.searchCache = Ja;
v.export = function(a, b, c = 0, d = 0) {
if (c < this.field.length) {
const g = this.field[c];
if ((b = this.index.get(g).export(a, g, c, d = 1)) && b.then) {
const h = this;
return b.then(function() {
return h.export(a, g, c + 1, d = 0);
return h.export(a, g, c + 1);
});
}
return this.export(a, g, c + 1, d = 0);
return this.export(a, g, c + 1);
}
let e, f;
switch(d) {
case 0:
e = "reg";
f = qa(this.reg);
f = sa(this.reg);
b = null;
break;
case 1:
e = "tag";
f = pa(this.tag);
f = qa(this.tag, this.reg.size);
b = null;
break;
case 2:
@@ -1261,33 +1292,36 @@ v.export = function(a, b, c = 0, d = 0) {
default:
return;
}
return ra.call(this, a, b, e, c, d, f);
return ua.call(this, a, b, e, f, c, d);
};
v.import = function(a, b) {
if (b) {
switch(G(b) && (b = JSON.parse(b)), a) {
case "tag":
break;
G(b) && (b = JSON.parse(b));
a = a.split(".");
"json" === a[a.length - 1] && a.pop();
var c = 2 < a.length ? a[0] : "";
a = 2 < a.length ? a[2] : a[1];
if (c) {
return this.index.get(c).import(a, b);
}
switch(a) {
case "reg":
this.fastupdate = !1;
this.reg = new Set(b);
this.reg = ta(b, this.reg);
for (let d = 0, e; d < this.field.length; d++) {
e = this.index.get(this.field[d]), e.fastupdate = !1, e.reg = this.reg;
}
break;
case "doc":
this.store = new Map(b);
case "tag":
this.tag = ra(b, this.tag);
break;
default:
a = a.split(".");
const c = a[0];
a = a[1];
c && a && this.index.get(c).import(a, b);
case "doc":
this.store = pa(b, this.store);
}
}
};
na(T.prototype);
function Ga(a, b, c) {
function Ja(a, b, c) {
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
let d = this.cache.get(a);
if (!d) {
@@ -1327,31 +1361,31 @@ U.prototype.clear = function() {
this.cache.clear();
this.h = "";
};
const Ha = {normalize:function(a) {
const Ka = {normalize:function(a) {
return a.toLowerCase();
}, dedupe:!1};
const Ia = 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 Ja = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Ka = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"];
const La = {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 Ma = /[\x00-\x7F]+/g;
const Na = /[\x00-\x7F]+/g;
const Oa = /[\x00-\x7F]+/g;
var Pa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ha, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Ia}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Ia, matcher:Ja, replacer:Ka}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Ia, replacer:Ka.concat([/(?!^)[aeo]/g, ""]), matcher:Ja}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) {
const La = 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 Ma = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), Na = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"];
const Oa = {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 Pa = /[\x00-\x7F]+/g;
const Qa = /[\x00-\x7F]+/g;
const Ra = /[\x00-\x7F]+/g;
var Sa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:Ka, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:La}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:La, matcher:Ma, replacer:Na}, LatinExtra:{normalize:!0, dedupe:!0, mapper:La, replacer:Na.concat([/(?!^)[aeo]/g, ""]), matcher:Ma}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) {
for (let c = 0; c < a.length; c++) {
var b = a[c];
let d = b.charAt(0), e = La[d];
for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = La[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) {
let d = b.charAt(0), e = Oa[d];
for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = Oa[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) {
}
a[c] = d;
}
}}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) {
return ("" + a).replace(Ma, " ");
return ("" + a).replace(Pa, " ");
}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) {
return ("" + a).replace(Na, "");
return ("" + a).replace(Qa, "");
}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) {
return ("" + a).replace(Oa, " ");
return ("" + a).replace(Ra, " ");
}}};
const Qa = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
const Ta = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
B();
L.prototype.add = function(a, b, c, d) {
if (b && (a || 0 === a)) {
@@ -1365,14 +1399,14 @@ L.prototype.add = function(a, b, c, d) {
let t = b[this.rtl ? d - 1 - q : q];
var e = t.length;
if (e && (p || !m[t])) {
var f = this.score ? this.score(b, t, q, null, 0) : Ra(n, d, q), g = "";
var f = this.score ? this.score(b, t, q, null, 0) : Ua(n, d, q), g = "";
switch(this.tokenize) {
case "full":
if (2 < e) {
for (f = 0; f < e; f++) {
for (var h = e; h > f; h--) {
g = t.substring(f, h);
var k = this.score ? this.score(b, t, q, g, f) : Ra(n, d, q, e, f);
var k = this.score ? this.score(b, t, q, g, f) : Ua(n, d, q, e, f);
V(this, m, g, k, a, c);
}
}
@@ -1381,7 +1415,7 @@ L.prototype.add = function(a, b, c, d) {
case "reverse":
if (1 < e) {
for (h = e - 1; 0 < h; h--) {
g = t[h] + g, k = this.score ? this.score(b, t, q, g, h) : Ra(n, d, q, e, h), V(this, m, g, k, a, c);
g = t[h] + g, k = this.score ? this.score(b, t, q, g, h) : Ua(n, d, q, e, h), V(this, m, g, k, a, c);
}
g = "";
}
@@ -1397,7 +1431,7 @@ L.prototype.add = function(a, b, c, d) {
for (e = B(), g = this.R, f = t, h = Math.min(p + 1, d - q), e[f] = 1, k = 1; k < h; k++) {
if ((t = b[this.rtl ? d - 1 - q - k : q + k]) && !e[t]) {
e[t] = 1;
const r = this.score ? this.score(b, f, q, t, k) : Ra(g + (d / 2 > g ? 0 : 1), d, q, h - 1, k - 1), u = this.bidirectional && t > f;
const r = this.score ? this.score(b, f, q, t, k) : Ua(g + (d / 2 > g ? 0 : 1), d, q, h - 1, k - 1), u = this.bidirectional && t > f;
V(this, l, u ? f : t, r, a, c, u ? t : f);
}
}
@@ -1410,7 +1444,7 @@ L.prototype.add = function(a, b, c, d) {
b = "";
}
}
this.db && (b || this.commit_task.push({del:a}), this.T && Sa(this));
this.db && (b || this.commit_task.push({del:a}), this.T && Va(this));
return this;
};
function V(a, b, c, d, e, f, g) {
@@ -1431,12 +1465,12 @@ function V(a, b, c, d, e, f, g) {
}
}
}
function Ra(a, b, c, d, e) {
function Ua(a, b, c, d, e) {
return c && 1 < a ? b + (d || 0) <= a ? c + (e || 0) : (a - 1) / (b + (d || 0)) * (c + (e || 0)) + 1 | 0 : 0;
}
;function W(a, b, c, d) {
if (1 === a.length) {
return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? Ta(a) : a;
return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? Wa(a) : a;
}
let e = [];
for (let f = 0, g, h; f < a.length; f++) {
@@ -1452,7 +1486,7 @@ function Ra(a, b, c, d, e) {
h > b && (g = g.slice(0, b), h = g.length), e.push(g);
} else {
if (h >= b) {
return h > b && (g = g.slice(0, b)), d ? Ta(g) : g;
return h > b && (g = g.slice(0, b)), d ? Wa(g) : g;
}
e = [g];
}
@@ -1466,9 +1500,9 @@ function Ra(a, b, c, d, e) {
return e;
}
e = 1 < e.length ? [].concat.apply([], e) : e[0];
return d ? Ta(e) : e;
return d ? Wa(e) : e;
}
function Ta(a) {
function Wa(a) {
for (let b = 0; b < a.length; b++) {
a[b] = {score:b, id:a[b]};
}
@@ -1518,19 +1552,19 @@ function Ta(a) {
if (c.length) {
return Promise.all(c).then(function() {
a.result.length && (d = d.concat([a.result]));
a.result = Ua(d, e, f, g, h, a.F);
a.result = Xa(d, e, f, g, h, a.F);
return h ? a.result : a;
});
}
d.length && (this.result.length && (d = d.concat([this.result])), this.result = Ua(d, e, f, g, h, this.F));
d.length && (this.result.length && (d = d.concat([this.result])), this.result = Xa(d, e, f, g, h, this.F));
return h ? this.result : this;
};
function Ua(a, b, c, d, e, f) {
function Xa(a, b, c, d, e, f) {
if (!a.length) {
return a;
}
"object" === typeof b && (c = b.offset || 0, d = b.enrich || !1, b = b.limit || 0);
return 2 > a.length ? e ? W(a[0], b, c, d) : a[0] : ya(a, c, b, e, f);
return 2 > a.length ? e ? W(a[0], b, c, d) : a[0] : Ba(a, c, b, e, f);
}
;X.prototype.and = function() {
if (this.result.length) {
@@ -1580,24 +1614,24 @@ function Ua(a, b, c, d, e, f) {
if (a.length) {
return Promise.all(a).then(function() {
d = [b.result].concat(d);
b.result = Va(d, e, f, g, b.F, h);
b.result = Ya(d, e, f, g, b.F, h);
return g ? b.result : b;
});
}
d = [this.result].concat(d);
this.result = Va(d, e, f, g, this.F, h);
this.result = Ya(d, e, f, g, this.F, h);
return g ? this.result : this;
}
return this;
};
function Va(a, b, c, d, e, f) {
function Ya(a, b, c, d, e, f) {
if (2 > a.length) {
return [];
}
let g = [];
B();
let h = ca(a);
return h ? xa(a, h, b, c, f, e, d) : g;
return h ? Aa(a, h, b, c, f, e, d) : g;
}
;X.prototype.xor = function() {
const a = this;
@@ -1643,14 +1677,14 @@ function Va(a, b, c, d, e, f) {
if (c.length) {
return Promise.all(c).then(function() {
a.result.length && (d = [a.result].concat(d));
a.result = Wa(d, e, f, g, !h, a.F);
a.result = Za(d, e, f, g, !h, a.F);
return h ? a.result : a;
});
}
d.length && (this.result.length && (d = [this.result].concat(d)), this.result = Wa(d, e, f, g, !h, a.F));
d.length && (this.result.length && (d = [this.result].concat(d)), this.result = Za(d, e, f, g, !h, a.F));
return h ? this.result : this;
};
function Wa(a, b, c, d, e, f) {
function Za(a, b, c, d, e, f) {
if (!a.length) {
return a;
}
@@ -1744,14 +1778,14 @@ function Wa(a, b, c, d, e, f) {
}
if (c.length) {
return Promise.all(c).then(function() {
a.result = Xa.call(a, d, e, f, g);
a.result = $a.call(a, d, e, f, g);
return g ? a.result : a;
});
}
d.length && (this.result = Xa.call(this, d, e, f, g));
d.length && (this.result = $a.call(this, d, e, f, g));
return g ? this.result : this;
};
function Xa(a, b, c, d) {
function $a(a, b, c, d) {
if (!a.length) {
return this.result;
}
@@ -1781,7 +1815,7 @@ function Xa(a, b, c, d) {
return e;
}
;function X(a) {
if (this.constructor !== X) {
if (!this || this.constructor !== X) {
return new X(a);
}
if (a && a.index) {
@@ -1826,12 +1860,12 @@ X.prototype.boost = function(a) {
return this;
};
X.prototype.resolve = function(a, b, c) {
Ya = 1;
ab = 1;
const d = this.result;
this.result = this.index = null;
return d.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), W(d, a || 100, b, c)) : d;
};
let Ya = 1;
let ab = 1;
L.prototype.search = function(a, b, c) {
c || (!b && H(a) ? (c = a, a = "") : H(b) && (c = b, b = 0));
let d = [], e;
@@ -1842,22 +1876,22 @@ L.prototype.search = function(a, b, c) {
g = c.offset || 0;
var p = c.context;
f = c.suggest;
(h = Ya && !1 !== c.resolve) || (Ya = 0);
(h = ab && !1 !== c.resolve) || (ab = 0);
k = h && c.enrich;
m = c.boost;
l = this.db && c.tag;
} else {
h = this.resolve || Ya;
h = this.resolve || ab;
}
a = this.encoder.encode(a);
e = a.length;
b || !h || (b = 100);
if (1 === e) {
return Za.call(this, a[0], "", b, g, h, k, l);
return bb.call(this, a[0], "", b, g, h, k, l);
}
p = this.depth && !1 !== p;
if (2 === e && p && !f) {
return Za.call(this, a[0], a[1], b, g, h, k, l);
return bb.call(this, a[0], a[1], b, g, h, k, l);
}
let n = c = 0;
if (1 < e) {
@@ -1882,10 +1916,10 @@ L.prototype.search = function(a, b, c) {
}
let q = 0, t;
if (1 === e) {
return Za.call(this, a[0], "", b, g, h, k, l);
return bb.call(this, a[0], "", b, g, h, k, l);
}
if (2 === e && p && !f) {
return Za.call(this, a[0], a[1], b, g, h, k, l);
return bb.call(this, a[0], a[1], b, g, h, k, l);
}
1 < e && (p ? (t = a[0], q = 1) : 9 < c && 3 < c / n && a.sort(aa));
if (this.db) {
@@ -1896,7 +1930,7 @@ L.prototype.search = function(a, b, c) {
return async function() {
for (let u, x; q < e; q++) {
x = a[q];
t ? (u = await Y(r, x, t, 0, 0, !1, !1), u = $a(u, d, f, r.R), f && !1 === u && d.length || (t = x)) : (u = await Y(r, x, "", 0, 0, !1, !1), u = $a(u, d, f, r.resolution));
t ? (u = await Y(r, x, t, 0, 0, !1, !1), u = cb(u, d, f, r.R), f && !1 === u && d.length || (t = x)) : (u = await Y(r, x, "", 0, 0, !1, !1), u = cb(u, d, f, r.resolution));
if (u) {
return u;
}
@@ -1915,12 +1949,12 @@ L.prototype.search = function(a, b, c) {
}
}
}
return h ? xa(d, r.resolution, b, g, f, m, h) : new X(d[0]);
return h ? Aa(d, r.resolution, b, g, f, m, h) : new X(d[0]);
}();
}
for (let r, u; q < e; q++) {
u = a[q];
t ? (r = Y(this, u, t, 0, 0, !1, !1), r = $a(r, d, f, this.R), f && !1 === r && d.length || (t = u)) : (r = Y(this, u, "", 0, 0, !1, !1), r = $a(r, d, f, this.resolution));
t ? (r = Y(this, u, t, 0, 0, !1, !1), r = cb(r, d, f, this.R), f && !1 === r && d.length || (t = u)) : (r = Y(this, u, "", 0, 0, !1, !1), r = cb(r, d, f, this.resolution));
if (r) {
return r;
}
@@ -1939,16 +1973,16 @@ L.prototype.search = function(a, b, c) {
}
}
}
d = xa(d, this.resolution, b, g, f, m, h);
d = Aa(d, this.resolution, b, g, f, m, h);
return h ? d : new X(d);
};
function Za(a, b, c, d, e, f, g) {
function bb(a, b, c, d, e, f, g) {
a = Y(this, a, b, c, d, e, f, g);
return this.db ? a.then(function(h) {
return e ? h : h && h.length ? e ? W(h, c, d) : new X(h) : e ? [] : new X([]);
}) : a && a.length ? e ? W(a, c, d) : new X(a) : e ? [] : new X([]);
}
function $a(a, b, c, d) {
function cb(a, b, c, d) {
let e = [];
if (a) {
d = Math.min(a.length, d);
@@ -1986,15 +2020,15 @@ function Y(a, b, c, d, e, f, g, h) {
}
}
} else {
ab(this.map, a), this.depth && ab(this.ctx, a);
db(this.map, a), this.depth && db(this.ctx, a);
}
b || this.reg.delete(a);
}
this.db && (this.commit_task.push({del:a}), this.T && Sa(this));
this.db && (this.commit_task.push({del:a}), this.T && Va(this));
this.cache && this.cache.remove(a);
return this;
};
function ab(a, b) {
function db(a, b) {
let c = 0;
if (a.constructor === Array) {
for (let d = 0, e, f; d < a.length; d++) {
@@ -2009,24 +2043,24 @@ function ab(a, b) {
}
} else {
for (let d of a) {
const e = d[0], f = ab(d[1], b);
const e = d[0], f = db(d[1], b);
f ? c += f : a.delete(e);
}
}
return c;
}
;function L(a, b) {
if (this.constructor !== L) {
if (!this || this.constructor !== L) {
return new L(a);
}
if (a) {
var c = G(a) ? a : a.preset;
c && (Qa[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Qa[c], a));
c && (Ta[c] || console.warn("Preset not found: " + c), a = Object.assign({}, Ta[c], a));
} else {
a = {};
}
c = a.context || {};
const d = G(a.encoder) ? Pa[a.encoder] : a.encode || a.encoder || Ha;
const d = G(a.encoder) ? Sa[a.encoder] : a.encode || a.encoder || Ka;
this.encoder = d.encode ? d : "object" === typeof d ? new K(d) : {encode:d};
let e;
this.resolution = a.resolution || 9;
@@ -2063,7 +2097,7 @@ v.destroy = function() {
this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null);
return this.db.destroy();
};
function Sa(a) {
function Va(a) {
a.commit_timer || (a.commit_timer = setTimeout(function() {
a.commit_timer = null;
a.db.commit(a, void 0, void 0);
@@ -2087,7 +2121,7 @@ v.update = function(a, b) {
const c = this, d = this.remove(a);
return d && d.then ? d.then(() => c.add(a, b)) : this.add(a, b);
};
function bb(a) {
function eb(a) {
let b = 0;
if (a.constructor === Array) {
for (let c = 0, d; c < a.length; c++) {
@@ -2095,7 +2129,7 @@ function bb(a) {
}
} else {
for (const c of a) {
const d = c[0], e = bb(c[1]);
const d = c[0], e = eb(c[1]);
e ? b += e : a.delete(d);
}
}
@@ -2105,17 +2139,17 @@ v.cleanup = function() {
if (!this.fastupdate) {
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
}
bb(this.map);
this.depth && bb(this.ctx);
eb(this.map);
this.depth && eb(this.ctx);
return this;
};
v.searchCache = Ga;
v.searchCache = Ja;
v.export = function(a, b, c, d = 0) {
let e, f;
switch(d) {
case 0:
e = "reg";
f = qa(this.reg);
f = sa(this.reg);
break;
case 1:
e = "cfg";
@@ -2123,29 +2157,29 @@ v.export = function(a, b, c, d = 0) {
break;
case 2:
e = "map";
f = oa(this.map);
f = oa(this.map, this.reg.size);
break;
case 3:
e = "ctx";
f = pa(this.ctx);
f = qa(this.ctx, this.reg.size);
break;
default:
return;
}
return ra.call(this, a, b, e, c, d, f);
return ua.call(this, a, b, e, f, c, d);
};
v.import = function(a, b) {
if (b) {
switch(G(b) && (b = JSON.parse(b)), a) {
switch(G(b) && (b = JSON.parse(b)), a = a.split("."), "json" === a[a.length - 1] && a.pop(), a = 1 < a.length ? a[1] : a[0], a) {
case "reg":
this.fastupdate = !1;
this.reg = new Set(b);
this.reg = ta(b, this.reg);
break;
case "map":
this.map = new Map(b);
this.map = pa(b, this.map);
break;
case "ctx":
this.ctx = new Map(b);
this.ctx = ra(b, this.ctx);
}
}
};
@@ -2200,10 +2234,10 @@ v.serialize = function(a = !0) {
return a ? "function inject(index){" + b + d + e + "}" : b + d + e;
};
na(L.prototype);
const db = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), eb = ["map", "ctx", "tag", "reg", "cfg"];
function fb(a, b = {}) {
const gb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), hb = ["map", "ctx", "tag", "reg", "cfg"];
function ib(a, b = {}) {
if (!this) {
return new fb(a, b);
return new ib(a, b);
}
"object" === typeof a && (b = a = a.name);
a || console.info("Default storage space was used, because a name was not passed.");
@@ -2213,7 +2247,7 @@ function fb(a, b = {}) {
this.db = null;
this.h = {};
}
v = fb.prototype;
v = ib.prototype;
v.mount = function(a) {
if (!a.encoder) {
return a.mount(this);
@@ -2225,10 +2259,10 @@ v.open = function() {
let a = this;
navigator.storage && navigator.storage.persist();
return this.db || new Promise(function(b, c) {
const d = db.open(a.id + (a.field ? ":" + a.field : ""), 1);
const d = gb.open(a.id + (a.field ? ":" + a.field : ""), 1);
d.onupgradeneeded = function() {
const e = a.db = this.result;
eb.forEach(f => {
hb.forEach(f => {
e.objectStoreNames.contains(f) || e.createObjectStore(f);
});
};
@@ -2254,12 +2288,12 @@ v.close = function() {
this.db = null;
};
v.destroy = function() {
return db.deleteDatabase(this.id + (this.field ? ":" + this.field : ""));
return gb.deleteDatabase(this.id + (this.field ? ":" + this.field : ""));
};
v.clear = function() {
const a = this.db.transaction(eb, "readwrite");
for (let b = 0; b < eb.length; b++) {
a.objectStore(eb[b]).clear();
const a = this.db.transaction(hb, "readwrite");
for (let b = 0; b < hb.length; b++) {
a.objectStore(hb[b]).clear();
}
return Z(a);
};
@@ -2443,7 +2477,7 @@ v.commit = async function(a, b, c) {
}
}), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear());
};
function gb(a, b, c) {
function jb(a, b, c) {
const d = a.value;
let e, f, g = 0;
for (let h = 0, k; h < d.length; h++) {
@@ -2472,17 +2506,17 @@ v.remove = function(a) {
return Promise.all([this.transaction("map", "readwrite", function(b) {
b.openCursor().onsuccess = function() {
const c = this.result;
c && gb(c, a);
c && jb(c, a);
};
}), this.transaction("ctx", "readwrite", function(b) {
b.openCursor().onsuccess = function() {
const c = this.result;
c && gb(c, a);
c && jb(c, a);
};
}), this.transaction("tag", "readwrite", function(b) {
b.openCursor().onsuccess = function() {
const c = this.result;
c && gb(c, a, !0);
c && jb(c, a, !0);
};
}), this.transaction("reg", "readwrite", function(b) {
for (let c = 0; c < a.length; c++) {
@@ -2502,6 +2536,6 @@ function Z(a) {
a = null;
});
}
;export default {Index:L, Charset:Pa, Encoder:K, Document:T, Worker:N, Resolver:X, IndexedDB:fb, Language:{}};
;export default {Index:L, Charset:Sa, Encoder:K, Document:T, Worker:N, Resolver:X, IndexedDB:ib, Language:{}};
export const Index=L;export const Charset=Pa;export const Encoder=K;export const Document=T;export const Worker=N;export const Resolver=X;export const IndexedDB=fb;export const Language={};
export const Index=L;export const Charset=Sa;export const Encoder=K;export const Document=T;export const Worker=N;export const Resolver=X;export const IndexedDB=ib;export const Language={};