mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-20 02:41:25 +02:00
type definitions v0.8
This commit is contained in:
375
dist/flexsearch.light.module.debug.js
vendored
375
dist/flexsearch.light.module.debug.js
vendored
@@ -5,7 +5,8 @@
|
||||
* Hosted by Nextapps GmbH
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
function t(a, c, b) {
|
||||
var r;
|
||||
function u(a, c, b) {
|
||||
const d = typeof b, e = typeof a;
|
||||
if ("undefined" !== d) {
|
||||
if ("undefined" !== e) {
|
||||
@@ -42,23 +43,24 @@ function t(a, c, b) {
|
||||
}
|
||||
return "undefined" === e ? c : a;
|
||||
}
|
||||
function u() {
|
||||
function x() {
|
||||
return Object.create(null);
|
||||
}
|
||||
function v(a, c) {
|
||||
function y(a, c) {
|
||||
return c.length - a.length;
|
||||
}
|
||||
;const w = /[^\p{L}\p{N}]+/u, x = /(\d{3})/g, y = /(\D)(\d{3})/g, z = /(\d{3})(\D)/g, B = "".normalize && /[\u0300-\u036f]/g;
|
||||
function C(a) {
|
||||
if (!this || this.constructor !== C) {
|
||||
return new C(...arguments);
|
||||
;const z = /[^\p{L}\p{N}]+/u, A = /(\d{3})/g, B = /(\D)(\d{3})/g, C = /(\d{3})(\D)/g, D = "".normalize && /[\u0300-\u036f]/g;
|
||||
function E(a) {
|
||||
if (!this || this.constructor !== E) {
|
||||
return new E(...arguments);
|
||||
}
|
||||
for (let c = 0; c < arguments.length; c++) {
|
||||
this.assign(arguments[c]);
|
||||
}
|
||||
}
|
||||
C.prototype.assign = function(a) {
|
||||
this.normalize = t(a.normalize, !0, this.normalize);
|
||||
r = E.prototype;
|
||||
r.assign = function(a) {
|
||||
this.normalize = u(a.normalize, !0, this.normalize);
|
||||
let c = a.include, b = c || a.exclude || a.split;
|
||||
if ("object" === typeof b) {
|
||||
let d = !c, e = "";
|
||||
@@ -79,55 +81,106 @@ C.prototype.assign = function(a) {
|
||||
this.numeric = d;
|
||||
} else {
|
||||
try {
|
||||
this.split = t(b, w, this.split);
|
||||
this.split = u(b, z, this.split);
|
||||
} catch (d) {
|
||||
this.split = /\s+/;
|
||||
}
|
||||
this.numeric = t(this.numeric, !0);
|
||||
this.numeric = u(this.numeric, !0);
|
||||
}
|
||||
this.prepare = t(a.prepare, null, this.prepare);
|
||||
this.finalize = t(a.finalize, null, this.finalize);
|
||||
this.prepare = u(a.prepare, null, this.prepare);
|
||||
this.finalize = u(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.dedupe = u(a.dedupe, !0, this.dedupe);
|
||||
this.filter = u((b = a.filter) && new Set(b), null, this.filter);
|
||||
this.matcher = u((b = a.matcher) && new Map(b), null, this.matcher);
|
||||
this.mapper = u((b = a.mapper) && new Map(b), null, this.mapper);
|
||||
this.stemmer = u((b = a.stemmer) && new Map(b), null, this.stemmer);
|
||||
this.replacer = u(a.replacer, null, this.replacer);
|
||||
this.minlength = u(a.minlength, 1, this.minlength);
|
||||
this.maxlength = u(a.maxlength, 0, this.maxlength);
|
||||
if (this.cache = b = u(a.cache, !0, this.cache)) {
|
||||
this.l = null, this.v = "number" === typeof b ? b : 2e5, this.h = new Map(), this.j = new Map(), this.o = this.m = 128;
|
||||
}
|
||||
this.m = "";
|
||||
this.g = "";
|
||||
this.s = null;
|
||||
this.o = "";
|
||||
this.i = "";
|
||||
this.u = null;
|
||||
if (this.matcher) {
|
||||
for (const d of this.matcher.keys()) {
|
||||
this.m += (this.m ? "|" : "") + d;
|
||||
this.g += (this.g ? "|" : "") + d;
|
||||
}
|
||||
}
|
||||
if (this.stemmer) {
|
||||
for (const d of this.stemmer.keys()) {
|
||||
this.o += (this.o ? "|" : "") + d;
|
||||
this.i += (this.i ? "|" : "") + d;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
C.prototype.encode = function(a) {
|
||||
if (this.cache && a.length <= this.g) {
|
||||
if (this.j) {
|
||||
r.addMatcher = function(a, c) {
|
||||
if ("object" === typeof a) {
|
||||
return this.addReplacer(a, c);
|
||||
}
|
||||
if (2 > a.length) {
|
||||
return this.addMapper(a, c);
|
||||
}
|
||||
this.matcher || (this.matcher = new Map());
|
||||
this.matcher.set(a, c);
|
||||
this.g += (this.g ? "|" : "") + a;
|
||||
this.s = null;
|
||||
this.cache && F(this);
|
||||
return this;
|
||||
};
|
||||
r.addStemmer = function(a, c) {
|
||||
this.stemmer || (this.stemmer = new Map());
|
||||
this.stemmer.set(a, c);
|
||||
this.i += (this.i ? "|" : "") + a;
|
||||
this.u = null;
|
||||
this.cache && F(this);
|
||||
return this;
|
||||
};
|
||||
r.addFilter = function(a) {
|
||||
this.filter || (this.filter = new Set());
|
||||
this.filter.add(a);
|
||||
this.cache && F(this);
|
||||
return this;
|
||||
};
|
||||
r.addMapper = function(a, c) {
|
||||
if ("object" === typeof a) {
|
||||
return this.addReplacer(a, c);
|
||||
}
|
||||
if (1 < a.length) {
|
||||
return this.addMatcher(a, c);
|
||||
}
|
||||
this.mapper || (this.mapper = new Map());
|
||||
this.mapper.set(a, c);
|
||||
this.cache && F(this);
|
||||
return this;
|
||||
};
|
||||
r.addReplacer = function(a, c) {
|
||||
"string" === typeof a && (a = new RegExp(a, "g"));
|
||||
this.replacer || (this.replacer = []);
|
||||
this.replacer.push(a, c || "");
|
||||
this.cache && F(this);
|
||||
return this;
|
||||
};
|
||||
function F(a) {
|
||||
a.h.clear();
|
||||
a.j.clear();
|
||||
}
|
||||
r.encode = function(a) {
|
||||
if (this.cache && a.length <= this.m) {
|
||||
if (this.l) {
|
||||
if (this.h.has(a)) {
|
||||
return this.h.get(a);
|
||||
}
|
||||
} else {
|
||||
this.j = setTimeout(D, 50, this);
|
||||
this.l = setTimeout(G, 50, this);
|
||||
}
|
||||
}
|
||||
this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : B ? a.normalize("NFKD").replace(B, "").toLowerCase() : a.toLowerCase());
|
||||
this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : D ? a.normalize("NFKD").replace(D, "").toLowerCase() : a.toLowerCase());
|
||||
this.prepare && (a = this.prepare(a));
|
||||
this.numeric && 3 < a.length && (a = a.replace(y, "$1 $2").replace(z, "$1 $2").replace(x, "$1 "));
|
||||
this.numeric && 3 < a.length && (a = a.replace(B, "$1 $2").replace(C, "$1 $2").replace(A, "$1 "));
|
||||
const c = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer);
|
||||
let b = [], d = this.split || "" === this.split ? a.split(this.split) : a;
|
||||
for (let g = 0, f, h; g < d.length; g++) {
|
||||
@@ -144,95 +197,95 @@ C.prototype.encode = function(a) {
|
||||
if (this.filter && this.filter.has(f)) {
|
||||
continue;
|
||||
}
|
||||
if (this.cache && f.length <= this.l) {
|
||||
if (this.j) {
|
||||
var e = this.i.get(f);
|
||||
if (this.cache && f.length <= this.o) {
|
||||
if (this.l) {
|
||||
var e = this.j.get(f);
|
||||
if (e || "" === e) {
|
||||
e && b.push(e);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
this.j = setTimeout(D, 50, this);
|
||||
this.l = setTimeout(G, 50, this);
|
||||
}
|
||||
}
|
||||
let k;
|
||||
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);
|
||||
this.stemmer && 2 < f.length && (this.u || (this.u = new RegExp("(?!^)(" + this.i + ")$")), f = f.replace(this.u, l => this.stemmer.get(l)), 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 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);
|
||||
for (let l = 0, t = "", q, n; l < f.length; l++) {
|
||||
q = f.charAt(l), q === t && this.dedupe || ((n = this.mapper && this.mapper.get(q)) || "" === n ? n === t && this.dedupe || !(t = n) || (e += n) : e += t = q);
|
||||
}
|
||||
f = e;
|
||||
}
|
||||
this.matcher && 1 < f.length && (this.s || (this.s = new RegExp("(" + this.m + ")", "g")), f = f.replace(this.s, p => this.matcher.get(p)));
|
||||
this.matcher && 1 < f.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), f = f.replace(this.s, l => this.matcher.get(l)));
|
||||
if (f && this.replacer) {
|
||||
for (e = 0; f && e < this.replacer.length; e += 2) {
|
||||
f = f.replace(this.replacer[e], this.replacer[e + 1]);
|
||||
}
|
||||
}
|
||||
this.cache && h.length <= this.l && (this.i.set(h, f), this.i.size > this.v && (this.i.clear(), this.l = this.l / 1.1 | 0));
|
||||
this.cache && h.length <= this.o && (this.j.set(h, f), this.j.size > this.v && (this.j.clear(), this.o = this.o / 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));
|
||||
this.cache && a.length <= this.m && (this.h.set(a, b), this.h.size > this.v && (this.h.clear(), this.m = this.m / 1.1 | 0));
|
||||
return b;
|
||||
};
|
||||
function D(a) {
|
||||
a.j = null;
|
||||
function G(a) {
|
||||
a.l = null;
|
||||
a.h.clear();
|
||||
a.i.clear();
|
||||
a.j.clear();
|
||||
}
|
||||
;function E(a) {
|
||||
;function H(a) {
|
||||
this.limit = a && !0 !== a ? a : 1000;
|
||||
this.cache = new Map();
|
||||
this.g = "";
|
||||
}
|
||||
E.prototype.set = function(a, c) {
|
||||
H.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) {
|
||||
H.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) {
|
||||
H.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() {
|
||||
H.prototype.clear = function() {
|
||||
this.cache.clear();
|
||||
this.g = "";
|
||||
};
|
||||
const F = {normalize:function(a) {
|
||||
const I = {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) {
|
||||
const J = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
|
||||
x();
|
||||
K.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; l < d; l++) {
|
||||
let n = c[this.rtl ? d - 1 - l : l];
|
||||
var e = n.length;
|
||||
if (e && (m || !q[n])) {
|
||||
var g = this.score ? this.score(c, n, l, null, 0) : J(r, d, l), f = "";
|
||||
const l = x(), t = x(), q = this.depth, n = this.resolution;
|
||||
for (let m = 0; m < d; m++) {
|
||||
let p = c[this.rtl ? d - 1 - m : m];
|
||||
var e = p.length;
|
||||
if (e && (q || !t[p])) {
|
||||
var g = this.score ? this.score(c, p, m, null, 0) : L(n, d, m), f = "";
|
||||
switch(this.tokenize) {
|
||||
case "full":
|
||||
if (2 < e) {
|
||||
for (g = 0; g < e; g++) {
|
||||
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, q, f, k, a, b);
|
||||
f = p.substring(g, h);
|
||||
var k = this.score ? this.score(c, p, m, f, g) : L(n, d, m, e, g);
|
||||
M(this, t, f, k, a, b);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -240,24 +293,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, q, f, k, a, b);
|
||||
f = p[h] + f, k = this.score ? this.score(c, p, m, f, h) : L(n, d, m, e, h), M(this, t, f, k, a, b);
|
||||
}
|
||||
f = "";
|
||||
}
|
||||
case "forward":
|
||||
if (1 < e) {
|
||||
for (h = 0; h < e; h++) {
|
||||
f += n[h], K(this, q, f, g, a, b);
|
||||
f += p[h], M(this, t, f, g, a, b);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
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, p, I ? g : n, A, a, b, I ? n : g);
|
||||
if (M(this, t, p, g, a, b), q && 1 < d && m < d - 1) {
|
||||
for (e = x(), f = this.A, g = p, h = Math.min(q + 1, d - m), e[g] = 1, k = 1; k < h; k++) {
|
||||
if ((p = c[this.rtl ? d - 1 - m - k : m + k]) && !e[p]) {
|
||||
e[p] = 1;
|
||||
const v = this.score ? this.score(c, g, m, p, k) : L(f + (d / 2 > f ? 0 : 1), d, m, h - 1, k - 1), w = this.bidirectional && p > g;
|
||||
M(this, l, w ? g : p, v, a, b, w ? p : g);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,16 +322,16 @@ H.prototype.add = function(a, c, b, d) {
|
||||
}
|
||||
return this;
|
||||
};
|
||||
function K(a, c, b, d, e, g, f) {
|
||||
function M(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])));
|
||||
f ? (c = k || (c[b] = x()), 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) {
|
||||
function L(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, c, b) {
|
||||
;function N(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;
|
||||
}
|
||||
@@ -308,7 +361,7 @@ function J(a, c, b, d, e) {
|
||||
}
|
||||
return d.length ? d = 1 < d.length ? [].concat.apply([], d) : d[0] : d;
|
||||
}
|
||||
;H.prototype.search = function(a, c, b) {
|
||||
;K.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 (b) {
|
||||
@@ -317,102 +370,104 @@ function J(a, c, b, d, e) {
|
||||
e = b.offset || 0;
|
||||
var g = b.context;
|
||||
var f = b.suggest;
|
||||
var h = !0;
|
||||
var k = b.resolution;
|
||||
} else {
|
||||
h = !0;
|
||||
}
|
||||
a = this.encoder.encode(a);
|
||||
b = a.length;
|
||||
c || (c = 100);
|
||||
var l = this.encoder.encode(a);
|
||||
b = l.length;
|
||||
c || !h || (c = 100);
|
||||
if (1 === b) {
|
||||
return M.call(this, a[0], "", c, e);
|
||||
return O.call(this, l[0], "", c, e);
|
||||
}
|
||||
g = this.depth && !1 !== g;
|
||||
if (2 === b && g && !f) {
|
||||
return M.call(this, a[0], a[1], c, e);
|
||||
return O.call(this, l[0], l[1], c, e);
|
||||
}
|
||||
var h = 0, k = 0;
|
||||
let t = h = 0;
|
||||
if (1 < b) {
|
||||
var p = u();
|
||||
const m = [];
|
||||
for (let r = 0, l; r < b; r++) {
|
||||
if ((l = a[r]) && !p[l]) {
|
||||
if (f || N(this, l)) {
|
||||
m.push(l), p[l] = 1;
|
||||
const n = x(), m = [];
|
||||
for (let p = 0, v; p < b; p++) {
|
||||
if ((v = l[p]) && !n[v]) {
|
||||
if (f || P(this, v)) {
|
||||
m.push(v), n[v] = 1;
|
||||
} else {
|
||||
return d;
|
||||
}
|
||||
const n = l.length;
|
||||
h = Math.max(h, n);
|
||||
k = k ? Math.min(k, n) : n;
|
||||
const w = v.length;
|
||||
h = Math.max(h, w);
|
||||
t = t ? Math.min(t, w) : w;
|
||||
}
|
||||
}
|
||||
a = m;
|
||||
l = m;
|
||||
b = a.length;
|
||||
}
|
||||
if (!b) {
|
||||
return d;
|
||||
}
|
||||
p = 0;
|
||||
a = 0;
|
||||
if (1 === b) {
|
||||
return M.call(this, a[0], "", c, e);
|
||||
return O.call(this, l[0], "", c, e);
|
||||
}
|
||||
if (2 === b && g && !f) {
|
||||
return M.call(this, a[0], a[1], c, e);
|
||||
return O.call(this, l[0], l[1], c, e);
|
||||
}
|
||||
if (1 < b) {
|
||||
if (g) {
|
||||
var q = a[0];
|
||||
p = 1;
|
||||
var q = l[0];
|
||||
a = 1;
|
||||
} else {
|
||||
9 < h && 3 < h / k && a.sort(v);
|
||||
9 < h && 3 < h / t && l.sort(y);
|
||||
}
|
||||
}
|
||||
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;
|
||||
k || 0 === k || (k = this.resolution);
|
||||
for (let n, m; a < b; a++) {
|
||||
m = l[a];
|
||||
q ? (n = P(this, m, q), n = Q(n, d, f, this.A), f && !1 === n && d.length || (q = m)) : (n = P(this, m, ""), n = Q(n, d, f, k));
|
||||
if (n) {
|
||||
return n;
|
||||
}
|
||||
if (f && p === b - 1) {
|
||||
if (f && a === b - 1) {
|
||||
g = d.length;
|
||||
if (!g) {
|
||||
if (q) {
|
||||
q = "";
|
||||
p = -1;
|
||||
a = -1;
|
||||
continue;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
if (1 === g) {
|
||||
return L(d[0], c, e);
|
||||
return N(d[0], c, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
a: {
|
||||
a = d;
|
||||
d = this.resolution;
|
||||
q = f;
|
||||
b = a.length;
|
||||
b = d.length;
|
||||
f = [];
|
||||
g = u();
|
||||
for (let m = 0, r, l, n, A; m < d; m++) {
|
||||
for (k = 0; k < b; k++) {
|
||||
if (n = a[k], m < n.length && (r = n[m])) {
|
||||
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);
|
||||
g = x();
|
||||
for (let n = 0, m, p, v, w; n < k; n++) {
|
||||
for (a = 0; a < b; a++) {
|
||||
if (v = d[a], n < v.length && (m = v[n])) {
|
||||
for (h = 0; h < m.length; h++) {
|
||||
p = m[h], (l = g[p]) ? g[p]++ : (l = 0, g[p] = 1), w = f[l] || (f[l] = []), w.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a = f.length) {
|
||||
if (k = f.length) {
|
||||
if (q) {
|
||||
if (1 < f.length) {
|
||||
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]) {
|
||||
for (k = [], d = x(), q = f.length, l = q - 1; 0 <= l; l--) {
|
||||
for (q = f[l], g = q.length, a = 0; a < g; a++) {
|
||||
if (b = q[a], !d[b]) {
|
||||
if (d[b] = 1, e) {
|
||||
e--;
|
||||
} else {
|
||||
if (a.push(b), a.length === c) {
|
||||
if (k.push(b), k.length === c) {
|
||||
break b;
|
||||
}
|
||||
}
|
||||
@@ -421,15 +476,15 @@ function J(a, c, b, d, e) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
a = (f = f[0]).length > c || e ? f.slice(e, c + e) : f;
|
||||
k = (f = f[0]).length > c || e ? f.slice(e, c + e) : f;
|
||||
}
|
||||
f = a;
|
||||
f = k;
|
||||
} else {
|
||||
if (a < b) {
|
||||
if (k < b) {
|
||||
d = [];
|
||||
break a;
|
||||
}
|
||||
f = f[a - 1];
|
||||
f = f[k - 1];
|
||||
if (c || e) {
|
||||
if (f.length > c || e) {
|
||||
f = f.slice(e, c + e);
|
||||
@@ -441,10 +496,10 @@ function J(a, c, b, d, e) {
|
||||
}
|
||||
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) {
|
||||
return (a = P(this, a, c)) && a.length ? N(a, b, d) : [];
|
||||
}
|
||||
function Q(a, c, b, d) {
|
||||
let e = [];
|
||||
if (a) {
|
||||
d = Math.min(a.length, d);
|
||||
@@ -458,13 +513,13 @@ function O(a, c, b, d) {
|
||||
}
|
||||
return !b && e;
|
||||
}
|
||||
function N(a, c, b) {
|
||||
function P(a, c, b) {
|
||||
let d;
|
||||
b && (d = a.bidirectional && c > b);
|
||||
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) {
|
||||
;K.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) {
|
||||
@@ -479,14 +534,14 @@ function N(a, c, b) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
P(this.map, a), this.depth && P(this.ctx, a);
|
||||
R(this.map, a), this.depth && R(this.ctx, a);
|
||||
}
|
||||
c || this.reg.delete(a);
|
||||
}
|
||||
this.cache && this.cache.remove(a);
|
||||
return this;
|
||||
};
|
||||
function P(a, c) {
|
||||
function R(a, c) {
|
||||
let b = 0;
|
||||
if (a.constructor === Array) {
|
||||
for (let d = 0, e, g; d < a.length; d++) {
|
||||
@@ -501,58 +556,58 @@ function P(a, c) {
|
||||
}
|
||||
} else {
|
||||
for (let d of a) {
|
||||
const e = d[0], g = P(d[1], c);
|
||||
const e = d[0], g = R(d[1], c);
|
||||
g ? b += g : a.delete(e);
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
;function H(a, c) {
|
||||
if (!this || this.constructor !== H) {
|
||||
return new H(a);
|
||||
;function K(a, c) {
|
||||
if (!this || this.constructor !== K) {
|
||||
return new K(a);
|
||||
}
|
||||
if (a) {
|
||||
var b = "string" === typeof a ? a : a.preset;
|
||||
b && (G[b] || console.warn("Preset not found: " + b), a = Object.assign({}, G[b], a));
|
||||
b && (J[b] || console.warn("Preset not found: " + b), a = Object.assign({}, J[b], a));
|
||||
} else {
|
||||
a = {};
|
||||
}
|
||||
b = a.context || {};
|
||||
const d = a.encode || a.encoder || F;
|
||||
this.encoder = d.encode ? d : "object" === typeof d ? new C(d) : {encode:d};
|
||||
let e;
|
||||
b = a.context;
|
||||
const d = !0 === b ? {depth:1} : b || {}, e = a.encode || a.encoder || I;
|
||||
this.encoder = e.encode ? e : "object" === typeof e ? new E(e) : {encode:e};
|
||||
this.resolution = a.resolution || 9;
|
||||
this.tokenize = e = a.tokenize || "strict";
|
||||
this.depth = "strict" === e && b.depth || 0;
|
||||
this.bidirectional = !1 !== b.bidirectional;
|
||||
this.tokenize = b = a.tokenize || "strict";
|
||||
this.depth = "strict" === b && d.depth || 0;
|
||||
this.bidirectional = !1 !== d.bidirectional;
|
||||
this.fastupdate = !!a.fastupdate;
|
||||
this.score = a.score || null;
|
||||
e = !1;
|
||||
b = !1;
|
||||
this.map = new Map();
|
||||
this.ctx = new Map();
|
||||
this.reg = c || (this.fastupdate ? new Map() : new Set());
|
||||
this.A = b.resolution || 1;
|
||||
this.rtl = d.rtl || a.rtl || !1;
|
||||
this.cache = (e = a.cache || null) && new E(e);
|
||||
this.A = d.resolution || 3;
|
||||
this.rtl = e.rtl || a.rtl || !1;
|
||||
this.cache = (b = a.cache || null) && new H(b);
|
||||
}
|
||||
H.prototype.clear = function() {
|
||||
r = K.prototype;
|
||||
r.clear = function() {
|
||||
this.map.clear();
|
||||
this.ctx.clear();
|
||||
this.reg.clear();
|
||||
this.cache && this.cache.clear();
|
||||
return this;
|
||||
};
|
||||
H.prototype.append = function(a, c) {
|
||||
r.append = function(a, c) {
|
||||
return this.add(a, c, !0);
|
||||
};
|
||||
H.prototype.contain = function(a) {
|
||||
r.contain = function(a) {
|
||||
return this.reg.has(a);
|
||||
};
|
||||
H.prototype.update = function(a, c) {
|
||||
r.update = function(a, c) {
|
||||
const b = this, d = this.remove(a);
|
||||
return d && d.then ? d.then(() => b.add(a, c)) : this.add(a, c);
|
||||
};
|
||||
function Q(a) {
|
||||
function S(a) {
|
||||
let c = 0;
|
||||
if (a.constructor === Array) {
|
||||
for (let b = 0, d; b < a.length; b++) {
|
||||
@@ -560,21 +615,21 @@ function Q(a) {
|
||||
}
|
||||
} else {
|
||||
for (const b of a) {
|
||||
const d = b[0], e = Q(b[1]);
|
||||
const d = b[0], e = S(b[1]);
|
||||
e ? c += e : a.delete(d);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
H.prototype.cleanup = function() {
|
||||
r.cleanup = function() {
|
||||
if (!this.fastupdate) {
|
||||
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
|
||||
}
|
||||
Q(this.map);
|
||||
this.depth && Q(this.ctx);
|
||||
S(this.map);
|
||||
this.depth && S(this.ctx);
|
||||
return this;
|
||||
};
|
||||
H.prototype.searchCache = function(a, c, b) {
|
||||
r.searchCache = function(a, c, b) {
|
||||
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
|
||||
let d = this.cache.get(a);
|
||||
if (!d) {
|
||||
@@ -590,6 +645,6 @@ H.prototype.searchCache = function(a, c, b) {
|
||||
}
|
||||
return d;
|
||||
};
|
||||
export default {Index:H, Charset:null, Encoder:C, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}};
|
||||
export default {Index:K, Charset:null, Encoder:E, Document:null, Worker:null, Resolver:null, IndexedDB:null, Language:{}};
|
||||
|
||||
export const Index=H;export const Charset=null;export const Encoder=C;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={};
|
||||
export const Index=K;export const Charset=null;export const Encoder=E;export const Document=null;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={};
|
Reference in New Issue
Block a user