mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-25 04:51:29 +02:00
proper limit/offset for suggestions
This commit is contained in:
362
dist/flexsearch.light.module.debug.js
vendored
362
dist/flexsearch.light.module.debug.js
vendored
@@ -8,27 +8,27 @@
|
||||
function t() {
|
||||
return Object.create(null);
|
||||
}
|
||||
function u(a, b) {
|
||||
return b.length - a.length;
|
||||
function u(a, c) {
|
||||
return c.length - a.length;
|
||||
}
|
||||
;function v(a) {
|
||||
this.limit = a && !0 !== a ? a : 1000;
|
||||
this.cache = new Map();
|
||||
this.B = "";
|
||||
}
|
||||
v.prototype.set = function(a, b) {
|
||||
this.cache.set(this.B = a, b);
|
||||
v.prototype.set = function(a, c) {
|
||||
this.cache.set(this.B = a, c);
|
||||
this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value);
|
||||
};
|
||||
v.prototype.get = function(a) {
|
||||
const b = this.cache.get(a);
|
||||
b && this.B !== a && (this.cache.delete(a), this.cache.set(this.B = a, b));
|
||||
return b;
|
||||
const c = this.cache.get(a);
|
||||
c && this.B !== a && (this.cache.delete(a), this.cache.set(this.B = a, c));
|
||||
return c;
|
||||
};
|
||||
v.prototype.remove = function(a) {
|
||||
for (const b of this.cache) {
|
||||
const c = b[0];
|
||||
b[1].includes(a) && this.cache.delete(c);
|
||||
for (const c of this.cache) {
|
||||
const b = c[0];
|
||||
c[1].includes(a) && this.cache.delete(b);
|
||||
}
|
||||
};
|
||||
v.prototype.clear = function() {
|
||||
@@ -44,12 +44,12 @@ const D = /[\x00-\x7F]+/g;
|
||||
var E = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:{normalize:function(a) {
|
||||
return a.toLowerCase();
|
||||
}, dedupe:!1}, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:w}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:w, replacer:z, matcher:x}, LatinExtra:{normalize:!0, dedupe:!0, mapper:w, replacer:z.concat([/(?!^)[aeoy]/g, ""]), matcher:x}, 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 = A[d];
|
||||
for (let f = 1, g; f < b.length && (g = b.charAt(f), "h" === g || "w" === g || !(g = A[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) {
|
||||
for (let b = 0; b < a.length; b++) {
|
||||
var c = a[b];
|
||||
let d = c.charAt(0), e = A[d];
|
||||
for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = A[g]) || g === e || (d += g, e = g, 4 !== d.length)); f++) {
|
||||
}
|
||||
a[c] = d;
|
||||
a[b] = d;
|
||||
}
|
||||
}}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) {
|
||||
return ("" + a).replace(B, " ");
|
||||
@@ -60,32 +60,32 @@ var E = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:{normalize:function(
|
||||
}}};
|
||||
const F = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
|
||||
function G(a) {
|
||||
const b = "string" === typeof a ? a : a.preset;
|
||||
b && (F[b] || console.warn("Preset not found: " + b), a = Object.assign({}, F[b], a));
|
||||
const c = "string" === typeof a ? a : a.preset;
|
||||
c && (F[c] || console.warn("Preset not found: " + c), a = Object.assign({}, F[c], a));
|
||||
return a;
|
||||
}
|
||||
;t();
|
||||
H.prototype.add = function(a, b, c, d) {
|
||||
if (b && (a || 0 === a)) {
|
||||
if (!d && !c && this.h.has(a)) {
|
||||
return this.update(a, b);
|
||||
H.prototype.add = function(a, c, b, d) {
|
||||
if (c && (a || 0 === a)) {
|
||||
if (!d && !b && this.h.has(a)) {
|
||||
return this.update(a, c);
|
||||
}
|
||||
b = this.encoder.encode(b);
|
||||
if (d = b.length) {
|
||||
const q = t(), n = t(), p = this.depth, r = this.resolution;
|
||||
for (let k = 0; k < d; k++) {
|
||||
let m = b[this.rtl ? d - 1 - k : k];
|
||||
var e = m.length;
|
||||
if (e && (p || !n[m])) {
|
||||
var f = this.score ? this.score(b, m, k, null, 0) : I(r, d, k), g = "";
|
||||
c = this.encoder.encode(c);
|
||||
if (d = c.length) {
|
||||
const p = t(), m = t(), q = 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 && (q || !m[n])) {
|
||||
var f = this.score ? this.score(c, n, l, null, 0) : I(r, d, l), g = "";
|
||||
switch(this.tokenize) {
|
||||
case "full":
|
||||
if (2 < e) {
|
||||
for (f = 0; f < e; f++) {
|
||||
for (var h = e; h > f; h--) {
|
||||
g = m.substring(f, h);
|
||||
var l = this.score ? this.score(b, m, k, g, f) : I(r, d, k, e, f);
|
||||
K(this, n, g, l, a, c);
|
||||
g = n.substring(f, h);
|
||||
var k = this.score ? this.score(c, n, l, g, f) : I(r, d, l, e, f);
|
||||
K(this, m, g, k, a, b);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -93,24 +93,24 @@ H.prototype.add = function(a, b, c, d) {
|
||||
case "reverse":
|
||||
if (1 < e) {
|
||||
for (h = e - 1; 0 < h; h--) {
|
||||
g = m[h] + g, l = this.score ? this.score(b, m, k, g, h) : I(r, d, k, e, h), K(this, n, g, l, a, c);
|
||||
g = n[h] + g, k = this.score ? this.score(c, n, l, g, h) : I(r, d, l, e, h), K(this, m, g, k, a, b);
|
||||
}
|
||||
g = "";
|
||||
}
|
||||
case "forward":
|
||||
if (1 < e) {
|
||||
for (h = 0; h < e; h++) {
|
||||
g += m[h], K(this, n, g, f, a, c);
|
||||
g += n[h], K(this, m, g, f, a, b);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (K(this, n, m, f, a, c), p && 1 < d && k < d - 1) {
|
||||
for (e = t(), g = this.C, f = m, h = Math.min(p + 1, d - k), e[f] = 1, l = 1; l < h; l++) {
|
||||
if ((m = b[this.rtl ? d - 1 - k - l : k + l]) && !e[m]) {
|
||||
e[m] = 1;
|
||||
const y = this.score ? this.score(b, f, k, m, l) : I(g + (d / 2 > g ? 0 : 1), d, k, h - 1, l - 1), J = this.bidirectional && m > f;
|
||||
K(this, q, J ? f : m, y, a, c, J ? m : f);
|
||||
if (K(this, m, n, f, a, b), q && 1 < d && l < d - 1) {
|
||||
for (e = t(), g = this.C, f = n, h = Math.min(q + 1, d - l), e[f] = 1, k = 1; k < h; k++) {
|
||||
if ((n = c[this.rtl ? d - 1 - l - k : l + k]) && !e[n]) {
|
||||
e[n] = 1;
|
||||
const y = this.score ? this.score(c, f, l, n, k) : I(g + (d / 2 > g ? 0 : 1), d, l, h - 1, k - 1), J = this.bidirectional && n > f;
|
||||
K(this, p, J ? f : n, y, a, b, J ? n : f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,202 +122,186 @@ H.prototype.add = function(a, b, c, d) {
|
||||
}
|
||||
return this;
|
||||
};
|
||||
function K(a, b, c, d, e, f, g) {
|
||||
let h = g ? a.A : a.map, l;
|
||||
b[c] && g && (l = b[c])[g] || (g ? (b = l || (b[c] = t()), b[g] = 1, (l = h.get(g)) ? h = l : h.set(g, h = new Map())) : b[c] = 1, (l = h.get(c)) ? h = l : h.set(c, h = []), h = h[d] || (h[d] = []), f && h.includes(e) || (h.push(e), a.fastupdate && ((b = a.h.get(e)) ? b.push(h) : a.h.set(e, [h]))));
|
||||
function K(a, c, b, d, e, f, g) {
|
||||
let h = g ? a.A : a.map, k;
|
||||
c[b] && g && (k = c[b])[g] || (g ? (c = k || (c[b] = t()), 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[d] || (h[d] = []), f && h.includes(e) || (h.push(e), a.fastupdate && ((c = a.h.get(e)) ? c.push(h) : a.h.set(e, [h]))));
|
||||
}
|
||||
function I(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 I(a, c, b, d, e) {
|
||||
return b && 1 < a ? c + (d || 0) <= a ? b + (e || 0) : (a - 1) / (c + (d || 0)) * (b + (e || 0)) + 1 | 0 : 0;
|
||||
}
|
||||
;function L(a, b, c) {
|
||||
;function L(a, c, b) {
|
||||
if (1 === a.length) {
|
||||
return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a;
|
||||
return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a;
|
||||
}
|
||||
let d = [];
|
||||
for (let e = 0, f, g; e < a.length; e++) {
|
||||
if ((f = a[e]) && (g = f.length)) {
|
||||
if (c) {
|
||||
if (c >= g) {
|
||||
c -= g;
|
||||
if (b) {
|
||||
if (b >= g) {
|
||||
b -= g;
|
||||
continue;
|
||||
}
|
||||
c < g && (f = b ? f.slice(c, c + b) : f.slice(c), g = f.length, c = 0);
|
||||
b < g && (f = c ? f.slice(b, b + c) : f.slice(b), g = f.length, b = 0);
|
||||
}
|
||||
if (d.length) {
|
||||
g > b && (f = f.slice(0, b), g = f.length), d.push(f);
|
||||
g > c && (f = f.slice(0, c), g = f.length), d.push(f);
|
||||
} else {
|
||||
if (g >= b) {
|
||||
return g > b && (f = f.slice(0, b)), f;
|
||||
if (g >= c) {
|
||||
return g > c && (f = f.slice(0, c)), f;
|
||||
}
|
||||
d = [f];
|
||||
}
|
||||
b -= g;
|
||||
if (!b) {
|
||||
c -= g;
|
||||
if (!c) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return d.length ? d = 1 < d.length ? [].concat.apply([], d) : d[0] : d;
|
||||
}
|
||||
;H.prototype.search = function(a, b, c) {
|
||||
c || (b || "object" !== typeof a ? "object" === typeof b && (c = b, b = 0) : (c = a, a = ""));
|
||||
;H.prototype.search = function(a, c, b) {
|
||||
b || (c || "object" !== typeof a ? "object" === typeof c && (b = c, c = 0) : (b = a, a = ""));
|
||||
var d = [], e = 0;
|
||||
if (c) {
|
||||
a = c.query || a;
|
||||
b = c.limit || b;
|
||||
e = c.offset || 0;
|
||||
var f = c.context;
|
||||
if (b) {
|
||||
a = b.query || a;
|
||||
c = b.limit || c;
|
||||
e = b.offset || 0;
|
||||
var f = b.context;
|
||||
var g = !1;
|
||||
}
|
||||
a = this.encoder.encode(a);
|
||||
c = a.length;
|
||||
b || (b = 100);
|
||||
if (1 === c) {
|
||||
return M.call(this, a[0], "", b, e);
|
||||
b = a.length;
|
||||
c || (c = 100);
|
||||
if (1 === b) {
|
||||
return M.call(this, a[0], "", c, e);
|
||||
}
|
||||
f = this.depth && !1 !== f;
|
||||
if (2 === c && f && !g) {
|
||||
return M.call(this, a[0], a[1], b, e);
|
||||
if (2 === b && f && !g) {
|
||||
return M.call(this, a[0], a[1], c, e);
|
||||
}
|
||||
var h = 0, l = 0;
|
||||
if (1 < c) {
|
||||
var q = t();
|
||||
const p = [];
|
||||
for (let r = 0, k; r < c; r++) {
|
||||
if ((k = a[r]) && !q[k]) {
|
||||
if (g || N(this, k)) {
|
||||
p.push(k), q[k] = 1;
|
||||
var h = 0, k = 0;
|
||||
if (1 < b) {
|
||||
var p = t();
|
||||
const q = [];
|
||||
for (let r = 0, l; r < b; r++) {
|
||||
if ((l = a[r]) && !p[l]) {
|
||||
if (g || N(this, l)) {
|
||||
q.push(l), p[l] = 1;
|
||||
} else {
|
||||
return d;
|
||||
}
|
||||
const m = k.length;
|
||||
h = Math.max(h, m);
|
||||
l = l ? Math.min(l, m) : m;
|
||||
const n = l.length;
|
||||
h = Math.max(h, n);
|
||||
k = k ? Math.min(k, n) : n;
|
||||
}
|
||||
}
|
||||
a = p;
|
||||
c = a.length;
|
||||
a = q;
|
||||
b = a.length;
|
||||
}
|
||||
if (!c) {
|
||||
if (!b) {
|
||||
return d;
|
||||
}
|
||||
q = 0;
|
||||
if (1 === c) {
|
||||
return M.call(this, a[0], "", b, e);
|
||||
p = 0;
|
||||
if (1 === b) {
|
||||
return M.call(this, a[0], "", c, e);
|
||||
}
|
||||
if (2 === c && f && !g) {
|
||||
return M.call(this, a[0], a[1], b, e);
|
||||
if (2 === b && f && !g) {
|
||||
return M.call(this, a[0], a[1], c, e);
|
||||
}
|
||||
if (1 < c) {
|
||||
if (1 < b) {
|
||||
if (f) {
|
||||
var n = a[0];
|
||||
q = 1;
|
||||
var m = a[0];
|
||||
p = 1;
|
||||
} else {
|
||||
9 < h && 3 < h / l && a.sort(u);
|
||||
9 < h && 3 < h / k && a.sort(u);
|
||||
}
|
||||
}
|
||||
for (let p, r; q < c; q++) {
|
||||
r = a[q];
|
||||
n ? (p = N(this, r, n), p = O(p, d, g, this.C, b, e, 2 === c), g && !1 === p && d.length || (n = r)) : (p = N(this, r), p = O(p, d, g, this.resolution, b, e, 1 === c));
|
||||
if (p) {
|
||||
return p;
|
||||
for (let q, r; p < b; p++) {
|
||||
r = a[p];
|
||||
m ? (q = N(this, r, m), q = O(q, d, g, this.C, c, e, 2 === b), g && !1 === q && d.length || (m = r)) : (q = N(this, r), q = O(q, d, g, this.resolution, c, e, 1 === b));
|
||||
if (q) {
|
||||
return q;
|
||||
}
|
||||
if (g && q === c - 1) {
|
||||
if (g && p === b - 1) {
|
||||
f = d.length;
|
||||
if (!f) {
|
||||
if (n) {
|
||||
n = "";
|
||||
q = -1;
|
||||
if (m) {
|
||||
m = "";
|
||||
p = -1;
|
||||
continue;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
if (1 === f) {
|
||||
return L(d[0], b, e);
|
||||
return L(d[0], c, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
a: {
|
||||
a = d;
|
||||
d = this.resolution;
|
||||
n = g;
|
||||
c = a.length;
|
||||
g = [];
|
||||
m = a.length;
|
||||
b = [];
|
||||
f = t();
|
||||
for (let p = 0, r, k, m, y; p < d; p++) {
|
||||
for (l = 0; l < c; l++) {
|
||||
if (m = a[l], p < m.length && (r = m[p])) {
|
||||
for (q = 0; q < r.length; q++) {
|
||||
k = r[q], (h = f[k]) ? f[k]++ : (h = 0, f[k] = 1), y = g[h] || (g[h] = []), y.push(k);
|
||||
for (let q = 0, r, l, n, y; q < d; q++) {
|
||||
for (k = 0; k < m; k++) {
|
||||
if (n = a[k], q < n.length && (r = n[q])) {
|
||||
for (p = 0; p < r.length; p++) {
|
||||
l = r[p], (h = f[l]) ? f[l]++ : (h = 0, f[l] = 1), y = b[h] || (b[h] = []), y.push(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a = g.length) {
|
||||
if (n) {
|
||||
d = [];
|
||||
for (let p = a - 1, r = 0, k, m; 0 <= p; p--) {
|
||||
if (k = g[p], m = k.length, e >= m) {
|
||||
e -= m;
|
||||
} else {
|
||||
if (m + r > b || e) {
|
||||
k = k.slice(e, b - r + e), m = k.length;
|
||||
}
|
||||
d.push(k);
|
||||
r += m;
|
||||
if (b === r) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (1 < d.length) {
|
||||
g = d;
|
||||
if (a = b.length) {
|
||||
if (g) {
|
||||
if (1 < b.length) {
|
||||
g = b;
|
||||
a = [];
|
||||
d = t();
|
||||
f = g.length;
|
||||
for (l = 0; l < f; l++) {
|
||||
for (n = g[l], h = n.length, q = 0; q < h; q++) {
|
||||
if (c = n[q], !d[c]) {
|
||||
if (d[c] = 1, e) {
|
||||
for (k = 0; k < f; k++) {
|
||||
for (m = g[k], h = m.length, p = 0; p < h; p++) {
|
||||
if (b = m[p], !d[b]) {
|
||||
if (d[b] = 1, e) {
|
||||
e--;
|
||||
} else {
|
||||
if (a.push(c), a.length === b) {
|
||||
if (a.push(b), a.length === c) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
b = a;
|
||||
c = a;
|
||||
} else {
|
||||
b = d[0];
|
||||
c = b[0];
|
||||
}
|
||||
g = b;
|
||||
b = c;
|
||||
} else {
|
||||
if (a < c) {
|
||||
if (a < m) {
|
||||
d = [];
|
||||
break a;
|
||||
}
|
||||
g = g[a - 1];
|
||||
if (g.length > b || e) {
|
||||
g = g.slice(e, b + e);
|
||||
b = b[a - 1];
|
||||
if (b.length > c || e) {
|
||||
b = b.slice(e, c + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
d = g;
|
||||
d = b;
|
||||
}
|
||||
return d;
|
||||
};
|
||||
function M(a, b, c, d) {
|
||||
return (a = N(this, a, b)) && a.length ? L(a, c, d) : [];
|
||||
function M(a, c, b, d) {
|
||||
return (a = N(this, a, c)) && a.length ? L(a, b, d) : [];
|
||||
}
|
||||
function O(a, b, c, d, e, f, g) {
|
||||
function O(a, c, b, d, e, f, g) {
|
||||
let h = [];
|
||||
if (a) {
|
||||
d = Math.min(a.length, d);
|
||||
for (let l = 0, q = 0, n; l < d; l++) {
|
||||
if (n = a[l]) {
|
||||
if (f && n && g && (n.length <= f ? (f -= n.length, n = null) : (n = n.slice(f), f = 0)), n && (h[l] = n, g && (q += n.length, q >= e))) {
|
||||
for (let k = 0, p = 0, m; k < d; k++) {
|
||||
if (m = a[k]) {
|
||||
if (f && m && g && (m.length <= f ? (f -= m.length, m = null) : (m = m.slice(f), f = 0)), m && (h[k] = m, g && (p += m.length, p >= e))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -326,82 +310,82 @@ function O(a, b, c, d, e, f, g) {
|
||||
if (g) {
|
||||
return L(h, e, 0);
|
||||
}
|
||||
b.push(h);
|
||||
c.push(h);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return !c && h;
|
||||
return !b && h;
|
||||
}
|
||||
function N(a, b, c) {
|
||||
function N(a, c, b) {
|
||||
let d;
|
||||
c && (d = a.bidirectional && b > c);
|
||||
a = c ? (a = a.A.get(d ? b : c)) && a.get(d ? c : b) : a.map.get(b);
|
||||
b && (d = a.bidirectional && c > b);
|
||||
a = b ? (a = a.A.get(d ? c : b)) && a.get(d ? b : c) : a.map.get(c);
|
||||
return a;
|
||||
}
|
||||
;H.prototype.remove = function(a, b) {
|
||||
const c = this.h.size && (this.fastupdate ? this.h.get(a) : this.h.has(a));
|
||||
if (c) {
|
||||
;H.prototype.remove = function(a, c) {
|
||||
const b = this.h.size && (this.fastupdate ? this.h.get(a) : this.h.has(a));
|
||||
if (b) {
|
||||
if (this.fastupdate) {
|
||||
for (let d = 0, e; d < c.length; d++) {
|
||||
if (e = c[d]) {
|
||||
for (let d = 0, e; d < b.length; d++) {
|
||||
if (e = b[d]) {
|
||||
if (2 > e.length) {
|
||||
e.pop();
|
||||
} else {
|
||||
const f = e.indexOf(a);
|
||||
f === c.length - 1 ? e.pop() : e.splice(f, 1);
|
||||
f === b.length - 1 ? e.pop() : e.splice(f, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
P(this.map, a), this.depth && P(this.A, a);
|
||||
}
|
||||
b || this.h.delete(a);
|
||||
c || this.h.delete(a);
|
||||
}
|
||||
this.cache && this.cache.remove(a);
|
||||
return this;
|
||||
};
|
||||
function P(a, b) {
|
||||
let c = 0;
|
||||
function P(a, c) {
|
||||
let b = 0;
|
||||
if (a.constructor === Array) {
|
||||
for (let d = 0, e, f; d < a.length; d++) {
|
||||
if ((e = a[d]) && e.length) {
|
||||
if (f = e.indexOf(b), 0 <= f) {
|
||||
1 < e.length ? (e.splice(f, 1), c++) : delete a[d];
|
||||
if (f = e.indexOf(c), 0 <= f) {
|
||||
1 < e.length ? (e.splice(f, 1), b++) : delete a[d];
|
||||
break;
|
||||
} else {
|
||||
c++;
|
||||
b++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let d of a) {
|
||||
const e = d[0], f = P(d[1], b);
|
||||
f ? c += f : a.delete(e);
|
||||
const e = d[0], f = P(d[1], c);
|
||||
f ? b += f : a.delete(e);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
return b;
|
||||
}
|
||||
;function H(a, b) {
|
||||
;function H(a, c) {
|
||||
if (!this) {
|
||||
return new H(a);
|
||||
}
|
||||
a = a ? G(a) : {};
|
||||
const c = a.context || {}, d = a.encode || a.encoder || function(f) {
|
||||
const b = a.context || {}, d = a.encode || a.encoder || function(f) {
|
||||
return f.toLowerCase().trim().split(/\s+/);
|
||||
};
|
||||
this.encoder = d.encode ? d : "object" === typeof d ? d : {encode:d};
|
||||
let e;
|
||||
this.resolution = a.resolution || 9;
|
||||
this.tokenize = e = a.tokenize || "strict";
|
||||
this.depth = "strict" === e && c.depth || 0;
|
||||
this.bidirectional = !1 !== c.bidirectional;
|
||||
this.depth = "strict" === e && b.depth || 0;
|
||||
this.bidirectional = !1 !== b.bidirectional;
|
||||
this.fastupdate = !!a.fastupdate;
|
||||
this.score = a.score || null;
|
||||
e = !1;
|
||||
this.map = new Map();
|
||||
this.A = new Map();
|
||||
this.h = b || (this.fastupdate ? new Map() : new Set());
|
||||
this.C = c.resolution || 1;
|
||||
this.h = c || (this.fastupdate ? new Map() : new Set());
|
||||
this.C = b.resolution || 1;
|
||||
this.rtl = d.rtl || a.rtl || !1;
|
||||
this.cache = (e = a.cache || null) && new v(e);
|
||||
}
|
||||
@@ -412,32 +396,32 @@ H.prototype.clear = function() {
|
||||
this.cache && this.cache.clear();
|
||||
return this;
|
||||
};
|
||||
H.prototype.append = function(a, b) {
|
||||
return this.add(a, b, !0);
|
||||
H.prototype.append = function(a, c) {
|
||||
return this.add(a, c, !0);
|
||||
};
|
||||
H.prototype.contain = function(a) {
|
||||
return this.h.has(a);
|
||||
};
|
||||
H.prototype.update = function(a, b) {
|
||||
H.prototype.update = function(a, c) {
|
||||
if (this.async) {
|
||||
const c = this, d = this.remove(a);
|
||||
return d.then ? d.then(() => c.add(a, b)) : this.add(a, b);
|
||||
const b = this, d = this.remove(a);
|
||||
return d.then ? d.then(() => b.add(a, c)) : this.add(a, c);
|
||||
}
|
||||
return this.remove(a).add(a, b);
|
||||
return this.remove(a).add(a, c);
|
||||
};
|
||||
function Q(a) {
|
||||
let b = 0;
|
||||
let c = 0;
|
||||
if (a.constructor === Array) {
|
||||
for (let c = 0, d; c < a.length; c++) {
|
||||
(d = a[c]) && (b += d.length);
|
||||
for (let b = 0, d; b < a.length; b++) {
|
||||
(d = a[b]) && (c += d.length);
|
||||
}
|
||||
} else {
|
||||
for (const c of a) {
|
||||
const d = c[0], e = Q(c[1]);
|
||||
e ? b += e : a.delete(d);
|
||||
for (const b of a) {
|
||||
const d = b[0], e = Q(b[1]);
|
||||
e ? c += e : a.delete(d);
|
||||
}
|
||||
}
|
||||
return b;
|
||||
return c;
|
||||
}
|
||||
H.prototype.cleanup = function() {
|
||||
if (!this.fastupdate) {
|
||||
@@ -447,11 +431,11 @@ H.prototype.cleanup = function() {
|
||||
this.depth && Q(this.A);
|
||||
return this;
|
||||
};
|
||||
H.prototype.searchCache = function(a, b, c) {
|
||||
H.prototype.searchCache = function(a, c, b) {
|
||||
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
|
||||
let d = this.cache.get(a);
|
||||
if (!d) {
|
||||
d = this.search(a, b, c);
|
||||
d = this.search(a, c, b);
|
||||
if (d.then) {
|
||||
const e = this;
|
||||
d.then(function(f) {
|
||||
|
Reference in New Issue
Block a user