From 41b55bead66790fc64dd1592e8f873c9d4f86f6b Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Sat, 15 Mar 2025 16:08:56 +0100 Subject: [PATCH] chunked export/import --- README.md | 29 +- dist/db/indexeddb/index.cjs | 343 ++++++++++--------- dist/flexsearch.bundle.debug.js | 374 +++++++++++---------- dist/flexsearch.bundle.min.js | 109 ++++--- dist/flexsearch.bundle.module.debug.js | 368 +++++++++++---------- dist/flexsearch.bundle.module.min.js | 111 ++++--- dist/flexsearch.compact.debug.js | 282 +++++++++------- dist/flexsearch.compact.min.js | 79 ++--- dist/flexsearch.compact.module.debug.js | 310 ++++++++++-------- dist/flexsearch.compact.module.min.js | 81 ++--- dist/flexsearch.es5.debug.js | 416 +++++++++++++----------- dist/flexsearch.es5.min.js | 127 ++++---- dist/flexsearch.light.debug.js | 4 +- dist/flexsearch.light.min.js | 6 +- dist/flexsearch.light.module.debug.js | 4 +- dist/flexsearch.light.module.min.js | 6 +- dist/lang/de.min.js | 74 ++++- dist/lang/en.min.js | 74 ++++- dist/lang/fr.min.js | 74 ++++- dist/module-debug/document.js | 10 +- dist/module-debug/encoder.js | 2 +- dist/module-debug/index.js | 2 +- dist/module-debug/resolver.js | 2 +- dist/module-debug/serialize.js | 307 ++++++++--------- dist/module-debug/worker.js | 2 +- dist/module-min/document.js | 2 +- dist/module-min/encoder.js | 2 +- dist/module-min/index.js | 2 +- dist/module-min/resolver.js | 2 +- dist/module-min/serialize.js | 2 +- dist/module-min/worker.js | 2 +- dist/module/document.js | 10 +- dist/module/encoder.js | 2 +- dist/module/index.js | 2 +- dist/module/resolver.js | 2 +- dist/module/serialize.js | 307 ++++++++--------- dist/module/worker.js | 2 +- src/document.js | 2 +- src/encoder.js | 2 +- src/index.js | 2 +- src/resolver.js | 2 +- src/serialize.js | 339 ++++++++++--------- src/worker.js | 2 +- task/build.js | 11 +- 44 files changed, 2177 insertions(+), 1716 deletions(-) diff --git a/README.md b/README.md index 7f83ea7..71064cd 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ npm install git+https://github.com/nextapps-de/flexsearch/tree/v0.8-preview - Custom Score Function - Added French language preset (stop-word filter, stemmer) - Enhanced Worker Support +- Export / Import index in chunks - Improved Build System + Bundler (Supported: CommonJS, ESM, Global Namespace), also the import of language packs are now supported for Node.js - Full covering index.d.ts type definitions - Fast-Boot Serialization optimized for Server-Side-Rendering (PHP, Python, Ruby, Rust, Java, Go, Node.js, ...) @@ -2273,7 +2274,7 @@ A formula to determine a well-balanced value for the `resolution` is: $2*floor(\ > Persistent-Indexes and Worker-Indexes don't support Import/Export. -Export a simple `Index` to the folder `/export/`: +Export an `Index` or `Document-Index` to the folder `/export/`: ```js import { promises as fs } from "fs"; @@ -2283,7 +2284,7 @@ await index.export(async function(key, data){ }); ``` -Import from folder `/export/` into a simple `Index`: +Import from folder `/export/` into an `Index` or `Document-Index`: ```js const index = new Index({/* keep old config and place it here */}); @@ -2295,29 +2296,7 @@ for(let i = 0; i < files.length; i++){ } ``` -This is very similar for document indexes. - -Export a `Document-Index` to the folder `/export/`: - -```js -import { promises as fs } from "fs"; - -await index.export(async function(key, data){ - await fs.writeFile("./export/" + key, data, "utf8"); -}); -``` - -Import from folder `/export/` into a `Document-Index`: - -```js -const index = new Document({/* keep old config and place it here */}); - -const files = await fs.readdir("./export/"); -for(let i = 0; i < files.length; i++){ - const data = await fs.readFile("./export/" + files[i], "utf8"); - await index.import(files[i], data); -} -``` +> You'll need to use the same configuration as you used before the export. Any changes on the configuration needs to be re-indexed. ## Migration diff --git a/dist/db/indexeddb/index.cjs b/dist/db/indexeddb/index.cjs index fde7f8f..e772dc9 100644 --- a/dist/db/indexeddb/index.cjs +++ b/dist/db/indexeddb/index.cjs @@ -430,7 +430,7 @@ const normalize = "".normalize && /[\u0300-\u036f]/g; // '´`’ʼ., function Encoder(options){ - if(this.constructor !== Encoder){ + if(!this || this.constructor !== Encoder){ return new Encoder(...arguments); } @@ -1009,7 +1009,7 @@ let pid = 0; function WorkerIndex(options = {}){ - if(this.constructor !== WorkerIndex) { + if(!this || this.constructor !== WorkerIndex) { return new WorkerIndex(options); } @@ -1245,80 +1245,172 @@ function register(key){ }; } -function map_to_json(map){ - const json = []; +const chunk_size_reg = 250000; +const chunk_size_map = 5000; +const chunk_size_ctx = 1000; + +function map_to_json(map, size = 0){ + let chunk = []; + let json = []; + if(size){ + size = chunk_size_map * (chunk_size_reg / size) | 0; + } for(const item of map.entries()){ json.push(item); + if(json.length === size){ + chunk.push(json); + json = []; + } } - return json; + json.length && chunk.push(json); + return chunk; } -function ctx_to_json(ctx){ - const json = []; - for(const item of ctx.entries()){ - json.push(map_to_json(item)); +function json_to_map(json, map){ + map || (map = new Map()); + for(let i = 0, entry; i < json.length; i++) { + entry = json[i]; + map.set(entry[0], entry[1]); } - return json; + return map; +} + +function ctx_to_json(ctx, size = 0){ + let chunk = []; + let json = []; + if(size){ + size = chunk_size_ctx * (chunk_size_reg / size) | 0; + } + for(const item of ctx.entries()){ + const key = item[0]; + const value = item[1]; + json.push([key, map_to_json(value)[0]]); + if(json.length === size){ + chunk.push(json); + json = []; + } + } + json.length && chunk.push(json); + return chunk; +} + +function json_to_ctx(json, ctx){ + ctx || (ctx = new Map()); + for(let i = 0, entry, map; i < json.length; i++) { + entry = json[i]; + map = ctx.get(entry[0]); + ctx.set(entry[0], json_to_map(entry[1], map)); + } + return ctx; } function reg_to_json(reg){ - const json = []; + let chunk = []; + let json = []; for(const key of reg.keys()){ json.push(key); + if(json.length === chunk_size_reg){ + chunk.push(json); + json = []; + } } - return json; + json.length && chunk.push(json); + return chunk; } -function save(callback, field, key, index_doc, index, data){ +function json_to_reg(json, reg){ + reg || (reg = new Set()); + for(let i = 0; i < json.length; i++) { + reg.add(json[i]); + } + return reg; +} - const res = callback(field ? field + "." + key : key, JSON.stringify(data)); +/** + * @this {Index|Document} + */ + +function save(callback, field, key, chunk, index_doc, index_obj, index_prt = 0){ + + const is_arr = chunk && chunk.constructor === Array; + const data = is_arr ? chunk.shift() : chunk; + if(!data){ + return this.export( + callback, + field, + index_doc, + index_obj + 1 + ); + } + + const res = callback( + (field ? field + "." : "") + (index_prt + 1) + "." + key, + JSON.stringify(data) + ); if(res && res["then"]){ const self = this; return res["then"](function(){ - return self.export(callback, field, index_doc, index + 1); + return save.call(self, + callback, + field, + key, + is_arr ? chunk : null, + index_doc, + index_obj, + index_prt + 1 + ); }); } - return this.export(callback, field, index_doc, index + 1); + return save.call(this, + callback, + field, + key, + is_arr ? chunk : null, + index_doc, + index_obj, + index_prt + 1 + ); } /** * @param callback * @param field * @param index_doc - * @param index - * @this {Index|Document} + * @param index_obj + * @this {Index} */ -function exportIndex(callback, field, index_doc, index = 0){ +function exportIndex(callback, field, index_doc, index_obj = 0){ - let key, data; + let key, chunk; - switch(index){ + switch(index_obj){ case 0: key = "reg"; - data = reg_to_json(this.reg); + chunk = reg_to_json(this.reg); break; case 1: + // todo key = "cfg"; - data = {}; + chunk = {}; break; case 2: key = "map"; - data = map_to_json(this.map); + chunk = map_to_json(this.map, this.reg.size); break; case 3: key = "ctx"; - data = ctx_to_json(this.ctx); + chunk = ctx_to_json(this.ctx, this.reg.size); break; default: @@ -1326,11 +1418,18 @@ function exportIndex(callback, field, index_doc, index = 0){ return; } - return save.call(this, callback, field, key, index_doc, index, data); + return save.call(this, + callback, + field, + key, + chunk, + index_doc, + index_obj + ); } /** - * @this Index + * @this {Index} */ function importIndex(key, data){ @@ -1342,83 +1441,90 @@ function importIndex(key, data){ data = JSON.parse(data); } + key = key.split("."); + if(key[key.length - 1] === "json"){ + key.pop(); + } + key = key.length > 1 ? key[1] : key[0]; + switch(key){ case "cfg": + // todo break; case "reg": // fast update isn't supported by export/import this.fastupdate = false; - this.reg = new Set(data); + this.reg = json_to_reg(data, this.reg); break; case "map": - this.map = new Map(data); + this.map = json_to_map(data, this.map); break; case "ctx": - this.ctx = new Map(data); + this.ctx = json_to_ctx(data, this.ctx); break; } } /** - * @this Document + * @this {Document} */ -function exportDocument(callback, field, index_doc = 0, index = 0){ +function exportDocument(callback, field, index_doc = 0, index_obj = 0){ if(index_doc < this.field.length){ const field = this.field[index_doc]; const idx = this.index.get(field); // start from index 1, because document indexes does not additionally store register - const res = idx.export(callback, field, index_doc, index = 1); + const res = idx.export(callback, field, index_doc, index_obj = 1); if(res && res["then"]){ const self = this; return res["then"](function(){ - return self.export(callback, field, index_doc + 1, index = 0); + return self.export(callback, field, index_doc + 1); }); } - return this.export(callback, field, index_doc + 1, index = 0); + return this.export(callback, field, index_doc + 1); } else { - let key, data; + let key, chunk; - switch(index){ + switch(index_obj){ case 0: key = "reg"; - data = reg_to_json(this.reg); + chunk = reg_to_json(this.reg); field = null; break; case 1: key = "tag"; - data = ctx_to_json(this.tag); + chunk = ctx_to_json(this.tag, this.reg.size); field = null; break; case 2: key = "doc"; - data = map_to_json(this.store); + chunk = map_to_json(this.store); field = null; break; case 3: key = "cfg"; - data = {}; + chunk = {}; field = null; break; @@ -1427,12 +1533,19 @@ function exportDocument(callback, field, index_doc = 0, index = 0){ return; } - return save.call(this, callback, field, key, index_doc, index, data); + return save.call(this, + callback, + field, + key, + chunk, + index_doc, + index_obj + ); } } /** - * @this Document + * @this {Document} */ function importDocument(key, data){ @@ -1444,41 +1557,46 @@ function importDocument(key, data){ data = JSON.parse(data); } - switch(key){ + key = key.split("."); + if(key[key.length - 1] === "json"){ + key.pop(); + } + const field = key.length > 2 ? key[0] : ""; + key = key.length > 2 ? key[2] : key[1]; - case "tag": + if(!field){ - this.tagindex = new Map(data); - break; + switch(key){ - case "reg": + case "reg": - // fast update isn't supported by export/import - this.fastupdate = false; - this.reg = new Set(data); + // fast update isn't supported by export/import + this.fastupdate = false; + this.reg = json_to_reg(data, this.reg); - for(let i = 0, idx; i < this.field.length; i++){ - idx = this.index.get(this.field[i]); - idx.fastupdate = false; - idx.reg = this.reg; - } + for(let i = 0, idx; i < this.field.length; i++){ + idx = this.index.get(this.field[i]); + idx.fastupdate = false; + idx.reg = this.reg; + } - break; + break; - case "doc": + case "tag": - this.store = new Map(data); - break; + this.tag = json_to_ctx(data, this.tag); + break; - default: + case "doc": - key = key.split("."); - const field = key[0]; - key = key[1]; + this.store = json_to_map(data, this.store); + break; - if(field && key){ - this.index.get(field).import(key, data); - } + } + } + else { + + return this.index.get(field).import(key, data); } } @@ -1556,91 +1674,6 @@ function serialize(withFunctionWrapper = true){ : reg + map + ctx } -// export function exportSnapshot(flexsearch){ -// -// if(!flexsearch.reg.size) return; -// -// let reg = ''; -// let type = ""; -// for(const key of flexsearch.reg.keys()){ -// type || (type = typeof key); -// reg += (reg ? ',' : '') + (type === "string" ? '"' + key + '"' : key); -// } -// reg = "f.reg=[" + reg + "];"; -// -// let map = ''; -// for(const item of flexsearch.map.entries()){ -// const key = item[0]; -// const value = item[1]; -// let res = ''; -// for(let i = 0, ids; i < value.length; i++){ -// ids = value[i] || ['']; -// let str = ''; -// for(let j = 0; j < ids.length; j++){ -// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]); -// } -// str = "[ -// res += (res ? '|' : '') + str; -// } -// map += (map ? ';' : '') + key + ':' + res; -// } -// -// -// let ctx = ''; -// for(const context of flexsearch.ctx.entries()){ -// const key_ctx = context[0]; -// const value_ctx = context[1]; -// -// for(const item of value_ctx.entries()){ -// const key = item[0]; -// const value = item[1]; -// -// let res = ''; -// for(let i = 0, ids; i < value.length; i++){ -// ids = value[i] || ['']; -// let str = ''; -// for(let j = 0; j < ids.length; j++){ -// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]); -// } -// res += (res ? '|' : '') + str; -// } -// ctx += (ctx ? ';' : '') + key_ctx + '+' + key + ':' + res; -// } -// } -// -// return reg + '#' + map + '#' + ctx; -// } -// -// export function importSnapshot(flexsearch, input){ -// -// if(!input) return; -// -// let pos_reg = input.indexOf("#"); -// const reg = input.substring(0, pos_reg).split(","); -// flexsearch.reg = new Set(reg); -// -// let pos_map = input.indexOf("#", pos_reg + 1); -// const map = input.substring(pos_reg + 1, pos_map).split(";").map(res => { -// const split = res.split(":"); -// split[1] = split[1].split("|").map(ids => ids ? ids.split(",") : null); -// return split; -// }); -// flexsearch.map = new Map(map); -// -// input = input.substring(pos_map + 1); -// if(input){ -// const ctx = input.split(";").map(res => { -// const split = res.split(":"); -// const context = split[0].split("+"); -// const map = new Map([ -// [context[1], split[1].split("|").map(ids => ids ? ids.split(",") : null)] -// ]); -// return [context[0], map] -// }); -// flexsearch.ctx = new Map(ctx); -// } -// } - // KeystoreObj.prototype.destroy = function(){ // this.index = null; // this.keys = null; @@ -3450,7 +3483,7 @@ function apply_enrich(res){ function Document(options){ - if(this.constructor !== Document) { + if(!this || this.constructor !== Document) { return new Document(options); } @@ -5430,7 +5463,7 @@ function exclusion(result, limit, offset, resolve){ */ function Resolver(result){ - if(this.constructor !== Resolver){ + if(!this || this.constructor !== Resolver){ return new Resolver(result); } if(result && result.index){ @@ -6190,7 +6223,7 @@ function remove_index(map, id){ function Index(options, _register){ - if(this.constructor !== Index){ + if(!this || this.constructor !== Index){ return new Index(options); } diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js index 2e90e31..dc9bc3c 100644 --- a/dist/flexsearch.bundle.debug.js +++ b/dist/flexsearch.bundle.debug.js @@ -90,7 +90,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++) { @@ -264,7 +264,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; @@ -314,37 +314,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) { @@ -410,12 +441,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) { @@ -446,7 +477,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)]; @@ -463,7 +494,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); @@ -505,7 +536,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; @@ -516,7 +547,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) { @@ -546,7 +577,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); } } } @@ -609,7 +640,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); @@ -617,21 +648,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) { @@ -647,17 +678,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; @@ -673,7 +704,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 []; @@ -706,7 +737,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; @@ -749,7 +780,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]; @@ -827,7 +858,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}); } @@ -879,7 +910,7 @@ function za(a, b) { } } } else { - for (let E = 0, F, fb; E < n.length; E += 2) { + for (let E = 0, F, ib; 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) { @@ -888,7 +919,7 @@ function za(a, b) { return e; } } - if (fb = (F = F && F.get(n[E + 1])) && F.length) { + if (ib = (F = F && F.get(n[E + 1])) && F.length) { x++, u.push(F); } else if (!t) { return e; @@ -896,7 +927,7 @@ function za(a, b) { } } if (x) { - w = za(w, u); + w = Ca(w, u); I = w.length; if (!I && !t) { return e; @@ -938,7 +969,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; } @@ -950,12 +981,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; @@ -997,7 +1028,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]; @@ -1016,7 +1047,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"), []; @@ -1025,11 +1056,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)}; @@ -1037,7 +1068,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; @@ -1045,7 +1076,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 && []; @@ -1053,7 +1084,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) { @@ -1066,7 +1097,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()); } @@ -1134,7 +1165,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]); @@ -1147,19 +1178,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++) { @@ -1225,28 +1256,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: @@ -1262,33 +1293,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) { @@ -1328,31 +1362,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)) { @@ -1366,14 +1400,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); } } @@ -1382,7 +1416,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 = ""; } @@ -1398,7 +1432,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); } } @@ -1411,7 +1445,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) { @@ -1432,12 +1466,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++) { @@ -1453,7 +1487,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]; } @@ -1467,9 +1501,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]}; } @@ -1519,19 +1553,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) { @@ -1581,24 +1615,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; @@ -1644,14 +1678,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; } @@ -1745,14 +1779,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; } @@ -1782,7 +1816,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) { @@ -1827,12 +1861,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; @@ -1843,22 +1877,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) { @@ -1883,10 +1917,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) { @@ -1897,7 +1931,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; } @@ -1916,12 +1950,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; } @@ -1940,16 +1974,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); @@ -1987,15 +2021,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++) { @@ -2010,24 +2044,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; @@ -2064,7 +2098,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); @@ -2088,7 +2122,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++) { @@ -2096,7 +2130,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); } } @@ -2106,17 +2140,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"; @@ -2124,29 +2158,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); } } }; @@ -2201,10 +2235,10 @@ v.serialize = function(a = !0) { return a ? "function inject(index){" + b + d + e + "}" : b + d + e; }; na(L.prototype); -const cb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), db = ["map", "ctx", "tag", "reg", "cfg"]; -function eb(a, b = {}) { +const fb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), gb = ["map", "ctx", "tag", "reg", "cfg"]; +function hb(a, b = {}) { if (!this) { - return new eb(a, b); + return new hb(a, b); } "object" === typeof a && (b = a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -2214,7 +2248,7 @@ function eb(a, b = {}) { this.db = null; this.h = {}; } -v = eb.prototype; +v = hb.prototype; v.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -2226,10 +2260,10 @@ v.open = function() { let a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { - const d = cb.open(a.id + (a.field ? ":" + a.field : ""), 1); + const d = fb.open(a.id + (a.field ? ":" + a.field : ""), 1); d.onupgradeneeded = function() { const e = a.db = this.result; - db.forEach(f => { + gb.forEach(f => { e.objectStoreNames.contains(f) || e.createObjectStore(f); }); }; @@ -2255,12 +2289,12 @@ v.close = function() { this.db = null; }; v.destroy = function() { - return cb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); + return fb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); }; v.clear = function() { - const a = this.db.transaction(db, "readwrite"); - for (let b = 0; b < db.length; b++) { - a.objectStore(db[b]).clear(); + const a = this.db.transaction(gb, "readwrite"); + for (let b = 0; b < gb.length; b++) { + a.objectStore(gb[b]).clear(); } return Z(a); }; @@ -2444,7 +2478,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++) { @@ -2473,17 +2507,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++) { @@ -2503,9 +2537,9 @@ function Z(a) { a = null; }); } -;const hb = {Index:L, Charset:Pa, Encoder:K, Document:T, Worker:N, Resolver:X, IndexedDB:eb, Language:{}}, ib = self; -let jb; -(jb = ib.define) && jb.amd ? jb([], function() { - return hb; -}) : "object" === typeof ib.exports ? ib.exports = hb : ib.FlexSearch = hb; +;const kb = {Index:L, Charset:Sa, Encoder:K, Document:T, Worker:N, Resolver:X, IndexedDB:hb, Language:{}}, lb = self; +let mb; +(mb = lb.define) && mb.amd ? mb([], function() { + return kb; +}) : "object" === typeof lb.exports ? lb.exports = kb : lb.FlexSearch = kb; }(this||self)); diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index 0264a58..6a5ee0e 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -12,7 +12,7 @@ function F(a){return"string"===typeof a}function G(a){return"object"===typeof a} "i"],["\u01d2","o"],["\u01d4","u"],["\u01d6","u"],["\u01d8","u"],["\u01da","u"],["\u01dc","u"],["\u01df","a"],["\u01e1","a"],["\u01e3","ae"],["\u00e6","ae"],["\u01fd","ae"],["\u01e7","g"],["\u01e9","k"],["\u01eb","o"],["\u01ed","o"],["\u01ef","\u0292"],["\u01f0","j"],["\u01f3","dz"],["\u01f5","g"],["\u01f9","n"],["\u01fb","a"],["\u01ff","\u00f8"],["\u0201","a"],["\u0203","a"],["\u0205","e"],["\u0207","e"],["\u0209","i"],["\u020b","i"],["\u020d","o"],["\u020f","o"],["\u0211","r"],["\u0213","r"],["\u0215", "u"],["\u0217","u"],["\u0219","s"],["\u021b","t"],["\u021f","h"],["\u0227","a"],["\u0229","e"],["\u022b","o"],["\u022d","o"],["\u022f","o"],["\u0231","o"],["\u0233","y"],["\u02b0","h"],["\u02b1","h"],["\u0266","h"],["\u02b2","j"],["\u02b3","r"],["\u02b4","\u0279"],["\u02b5","\u027b"],["\u02b6","\u0281"],["\u02b7","w"],["\u02b8","y"],["\u02e0","\u0263"],["\u02e1","l"],["\u02e2","s"],["\u02e3","x"],["\u02e4","\u0295"],["\u0390","\u03b9"],["\u03ac","\u03b1"],["\u03ad","\u03b5"],["\u03ae","\u03b7"],["\u03af", "\u03b9"],["\u03b0","\u03c5"],["\u03ca","\u03b9"],["\u03cb","\u03c5"],["\u03cc","\u03bf"],["\u03cd","\u03c5"],["\u03ce","\u03c9"],["\u03d0","\u03b2"],["\u03d1","\u03b8"],["\u03d2","\u03a5"],["\u03d3","\u03a5"],["\u03d4","\u03a5"],["\u03d5","\u03c6"],["\u03d6","\u03c0"],["\u03f0","\u03ba"],["\u03f1","\u03c1"],["\u03f2","\u03c2"],["\u03f5","\u03b5"],["\u0439","\u0438"],["\u0450","\u0435"],["\u0451","\u0435"],["\u0453","\u0433"],["\u0457","\u0456"],["\u045c","\u043a"],["\u045d","\u0438"],["\u045e","\u0443"], -["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];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)return new K(...arguments);for(let b=0;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(e=0;g&&ethis.S&&(this.J.clear(),this.A=this.A/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.h&&(this.H.set(a,c),this.H.size>this.S&&(this.H.clear(),this.h=this.h/1.1|0));return c};function ka(a){a.L=null;a.H.clear();a.J.clear()};async function la(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};(b=d.config)&&(d=(await import(b))["default"]);(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new L(d);postMessage({id:a.id});break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let M=0; -function N(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=g;this.h=B();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++M]=function(){k(e)};e.worker.postMessage({id:M,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(this.constructor!==N)return new N(a);let c="undefined"!==typeof self?self._factory:"undefined"!== +function N(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=g;this.h=B();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++M]=function(){k(e)};e.worker.postMessage({id:M,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==N)return new N(a);let c="undefined"!==typeof self?self._factory:"undefined"!== typeof window?window._factory:null;c&&(c=c.toString());const d="undefined"===typeof window,e=this,f=ma(c,d,a.worker);return f.then?f.then(function(g){return b.call(e,g)}):b.call(this,f)}O("add");O("append");O("search");O("update");O("remove"); function O(a){N.prototype[a]=N.prototype[a+"Async"]=async function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;"function"===typeof d&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){b.h[++M]=f;b.worker.postMessage({task:a,id:M,args:c})});return e?(d.then(e),this):d}} function ma(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="+la.toString()],{type:"text/javascript"}))):new window.Worker(F(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){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}function P(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(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){const b=[];for(const c of a.entries())b.push(c);return b}function pa(a){const b=[];for(const c of a.entries())b.push(oa(c));return b}function qa(a){const b=[];for(const c of a.keys())b.push(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)})}return this.export(a,b,d,e+1)};function sa(a,b,c,d){let e=[];for(let f=0,g;f=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} +"module/worker/worker.js"),{type:"module"})};function na(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}function P(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(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=0){let c=[],d=[];b&&(b=25E4/b*5E3|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=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} function Q(a){if(!this)return new Q(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(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){let f=0;for(let g=0,h,k;gc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(let p=0,n;pd)d-=n.length; +this.C[k];if((c=l.I)&&!c(b))continue;let m;if("function"===typeof l){m=l(b);if(!m)continue;l=[l.U]}else if(F(l)||l.constructor===String){h[l]=b[l];continue}za(b,h,l,0,l[0],m)}}this.store.set(a,h||b)}}return this};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;ec||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(let p=0,n;pd)d-=n.length; else{if(n.length>c||d)n=n.slice(d,c+d),c-=n.length,d&&(d-=n.length);e.push(n);if(!c)break}k=1c||d)a=a.slice(d,d+c);e&&(a=Ba.call(this,a));return a}} -function Ba(a){const b=Array(a.length);for(let c=0,d;cc||d)a=a.slice(d,d+c);e&&(a=Ea.call(this,a));return a}} +function Ea(a){const b=Array(a.length);for(let c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -U.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};U.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};U.prototype.clear=function(){this.cache.clear();this.h=""};const Ha={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){for(let c=0;cf;h--){g=r.substring(f,h);var k=this.score?this.score(b,r,q,g,f):Ra(n,d,q,e,f);V(this,m,g,k,a,c)}break}case "reverse":if(1< -e){for(h=e-1;0g?0:1),d,q,h-1,k-1),u=this.bidirectional&&r>f;V(this,l,u?f:r,t,a,c,u?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& -(b||this.commit_task.push({del:a}),this.T&&Sa(this));return this};function V(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=B()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new Q(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} -function Ra(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?Ta(a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(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;e=[g]}b-=h;if(!b)break}if(!e.length)return e;e=1a.length?e?W(a[0],b,c,d):a[0]:ya(a,c,b,e,f)};X.prototype.and=function(){if(this.result.length){const b=this;let c=arguments;var a=c[0];if(a.then)return a.then(function(){return b.and.apply(b,c)});if(a[0]&&a[0].index)return this.and.apply(this,a);let d=[];a=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return[];let g=[];B();let h=ca(a);return h?xa(a,h,b,c,f,e,d):g};X.prototype.xor=function(){const a=this;let b=arguments;var 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);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return e?W(a[0],b,c,d):a[0];d=[];const g=B();let h=0;for(let k=0,l;kthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +U.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};U.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};U.prototype.clear=function(){this.cache.clear();this.h=""};const Ka={normalize:function(a){return a.toLowerCase()},dedupe:!1};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;cf;h--){g=r.substring(f,h);var k=this.score?this.score(b,r,q,g,f):Ua(n,d,q,e,f);V(this,m,g,k,a,c)}break}case "reverse":if(1< +e){for(h=e-1;0g?0:1),d,q,h-1,k-1),u=this.bidirectional&&r>f;V(this,l,u?f:r,t,a,c,u?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& +(b||this.commit_task.push({del:a}),this.T&&Va(this));return this};function V(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=B()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new Q(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} +function Ua(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?Wa(a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=g.length),e.push(g);else{if(h>=b)return h>b&&(g=g.slice(0,b)),d?Wa(g):g;e=[g]}b-=h;if(!b)break}if(!e.length)return e;e=1a.length?e?W(a[0],b,c,d):a[0]:Ba(a,c,b,e,f)};X.prototype.and=function(){if(this.result.length){const b=this;let c=arguments;var a=c[0];if(a.then)return a.then(function(){return b.and.apply(b,c)});if(a[0]&&a[0].index)return this.and.apply(this,a);let d=[];a=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return[];let g=[];B();let h=ca(a);return h?Aa(a,h,b,c,f,e,d):g};X.prototype.xor=function(){const a=this;let b=arguments;var 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);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return e?W(a[0],b,c,d):a[0];d=[];const g=B();let h=0;for(let k=0,l;kc);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.ctx.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};L.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let d=0,e;de.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else ab(this.map,a),this.depth&&ab(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&Sa(this));this.cache&&this.cache.remove(a);return this}; -function ab(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;dc);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.ctx.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};L.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let d=0,e;de.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else 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&&Va(this));this.cache&&this.cache.remove(a);return this}; +function db(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;dc.add(a,b)):this.add(a,b)}; -function bb(a){let b=0;if(a.constructor===Array)for(let c=0,d;c{e.objectStoreNames.contains(f)||e.createObjectStore(f)})};d.onblocked=function(e){console.error("blocked",e);c()};d.onerror=function(e){console.error(this.error,e);c()};d.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; -v.close=function(){this.db.close();this.db=null};v.destroy=function(){return cb.deleteDatabase(this.id+(this.field?":"+this.field:""))};v.clear=function(){const a=this.db.transaction(db,"readwrite");for(let b=0;b{e.objectStoreNames.contains(f)||e.createObjectStore(f)})};d.onblocked=function(e){console.error("blocked",e);c()};d.onerror=function(e){console.error(this.error,e);c()};d.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; +v.close=function(){this.db.close();this.db=null};v.destroy=function(){return fb.deleteDatabase(this.id+(this.field?":"+this.field:""))};v.clear=function(){const a=this.db.transaction(gb,"readwrite");for(let b=0;b=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;dm&&!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})};const hb={Index:L,Charset:Pa,Encoder:K,Document:T,Worker:N,Resolver:X,IndexedDB:fb,Language:{}},ib=self;let jb;(jb=ib.define)&&jb.amd?jb([],function(){return hb}):"object"===typeof ib.exports?ib.exports=hb:ib.FlexSearch=hb;}(this||self)); +function jb(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})};const kb={Index:L,Charset:Sa,Encoder:K,Document:T,Worker:N,Resolver:X,IndexedDB:ib,Language:{}},lb=self;let mb;(mb=lb.define)&&mb.amd?mb([],function(){return kb}):"object"===typeof lb.exports?lb.exports=kb:lb.FlexSearch=kb;}(this||self)); diff --git a/dist/flexsearch.bundle.module.debug.js b/dist/flexsearch.bundle.module.debug.js index a170ce0..2143567 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -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={}; \ No newline at end of file +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={}; \ No newline at end of file diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js index e131e54..24f3319 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -12,7 +12,7 @@ function F(a){return"string"===typeof a}function G(a){return"object"===typeof a} "i"],["\u01d2","o"],["\u01d4","u"],["\u01d6","u"],["\u01d8","u"],["\u01da","u"],["\u01dc","u"],["\u01df","a"],["\u01e1","a"],["\u01e3","ae"],["\u00e6","ae"],["\u01fd","ae"],["\u01e7","g"],["\u01e9","k"],["\u01eb","o"],["\u01ed","o"],["\u01ef","\u0292"],["\u01f0","j"],["\u01f3","dz"],["\u01f5","g"],["\u01f9","n"],["\u01fb","a"],["\u01ff","\u00f8"],["\u0201","a"],["\u0203","a"],["\u0205","e"],["\u0207","e"],["\u0209","i"],["\u020b","i"],["\u020d","o"],["\u020f","o"],["\u0211","r"],["\u0213","r"],["\u0215", "u"],["\u0217","u"],["\u0219","s"],["\u021b","t"],["\u021f","h"],["\u0227","a"],["\u0229","e"],["\u022b","o"],["\u022d","o"],["\u022f","o"],["\u0231","o"],["\u0233","y"],["\u02b0","h"],["\u02b1","h"],["\u0266","h"],["\u02b2","j"],["\u02b3","r"],["\u02b4","\u0279"],["\u02b5","\u027b"],["\u02b6","\u0281"],["\u02b7","w"],["\u02b8","y"],["\u02e0","\u0263"],["\u02e1","l"],["\u02e2","s"],["\u02e3","x"],["\u02e4","\u0295"],["\u0390","\u03b9"],["\u03ac","\u03b1"],["\u03ad","\u03b5"],["\u03ae","\u03b7"],["\u03af", "\u03b9"],["\u03b0","\u03c5"],["\u03ca","\u03b9"],["\u03cb","\u03c5"],["\u03cc","\u03bf"],["\u03cd","\u03c5"],["\u03ce","\u03c9"],["\u03d0","\u03b2"],["\u03d1","\u03b8"],["\u03d2","\u03a5"],["\u03d3","\u03a5"],["\u03d4","\u03a5"],["\u03d5","\u03c6"],["\u03d6","\u03c0"],["\u03f0","\u03ba"],["\u03f1","\u03c1"],["\u03f2","\u03c2"],["\u03f5","\u03b5"],["\u0439","\u0438"],["\u0450","\u0435"],["\u0451","\u0435"],["\u0453","\u0433"],["\u0457","\u0456"],["\u045c","\u043a"],["\u045d","\u0438"],["\u045e","\u0443"], -["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];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)return new K(...arguments);for(let b=0;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(e=0;g&&ethis.S&&(this.J.clear(),this.A=this.A/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.h&&(this.H.set(a,c),this.H.size>this.S&&(this.H.clear(),this.h=this.h/1.1|0));return c};function ka(a){a.L=null;a.H.clear();a.J.clear()};async function la(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};(b=d.config)&&(d=(await import(b))["default"]);(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new L(d);postMessage({id:a.id});break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let M=0; -function N(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=g;this.h=B();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++M]=function(){k(e)};e.worker.postMessage({id:M,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(this.constructor!==N)return new N(a);let c="undefined"!==typeof self?self._factory:"undefined"!== +function N(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.worker=g;this.h=B();if(this.worker){d?this.worker.on("message",h):this.worker.onmessage=h;if(a.config)return new Promise(function(k){e.h[++M]=function(){k(e)};e.worker.postMessage({id:M,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==N)return new N(a);let c="undefined"!==typeof self?self._factory:"undefined"!== typeof window?window._factory:null;c&&(c=c.toString());const d="undefined"===typeof window,e=this,f=ma(c,d,a.worker);return f.then?f.then(function(g){return b.call(e,g)}):b.call(this,f)}O("add");O("append");O("search");O("update");O("remove"); function O(a){N.prototype[a]=N.prototype[a+"Async"]=async function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;"function"===typeof d&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){b.h[++M]=f;b.worker.postMessage({task:a,id:M,args:c})});return e?(d.then(e),this):d}} function ma(a,b,c){return b?"undefined"!==typeof module?new (require("worker_threads")["Worker"])(__dirname + "/node/node.js"):import("worker_threads").then(function(worker){ return new worker["Worker"](import.meta.dirname + "/node/node.mjs"); }):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+la.toString()],{type:"text/javascript"}))):new window.Worker(F(c)?c:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js", -"module/worker/worker.js"),{type:"module"})};function na(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}function P(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(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){const b=[];for(const c of a.entries())b.push(c);return b}function pa(a){const b=[];for(const c of a.entries())b.push(oa(c));return b}function qa(a){const b=[];for(const c of a.keys())b.push(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)})}return this.export(a,b,d,e+1)};function sa(a,b,c,d){let e=[];for(let f=0,g;f=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} +"module/worker/worker.js"),{type:"module"})};function na(a){P.call(a,"add");P.call(a,"append");P.call(a,"search");P.call(a,"update");P.call(a,"remove")}function P(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(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=0){let c=[],d=[];b&&(b=25E4/b*5E3|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=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} function Q(a){if(!this)return new Q(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(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){let f=0;for(let g=0,h,k;gc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(let p=0,n;pd)d-=n.length; +this.C[k];if((c=l.I)&&!c(b))continue;let m;if("function"===typeof l){m=l(b);if(!m)continue;l=[l.U]}else if(F(l)||l.constructor===String){h[l]=b[l];continue}za(b,h,l,0,l[0],m)}}this.store.set(a,h||b)}}return this};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;ec||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(let p=0,n;pd)d-=n.length; else{if(n.length>c||d)n=n.slice(d,c+d),c-=n.length,d&&(d-=n.length);e.push(n);if(!c)break}k=1c||d)a=a.slice(d,d+c);e&&(a=Ba.call(this,a));return a}} -function Ba(a){const b=Array(a.length);for(let c=0,d;cc||d)a=a.slice(d,d+c);e&&(a=Ea.call(this,a));return a}} +function Ea(a){const b=Array(a.length);for(let c=0,d;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -U.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};U.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};U.prototype.clear=function(){this.cache.clear();this.h=""};const Ha={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){for(let c=0;cf;h--){g=r.substring(f,h);var k=this.score?this.score(b,r,q,g,f):Ra(n,d,q,e,f);V(this,m,g,k,a,c)}break}case "reverse":if(1< -e){for(h=e-1;0g?0:1),d,q,h-1,k-1),u=this.bidirectional&&r>f;V(this,l,u?f:r,t,a,c,u?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& -(b||this.commit_task.push({del:a}),this.T&&Sa(this));return this};function V(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=B()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new Q(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} -function Ra(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?Ta(a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(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;e=[g]}b-=h;if(!b)break}if(!e.length)return e;e=1a.length?e?W(a[0],b,c,d):a[0]:ya(a,c,b,e,f)};X.prototype.and=function(){if(this.result.length){const b=this;let c=arguments;var a=c[0];if(a.then)return a.then(function(){return b.and.apply(b,c)});if(a[0]&&a[0].index)return this.and.apply(this,a);let d=[];a=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return[];let g=[];B();let h=ca(a);return h?xa(a,h,b,c,f,e,d):g};X.prototype.xor=function(){const a=this;let b=arguments;var 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);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return e?W(a[0],b,c,d):a[0];d=[];const g=B();let h=0;for(let k=0,l;kthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +U.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};U.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};U.prototype.clear=function(){this.cache.clear();this.h=""};const Ka={normalize:function(a){return a.toLowerCase()},dedupe:!1};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;cf;h--){g=r.substring(f,h);var k=this.score?this.score(b,r,q,g,f):Ua(n,d,q,e,f);V(this,m,g,k,a,c)}break}case "reverse":if(1< +e){for(h=e-1;0g?0:1),d,q,h-1,k-1),u=this.bidirectional&&r>f;V(this,l,u?f:r,t,a,c,u?r:f)}}}}this.fastupdate||this.reg.add(a)}else b=""}this.db&& +(b||this.commit_task.push({del:a}),this.T&&Va(this));return this};function V(a,b,c,d,e,f,g){let h=g?a.ctx:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=B()),b[g]=1,(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new Q(h);if(a.fastupdate)for(let l of a.reg.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.fastupdate&&((d=a.reg.get(e))?d.push(h):a.reg.set(e,[h]))}} +function Ua(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?Wa(a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=g.length),e.push(g);else{if(h>=b)return h>b&&(g=g.slice(0,b)),d?Wa(g):g;e=[g]}b-=h;if(!b)break}if(!e.length)return e;e=1a.length?e?W(a[0],b,c,d):a[0]:Ba(a,c,b,e,f)};X.prototype.and=function(){if(this.result.length){const b=this;let c=arguments;var a=c[0];if(a.then)return a.then(function(){return b.and.apply(b,c)});if(a[0]&&a[0].index)return this.and.apply(this,a);let d=[];a=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return[];let g=[];B();let h=ca(a);return h?Aa(a,h,b,c,f,e,d):g};X.prototype.xor=function(){const a=this;let b=arguments;var 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);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return e?W(a[0],b,c,d):a[0];d=[];const g=B();let h=0;for(let k=0,l;kc);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.ctx.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};L.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let d=0,e;de.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else ab(this.map,a),this.depth&&ab(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.T&&Sa(this));this.cache&&this.cache.remove(a);return this}; -function ab(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;dc);if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.ctx.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};L.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let d=0,e;de.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else 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&&Va(this));this.cache&&this.cache.remove(a);return this}; +function db(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;dc.add(a,b)):this.add(a,b)}; -function cb(a){let b=0;if(a.constructor===Array)for(let c=0,d;c{e.objectStoreNames.contains(f)||e.createObjectStore(f)})};d.onblocked=function(e){console.error("blocked",e);c()};d.onerror=function(e){console.error(this.error,e);c()};d.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; -v.close=function(){this.db.close();this.db=null};v.destroy=function(){return db.deleteDatabase(this.id+(this.field?":"+this.field:""))};v.clear=function(){const a=this.db.transaction(eb,"readwrite");for(let b=0;b{e.objectStoreNames.contains(f)||e.createObjectStore(f)})};d.onblocked=function(e){console.error("blocked",e);c()};d.onerror=function(e){console.error(this.error,e);c()};d.onsuccess=function(){a.db=this.result;a.db.onversionchange=function(){a.close()};b(a)}})}; +v.close=function(){this.db.close();this.db=null};v.destroy=function(){return gb.deleteDatabase(this.id+(this.field?":"+this.field:""))};v.clear=function(){const a=this.db.transaction(hb,"readwrite");for(let b=0;b=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;dm&&!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:Pa,Encoder:K,Document:T,Worker:N,Resolver:X,IndexedDB:fb,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={}; \ No newline at end of file +function jb(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:Sa,Encoder:K,Document:T,Worker:N,Resolver:X,IndexedDB:ib,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={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.debug.js b/dist/flexsearch.compact.debug.js index da392ff..4fc1c62 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -76,7 +76,7 @@ function I(a, c) { "\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) { - if (this.constructor !== K) { + if (!this || this.constructor !== K) { return new K(...arguments); } for (let c = 0; c < arguments.length; c++) { @@ -228,37 +228,68 @@ function M(a) { return c; }; } -;function N(a) { - const c = []; - for (const b of a.entries()) { - c.push(b); +;function N(a, c = 0) { + let b = [], e = []; + c && (c = 250000 / c * 5000 | 0); + for (const d of a.entries()) { + e.push(d), e.length === c && (b.push(e), e = []); + } + e.length && b.push(e); + return b; +} +function O(a, c) { + c || (c = new Map()); + for (let b = 0, e; b < a.length; b++) { + e = a[b], c.set(e[0], e[1]); } return c; } -function ja(a) { - const c = []; - for (const b of a.entries()) { - c.push(N(b)); +function ja(a, c = 0) { + let b = [], e = []; + c && (c = 250000 / c * 1000 | 0); + for (const d of a.entries()) { + e.push([d[0], N(d[1])[0]]), e.length === c && (b.push(e), e = []); + } + e.length && b.push(e); + return b; +} +function ka(a, c) { + c || (c = new Map()); + for (let b = 0, e, d; b < a.length; b++) { + e = a[b], d = c.get(e[0]), c.set(e[0], O(e[1], d)); } return c; } -function ka(a) { - const c = []; - for (const b of a.keys()) { - c.push(b); +function la(a) { + let c = [], b = []; + for (const e of a.keys()) { + b.push(e), 250000 === b.length && (c.push(b), b = []); + } + b.length && c.push(b); + return c; +} +function ma(a, c) { + c || (c = new Set()); + for (let b = 0; b < a.length; b++) { + c.add(a[b]); } return c; } -function la(a, c, b, e, d, f) { - if ((b = a(c ? c + "." + b : b, JSON.stringify(f))) && b.then) { - const g = this; - return b.then(function() { - return g.export(a, c, e, d + 1); +function P(a, c, b, e, d, f, g = 0) { + const h = e && e.constructor === Array; + var k = h ? e.shift() : e; + if (!k) { + return this.export(a, c, d, f + 1); + } + if ((k = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(k))) && k.then) { + const l = this; + return k.then(function() { + return P.call(l, a, c, b, h ? e : null, d, f, g + 1); }); } - return this.export(a, c, e, d + 1); + return P.call(this, a, c, b, h ? e : null, d, f, g + 1); } -;O.prototype.add = function(a, c, b) { +;Q.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)) { @@ -272,7 +303,7 @@ function la(a, c, b, e, d, f) { d && e.add(a, d, !1, !0); } else { if (d = k.F, !d || d(c)) { - k.constructor === String ? k = ["" + k] : E(k) && (k = [k]), P(c, k, this.H, 0, e, a, k[0], b); + k.constructor === String ? k = ["" + k] : E(k) && (k = [k]), R(c, k, this.H, 0, e, a, k[0], b); } } } @@ -323,7 +354,7 @@ function la(a, c, b, e, d, f) { h[l] = c[l]; continue; } - Q(c, h, l, 0, l[0], m); + na(c, h, l, 0, l[0], m); } } this.store.set(a, h || c); @@ -331,21 +362,21 @@ function la(a, c, b, e, d, f) { } return this; }; -function Q(a, c, b, e, d, f) { +function na(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++) { - Q(a, c, b, e, d); + na(a, c, b, e, d); } } else { - c = c[d] || (c[d] = C()), d = b[++e], Q(a, c, b, e, d); + c = c[d] || (c[d] = C()), d = b[++e], na(a, c, b, e, d); } } } -function P(a, c, b, e, d, f, g, h) { +function R(a, c, b, e, d, f, g, h) { if (a = a[g]) { if (e === c.length - 1) { if (a.constructor === Array) { @@ -361,15 +392,15 @@ function P(a, c, b, e, d, f, g, h) { } else { if (a.constructor === Array) { for (g = 0; g < a.length; g++) { - P(a, c, b, e, d, f, g, h); + R(a, c, b, e, d, f, g, h); } } else { - g = c[++e], P(a, c, b, e, d, f, g, h); + g = c[++e], R(a, c, b, e, d, f, g, h); } } } } -;function ma(a, c) { +;function oa(a, c) { const b = C(), e = []; for (let d = 0, f; d < c.length; d++) { f = c[d]; @@ -382,7 +413,7 @@ function P(a, c, b, e, d, f, g, h) { } return e; } -;O.prototype.search = function(a, c, b, e) { +;Q.prototype.search = function(a, c, b, e) { b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0)); let d = []; var f = []; @@ -438,7 +469,7 @@ function P(a, c, b, e, d, f, g, h) { e = []; if (u.length) { for (f = 0; f < u.length; f += 2) { - r = na.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:r}); + r = pa.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(w) { @@ -488,7 +519,7 @@ function P(a, c, b, e, d, f, g, h) { } } if (y) { - q = ma(q, v); + q = oa(q, v); A = q.length; if (!A && !k) { return d; @@ -517,15 +548,15 @@ function P(a, c, b, e, d, f, g, h) { u = []; for (let w = 0, q; w < f.length; w++) { q = d[w]; - g && q.length && !q[0].doc && q.length && (q = oa.call(this, q)); + g && q.length && !q[0].doc && q.length && (q = qa.call(this, q)); if (r) { return q; } d[w] = {field:f[w], result:q}; } - return h ? pa(d, c) : p ? qa(d, a, this.index, this.field, this.C, p) : d; + return h ? ra(d, c) : p ? sa(d, a, this.index, this.field, this.C, p) : d; }; -function qa(a, c, b, e, d, f) { +function sa(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; @@ -567,7 +598,7 @@ function qa(a, c, b, e, d, f) { } return a; } -function pa(a, c) { +function ra(a, c) { const b = [], e = C(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -586,7 +617,7 @@ function pa(a, c) { } return b; } -function na(a, c, b, e, d) { +function pa(a, c, b, e, d) { let f = this.tag.get(a); if (!f) { return console.warn("Tag '" + a + "' was not found"), []; @@ -595,43 +626,43 @@ function na(a, c, b, e, d) { if (a > b || e) { f = f.slice(e, e + b); } - d && (f = oa.call(this, f)); + d && (f = qa.call(this, f)); return f; } } -function oa(a) { +function qa(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)}; } return c; } -;function O(a) { - if (this.constructor !== O) { - return new O(a); +;function Q(a) { + if (!this || this.constructor !== Q) { + return new Q(a); } const c = a.document || a.doc || a; var b; this.C = []; this.field = []; this.H = []; - this.key = (b = c.key || c.id) && R(b, this.H) || "id"; + this.key = (b = c.key || c.id) && S(b, this.H) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); this.h = (b = c.store || null) && !0 !== b && []; this.store = b && new Map(); - this.cache = (b = a.cache || null) && new S(b); + this.cache = (b = a.cache || null) && new T(b); a.cache = !1; b = new Map(); let e = c.index || c.field || c; E(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], E(f) || (g = f, f = f.field), g = H(g) ? Object.assign({}, a, g) : a, b.set(f, new T(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = R(f, this.H), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].F = g.filter)), this.field[d] = f; + f = e[d], E(f) || (g = f, f = f.field), g = H(g) ? Object.assign({}, a, g) : a, b.set(f, new U(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = S(f, this.H), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].F = g.filter)), this.field[d] = f; } if (this.h) { a = c.store; E(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.h[d] = f.custom, f.custom.S = g) : (this.h[d] = R(g, this.H), f.filter && ("string" === typeof this.h[d] && (this.h[d] = new String(this.h[d])), this.h[d].F = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.h[d] = f.custom, f.custom.S = g) : (this.h[d] = S(g, this.H), f.filter && ("string" === typeof this.h[d] && (this.h[d] = new String(this.h[d])), this.h[d].F = f.filter)); } } this.index = b; @@ -647,14 +678,14 @@ function oa(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.B[d] = f.custom : (this.B[d] = R(g, this.H), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].F = f.filter)); + f.custom ? this.B[d] = f.custom : (this.B[d] = S(g, this.H), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].F = f.filter)); this.R[d] = g; this.tag.set(g, new Map()); } } } } -function R(a, c) { +function S(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { @@ -663,7 +694,7 @@ function R(a, c) { e < b.length && (b.length = e); return 1 < e ? b : b[0]; } -x = O.prototype; +x = Q.prototype; x.append = function(a, c) { return this.add(a, c, !0); }; @@ -719,28 +750,28 @@ x.set = function(a, c) { this.store.set(a, c); return this; }; -x.searchCache = ra; +x.searchCache = ta; x.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { const h = this; return c.then(function() { - return h.export(a, g, b + 1, e = 0); + return h.export(a, g, b + 1); }); } - return this.export(a, g, b + 1, e = 0); + return this.export(a, g, b + 1); } let d, f; switch(e) { case 0: d = "reg"; - f = ka(this.reg); + f = la(this.reg); c = null; break; case 1: d = "tag"; - f = ja(this.tag); + f = ja(this.tag, this.reg.size); c = null; break; case 2: @@ -756,33 +787,36 @@ x.export = function(a, c, b = 0, e = 0) { default: return; } - return la.call(this, a, c, d, b, e, f); + return P.call(this, a, c, d, f, b, e); }; x.import = function(a, c) { if (c) { - switch(E(c) && (c = JSON.parse(c)), a) { - case "tag": - break; + E(c) && (c = JSON.parse(c)); + a = a.split("."); + "json" === a[a.length - 1] && a.pop(); + var b = 2 < a.length ? a[0] : ""; + a = 2 < a.length ? a[2] : a[1]; + if (b) { + return this.index.get(b).import(a, c); + } + switch(a) { case "reg": this.fastupdate = !1; - this.reg = new Set(c); + this.reg = ma(c, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; - case "doc": - this.store = new Map(c); + case "tag": + this.tag = ka(c, this.tag); break; - default: - a = a.split("."); - const b = a[0]; - a = a[1]; - b && a && this.index.get(b).import(a, c); + case "doc": + this.store = O(c, this.store); } } }; -ia(O.prototype); -function ra(a, c, b) { +ia(Q.prototype); +function ta(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); let e = this.cache.get(a); if (!e) { @@ -798,57 +832,57 @@ function ra(a, c, b) { } return e; } -function S(a) { +function T(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.A = ""; } -S.prototype.set = function(a, c) { +T.prototype.set = function(a, c) { this.cache.set(this.A = a, c); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -S.prototype.get = function(a) { +T.prototype.get = function(a) { const c = this.cache.get(a); c && this.A !== a && (this.cache.delete(a), this.cache.set(this.A = a, c)); return c; }; -S.prototype.remove = function(a) { +T.prototype.remove = function(a) { for (const c of this.cache) { const b = c[0]; c[1].includes(a) && this.cache.delete(b); } }; -S.prototype.clear = function() { +T.prototype.clear = function() { this.cache.clear(); this.A = ""; }; -const sa = {normalize:function(a) { +const ua = {normalize:function(a) { return a.toLowerCase(); }, dedupe:!1}; -const U = 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 ta = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), ua = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -const va = {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 wa = /[\x00-\x7F]+/g; -const xa = /[\x00-\x7F]+/g; -const ya = /[\x00-\x7F]+/g; -var za = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:sa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:U}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:U, matcher:ta, replacer:ua}, LatinExtra:{normalize:!0, dedupe:!0, mapper:U, replacer:ua.concat([/(?!^)[aeo]/g, ""]), matcher:ta}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +const va = 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 wa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), xa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const ya = {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 za = /[\x00-\x7F]+/g; +const Aa = /[\x00-\x7F]+/g; +const Ba = /[\x00-\x7F]+/g; +var Ca = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:ua, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:va}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:va, matcher:wa, replacer:xa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:va, replacer:xa.concat([/(?!^)[aeo]/g, ""]), matcher:wa}, 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 = va[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = va[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = ya[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = ya[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(wa, " "); + return ("" + a).replace(za, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(xa, ""); + return ("" + a).replace(Aa, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(ya, " "); + return ("" + a).replace(Ba, " "); }}}; -const Aa = {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 Da = {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(); -T.prototype.add = function(a, c, b, e) { +U.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { return this.update(a, c); @@ -914,7 +948,7 @@ function W(a, c, b, e, d, f, g) { function V(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 Ba(a, c, b) { +;function Ea(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; } @@ -944,7 +978,7 @@ function V(a, c, b, e, d) { } return e.length ? e = 1 < e.length ? [].concat.apply([], e) : e[0] : e; } -;T.prototype.search = function(a, c, b) { +;U.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) { @@ -1003,7 +1037,7 @@ function V(a, c, b, e, d) { } for (let n, t; l < b; l++) { t = a[l]; - m ? (n = Y(this, t, m), n = Ca(n, e, g, this.P), g && !1 === n && e.length || (m = t)) : (n = Y(this, t, ""), n = Ca(n, e, g, this.resolution)); + m ? (n = Y(this, t, m), n = Fa(n, e, g, this.P), g && !1 === n && e.length || (m = t)) : (n = Y(this, t, ""), n = Fa(n, e, g, this.resolution)); if (n) { return n; } @@ -1018,7 +1052,7 @@ function V(a, c, b, e, d) { return e; } if (1 === f) { - return Ba(e[0], c, d); + return Ea(e[0], c, d); } } } @@ -1078,9 +1112,9 @@ function V(a, c, b, e, d) { return e; }; function X(a, c, b, e) { - return (a = Y(this, a, c)) && a.length ? Ba(a, b, e) : []; + return (a = Y(this, a, c)) && a.length ? Ea(a, b, e) : []; } -function Ca(a, c, b, e) { +function Fa(a, c, b, e) { let d = []; if (a) { e = Math.min(a.length, e); @@ -1100,7 +1134,7 @@ function Y(a, c, b) { a = b ? (a = a.ctx.get(e ? c : b)) && a.get(e ? b : c) : a.map.get(c); return a; } -;T.prototype.remove = function(a, c) { +;U.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) { @@ -1115,14 +1149,14 @@ function Y(a, c, b) { } } } else { - Da(this.map, a), this.depth && Da(this.ctx, a); + Ga(this.map, a), this.depth && Ga(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function Da(a, c) { +function Ga(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1137,24 +1171,24 @@ function Da(a, c) { } } else { for (let e of a) { - const d = e[0], f = Da(e[1], c); + const d = e[0], f = Ga(e[1], c); f ? b += f : a.delete(d); } } return b; } -;function T(a, c) { - if (this.constructor !== T) { - return new T(a); +;function U(a, c) { + if (!this || this.constructor !== U) { + return new U(a); } if (a) { var b = E(a) ? a : a.preset; - b && (Aa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Aa[b], a)); + b && (Da[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Da[b], a)); } else { a = {}; } b = a.context || {}; - const e = E(a.encoder) ? za[a.encoder] : a.encode || a.encoder || sa; + const e = E(a.encoder) ? Ca[a.encoder] : a.encode || a.encoder || ua; this.encoder = e.encode ? e : "object" === typeof e ? new K(e) : {encode:e}; let d; this.resolution = a.resolution || 9; @@ -1169,9 +1203,9 @@ function Da(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 S(d); + this.cache = (d = a.cache || null) && new T(d); } -x = T.prototype; +x = U.prototype; x.clear = function() { this.map.clear(); this.ctx.clear(); @@ -1189,7 +1223,7 @@ 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 Ea(a) { +function Ha(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1197,7 +1231,7 @@ function Ea(a) { } } else { for (const b of a) { - const e = b[0], d = Ea(b[1]); + const e = b[0], d = Ha(b[1]); d ? c += d : a.delete(e); } } @@ -1207,17 +1241,17 @@ x.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Ea(this.map); - this.depth && Ea(this.ctx); + Ha(this.map); + this.depth && Ha(this.ctx); return this; }; -x.searchCache = ra; +x.searchCache = ta; x.export = function(a, c, b, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = ka(this.reg); + f = la(this.reg); break; case 1: d = "cfg"; @@ -1225,29 +1259,29 @@ x.export = function(a, c, b, e = 0) { break; case 2: d = "map"; - f = N(this.map); + f = N(this.map, this.reg.size); break; case 3: d = "ctx"; - f = ja(this.ctx); + f = ja(this.ctx, this.reg.size); break; default: return; } - return la.call(this, a, c, d, b, e, f); + return P.call(this, a, c, d, f, b, e); }; x.import = function(a, c) { if (c) { - switch(E(c) && (c = JSON.parse(c)), a) { + switch(E(c) && (c = JSON.parse(c)), 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(c); + this.reg = ma(c, this.reg); break; case "map": - this.map = new Map(c); + this.map = O(c, this.map); break; case "ctx": - this.ctx = new Map(c); + this.ctx = ka(c, this.ctx); } } }; @@ -1301,10 +1335,10 @@ x.serialize = function(a = !0) { d = "index.ctx=new Map([" + d + "]);"; return a ? "function inject(index){" + c + e + d + "}" : c + e + d; }; -ia(T.prototype); -const Fa = {Index:T, Charset:za, Encoder:K, Document:O, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, Z = self; -let Ga; -(Ga = Z.define) && Ga.amd ? Ga([], function() { - return Fa; -}) : "object" === typeof Z.exports ? Z.exports = Fa : Z.FlexSearch = Fa; +ia(U.prototype); +const Ia = {Index:U, Charset:Ca, Encoder:K, Document:Q, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, Z = self; +let Ja; +(Ja = Z.define) && Ja.amd ? Ja([], function() { + return Ia; +}) : "object" === typeof Z.exports ? Z.exports = Ia : Z.FlexSearch = Ia; }(this||self)); diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index 5f9ec2d..4e50808 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -5,47 +5,50 @@ * 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 x;function B(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var f of a)g.set(f[0],f[1]);return g}if(c===Set){f=new Set(b);for(g of a.values())f.add(g);return f}}}return a}return b}return"undefined"===d?c:a}function D(){return Object.create(null)}function aa(a,c){return c.length-a.length} -function E(a){return"string"===typeof a}function G(a){return"object"===typeof a}function I(a,c){if(E(c))a=a[c];else for(let b=0;a&&bthis.stemmer.get(l)),k=1);f&&k&&(f.length< +["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const ca=/[^\p{L}\p{N}]+/u,da=/(\d{3})/g,ea=/(\D)(\d{3})/g,fa=/(\d{3})(\D)/g,J="".normalize&&/[\u0300-\u036f]/g;function K(a){if(!this||this.constructor!==K)return new K(...arguments);for(let b=0;bthis.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.G.clear(),this.J=this.J/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.A&&(this.D.set(a,b),this.D.size>this.O&&(this.D.clear(),this.A=this.A/1.1|0));return b};function ha(a){a.I=null;a.D.clear();a.G.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 N(a){const c=[];for(const b of a.entries())c.push(b);return c}function ja(a){const c=[];for(const b of a.entries())c.push(N(b));return c}function ka(a){const c=[];for(const b of a.keys())c.push(b);return c}function la(a,c,b,e,d,g){if((b=a(c?c+"."+b:b,JSON.stringify(g)))&&b.then){const f=this;return b.then(function(){return f.export(a,c,e,d+1)})}return this.export(a,c,e,d+1)};O.prototype.add=function(a,c,b){G(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=oa.call(this,a));return a}} -function oa(a){const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -S.prototype.get=function(a){const c=this.cache.get(a);c&&this.A!==a&&(this.cache.delete(a),this.cache.set(this.A=a,c));return c};S.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};S.prototype.clear=function(){this.cache.clear();this.A=""};const sa={normalize:function(a){return a.toLowerCase()},dedupe:!1};const U=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 ta=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),ua=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const va={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 wa=/[\x00-\x7F]+/g;const xa=/[\x00-\x7F]+/g;const ya=/[\x00-\x7F]+/g;var za={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:sa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:U},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:U,matcher:ta,replacer:ua},LatinExtra:{normalize:!0,dedupe:!0,mapper:U,replacer:ua.concat([/(?!^)[aeo]/g,""]),matcher:ta},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):V(t,e,p,d,g);W(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;W(this,l,u?g:r,v,a,b,u?r:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function W(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]=D()),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 V(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 X(a,c,b,e){return(a=Y(this,a,c))&&a.length?Ba(a,b,e):[]}function Ca(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};T.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 Da(this.map,a),this.depth&&Da(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Da(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,g;eb.add(a,c)):this.add(a,c)}; -function Ea(a){let c=0;if(a.constructor===Array)for(let b=0,e;bthis.O&&(this.G.clear(),this.J=this.J/1.1|0));f&&c.push(f)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.A&&(this.D.set(a,c),this.D.size>this.O&&(this.D.clear(),this.A=this.A/1.1|0));return c};function ha(a){a.I=null;a.D.clear();a.G.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 b=arguments;const c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);b=this[a].apply(this,b);e&&(b.then?b.then(e):e(b));return b}};function N(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function O(a,b){b||(b=new Map);for(let c=0,e;cc||e)a=a.slice(e,e+c);d&&(a=qa.call(this,a));return a}} +function qa(a){const b=Array(a.length);for(let c=0,e;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +T.prototype.get=function(a){const b=this.cache.get(a);b&&this.A!==a&&(this.cache.delete(a),this.cache.set(this.A=a,b));return b};T.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};T.prototype.clear=function(){this.cache.clear();this.A=""};const ua={normalize:function(a){return a.toLowerCase()},dedupe:!1};const va=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 wa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),xa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const ya={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 za=/[\x00-\x7F]+/g;const Aa=/[\x00-\x7F]+/g;const Ba=/[\x00-\x7F]+/g;var Ca={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:ua,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:va},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:va,matcher:wa,replacer:xa},LatinExtra:{normalize:!0,dedupe:!0,mapper:va,replacer:xa.concat([/(?!^)[aeo]/g,""]),matcher:wa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cg;h--){f=r.substring(g,h);var k=this.score?this.score(b,r,p,f,g):V(t,e,p,d,g);W(this,m,f,k,a,c)}break}case "reverse":if(1< +d){for(h=d-1;0f?0:1),e,p,h-1,k-1),u=this.bidirectional&&r>g;W(this,l,u?g:r,v,a,c,u?r:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function W(a,b,c,e,d,g,f){let h=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])f?(b=k||(b[c]=D()),b[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=[]),h=h[e]||(h[e]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((b=a.reg.get(d))?b.push(h):a.reg.set(d,[h])))}function V(a,b,c,e,d){return c&&1b?b?a.slice(c,c+b):a.slice(c):a;let e=[];for(let d=0,g,f;d=f){c-=f;continue}cb&&(g=g.slice(0,b),f=g.length),e.push(g);else{if(f>=b)return f>b&&(g=g.slice(0,b)),g;e=[g]}b-=f;if(!b)break}return e.length?e=1b||d?f.slice(d,b+d):f;f=a}else{if(ab||d)f=f.slice(d,b+d)}e=f}return e}; +function X(a,b,c,e){return(a=Y(this,a,b))&&a.length?Ea(a,c,e):[]}function Fa(a,b,c,e){let d=[];if(a){e=Math.min(a.length,e);for(let g=0,f;gc);a=c?(a=a.ctx.get(e?b:c))&&a.get(e?c:b):a.map.get(b);return a};U.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const g=d.indexOf(a);g===c.length-1?d.pop():d.splice(g,1)}}else Ga(this.map,a),this.depth&&Ga(this.ctx,a);b||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Ga(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,g;ec.add(a,b)):this.add(a,b)}; +function Ha(a){let b=0;if(a.constructor===Array)for(let c=0,e;c b || e) { f = f.slice(e, e + b); } - d && (f = oa.call(this, f)); + d && (f = pa.call(this, f)); return f; } } -function oa(a) { +function pa(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)}; } return c; } -;function O(a) { - if (this.constructor !== O) { - return new O(a); +;function Q(a) { + if (!this || this.constructor !== Q) { + return new Q(a); } const c = a.document || a.doc || a; var b; this.C = []; this.field = []; this.H = []; - this.key = (b = c.key || c.id) && R(b, this.H) || "id"; + this.key = (b = c.key || c.id) && T(b, this.H) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); this.h = (b = c.store || null) && !0 !== b && []; this.store = b && new Map(); - this.cache = (b = a.cache || null) && new S(b); + this.cache = (b = a.cache || null) && new U(b); a.cache = !1; b = new Map(); let e = c.index || c.field || c; E(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], E(f) || (g = f, f = f.field), g = H(g) ? Object.assign({}, a, g) : a, b.set(f, new T(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = R(f, this.H), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].F = g.filter)), this.field[d] = f; + f = e[d], E(f) || (g = f, f = f.field), g = H(g) ? Object.assign({}, a, g) : a, b.set(f, new V(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = T(f, this.H), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].F = g.filter)), this.field[d] = f; } if (this.h) { a = c.store; E(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.h[d] = f.custom, f.custom.S = g) : (this.h[d] = R(g, this.H), f.filter && ("string" === typeof this.h[d] && (this.h[d] = new String(this.h[d])), this.h[d].F = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.h[d] = f.custom, f.custom.S = g) : (this.h[d] = T(g, this.H), f.filter && ("string" === typeof this.h[d] && (this.h[d] = new String(this.h[d])), this.h[d].F = f.filter)); } } this.index = b; @@ -646,14 +677,14 @@ function oa(a) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.B[d] = f.custom : (this.B[d] = R(g, this.H), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].F = f.filter)); + f.custom ? this.B[d] = f.custom : (this.B[d] = T(g, this.H), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].F = f.filter)); this.R[d] = g; this.tag.set(g, new Map()); } } } } -function R(a, c) { +function T(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { @@ -662,7 +693,7 @@ function R(a, c) { e < b.length && (b.length = e); return 1 < e ? b : b[0]; } -x = O.prototype; +x = Q.prototype; x.append = function(a, c) { return this.add(a, c, !0); }; @@ -718,28 +749,28 @@ x.set = function(a, c) { this.store.set(a, c); return this; }; -x.searchCache = ra; +x.searchCache = sa; x.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) { const h = this; return c.then(function() { - return h.export(a, g, b + 1, e = 0); + return h.export(a, g, b + 1); }); } - return this.export(a, g, b + 1, e = 0); + return this.export(a, g, b + 1); } let d, f; switch(e) { case 0: d = "reg"; - f = ka(this.reg); + f = la(this.reg); c = null; break; case 1: d = "tag"; - f = ja(this.tag); + f = ja(this.tag, this.reg.size); c = null; break; case 2: @@ -755,33 +786,36 @@ x.export = function(a, c, b = 0, e = 0) { default: return; } - return la.call(this, a, c, d, b, e, f); + return P.call(this, a, c, d, f, b, e); }; x.import = function(a, c) { if (c) { - switch(E(c) && (c = JSON.parse(c)), a) { - case "tag": - break; + E(c) && (c = JSON.parse(c)); + a = a.split("."); + "json" === a[a.length - 1] && a.pop(); + var b = 2 < a.length ? a[0] : ""; + a = 2 < a.length ? a[2] : a[1]; + if (b) { + return this.index.get(b).import(a, c); + } + switch(a) { case "reg": this.fastupdate = !1; - this.reg = new Set(c); + this.reg = ma(c, this.reg); for (let e = 0, d; e < this.field.length; e++) { d = this.index.get(this.field[e]), d.fastupdate = !1, d.reg = this.reg; } break; - case "doc": - this.store = new Map(c); + case "tag": + this.tag = ka(c, this.tag); break; - default: - a = a.split("."); - const b = a[0]; - a = a[1]; - b && a && this.index.get(b).import(a, c); + case "doc": + this.store = O(c, this.store); } } }; -ia(O.prototype); -function ra(a, c, b) { +ia(Q.prototype); +function sa(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); let e = this.cache.get(a); if (!e) { @@ -797,57 +831,57 @@ function ra(a, c, b) { } return e; } -function S(a) { +function U(a) { this.limit = a && !0 !== a ? a : 1000; this.cache = new Map(); this.A = ""; } -S.prototype.set = function(a, c) { +U.prototype.set = function(a, c) { this.cache.set(this.A = a, c); this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value); }; -S.prototype.get = function(a) { +U.prototype.get = function(a) { const c = this.cache.get(a); c && this.A !== a && (this.cache.delete(a), this.cache.set(this.A = a, c)); return c; }; -S.prototype.remove = function(a) { +U.prototype.remove = function(a) { for (const c of this.cache) { const b = c[0]; c[1].includes(a) && this.cache.delete(b); } }; -S.prototype.clear = function() { +U.prototype.clear = function() { this.cache.clear(); this.A = ""; }; -const sa = {normalize:function(a) { +const ta = {normalize:function(a) { return a.toLowerCase(); }, dedupe:!1}; -const U = 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 ta = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), ua = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -const va = {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 wa = /[\x00-\x7F]+/g; -const xa = /[\x00-\x7F]+/g; +const ua = 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 va = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), wa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +const xa = {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 ya = /[\x00-\x7F]+/g; -var za = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:sa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:U}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:U, matcher:ta, replacer:ua}, LatinExtra:{normalize:!0, dedupe:!0, mapper:U, replacer:ua.concat([/(?!^)[aeo]/g, ""]), matcher:ta}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +const za = /[\x00-\x7F]+/g; +const Aa = /[\x00-\x7F]+/g; +var Ba = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:ta, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:ua}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:ua, matcher:va, replacer:wa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:ua, replacer:wa.concat([/(?!^)[aeo]/g, ""]), matcher:va}, 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 = va[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = va[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = xa[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = xa[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(wa, " "); -}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(xa, ""); -}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { return ("" + a).replace(ya, " "); +}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { + return ("" + a).replace(za, ""); +}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { + return ("" + a).replace(Aa, " "); }}}; -const Aa = {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 Ca = {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(); -T.prototype.add = function(a, c, b, e) { +V.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { return this.update(a, c); @@ -859,15 +893,15 @@ T.prototype.add = function(a, c, b, e) { 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) : V(t, e, p), g = ""; + var f = this.score ? this.score(c, r, p, null, 0) : W(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 = r.substring(f, h); - var k = this.score ? this.score(c, r, p, g, f) : V(t, e, p, d, f); - W(this, m, g, k, a, b); + var k = this.score ? this.score(c, r, p, g, f) : W(t, e, p, d, f); + X(this, m, g, k, a, b); } } break; @@ -875,24 +909,24 @@ T.prototype.add = function(a, c, b, e) { case "reverse": if (1 < d) { for (h = d - 1; 0 < h; h--) { - g = r[h] + g, k = this.score ? this.score(c, r, p, g, h) : V(t, e, p, d, h), W(this, m, g, k, a, b); + g = r[h] + g, k = this.score ? this.score(c, r, p, g, h) : W(t, e, p, d, h), X(this, m, g, k, a, b); } g = ""; } case "forward": if (1 < d) { for (h = 0; h < d; h++) { - g += r[h], W(this, m, g, f, a, b); + g += r[h], X(this, m, g, f, a, b); } break; } default: - if (W(this, m, r, f, a, b), n && 1 < e && p < e - 1) { + if (X(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) : V(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), v = this.bidirectional && r > f; - W(this, l, v ? f : r, u, a, b, v ? r : f); + const u = this.score ? this.score(c, f, p, r, k) : W(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), v = this.bidirectional && r > f; + X(this, l, v ? f : r, u, a, b, v ? r : f); } } } @@ -904,16 +938,16 @@ T.prototype.add = function(a, c, b, e) { } return this; }; -function W(a, c, b, e, d, f, g) { +function X(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] = 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 V(a, c, b, e, d) { +function W(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 Ba(a, c, b) { +;function Da(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; } @@ -943,7 +977,7 @@ function V(a, c, b, e, d) { } return e.length ? e = 1 < e.length ? [].concat.apply([], e) : e[0] : e; } -;T.prototype.search = function(a, c, b) { +;V.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) { @@ -957,11 +991,11 @@ function V(a, c, b, e, d) { b = a.length; c || (c = 100); if (1 === b) { - return X.call(this, a[0], "", c, d); + return Y.call(this, a[0], "", c, d); } f = this.depth && !1 !== f; if (2 === b && f && !g) { - return X.call(this, a[0], a[1], c, d); + return Y.call(this, a[0], a[1], c, d); } var h = 0, k = 0; if (1 < b) { @@ -969,7 +1003,7 @@ function V(a, c, b, e, d) { const n = []; for (let t = 0, p; t < b; t++) { if ((p = a[t]) && !l[p]) { - if (g || Y(this, p)) { + if (g || Z(this, p)) { n.push(p), l[p] = 1; } else { return e; @@ -987,10 +1021,10 @@ function V(a, c, b, e, d) { } l = 0; if (1 === b) { - return X.call(this, a[0], "", c, d); + return Y.call(this, a[0], "", c, d); } if (2 === b && f && !g) { - return X.call(this, a[0], a[1], c, d); + return Y.call(this, a[0], a[1], c, d); } if (1 < b) { if (f) { @@ -1002,7 +1036,7 @@ function V(a, c, b, e, d) { } for (let n, t; l < b; l++) { t = a[l]; - m ? (n = Y(this, t, m), n = Ca(n, e, g, this.P), g && !1 === n && e.length || (m = t)) : (n = Y(this, t, ""), n = Ca(n, e, g, this.resolution)); + m ? (n = Z(this, t, m), n = Ea(n, e, g, this.P), g && !1 === n && e.length || (m = t)) : (n = Z(this, t, ""), n = Ea(n, e, g, this.resolution)); if (n) { return n; } @@ -1017,7 +1051,7 @@ function V(a, c, b, e, d) { return e; } if (1 === f) { - return Ba(e[0], c, d); + return Da(e[0], c, d); } } } @@ -1076,10 +1110,10 @@ function V(a, c, b, e, d) { } return e; }; -function X(a, c, b, e) { - return (a = Y(this, a, c)) && a.length ? Ba(a, b, e) : []; +function Y(a, c, b, e) { + return (a = Z(this, a, c)) && a.length ? Da(a, b, e) : []; } -function Ca(a, c, b, e) { +function Ea(a, c, b, e) { let d = []; if (a) { e = Math.min(a.length, e); @@ -1093,13 +1127,13 @@ function Ca(a, c, b, e) { } return !b && d; } -function Y(a, c, b) { +function Z(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; } -;T.prototype.remove = function(a, c) { +;V.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) { @@ -1114,14 +1148,14 @@ function Y(a, c, b) { } } } else { - Z(this.map, a), this.depth && Z(this.ctx, a); + Fa(this.map, a), this.depth && Fa(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function Z(a, c) { +function Fa(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1136,24 +1170,24 @@ function Z(a, c) { } } else { for (let e of a) { - const d = e[0], f = Z(e[1], c); + const d = e[0], f = Fa(e[1], c); f ? b += f : a.delete(d); } } return b; } -;function T(a, c) { - if (this.constructor !== T) { - return new T(a); +;function V(a, c) { + if (!this || this.constructor !== V) { + return new V(a); } if (a) { var b = E(a) ? a : a.preset; - b && (Aa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Aa[b], a)); + b && (Ca[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Ca[b], a)); } else { a = {}; } b = a.context || {}; - const e = E(a.encoder) ? za[a.encoder] : a.encode || a.encoder || sa; + const e = E(a.encoder) ? Ba[a.encoder] : a.encode || a.encoder || ta; this.encoder = e.encode ? e : "object" === typeof e ? new K(e) : {encode:e}; let d; this.resolution = a.resolution || 9; @@ -1168,9 +1202,9 @@ function Z(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 S(d); + this.cache = (d = a.cache || null) && new U(d); } -x = T.prototype; +x = V.prototype; x.clear = function() { this.map.clear(); this.ctx.clear(); @@ -1188,7 +1222,7 @@ 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 Da(a) { +function Ga(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1196,7 +1230,7 @@ function Da(a) { } } else { for (const b of a) { - const e = b[0], d = Da(b[1]); + const e = b[0], d = Ga(b[1]); d ? c += d : a.delete(e); } } @@ -1206,17 +1240,17 @@ x.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Da(this.map); - this.depth && Da(this.ctx); + Ga(this.map); + this.depth && Ga(this.ctx); return this; }; -x.searchCache = ra; +x.searchCache = sa; x.export = function(a, c, b, e = 0) { let d, f; switch(e) { case 0: d = "reg"; - f = ka(this.reg); + f = la(this.reg); break; case 1: d = "cfg"; @@ -1224,29 +1258,29 @@ x.export = function(a, c, b, e = 0) { break; case 2: d = "map"; - f = N(this.map); + f = N(this.map, this.reg.size); break; case 3: d = "ctx"; - f = ja(this.ctx); + f = ja(this.ctx, this.reg.size); break; default: return; } - return la.call(this, a, c, d, b, e, f); + return P.call(this, a, c, d, f, b, e); }; x.import = function(a, c) { if (c) { - switch(E(c) && (c = JSON.parse(c)), a) { + switch(E(c) && (c = JSON.parse(c)), 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(c); + this.reg = ma(c, this.reg); break; case "map": - this.map = new Map(c); + this.map = O(c, this.map); break; case "ctx": - this.ctx = new Map(c); + this.ctx = ka(c, this.ctx); } } }; @@ -1300,7 +1334,7 @@ x.serialize = function(a = !0) { d = "index.ctx=new Map([" + d + "]);"; return a ? "function inject(index){" + c + e + d + "}" : c + e + d; }; -ia(T.prototype); -export default {Index:T, Charset:za, Encoder:K, Document:O, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; +ia(V.prototype); +export default {Index:V, Charset:Ba, Encoder:K, Document:Q, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; -export const Index=T;export const Charset=za;export const Encoder=K;export const Document=O;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file +export const Index=V;export const Charset=Ba;export const Encoder=K;export const Document=Q;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 04c5911..d4b46d5 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -5,48 +5,51 @@ * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ -var x;function B(a,c,b){const e=typeof b,d=typeof a;if("undefined"!==e){if("undefined"!==d){if(b){if("function"===d&&e===d)return function(h){return a(b(h))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var g=new Map(b);for(var f of a)g.set(f[0],f[1]);return g}if(c===Set){f=new Set(b);for(g of a.values())f.add(g);return f}}}return a}return b}return"undefined"===d?c:a}function D(){return Object.create(null)}function aa(a,c){return c.length-a.length} -function E(a){return"string"===typeof a}function G(a){return"object"===typeof a}function I(a,c){if(E(c))a=a[c];else for(let b=0;a&&bthis.stemmer.get(l)),k=1);f&&k&&(f.length< +["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];const ca=/[^\p{L}\p{N}]+/u,da=/(\d{3})/g,ea=/(\D)(\d{3})/g,fa=/(\d{3})(\D)/g,J="".normalize&&/[\u0300-\u036f]/g;function K(a){if(!this||this.constructor!==K)return new K(...arguments);for(let b=0;bthis.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.G.clear(),this.J=this.J/1.1|0));f&&b.push(f)}this.finalize&&(b=this.finalize(b)||b);this.cache&&a.length<=this.A&&(this.D.set(a,b),this.D.size>this.O&&(this.D.clear(),this.A=this.A/1.1|0));return b};function ha(a){a.I=null;a.D.clear();a.G.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 N(a){const c=[];for(const b of a.entries())c.push(b);return c}function ja(a){const c=[];for(const b of a.entries())c.push(N(b));return c}function ka(a){const c=[];for(const b of a.keys())c.push(b);return c}function la(a,c,b,e,d,g){if((b=a(c?c+"."+b:b,JSON.stringify(g)))&&b.then){const f=this;return b.then(function(){return f.export(a,c,e,d+1)})}return this.export(a,c,e,d+1)};O.prototype.add=function(a,c,b){G(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=oa.call(this,a));return a}} -function oa(a){const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -S.prototype.get=function(a){const c=this.cache.get(a);c&&this.A!==a&&(this.cache.delete(a),this.cache.set(this.A=a,c));return c};S.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};S.prototype.clear=function(){this.cache.clear();this.A=""};const sa={normalize:function(a){return a.toLowerCase()},dedupe:!1};const U=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 ta=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),ua=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const va={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 wa=/[\x00-\x7F]+/g;const xa=/[\x00-\x7F]+/g;const ya=/[\x00-\x7F]+/g;var za={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:sa,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:U},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:U,matcher:ta,replacer:ua},LatinExtra:{normalize:!0,dedupe:!0,mapper:U,replacer:ua.concat([/(?!^)[aeo]/g,""]),matcher:ta},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):V(t,e,p,d,g);W(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;W(this,l,u?g:r,v,a,b,u?r:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; -function W(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]=D()),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 V(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 X(a,c,b,e){return(a=Y(this,a,c))&&a.length?Ba(a,b,e):[]}function Ca(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};T.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 Z(this.map,a),this.depth&&Z(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Z(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,g;eb.add(a,c)):this.add(a,c)}; -function Da(a){let c=0;if(a.constructor===Array)for(let b=0,e;bthis.O&&(this.G.clear(),this.J=this.J/1.1|0));f&&c.push(f)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.A&&(this.D.set(a,c),this.D.size>this.O&&(this.D.clear(),this.A=this.A/1.1|0));return c};function ha(a){a.I=null;a.D.clear();a.G.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 b=arguments;const c=b[b.length-1];let e;"function"===typeof c&&(e=c,delete b[b.length-1]);b=this[a].apply(this,b);e&&(b.then?b.then(e):e(b));return b}};function N(a,b=0){let c=[],e=[];b&&(b=25E4/b*5E3|0);for(const d of a.entries())e.push(d),e.length===b&&(c.push(e),e=[]);e.length&&c.push(e);return c}function O(a,b){b||(b=new Map);for(let c=0,e;cc||e)a=a.slice(e,e+c);d&&(a=pa.call(this,a));return a}} +function pa(a){const b=Array(a.length);for(let c=0,e;cthis.limit&&this.cache.delete(this.cache.keys().next().value)}; +U.prototype.get=function(a){const b=this.cache.get(a);b&&this.A!==a&&(this.cache.delete(a),this.cache.set(this.A=a,b));return b};U.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};U.prototype.clear=function(){this.cache.clear();this.A=""};const ta={normalize:function(a){return a.toLowerCase()},dedupe:!1};const ua=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 va=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),wa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const xa={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 ya=/[\x00-\x7F]+/g;const za=/[\x00-\x7F]+/g;const Aa=/[\x00-\x7F]+/g;var Ba={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:ta,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:ua},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:ua,matcher:va,replacer:wa},LatinExtra:{normalize:!0,dedupe:!0,mapper:ua,replacer:wa.concat([/(?!^)[aeo]/g,""]),matcher:va},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cg;h--){f=r.substring(g,h);var k=this.score?this.score(b,r,p,f,g):W(t,e,p,d,g);X(this,m,f,k,a,c)}break}case "reverse":if(1< +d){for(h=d-1;0f?0:1),e,p,h-1,k-1),u=this.bidirectional&&r>g;X(this,l,u?g:r,v,a,c,u?r:g)}}}}this.fastupdate||this.reg.add(a)}}return this}; +function X(a,b,c,e,d,g,f){let h=f?a.ctx:a.map,k;if(!b[c]||f&&!(k=b[c])[f])f?(b=k||(b[c]=D()),b[f]=1,(k=h.get(f))?h=k:h.set(f,h=new Map)):b[c]=1,(k=h.get(c))?h=k:h.set(c,h=[]),h=h[e]||(h[e]=[]),g&&h.includes(d)||(h.push(d),a.fastupdate&&((b=a.reg.get(d))?b.push(h):a.reg.set(d,[h])))}function W(a,b,c,e,d){return c&&1b?b?a.slice(c,c+b):a.slice(c):a;let e=[];for(let d=0,g,f;d=f){c-=f;continue}cb&&(g=g.slice(0,b),f=g.length),e.push(g);else{if(f>=b)return f>b&&(g=g.slice(0,b)),g;e=[g]}b-=f;if(!b)break}return e.length?e=1b||d?f.slice(d,b+d):f;f=a}else{if(ab||d)f=f.slice(d,b+d)}e=f}return e}; +function Y(a,b,c,e){return(a=Z(this,a,b))&&a.length?Da(a,c,e):[]}function Ea(a,b,c,e){let d=[];if(a){e=Math.min(a.length,e);for(let g=0,f;gc);a=c?(a=a.ctx.get(e?b:c))&&a.get(e?c:b):a.map.get(b);return a};V.prototype.remove=function(a,b){const c=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(c){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const g=d.indexOf(a);g===c.length-1?d.pop():d.splice(g,1)}}else Fa(this.map,a),this.depth&&Fa(this.ctx,a);b||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function Fa(a,b){let c=0;if(a.constructor===Array)for(let e=0,d,g;ec.add(a,b)):this.add(a,b)}; +function Ga(a){let b=0;if(a.constructor===Array)for(let c=0,e;c= f.length) { b -= f.length; @@ -1248,12 +1281,12 @@ function S(a) { } if ("slice" === d) { return function(e, g) { - return Ta(b, e || 0, g || b.length, !1); + return Wa(b, e || 0, g || b.length, !1); }; } if ("splice" === d) { return function(e, g) { - return Ta(b, e || 0, g || b.length, !0); + return Wa(b, e || 0, g || b.length, !0); }; } if ("constructor" === d) { @@ -1285,7 +1318,7 @@ function T(a) { this.index = J(); this.B = []; this.size = 0; - 32 < a ? (this.h = Ua, this.A = BigInt(a)) : (this.h = Va, this.A = a); + 32 < a ? (this.h = Xa, this.A = BigInt(a)) : (this.h = Ya, this.A = a); } T.prototype.get = function(a) { var b = this.h(a); @@ -1302,7 +1335,7 @@ function U(a) { } this.index = J(); this.h = []; - 32 < a ? (this.B = Ua, this.A = BigInt(a)) : (this.B = Va, this.A = a); + 32 < a ? (this.B = Xa, this.A = BigInt(a)) : (this.B = Ya, this.A = a); } U.prototype.add = function(a) { var b = this.B(a), c = this.index[b]; @@ -1322,9 +1355,9 @@ v.clear = U.prototype.clear = function() { this.h = []; this.size = 0; }; -v.values = U.prototype.values = function Wa() { +v.values = U.prototype.values = function Za() { var b, c = this, d, e, g; - return ra(Wa, function(f) { + return ra(Za, function(f) { switch(f.h) { case 1: b = 0; @@ -1348,9 +1381,9 @@ v.values = U.prototype.values = function Wa() { } }); }; -v.keys = U.prototype.keys = function Xa() { +v.keys = U.prototype.keys = function $a() { var b, c = this, d, e, g; - return ra(Xa, function(f) { + return ra($a, function(f) { switch(f.h) { case 1: b = 0; @@ -1374,9 +1407,9 @@ v.keys = U.prototype.keys = function Xa() { } }); }; -v.entries = U.prototype.entries = function Ya() { +v.entries = U.prototype.entries = function ab() { var b, c = this, d, e, g; - return ra(Ya, function(f) { + return ra(ab, function(f) { switch(f.h) { case 1: b = 0; @@ -1400,7 +1433,7 @@ v.entries = U.prototype.entries = function Ya() { } }); }; -function Va(a) { +function Ya(a) { var b = Math.pow(2, this.A) - 1; if ("number" == typeof a) { return a & b; @@ -1410,7 +1443,7 @@ function Va(a) { } return 32 === this.A ? c + Math.pow(2, 31) : c; } -function Ua() { +function Xa() { throw Error("The keystore is limited to 32 for EcmaScript5"); } ;V.prototype.add = function(a, b, c) { @@ -1427,7 +1460,7 @@ function Ua() { } else { var f = e.R; if (!f || f(b)) { - e.constructor === String ? e = ["" + e] : K(e) && (e = [e]), Za(b, e, this.T, 0, g, a, e[0], c); + e.constructor === String ? e = ["" + e] : K(e) && (e = [e]), bb(b, e, this.T, 0, g, a, e[0], c); } } } @@ -1492,7 +1525,7 @@ function Ua() { q[d] = b[d]; continue; } - $a(b, q, d, 0, d[0], g); + cb(b, q, d, 0, d[0], g); } } } @@ -1501,21 +1534,21 @@ function Ua() { } return this; }; -function $a(a, b, c, d, e, g) { +function cb(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++) { - $a(a, b, c, d, e); + cb(a, b, c, d, e); } } else { - b = b[e] || (b[e] = J()), e = c[++d], $a(a, b, c, d, e); + b = b[e] || (b[e] = J()), e = c[++d], cb(a, b, c, d, e); } } } -function Za(a, b, c, d, e, g, f, h) { +function bb(a, b, c, d, e, g, f, h) { if (a = a[f]) { if (d === b.length - 1) { if (a.constructor === Array) { @@ -1531,17 +1564,17 @@ function Za(a, b, c, d, e, g, f, h) { } else { if (a.constructor === Array) { for (f = 0; f < a.length; f++) { - Za(a, b, c, d, e, g, f, h); + bb(a, b, c, d, e, g, f, h); } } else { - f = b[++d], Za(a, b, c, d, e, g, f, h); + f = b[++d], bb(a, b, c, d, e, g, f, h); } } } else { e.db && e.remove(g); } } -;function ab(a, b, c, d, e, g, f) { +;function db(a, b, c, d, e, g, f) { var h = a.length, k = [], l; var m = J(); for (var n = 0, p = void 0, q; n < b; n++) { @@ -1562,7 +1595,7 @@ function Za(a, b, c, d, e, g, f, h) { } if (a = k.length) { if (e) { - k = 1 < k.length ? bb(k, d, c, f, 0) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; + k = 1 < k.length ? eb(k, d, c, f, 0) : (k = k[0]).length > c || d ? k.slice(d, c + d) : k; } else { if (a < h) { return []; @@ -1595,7 +1628,7 @@ function Za(a, b, c, d, e, g, f, h) { } return k; } -function bb(a, b, c, d, e) { +function eb(a, b, c, d, e) { var g = [], f = J(), h = a.length, k = 0; if (d) { for (e = h - 1; 0 <= e; e--) { @@ -1637,7 +1670,7 @@ function bb(a, b, c, d, e) { } return g; } -function cb(a, b) { +function fb(a, b) { for (var c = J(), d = [], e = 0, g; e < b.length; e++) { g = b[e]; for (var f = 0; f < g.length; f++) { @@ -1712,7 +1745,7 @@ function cb(a, b) { } g.push(p = p.db.tag(u[h + 1], b, r, n)); } else { - p = db.call(this, u[h], u[h + 1], b, r, n); + p = gb.call(this, u[h], u[h + 1], b, r, n); } e.push({field:u[h], tag:u[h + 1], result:p}); } @@ -1772,7 +1805,7 @@ function cb(a, b) { } } else { D = 0; - for (var Lb = L = void 0; D < m.length; D += 2) { + for (var Ob = L = void 0; D < m.length; D += 2) { L = this.tag.get(m[D]); if (!L) { if (console.warn("Tag '" + m[D] + ":" + m[D + 1] + "' will be skipped because there is no field '" + m[D] + "'."), p) { @@ -1781,7 +1814,7 @@ function cb(a, b) { return e; } } - if (Lb = (L = L && L.get(m[D + 1])) && L.length) { + if (Ob = (L = L && L.get(m[D + 1])) && L.length) { B++, A.push(L); } else if (!p) { return e; @@ -1789,7 +1822,7 @@ function cb(a, b) { } } if (B) { - t = cb(t, A); + t = fb(t, A); z = t.length; if (!z && !p) { return e; @@ -1818,9 +1851,9 @@ function cb(a, b) { u.push(g.db.tag(m[n + 1], b, r, !1)); } } - var Mb = this; + var Pb = this; return Promise.all(u).then(function(P) { - return P.length ? Mb.search(a, b, c, P) : P; + return P.length ? Pb.search(a, b, c, P) : P; }); } if (!f) { @@ -1833,24 +1866,24 @@ function cb(a, b) { r = 0; for (p = void 0; r < g.length; r++) { p = e[r]; - n && p.length && !p[0].doc && (this.db ? u.push(p = this.index.get(this.field[0]).db.enrich(p)) : p.length && (p = eb.call(this, p))); + n && p.length && !p[0].doc && (this.db ? u.push(p = this.index.get(this.field[0]).db.enrich(p)) : p.length && (p = hb.call(this, p))); if (h) { return p; } e[r] = {field:g[r], result:p}; } if (n && this.db && u.length) { - var Ea = this; + var Ga = this; return Promise.all(u).then(function(P) { for (var Q = 0; Q < P.length; Q++) { e[Q].result = P[Q]; } - return k ? fb(e, b) : q ? gb(e, a, Ea.index, Ea.field, Ea.I, q) : e; + return k ? ib(e, b) : q ? jb(e, a, Ga.index, Ga.field, Ga.I, q) : e; }); } - return k ? fb(e, b) : q ? gb(e, a, this.index, this.field, this.I, q) : e; + return k ? ib(e, b) : q ? jb(e, a, this.index, this.field, this.I, q) : e; }; -function gb(a, b, c, d, e, g) { +function jb(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 = za(m[p].doc, n), u = f.encode(r); @@ -1881,7 +1914,7 @@ function gb(a, b, c, d, e, g) { } return a; } -function fb(a, b) { +function ib(a, b) { for (var c = [], d = J(), e = 0, g, f; e < a.length; e++) { g = a[e]; f = g.result; @@ -1899,7 +1932,7 @@ function fb(a, b) { } return c; } -function db(a, b, c, d, e) { +function gb(a, b, c, d, e) { var g = this.tag.get(a); if (!g) { return console.warn("Tag '" + a + "' was not found"), []; @@ -1908,25 +1941,25 @@ function db(a, b, c, d, e) { if (a > c || d) { g = g.slice(d, d + c); } - e && (g = eb.call(this, g)); + e && (g = hb.call(this, g)); return g; } } -function eb(a) { +function hb(a) { for (var b = Array(a.length), c = 0, d; c < a.length; c++) { d = a[c], b[c] = {id:d, doc:this.store.get(d)}; } return b; } ;function V(a) { - if (this.constructor !== V) { + if (!this || this.constructor !== V) { return new V(a); } var b = a.document || a.doc || a, c, d; this.I = []; this.field = []; this.T = []; - this.key = (c = b.key || b.id) && hb(c, this.T) || "id"; + this.key = (c = b.key || b.id) && kb(c, this.T) || "id"; (d = a.keystore || 0) && (this.keystore = d); this.reg = (this.fastupdate = !!a.fastupdate) ? d ? new T(d) : new Map() : d ? new U(d) : new Set(); this.H = (c = b.store || null) && !0 !== c && []; @@ -1934,7 +1967,7 @@ function eb(a) { this.cache = (c = a.cache || null) && new W(c); a.cache = !1; this.worker = a.worker; - this.index = ib.call(this, a, b); + this.index = lb.call(this, a, b); this.tag = null; if (c = b.tag) { if ("string" === typeof c && (c = [c]), c.length) { @@ -1948,7 +1981,7 @@ function eb(a) { if (!e) { throw Error("The tag field from the document descriptor is undefined."); } - d.custom ? this.M[b] = d.custom : (this.M[b] = hb(e, this.T), d.filter && ("string" === typeof this.M[b] && (this.M[b] = new String(this.M[b])), this.M[b].R = d.filter)); + d.custom ? this.M[b] = d.custom : (this.M[b] = kb(e, this.T), d.filter && ("string" === typeof this.M[b] && (this.M[b] = new String(this.M[b])), this.M[b].R = d.filter)); this.$[b] = e; this.tag.set(e, new Map()); } @@ -2024,7 +2057,7 @@ v.destroy = function() { } return Promise.all(a); }; -function ib(a, b) { +function lb(a, b) { var c = new Map(), d = b.index || b.field || b; K(d) && (d = [d]); for (var e = 0, g, f = void 0; e < d.length; e++) { @@ -2036,17 +2069,17 @@ function ib(a, b) { c.set(g, h); } this.worker || c.set(g, new O(f, this.reg)); - f.custom ? this.I[e] = f.custom : (this.I[e] = hb(g, this.T), f.filter && ("string" === typeof this.I[e] && (this.I[e] = new String(this.I[e])), this.I[e].R = f.filter)); + f.custom ? this.I[e] = f.custom : (this.I[e] = kb(g, this.T), f.filter && ("string" === typeof this.I[e] && (this.I[e] = new String(this.I[e])), this.I[e].R = f.filter)); this.field[e] = g; } if (this.H) { for (a = b.store, K(a) && (a = [a]), b = 0; b < a.length; b++) { - d = a[b], e = d.field || d, d.custom ? (this.H[b] = d.custom, d.custom.la = e) : (this.H[b] = hb(e, this.T), d.filter && ("string" === typeof this.H[b] && (this.H[b] = new String(this.H[b])), this.H[b].R = d.filter)); + d = a[b], e = d.field || d, d.custom ? (this.H[b] = d.custom, d.custom.la = e) : (this.H[b] = kb(e, this.T), d.filter && ("string" === typeof this.H[b] && (this.H[b] = new String(this.H[b])), this.H[b].R = d.filter)); } } return c; } -function hb(a, b) { +function kb(a, b) { for (var c = a.split(":"), d = 0, e = 0; e < c.length; e++) { a = c[e], "]" === a[a.length - 1] && (a = a.substring(0, a.length - 2)) && (b[d] = !0), a && (c[d++] = a); } @@ -2113,7 +2146,7 @@ v.set = function(a, b) { this.store.set(a, b); return this; }; -v.searchCache = jb; +v.searchCache = mb; v.export = function(a, b, c, d) { c = void 0 === c ? 0 : c; d = void 0 === d ? 0 : d; @@ -2122,20 +2155,20 @@ v.export = function(a, b, c, d) { if ((b = this.index.get(e).export(a, e, c, d = 1)) && b.then) { var g = this; return b.then(function() { - return g.export(a, e, c + 1, d = 0); + return g.export(a, e, c + 1); }); } - return this.export(a, e, c + 1, d = 0); + return this.export(a, e, c + 1); } switch(d) { case 0: var f = "reg"; - var h = Ra(this.reg); + var h = Ta(this.reg); b = null; break; case 1: f = "tag"; - h = Qa(this.tag); + h = Ra(this.tag, this.reg.size); b = null; break; case 2: @@ -2151,33 +2184,36 @@ v.export = function(a, b, c, d) { default: return; } - return Sa.call(this, a, b, f, c, d, h); + return Va.call(this, a, b, f, h, c, d); }; v.import = function(a, b) { if (b) { - switch(K(b) && (b = JSON.parse(b)), a) { - case "tag": - break; + K(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 = Ua(b, this.reg); for (a = 0; a < this.field.length; a++) { b = this.index.get(this.field[a]), b.fastupdate = !1, b.reg = this.reg; } break; - case "doc": - this.store = new Map(b); + case "tag": + this.tag = Sa(b, this.tag); break; - default: - a = a.split("."); - var c = a[0]; - a = a[1]; - c && a && this.index.get(c).import(a, b); + case "doc": + this.store = Qa(b, this.store); } } }; Na(V.prototype); -function jb(a, b, c) { +function mb(a, b, c) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); var d = this.cache.get(a); if (!d) { @@ -2218,29 +2254,29 @@ W.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -var kb = {normalize:function(a) { +var nb = {normalize:function(a) { return a.toLowerCase(); }, dedupe:!1}; -var lb = 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 mb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), nb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; -var ob = {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 pb = /[\x00-\x7F]+/g; -var qb = /[\x00-\x7F]+/g; -var rb = /[\x00-\x7F]+/g; -var sb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:kb, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:lb}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:lb, matcher:mb, replacer:nb}, LatinExtra:{normalize:!0, dedupe:!0, mapper:lb, replacer:nb.concat([/(?!^)[aeo]/g, ""]), matcher:mb}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +var ob = 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 pb = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), qb = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"]; +var rb = {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 sb = /[\x00-\x7F]+/g; +var tb = /[\x00-\x7F]+/g; +var ub = /[\x00-\x7F]+/g; +var vb = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:nb, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:ob}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:ob, matcher:pb, replacer:qb}, LatinExtra:{normalize:!0, dedupe:!0, mapper:ob, replacer:qb.concat([/(?!^)[aeo]/g, ""]), matcher:pb}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (var b = 0; b < a.length; b++) { - for (var c = a[b], d = c.charAt(0), e = ob[d], g = 1, f; g < c.length && (f = c.charAt(g), "h" === f || "w" === f || !(f = ob[f]) || f === e || (d += f, e = f, 4 !== d.length)); g++) { + for (var c = a[b], d = c.charAt(0), e = rb[d], g = 1, f; g < c.length && (f = c.charAt(g), "h" === f || "w" === f || !(f = rb[f]) || f === e || (d += f, e = f, 4 !== d.length)); g++) { } a[b] = d; } }}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(pb, " "); + return ("" + a).replace(sb, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(qb, ""); + return ("" + a).replace(tb, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(rb, " "); + return ("" + a).replace(ub, " "); }}}; -var tb = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; +var wb = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}}; J(); O.prototype.add = function(a, b, c, d) { if (b && (a || 0 === a)) { @@ -2252,15 +2288,15 @@ O.prototype.add = function(a, b, c, d) { for (var e = J(), g = J(), f = this.depth, h = this.resolution, k = 0; k < d; k++) { var l = b[this.rtl ? d - 1 - k : k], m = l.length; if (m && (f || !g[l])) { - var n = this.score ? this.score(b, l, k, null, 0) : ub(h, d, k), p = ""; + var n = this.score ? this.score(b, l, k, null, 0) : xb(h, d, k), p = ""; switch(this.tokenize) { case "full": if (2 < m) { for (n = 0; n < m; n++) { for (var q = m; q > n; q--) { p = l.substring(n, q); - var r = this.score ? this.score(b, l, k, p, n) : ub(h, d, k, m, n); - vb(this, g, p, r, a, c); + var r = this.score ? this.score(b, l, k, p, n) : xb(h, d, k, m, n); + yb(this, g, p, r, a, c); } } break; @@ -2268,24 +2304,24 @@ O.prototype.add = function(a, b, c, d) { case "reverse": if (1 < m) { for (q = m - 1; 0 < q; q--) { - p = l[q] + p, r = this.score ? this.score(b, l, k, p, q) : ub(h, d, k, m, q), vb(this, g, p, r, a, c); + p = l[q] + p, r = this.score ? this.score(b, l, k, p, q) : xb(h, d, k, m, q), yb(this, g, p, r, a, c); } p = ""; } case "forward": if (1 < m) { for (q = 0; q < m; q++) { - p += l[q], vb(this, g, p, n, a, c); + p += l[q], yb(this, g, p, n, a, c); } break; } default: - if (vb(this, g, l, n, a, c), f && 1 < d && k < d - 1) { + if (yb(this, g, l, n, a, c), f && 1 < d && k < d - 1) { for (m = J(), 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) : ub(p + (d / 2 > p ? 0 : 1), d, k, q - 1, r - 1), w = this.bidirectional && l > n; - vb(this, e, w ? n : l, u, a, c, w ? l : n); + var u = this.score ? this.score(b, n, k, l, r) : xb(p + (d / 2 > p ? 0 : 1), d, k, q - 1, r - 1), w = this.bidirectional && l > n; + yb(this, e, w ? n : l, u, a, c, w ? l : n); } } } @@ -2297,10 +2333,10 @@ O.prototype.add = function(a, b, c, d) { b = ""; } } - this.db && (b || this.commit_task.push({del:a}), this.da && wb(this)); + this.db && (b || this.commit_task.push({del:a}), this.da && zb(this)); return this; }; -function vb(a, b, c, d, e, g, f) { +function yb(a, b, c, d, e, g, f) { var h = f ? a.ctx : a.map, k; if (!b[c] || f && !(k = b[c])[f]) { if (f ? (b = k || (b[c] = J()), b[f] = 1, (k = h.get(f)) ? h = k : h.set(f, h = new Map())) : b[c] = 1, (k = h.get(c)) ? h = k : h.set(c, h = k = []), h = h[d] || (h[d] = []), !g || !h.includes(e)) { @@ -2318,12 +2354,12 @@ function vb(a, b, c, d, e, g, f) { } } } -function ub(a, b, c, d, e) { +function xb(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 X(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 ? xb(a) : a; + return a = a[0], a = c || a.length > b ? b ? a.slice(c, c + b) : a.slice(c) : a, d ? Ab(a) : a; } for (var e = [], g = 0, f = void 0, h = void 0; g < a.length; g++) { if ((f = a[g]) && (h = f.length)) { @@ -2338,7 +2374,7 @@ function ub(a, b, c, d, e) { h > b && (f = f.slice(0, b), h = f.length), e.push(f); } else { if (h >= b) { - return h > b && (f = f.slice(0, b)), d ? xb(f) : f; + return h > b && (f = f.slice(0, b)), d ? Ab(f) : f; } e = [f]; } @@ -2352,9 +2388,9 @@ function ub(a, b, c, d, e) { return e; } e = 1 < e.length ? [].concat.apply([], e) : e[0]; - return d ? xb(e) : e; + return d ? Ab(e) : e; } -function xb(a) { +function Ab(a) { for (var b = 0; b < a.length; b++) { a[b] = {score:b, id:a[b]}; } @@ -2401,19 +2437,19 @@ function xb(a) { if (c.length) { return Promise.all(c).then(function() { a.result.length && (d = d.concat([a.result])); - a.result = yb(d, e, g, f, h, a.J); + a.result = Bb(d, e, g, f, h, a.J); return h ? a.result : a; }); } - d.length && (this.result.length && (d = d.concat([this.result])), this.result = yb(d, e, g, f, h, this.J)); + d.length && (this.result.length && (d = d.concat([this.result])), this.result = Bb(d, e, g, f, h, this.J)); return h ? this.result : this; }; -function yb(a, b, c, d, e, g) { +function Bb(a, b, c, d, e, g) { 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 ? X(a[0], b, c, d) : a[0] : bb(a, c, b, e, g); + return 2 > a.length ? e ? X(a[0], b, c, d) : a[0] : eb(a, c, b, e, g); } ;Y.prototype.and = function() { if (this.result.length) { @@ -2460,24 +2496,24 @@ function yb(a, b, c, d, e, g) { if (c.length) { return Promise.all(c).then(function() { d = [a.result].concat(d); - a.result = zb(d, e, g, f, a.J, h); + a.result = Cb(d, e, g, f, a.J, h); return f ? a.result : a; }); } d = [this.result].concat(d); - this.result = zb(d, e, g, f, this.J, h); + this.result = Cb(d, e, g, f, this.J, h); return f ? this.result : this; } return this; }; -function zb(a, b, c, d, e, g) { +function Cb(a, b, c, d, e, g) { if (2 > a.length) { return []; } var f = []; J(); var h = Aa(a); - return h ? ab(a, h, b, c, g, e, d) : f; + return h ? db(a, h, b, c, g, e, d) : f; } ;Y.prototype.xor = function() { var a = this, b = arguments, c = b[0]; @@ -2520,14 +2556,14 @@ function zb(a, b, c, d, e, g) { if (c.length) { return Promise.all(c).then(function() { a.result.length && (d = [a.result].concat(d)); - a.result = Ab(d, e, g, f, !h, a.J); + a.result = Db(d, e, g, f, !h, a.J); return h ? a.result : a; }); } - d.length && (this.result.length && (d = [this.result].concat(d)), this.result = Ab(d, e, g, f, !h, a.J)); + d.length && (this.result.length && (d = [this.result].concat(d)), this.result = Db(d, e, g, f, !h, a.J)); return h ? this.result : this; }; -function Ab(a, b, c, d, e, g) { +function Db(a, b, c, d, e, g) { if (!a.length) { return a; } @@ -2616,14 +2652,14 @@ function Ab(a, b, c, d, e, g) { } if (c.length) { return Promise.all(c).then(function() { - a.result = Bb.call(a, d, e, g, f); + a.result = Eb.call(a, d, e, g, f); return f ? a.result : a; }); } - d.length && (this.result = Bb.call(this, d, e, g, f)); + d.length && (this.result = Eb.call(this, d, e, g, f)); return f ? this.result : this; }; -function Bb(a, b, c, d) { +function Eb(a, b, c, d) { if (!a.length) { return this.result; } @@ -2653,7 +2689,7 @@ function Bb(a, b, c, d) { return e; } ;function Y(a) { - if (this.constructor !== Y) { + if (!this || this.constructor !== Y) { return new Y(a); } if (a && a.index) { @@ -2694,12 +2730,12 @@ Y.prototype.boost = function(a) { return this; }; Y.prototype.resolve = function(a, b, c) { - Cb = 1; + Fb = 1; var d = this.result; this.result = this.index = null; return d.length ? ("object" === typeof a && (c = a.enrich, b = a.offset, a = a.limit), X(d, a || 100, b, c)) : d; }; -var Cb = 1; +var Fb = 1; O.prototype.search = function(a, b, c) { c || (!b && M(a) ? (c = a, a = "") : M(b) && (c = b, b = 0)); var d = [], e = 0, g; @@ -2709,22 +2745,22 @@ O.prototype.search = function(a, b, c) { e = c.offset || 0; var f = c.context; var h = c.suggest; - (g = Cb && !1 !== c.resolve) || (Cb = 0); + (g = Fb && !1 !== c.resolve) || (Fb = 0); var k = g && c.enrich; var l = c.boost; var m = this.db && c.tag; } else { - g = this.resolve || Cb; + g = this.resolve || Fb; } a = this.encoder.encode(a); var n = a.length; b || !g || (b = 100); if (1 === n) { - return Db.call(this, a[0], "", b, e, g, k, m); + return Gb.call(this, a[0], "", b, e, g, k, m); } f = this.depth && !1 !== f; if (2 === n && f && !h) { - return Db.call(this, a[0], a[1], b, e, g, k, m); + return Gb.call(this, a[0], a[1], b, e, g, k, m); } var p = c = 0; if (1 < n) { @@ -2748,10 +2784,10 @@ O.prototype.search = function(a, b, c) { } var x = 0; if (1 === n) { - return Db.call(this, a[0], "", b, e, g, k, m); + return Gb.call(this, a[0], "", b, e, g, k, m); } if (2 === n && f && !h) { - return Db.call(this, a[0], a[1], b, e, g, k, m); + return Gb.call(this, a[0], a[1], b, e, g, k, m); } if (1 < n) { if (f) { @@ -2781,11 +2817,11 @@ O.prototype.search = function(a, b, c) { 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 = Eb(A, d, h, z.resolution); + A = Hb(A, d, h, z.resolution); F.h = 6; break; case 8: - A = F.F, A = Eb(A, d, h, z.aa), h && !1 === A && d.length || (t = B); + A = F.F, A = Hb(A, d, h, z.aa), h && !1 === A && d.length || (t = B); case 6: if (A) { return F.return(A); @@ -2810,14 +2846,14 @@ O.prototype.search = function(a, b, c) { F.h = 2; break; case 4: - return F.return(g ? ab(d, z.resolution, b, e, h, l, g) : new Y(d[0])); + return F.return(g ? db(d, z.resolution, b, e, h, l, g) : new Y(d[0])); } }); }(); } for (k = f = void 0; x < n; x++) { k = a[x]; - t ? (f = Z(this, k, t, 0, 0, !1, !1), f = Eb(f, d, h, this.aa), h && !1 === f && d.length || (t = k)) : (f = Z(this, k, "", 0, 0, !1, !1), f = Eb(f, d, h, this.resolution)); + t ? (f = Z(this, k, t, 0, 0, !1, !1), f = Hb(f, d, h, this.aa), h && !1 === f && d.length || (t = k)) : (f = Z(this, k, "", 0, 0, !1, !1), f = Hb(f, d, h, this.resolution)); if (f) { return f; } @@ -2836,16 +2872,16 @@ O.prototype.search = function(a, b, c) { } } } - d = ab(d, this.resolution, b, e, h, l, g); + d = db(d, this.resolution, b, e, h, l, g); return g ? d : new Y(d); }; -function Db(a, b, c, d, e, g, f) { +function Gb(a, b, c, d, e, g, f) { a = Z(this, a, b, c, d, e, g, f); return this.db ? a.then(function(h) { return e ? h : h && h.length ? e ? X(h, c, d) : new Y(h) : e ? [] : new Y([]); }) : a && a.length ? e ? X(a, c, d) : new Y(a) : e ? [] : new Y([]); } -function Eb(a, b, c, d) { +function Hb(a, b, c, d) { var e = []; if (a) { d = Math.min(a.length, d); @@ -2883,15 +2919,15 @@ function Z(a, b, c, d, e, g, f, h) { } } } else { - Fb(this.map, a), this.depth && Fb(this.ctx, a); + Ib(this.map, a), this.depth && Ib(this.ctx, a); } b || this.reg.delete(a); } - this.db && (this.commit_task.push({del:a}), this.da && wb(this)); + this.db && (this.commit_task.push({del:a}), this.da && zb(this)); this.cache && this.cache.remove(a); return this; }; -function Fb(a, b) { +function Ib(a, b) { var c = 0; if (a.constructor === Array) { for (var d = 0, e = void 0, g; d < a.length; d++) { @@ -2906,23 +2942,23 @@ function Fb(a, b) { } } else { for (d = y(a), e = d.next(); !e.done; e = d.next()) { - g = e.value, e = g[0], (g = Fb(g[1], b)) ? c += g : a.delete(e); + g = e.value, e = g[0], (g = Ib(g[1], b)) ? c += g : a.delete(e); } } return c; } ;function O(a, b) { - if (this.constructor !== O) { + if (!this || this.constructor !== O) { return new O(a); } if (a) { var c = K(a) ? a : a.preset; - c && (tb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, tb[c], a)); + c && (wb[c] || console.warn("Preset not found: " + c), a = Object.assign({}, wb[c], a)); } else { a = {}; } c = a.context || {}; - var d = K(a.encoder) ? sb[a.encoder] : a.encode || a.encoder || kb; + var d = K(a.encoder) ? vb[a.encoder] : a.encode || a.encoder || nb; this.encoder = d.encode ? d : "object" === typeof d ? new N(d) : {encode:d}; var e; this.resolution = a.resolution || 9; @@ -2959,7 +2995,7 @@ v.destroy = function() { this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null); return this.db.destroy(); }; -function wb(a) { +function zb(a) { a.commit_timer || (a.commit_timer = setTimeout(function() { a.commit_timer = null; a.db.commit(a, void 0, void 0); @@ -2985,7 +3021,7 @@ v.update = function(a, b) { return c.add(a, b); }) : this.add(a, b); }; -function Gb(a) { +function Jb(a) { var b = 0; if (a.constructor === Array) { for (var c = 0, d = void 0; c < a.length; c++) { @@ -2995,7 +3031,7 @@ function Gb(a) { for (c = y(a), d = c.next(); !d.done; d = c.next()) { var e = d.value; d = e[0]; - (e = Gb(e[1])) ? b += e : a.delete(d); + (e = Jb(e[1])) ? b += e : a.delete(d); } } return b; @@ -3004,17 +3040,17 @@ v.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - Gb(this.map); - this.depth && Gb(this.ctx); + Jb(this.map); + this.depth && Jb(this.ctx); return this; }; -v.searchCache = jb; +v.searchCache = mb; v.export = function(a, b, c, d) { d = void 0 === d ? 0 : d; switch(d) { case 0: var e = "reg"; - var g = Ra(this.reg); + var g = Ta(this.reg); break; case 1: e = "cfg"; @@ -3022,29 +3058,29 @@ v.export = function(a, b, c, d) { break; case 2: e = "map"; - g = Pa(this.map); + g = Pa(this.map, this.reg.size); break; case 3: e = "ctx"; - g = Qa(this.ctx); + g = Ra(this.ctx, this.reg.size); break; default: return; } - return Sa.call(this, a, b, e, c, d, g); + return Va.call(this, a, b, e, g, c, d); }; v.import = function(a, b) { if (b) { - switch(K(b) && (b = JSON.parse(b)), a) { + switch(K(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 = Ua(b, this.reg); break; case "map": - this.map = new Map(b); + this.map = Qa(b, this.map); break; case "ctx": - this.ctx = new Map(b); + this.ctx = Sa(b, this.ctx); } } }; @@ -3101,11 +3137,11 @@ v.serialize = function(a) { return a ? "function inject(index){" + b + d + e + "}" : b + d + e; }; Na(O.prototype); -var Hb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Ib = ["map", "ctx", "tag", "reg", "cfg"]; -function Jb(a, b) { +var Kb = "undefined" !== typeof window && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB), Lb = ["map", "ctx", "tag", "reg", "cfg"]; +function Mb(a, b) { b = void 0 === b ? {} : b; if (!this) { - return new Jb(a, b); + return new Mb(a, b); } "object" === typeof a && (b = a = a.name); a || console.info("Default storage space was used, because a name was not passed."); @@ -3115,7 +3151,7 @@ function Jb(a, b) { this.db = null; this.h = {}; } -v = Jb.prototype; +v = Mb.prototype; v.mount = function(a) { if (!a.encoder) { return a.mount(this); @@ -3127,10 +3163,10 @@ v.open = function() { var a = this; navigator.storage && navigator.storage.persist(); return this.db || new Promise(function(b, c) { - var d = Hb.open(a.id + (a.field ? ":" + a.field : ""), 1); + var d = Kb.open(a.id + (a.field ? ":" + a.field : ""), 1); d.onupgradeneeded = function() { var e = a.db = this.result; - Ib.forEach(function(g) { + Lb.forEach(function(g) { e.objectStoreNames.contains(g) || e.createObjectStore(g); }); }; @@ -3156,13 +3192,13 @@ v.close = function() { this.db = null; }; v.destroy = function() { - return Hb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); + return Kb.deleteDatabase(this.id + (this.field ? ":" + this.field : "")); }; v.clear = function() { - for (var a = this.db.transaction(Ib, "readwrite"), b = 0; b < Ib.length; b++) { - a.objectStore(Ib[b]).clear(); + for (var a = this.db.transaction(Lb, "readwrite"), b = 0; b < Lb.length; b++) { + a.objectStore(Lb[b]).clear(); } - return Kb(a); + return Nb(a); }; v.get = function(a, b, c, d, e, g) { c = void 0 === c ? 0 : c; @@ -3171,7 +3207,7 @@ v.get = function(a, b, c, d, e, g) { g = void 0 === g ? !1 : g; a = this.db.transaction(b ? "ctx" : "map", "readonly").objectStore(b ? "ctx" : "map").get(b ? b + ":" + a : a); var f = this; - return Kb(a).then(function(h) { + return Nb(a).then(function(h) { var k = []; if (!h || !h.length) { return k; @@ -3206,7 +3242,7 @@ v.tag = function(a, b, c, d) { d = void 0 === d ? !1 : d; a = this.db.transaction("tag", "readonly").objectStore("tag").get(a); var e = this; - return Kb(a).then(function(g) { + return Nb(a).then(function(g) { if (!g || !g.length || c >= g.length) { return []; } @@ -3220,7 +3256,7 @@ v.tag = function(a, b, c, d) { 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] = Kb(b.get(a[d])); + c[d] = Nb(b.get(a[d])); } return Promise.all(c).then(function(e) { for (var g = 0; g < e.length; g++) { @@ -3231,7 +3267,7 @@ v.enrich = function(a) { }; v.has = function(a) { a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a); - return Kb(a); + return Nb(a); }; v.search = null; v.info = function() { @@ -3406,7 +3442,7 @@ v.commit = function(a, b, c) { } }); }; -function Nb(a, b, c) { +function Qb(a, b, c) { for (var d = a.value, e, g, f = 0, h = 0, k; h < d.length; h++) { if (k = c ? d : d[h]) { for (var l = 0, m, n; l < b.length; l++) { @@ -3433,17 +3469,17 @@ v.remove = function(a) { return Promise.all([this.transaction("map", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && Nb(c, a); + c && Qb(c, a); }; }), this.transaction("ctx", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && Nb(c, a); + c && Qb(c, a); }; }), this.transaction("tag", "readwrite", function(b) { b.openCursor().onsuccess = function() { var c = this.result; - c && Nb(c, a, !0); + c && Qb(c, a, !0); }; }), this.transaction("reg", "readwrite", function(b) { for (var c = 0; c < a.length; c++) { @@ -3451,7 +3487,7 @@ v.remove = function(a) { } })]); }; -function Kb(a) { +function Nb(a) { return new Promise(function(b, c) { a.onsuccess = function() { b(this.result); @@ -3463,8 +3499,8 @@ function Kb(a) { a = null; }); } -;var Ob = {Index:O, Charset:sb, Encoder:N, Document:V, Worker:R, Resolver:Y, IndexedDB:Jb, Language:{}}, Pb = self, Qb; -(Qb = Pb.define) && Qb.amd ? Qb([], function() { - return Ob; -}) : "object" === typeof Pb.exports ? Pb.exports = Ob : Pb.FlexSearch = Ob; +;var Rb = {Index:O, Charset:vb, Encoder:N, Document:V, Worker:R, Resolver:Y, IndexedDB:Mb, Language:{}}, Sb = self, Tb; +(Tb = Sb.define) && Tb.amd ? Tb([], function() { + return Rb; +}) : "object" === typeof Sb.exports ? Sb.exports = Rb : Sb.FlexSearch = Rb; }(this||self)); diff --git a/dist/flexsearch.es5.min.js b/dist/flexsearch.es5.min.js index 9fdfbb8..a9e5571 100644 --- a/dist/flexsearch.es5.min.js +++ b/dist/flexsearch.es5.min.js @@ -41,93 +41,96 @@ function J(){return Object.create(null)}function xa(a,b){return b.length-a.lengt "i"],["\u01d2","o"],["\u01d4","u"],["\u01d6","u"],["\u01d8","u"],["\u01da","u"],["\u01dc","u"],["\u01df","a"],["\u01e1","a"],["\u01e3","ae"],["\u00e6","ae"],["\u01fd","ae"],["\u01e7","g"],["\u01e9","k"],["\u01eb","o"],["\u01ed","o"],["\u01ef","\u0292"],["\u01f0","j"],["\u01f3","dz"],["\u01f5","g"],["\u01f9","n"],["\u01fb","a"],["\u01ff","\u00f8"],["\u0201","a"],["\u0203","a"],["\u0205","e"],["\u0207","e"],["\u0209","i"],["\u020b","i"],["\u020d","o"],["\u020f","o"],["\u0211","r"],["\u0213","r"],["\u0215", "u"],["\u0217","u"],["\u0219","s"],["\u021b","t"],["\u021f","h"],["\u0227","a"],["\u0229","e"],["\u022b","o"],["\u022d","o"],["\u022f","o"],["\u0231","o"],["\u0233","y"],["\u02b0","h"],["\u02b1","h"],["\u0266","h"],["\u02b2","j"],["\u02b3","r"],["\u02b4","\u0279"],["\u02b5","\u027b"],["\u02b6","\u0281"],["\u02b7","w"],["\u02b8","y"],["\u02e0","\u0263"],["\u02e1","l"],["\u02e2","s"],["\u02e3","x"],["\u02e4","\u0295"],["\u0390","\u03b9"],["\u03ac","\u03b1"],["\u03ad","\u03b5"],["\u03ae","\u03b7"],["\u03af", "\u03b9"],["\u03b0","\u03c5"],["\u03ca","\u03b9"],["\u03cb","\u03c5"],["\u03cc","\u03bf"],["\u03cd","\u03c5"],["\u03ce","\u03c9"],["\u03d0","\u03b2"],["\u03d1","\u03b8"],["\u03d2","\u03a5"],["\u03d3","\u03a5"],["\u03d4","\u03a5"],["\u03d5","\u03c6"],["\u03d6","\u03c0"],["\u03f0","\u03ba"],["\u03f1","\u03c1"],["\u03f2","\u03c2"],["\u03f5","\u03b5"],["\u0439","\u0438"],["\u0450","\u0435"],["\u0451","\u0435"],["\u0453","\u0433"],["\u0457","\u0456"],["\u045c","\u043a"],["\u045d","\u0438"],["\u045e","\u0443"], -["\u0477","\u0475"],["\u04c2","\u0436"],["\u04d1","\u0430"],["\u04d3","\u0430"],["\u04d7","\u0435"],["\u04db","\u04d9"],["\u04dd","\u0436"],["\u04df","\u0437"],["\u04e3","\u0438"],["\u04e5","\u0438"],["\u04e7","\u043e"],["\u04eb","\u04e9"],["\u04ed","\u044d"],["\u04ef","\u0443"],["\u04f1","\u0443"],["\u04f3","\u0443"],["\u04f5","\u0447"]];var Ca=/[^\p{L}\p{N}]+/u,Da=/(\d{3})/g,Fa=/(\D)(\d{3})/g,Ga=/(\d{3})(\D)/g,Ha="".normalize&&/[\u0300-\u036f]/g;function N(a){if(this.constructor!==N){var b=Function.prototype.bind,c=b.apply,d=[null],e=d.concat;if(arguments instanceof Array)var h=arguments;else{h=x(arguments);for(var f,g=[];!(f=h.next()).done;)g.push(f.value);h=g}return new (c.call(b,N,e.call(d,h)))}for(b=0;bthis.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 Ia(a){a.U=null;a.N.clear();a.S.clear()};function Ja(a){var b,c,d,e,h,f,g,k;return ta(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 O(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 Ka=0; -function R(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=J();if(this.worker){d?this.worker.on("message",g):this.worker.onmessage=g;if(a.config)return new Promise(function(k){e.h[++Ka]=function(){k(e)};e.worker.postMessage({id:Ka,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}a=void 0===a?{}:a;if(this.constructor!==R)return new R(a);var c="undefined"!==typeof self?self._factory: +function R(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=J();if(this.worker){d?this.worker.on("message",g):this.worker.onmessage=g;if(a.config)return new Promise(function(k){e.h[++Ka]=function(){k(e)};e.worker.postMessage({id:Ka,task:"init",factory:c,options:a})});this.worker.postMessage({task:"init",factory:c,options:a});return this}}a=void 0===a?{}:a;if(!this||this.constructor!==R)return new R(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){R.prototype[a]=R.prototype[a+"Async"]=function(){var b=this,c=arguments,d,e,h,f,g;return ta(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[++Ka]=l;d.worker.postMessage({task:a,id:Ka,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="+Ja.toString()],{type:"text/javascript"}))):new window.Worker(K(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){var b=[];a=x(a.entries());for(var c=a.next();!c.done;c=a.next())b.push(c.value);return b}function Qa(a){var b=[];a=x(a.entries());for(var c=a.next();!c.done;c=a.next())b.push(Pa(c.value));return b}function Ra(a){var b=[];a=x(a.keys());for(var c=a.next();!c.done;c=a.next())b.push(c.value);return b}function Sa(a,b,c,d,e,h){if((c=a(b?b+"."+c:c,JSON.stringify(h)))&&c.then){var f=this;return c.then(function(){return f.export(a,b,d,e+1)})}return this.export(a,b,d,e+1)};function Ta(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} +"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){b=void 0===b?0:b;var c=[],d=[];b&&(b=25E4/b*5E3|0);a=x(a.entries());for(var e=a.next();!e.done;e=a.next())d.push(e.value),d.length===b&&(c.push(d),d=[]);d.length&&c.push(d);return c}function Qa(a,b){b||(b=new Map);for(var c=0,d;c=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.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(f=0;fd)d-=g.length; +J();for(c=0;cc||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=eb.call(this,a));return a}} -function eb(a){for(var b=Array(a.length),c=0,d;cc||d)a=a.slice(d,d+c);e&&(a=hb.call(this,a));return a}} +function hb(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=x(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 kb={normalize:function(a){return a.toLowerCase()},dedupe:!1};var lb=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 mb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),nb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];var ob={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 pb=/[\x00-\x7F]+/g;var qb=/[\x00-\x7F]+/g;var rb=/[\x00-\x7F]+/g;var sb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:kb,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:lb},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:lb,matcher:mb,replacer:nb},LatinExtra:{normalize:!0,dedupe:!0,mapper:lb,replacer:nb.concat([/(?!^)[aeo]/g,""]),matcher:mb},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):ub(g,d,k,m,n);vb(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),w=this.bidirectional&&l>n;vb(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&&wb(this));return this}; -function vb(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]=J()),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=x(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 ub(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?xb(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?xb(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]:bb(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=[];J();var g=Aa(a);return g?ab(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=J(),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};O.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 Fb(this.map,a),this.depth&&Fb(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.da&&wb(this));this.cache&&this.cache.remove(a);return this}; -function Fb(a,b){var c=0;if(a.constructor===Array)for(var d=0,e=void 0,h;dthis.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=x(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 nb={normalize:function(a){return a.toLowerCase()},dedupe:!1};var ob=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 pb=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),qb=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];var rb={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 sb=/[\x00-\x7F]+/g;var tb=/[\x00-\x7F]+/g;var ub=/[\x00-\x7F]+/g;var vb={LatinExact:{normalize:!1,dedupe:!1},LatinDefault:nb,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:ob},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:ob,matcher:pb,replacer:qb},LatinExtra:{normalize:!0,dedupe:!0,mapper:ob,replacer:qb.concat([/(?!^)[aeo]/g,""]),matcher:pb},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):xb(g,d,k,m,n);yb(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),w=this.bidirectional&&l>n;yb(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&&zb(this));return this}; +function yb(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]=J()),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=x(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 xb(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?Ab(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?Ab(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]:eb(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=[];J();var g=Aa(a);return g?db(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=J(),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};O.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 Ib(this.map,a),this.depth&&Ib(this.ctx,a);b||this.reg.delete(a)}this.db&&(this.commit_task.push({del:a}),this.da&&zb(this));this.cache&&this.cache.remove(a);return this}; +function Ib(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})}; -u.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,1m&&!h&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(h=1),0<=m)if(e=1,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)}; +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)}; function Q(a){let c=0;if(a.constructor===Array)for(let b=0,d;bc||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)}; +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)}; function Q(a){let c=0;if(a.constructor===Array)for(let b=0,d;bb.get(d)));return a.replace(/str\b/g,"strasse").replace(/(?!\b)strasse\b/g," strasse")},filter:new Set("aber als am an auch auf aus bei bin bis bist da dadurch daher darum das dass dass dein deine dem den der des dessen deshalb die dies dieser dieses doch dort du durch ein eine einem einen einer eines er es euer eure fuer hatte hatten hattest hattet hier hinter ich ihr ihre im in ist ja jede jedem jeden jeder jedes jener jenes jetzt ggf kann kannst koennen koennt machen mein meine mit muss musst musst muessen muesst nach nachdem nein nicht noch nun oder seid sein seine sich sie sind soll sollen sollst sollt sonst soweit sowie und unser unsere unter usw uvm vom von vor wann warum was weiter weitere wenn wer werde werden werdet weshalb wie wieder wieso wir wird wirst wo woher wohin zu zum zur ueber".split(" ")), -stemmer:new Map([["niss",""],["isch",""],["lich",""],["heit",""],["keit",""],["ell",""],["bar",""],["end",""],["ung",""],["est",""],["ern",""],["em",""],["er",""],["en",""],["es",""],["st",""],["ig",""],["ik",""],["e",""],["s",""]])};"undefined"!==typeof module&&module.exports?module.exports=c:self.FlexSearch&&(self.FlexSearch.Language.de=c);}(this||self)); +(function(self){'use strict';var y;function z(a,b,c){const d=typeof c,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(c){if("function"===e&&d===e)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===e?b:a}function B(){return Object.create(null)}function aa(a,b){return b.length-a.length} +function G(a){return"string"===typeof a}function H(a){return"object"===typeof a}function J(a,b){if(G(b))a=a[b];else for(let c=0;a&&cthis.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(e=0;g&&ethis.la&&(this.W.clear(),this.D=this.D/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.h&&(this.R.set(a,c),this.R.size>this.la&&(this.R.clear(),this.h=this.h/1.1|0));return c};function ja(a){a.Z=null;a.R.clear();a.W.clear()};async function ka(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};(b=d.config)&&(d=b);(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new L(d);postMessage({id:a.id});break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let la=0; +function M(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.F=g;this.h=B();if(this.F){d?this.F.on("message",h):this.F.onmessage=h;if(a.config)return new Promise(function(k){e.h[++la]=function(){k(e)};e.F.postMessage({id:la,task:"init",factory:c,options:a})});this.F.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==M)return new M(a);let c="undefined"!==typeof self?self._factory:"undefined"!==typeof window?window._factory: +null;c&&(c=c.toString());const d="undefined"===typeof window,e=this,f=ma(c,d,a.F);return f.then?f.then(function(g){return b.call(e,g)}):b.call(this,f)}N("add");N("append");N("search");N("update");N("remove"); +function N(a){M.prototype[a]=M.prototype[a+"Async"]=async function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;"function"===typeof d&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){b.h[++la]=f;b.F.postMessage({task:a,id:la,args:c})});return e?(d.then(e),this):d}} +function ma(a,b,c){return b?"undefined"!==typeof module?(0,eval)('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")'):(0,eval)('import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); })'):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ka.toString()],{type:"text/javascript"}))):new window.Worker(G(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){O.call(a,"add");O.call(a,"append");O.call(a,"search");O.call(a,"update");O.call(a,"remove")}function O(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(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){b||(b=new Map);for(let c=0,d;c=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} +function P(a){if(!this)return new P(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(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){let f=0;for(let g=0,h,k;gc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(let r=0,n;rd)d-=n.length; +else{if(n.length>c||d)n=n.slice(d,c+d),c-=n.length,d&&(d-=n.length);e.push(n);if(!c)break}k=1c||d)f=f.slice(d,d+c);e&&(f=Aa.call(this,f));return f}}function Aa(a){const b=Array(a.length);for(let c=0,d;cthis.J&&this.cache.delete(this.cache.keys().next().value)};T.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};T.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};T.prototype.clear=function(){this.cache.clear();this.h=""};const Fa={normalize:function(a){return a.toLowerCase()},dedupe:!1};const Ga=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 Ha=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ia=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Ja={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 Ka=/[\x00-\x7F]+/g;const La=/[\x00-\x7F]+/g;const Ma=/[\x00-\x7F]+/g;var Na={wa:{normalize:!1,dedupe:!1},va:Fa,ya:{normalize:!0,dedupe:!0},ua:{normalize:!0,dedupe:!0,mapper:Ga},ta:{normalize:!0,dedupe:!0,mapper:Ga,matcher:Ha,replacer:Ia},xa:{normalize:!0,dedupe:!0,mapper:Ga,replacer:Ia.concat([/(?!^)[aeo]/g,""]),matcher:Ha},za:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cc;c++)U[c]=c+1;U=String.fromCharCode.apply(null,U)}c=b;for(d="";b=c%255,d=U.charAt(b)+d,c=c/255|0,c;);b=d;2E5f;h--){g=t.substring(f,h);var k=this.L?this.L(b,t,p,g,f):Ta(n,d,p,e,f);W(this,m,g,k,a,c)}break}case "reverse":if(1g?0:1),d,p,h-1,k-1),u=this.fa&&t>f;W(this,l,u?f:t,q,a,c,u?t:f)}}}}this.C||this.B.add(a)}else b=""}this.db&&(b||this.ga.push({del:a}),this.na&&Ua(this));return this}; +function W(a,b,c,d,e,f,g){let h=g?a.S:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=B()),b[g]=1,a.aa&&(g=Ra(g)),(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,a.aa&&(c=Ra(c)),(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new P(h);if(a.C)for(let l of a.B.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.C&&((d=a.B.get(e))?d.push(h):a.B.set(e,[h]))}} +function Ta(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?Va(a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=g.length),e.push(g);else{if(h>=b)return h>b&&(g=g.slice(0,b)),d?Va(g):g;e=[g]}b-=h;if(!b)break}if(!e.length)return e;e=1a.length?e?X(a[0],b,c,d):a[0]:xa(a,c,b,e,f)};Y.prototype.and=function(){if(this.result.length){const b=this;let c=arguments;var a=c[0];if(a.then)return a.then(function(){return b.and.apply(b,c)});if(a[0]&&a[0].index)return this.and.apply(this,a);let d=[];a=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return[];let g=[];B();let h=ba(a);return h?wa(a,h,b,c,f,e,d):g};Y.prototype.xor=function(){const a=this;let b=arguments;var 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);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return e?X(a[0],b,c,d):a[0];d=[];const g=B();let h=0;for(let k=0,l;kc);a.aa&&(b=Ra(b),c&&(c=Ra(c)));if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.S.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};L.prototype.remove=function(a,b){const c=this.B.size&&(this.C?this.B.get(a):this.B.has(a));if(c){if(this.C)for(let d=0,e;de.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else db(this.map,a),this.depth&&db(this.S,a);b||this.B.delete(a)}this.db&&(this.ga.push({del:a}),this.na&&Ua(this));this.cache&&this.cache.remove(a);return this}; +function db(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;dc.add(a,b)):this.add(a,b)}; +y.import=function(a,b){if(b)switch(G(b)&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),a=1eb.get(b)));return a.replace(/str\b/g,"strasse").replace(/(?!\b)strasse\b/g," strasse")},filter:new Set("aber als am an auch auf aus bei bin bis bist da dadurch daher darum das dass dass dein deine dem den der des dessen deshalb die dies dieser dieses doch dort du durch ein eine einem einen einer eines er es euer eure fuer hatte hatten hattest hattet hier hinter ich ihr ihre im in ist ja jede jedem jeden jeder jedes jener jenes jetzt ggf kann kannst koennen koennt machen mein meine mit muss musst musst muessen muesst nach nachdem nein nicht noch nun oder seid sein seine sich sie sind soll sollen sollst sollt sonst soweit sowie und unser unsere unter usw uvm vom von vor wann warum was weiter weitere wenn wer werde werden werdet weshalb wie wieder wieso wir wird wirst wo woher wohin zu zum zur ueber".split(" ")), +stemmer:new Map([["niss",""],["isch",""],["lich",""],["heit",""],["keit",""],["ell",""],["bar",""],["end",""],["ung",""],["est",""],["ern",""],["em",""],["er",""],["en",""],["es",""],["st",""],["ig",""],["ik",""],["e",""],["s",""]])};"undefined"!==typeof module&&module.exports?module.exports=fb:self.FlexSearch&&(self.FlexSearch.Language.de=fb);}(this||self)); diff --git a/dist/lang/en.min.js b/dist/lang/en.min.js index bb2617b..0b7cfaa 100644 --- a/dist/lang/en.min.js +++ b/dist/lang/en.min.js @@ -1,3 +1,73 @@ -(function(self){'use strict';const a={prepare:function(b){return b.replace(/\u00b4`\u2019\u02bc/g,"'").replace(/_+/g," ").replace(/&/g," and ").replace(/\$/g," USD ").replace(/\u00a3/g," GBP ").replace(/([a-z])'s\b/g,"$1 is").replace(/\bi'm\b/g,"i am").replace(/\b(can't|cannot)\b/g,"can not").replace(/\bwon't\b/g,"will not").replace(/([a-z])n't\b/g,"$1 not").replace(/([a-z])'ll\b/g,"$1 will").replace(/([a-z])'re\b/g,"$1 are").replace(/([a-z])'ve\b/g,"$1 have").replace(/([a-z])'d\b/g,"$1 would")},filter:new Set("a about above after again against all also am an and any are arent as at back be because been before being below between both but by can cannot cant come could couldnt did didnt do does doesnt doing dont down during each even few for from further get go good had hadnt has hasnt have havent having he hed her here heres hers herself hes him himself his how hows i id if ill im in into is isnt it its itself ive just know lets like lot make made me more most mustnt my myself new no nor not now of off on once one only or other ought our ours ourselves out over own people same say see shant she shed shell shes should shouldnt so some such take than that thats the their theirs them themselves then there theres these they theyd theyll theyre theyve think this those through time times to too under until up us use very want was wasnt way we wed well were werent weve what whats when whens where wheres which while who whom whos why whys will with wont work would wouldnt ya you youd youll your youre yours yourself yourselves youve".split(" ")), +(function(self){'use strict';var y;function z(a,b,c){const d=typeof c,e=typeof a;if("undefined"!==d){if("undefined"!==e){if(c){if("function"===e&&d===e)return function(h){return a(c(h))};b=a.constructor;if(b===c.constructor){if(b===Array)return c.concat(a);if(b===Map){var f=new Map(c);for(var g of a)f.set(g[0],g[1]);return f}if(b===Set){g=new Set(c);for(f of a.values())g.add(f);return g}}}return a}return c}return"undefined"===e?b:a}function B(){return Object.create(null)}function aa(a,b){return b.length-a.length} +function G(a){return"string"===typeof a}function H(a){return"object"===typeof a}function J(a,b){if(G(b))a=a[b];else for(let c=0;a&&cthis.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(e=0;g&&ethis.la&&(this.W.clear(),this.D=this.D/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.h&&(this.R.set(a,c),this.R.size>this.la&&(this.R.clear(),this.h=this.h/1.1|0));return c};function ja(a){a.Z=null;a.R.clear();a.W.clear()};async function ka(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};(b=d.config)&&(d=b);(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new L(d);postMessage({id:a.id});break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let la=0; +function M(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.F=g;this.h=B();if(this.F){d?this.F.on("message",h):this.F.onmessage=h;if(a.config)return new Promise(function(k){e.h[++la]=function(){k(e)};e.F.postMessage({id:la,task:"init",factory:c,options:a})});this.F.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==M)return new M(a);let c="undefined"!==typeof self?self._factory:"undefined"!==typeof window?window._factory: +null;c&&(c=c.toString());const d="undefined"===typeof window,e=this,f=ma(c,d,a.F);return f.then?f.then(function(g){return b.call(e,g)}):b.call(this,f)}N("add");N("append");N("search");N("update");N("remove"); +function N(a){M.prototype[a]=M.prototype[a+"Async"]=async function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;"function"===typeof d&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){b.h[++la]=f;b.F.postMessage({task:a,id:la,args:c})});return e?(d.then(e),this):d}} +function ma(a,b,c){return b?"undefined"!==typeof module?(0,eval)('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")'):(0,eval)('import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); })'):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ka.toString()],{type:"text/javascript"}))):new window.Worker(G(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){O.call(a,"add");O.call(a,"append");O.call(a,"search");O.call(a,"update");O.call(a,"remove")}function O(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(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){b||(b=new Map);for(let c=0,d;c=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} +function P(a){if(!this)return new P(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(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){let f=0;for(let g=0,h,k;gc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(let r=0,n;rd)d-=n.length; +else{if(n.length>c||d)n=n.slice(d,c+d),c-=n.length,d&&(d-=n.length);e.push(n);if(!c)break}k=1c||d)f=f.slice(d,d+c);e&&(f=Aa.call(this,f));return f}}function Aa(a){const b=Array(a.length);for(let c=0,d;cthis.J&&this.cache.delete(this.cache.keys().next().value)};T.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};T.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};T.prototype.clear=function(){this.cache.clear();this.h=""};const Fa={normalize:function(a){return a.toLowerCase()},dedupe:!1};const Ga=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 Ha=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ia=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Ja={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 Ka=/[\x00-\x7F]+/g;const La=/[\x00-\x7F]+/g;const Ma=/[\x00-\x7F]+/g;var Na={wa:{normalize:!1,dedupe:!1},va:Fa,ya:{normalize:!0,dedupe:!0},ua:{normalize:!0,dedupe:!0,mapper:Ga},ta:{normalize:!0,dedupe:!0,mapper:Ga,matcher:Ha,replacer:Ia},xa:{normalize:!0,dedupe:!0,mapper:Ga,replacer:Ia.concat([/(?!^)[aeo]/g,""]),matcher:Ha},za:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cc;c++)U[c]=c+1;U=String.fromCharCode.apply(null,U)}c=b;for(d="";b=c%255,d=U.charAt(b)+d,c=c/255|0,c;);b=d;2E5f;h--){g=t.substring(f,h);var k=this.L?this.L(b,t,p,g,f):Ta(n,d,p,e,f);W(this,m,g,k,a,c)}break}case "reverse":if(1g?0:1),d,p,h-1,k-1),u=this.fa&&t>f;W(this,l,u?f:t,q,a,c,u?t:f)}}}}this.C||this.B.add(a)}else b=""}this.db&&(b||this.ga.push({del:a}),this.na&&Ua(this));return this}; +function W(a,b,c,d,e,f,g){let h=g?a.S:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=B()),b[g]=1,a.aa&&(g=Ra(g)),(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,a.aa&&(c=Ra(c)),(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new P(h);if(a.C)for(let l of a.B.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.C&&((d=a.B.get(e))?d.push(h):a.B.set(e,[h]))}} +function Ta(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?Va(a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=g.length),e.push(g);else{if(h>=b)return h>b&&(g=g.slice(0,b)),d?Va(g):g;e=[g]}b-=h;if(!b)break}if(!e.length)return e;e=1a.length?e?X(a[0],b,c,d):a[0]:xa(a,c,b,e,f)};Y.prototype.and=function(){if(this.result.length){const b=this;let c=arguments;var a=c[0];if(a.then)return a.then(function(){return b.and.apply(b,c)});if(a[0]&&a[0].index)return this.and.apply(this,a);let d=[];a=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return[];let g=[];B();let h=ba(a);return h?wa(a,h,b,c,f,e,d):g};Y.prototype.xor=function(){const a=this;let b=arguments;var 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);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return e?X(a[0],b,c,d):a[0];d=[];const g=B();let h=0;for(let k=0,l;kc);a.aa&&(b=Ra(b),c&&(c=Ra(c)));if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.S.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};L.prototype.remove=function(a,b){const c=this.B.size&&(this.C?this.B.get(a):this.B.has(a));if(c){if(this.C)for(let d=0,e;de.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else db(this.map,a),this.depth&&db(this.S,a);b||this.B.delete(a)}this.db&&(this.ga.push({del:a}),this.na&&Ua(this));this.cache&&this.cache.remove(a);return this}; +function db(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;dc.add(a,b)):this.add(a,b)}; +y.import=function(a,b){if(b)switch(G(b)&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),a=1this.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(e=0;g&&ethis.la&&(this.W.clear(),this.D=this.D/1.1|0));g&&c.push(g)}this.finalize&&(c=this.finalize(c)||c);this.cache&&a.length<=this.h&&(this.R.set(a,c),this.R.size>this.la&&(this.R.clear(),this.h=this.h/1.1|0));return c};function ja(a){a.Z=null;a.R.clear();a.W.clear()};async function ka(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};(b=d.config)&&(d=b);(b=a.factory)?(Function("return "+b)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new L(d);postMessage({id:a.id});break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let la=0; +function M(a={}){function b(g){function h(k){k=k.data||k;const l=k.id,m=l&&e.h[l];m&&(m(k.msg),delete e.h[l])}this.F=g;this.h=B();if(this.F){d?this.F.on("message",h):this.F.onmessage=h;if(a.config)return new Promise(function(k){e.h[++la]=function(){k(e)};e.F.postMessage({id:la,task:"init",factory:c,options:a})});this.F.postMessage({task:"init",factory:c,options:a});return this}}if(!this||this.constructor!==M)return new M(a);let c="undefined"!==typeof self?self._factory:"undefined"!==typeof window?window._factory: +null;c&&(c=c.toString());const d="undefined"===typeof window,e=this,f=ma(c,d,a.F);return f.then?f.then(function(g){return b.call(e,g)}):b.call(this,f)}N("add");N("append");N("search");N("update");N("remove"); +function N(a){M.prototype[a]=M.prototype[a+"Async"]=async function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;"function"===typeof d&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){b.h[++la]=f;b.F.postMessage({task:a,id:la,args:c})});return e?(d.then(e),this):d}} +function ma(a,b,c){return b?"undefined"!==typeof module?(0,eval)('new (require("worker_threads")["Worker"])(__dirname + "/node/node.js")'):(0,eval)('import("worker_threads").then(function(worker){ return new worker["Worker"]((1,eval)("import.meta.dirname") + "/node/node.mjs"); })'):a?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ka.toString()],{type:"text/javascript"}))):new window.Worker(G(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){O.call(a,"add");O.call(a,"append");O.call(a,"search");O.call(a,"update");O.call(a,"remove")}function O(a){this[a+"Async"]=function(){var b=arguments;const c=b[b.length-1];let d;"function"===typeof c&&(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){b||(b=new Map);for(let c=0,d;c=g.length)b-=g.length;else{b=g[d?"splice":"slice"](b,c);const h=b.length;if(h&&(e=e.length?e.concat(b):b,c-=h,d&&(a.length-=h),!c))break;b=0}return e} +function P(a){if(!this)return new P(a);this.index=a?[a]:[];this.length=a?a.length:0;const b=this;return new Proxy([],{get(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){let f=0;for(let g=0,h,k;gc||d?k.slice(d,c+d):k;else{if(ac||d)k=k.slice(d,c+d)}else{e=[];for(let r=0,n;rd)d-=n.length; +else{if(n.length>c||d)n=n.slice(d,c+d),c-=n.length,d&&(d-=n.length);e.push(n);if(!c)break}k=1c||d)f=f.slice(d,d+c);e&&(f=Aa.call(this,f));return f}}function Aa(a){const b=Array(a.length);for(let c=0,d;cthis.J&&this.cache.delete(this.cache.keys().next().value)};T.prototype.get=function(a){const b=this.cache.get(a);b&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,b));return b};T.prototype.remove=function(a){for(const b of this.cache){const c=b[0];b[1].includes(a)&&this.cache.delete(c)}};T.prototype.clear=function(){this.cache.clear();this.h=""};const Fa={normalize:function(a){return a.toLowerCase()},dedupe:!1};const Ga=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 Ha=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["pf","f"]]),Ia=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/([^0-9])\1+/g,"$1"];const Ja={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 Ka=/[\x00-\x7F]+/g;const La=/[\x00-\x7F]+/g;const Ma=/[\x00-\x7F]+/g;var Na={wa:{normalize:!1,dedupe:!1},va:Fa,ya:{normalize:!0,dedupe:!0},ua:{normalize:!0,dedupe:!0,mapper:Ga},ta:{normalize:!0,dedupe:!0,mapper:Ga,matcher:Ha,replacer:Ia},xa:{normalize:!0,dedupe:!0,mapper:Ga,replacer:Ia.concat([/(?!^)[aeo]/g,""]),matcher:Ha},za:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let c=0;cc;c++)U[c]=c+1;U=String.fromCharCode.apply(null,U)}c=b;for(d="";b=c%255,d=U.charAt(b)+d,c=c/255|0,c;);b=d;2E5f;h--){g=t.substring(f,h);var k=this.L?this.L(b,t,p,g,f):Ta(n,d,p,e,f);W(this,m,g,k,a,c)}break}case "reverse":if(1g?0:1),d,p,h-1,k-1),u=this.fa&&t>f;W(this,l,u?f:t,q,a,c,u?t:f)}}}}this.C||this.B.add(a)}else b=""}this.db&&(b||this.ga.push({del:a}),this.na&&Ua(this));return this}; +function W(a,b,c,d,e,f,g){let h=g?a.S:a.map,k;if(!b[c]||g&&!(k=b[c])[g])if(g?(b=k||(b[c]=B()),b[g]=1,a.aa&&(g=Ra(g)),(k=h.get(g))?h=k:h.set(g,h=new Map)):b[c]=1,a.aa&&(c=Ra(c)),(k=h.get(c))?h=k:h.set(c,h=k=[]),h=h[d]||(h[d]=[]),!f||!h.includes(e)){if(h.length===2**31-1){b=new P(h);if(a.C)for(let l of a.B.values())l.includes(h)&&(l[l.indexOf(h)]=b);k[d]=h=b}h.push(e);a.C&&((d=a.B.get(e))?d.push(h):a.B.set(e,[h]))}} +function Ta(a,b,c,d,e){return c&&1b?b?a.slice(c,c+b):a.slice(c):a,d?Va(a):a;let e=[];for(let f=0,g,h;f=h){c-=h;continue}cb&&(g=g.slice(0,b),h=g.length),e.push(g);else{if(h>=b)return h>b&&(g=g.slice(0,b)),d?Va(g):g;e=[g]}b-=h;if(!b)break}if(!e.length)return e;e=1a.length?e?X(a[0],b,c,d):a[0]:xa(a,c,b,e,f)};Y.prototype.and=function(){if(this.result.length){const b=this;let c=arguments;var a=c[0];if(a.then)return a.then(function(){return b.and.apply(b,c)});if(a[0]&&a[0].index)return this.and.apply(this,a);let d=[];a=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return[];let g=[];B();let h=ba(a);return h?wa(a,h,b,c,f,e,d):g};Y.prototype.xor=function(){const a=this;let b=arguments;var 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);let d=[];c=[];let e=0,f=0,g,h;for(let k=0,l;ka.length)return e?X(a[0],b,c,d):a[0];d=[];const g=B();let h=0;for(let k=0,l;kc);a.aa&&(b=Ra(b),c&&(c=Ra(c)));if(a.db)return c?a.db.get(k?c:b,k?b:c,d,e,f,g,h):a.db.get(b,"",d,e,f,g,h);a=c?(a=a.S.get(k?b:c))&&a.get(k?c:b):a.map.get(b);return a};L.prototype.remove=function(a,b){const c=this.B.size&&(this.C?this.B.get(a):this.B.has(a));if(c){if(this.C)for(let d=0,e;de.length)e.pop();else{const f=e.indexOf(a);f===c.length-1?e.pop():e.splice(f,1)}}else db(this.map,a),this.depth&&db(this.S,a);b||this.B.delete(a)}this.db&&(this.ga.push({del:a}),this.na&&Ua(this));this.cache&&this.cache.remove(a);return this}; +function db(a,b){let c=0;if(a.constructor===Array)for(let d=0,e,f;dc.add(a,b)):this.add(a,b)}; +y.import=function(a,b){if(b)switch(G(b)&&(b=JSON.parse(b)),a=a.split("."),"json"===a[a.length-1]&&a.pop(),a=1 { -// const split = res.split(":"); -// split[1] = split[1].split("|").map(ids => ids ? ids.split(",") : null); -// return split; -// }); -// flexsearch.map = new Map(map); -// -// input = input.substring(pos_map + 1); -// if(input){ -// const ctx = input.split(";").map(res => { -// const split = res.split(":"); -// const context = split[0].split("+"); -// const map = new Map([ -// [context[1], split[1].split("|").map(ids => ids ? ids.split(",") : null)] -// ]); -// return [context[0], map] -// }); -// flexsearch.ctx = new Map(ctx); -// } -// } \ No newline at end of file +} \ No newline at end of file diff --git a/dist/module-debug/worker.js b/dist/module-debug/worker.js index 2a23bd3..39ca44d 100644 --- a/dist/module-debug/worker.js +++ b/dist/module-debug/worker.js @@ -11,7 +11,7 @@ let pid = 0; export default function WorkerIndex(options = {}) { - if (this.constructor !== WorkerIndex) { + if (!this || this.constructor !== WorkerIndex) { return new WorkerIndex(options); } diff --git a/dist/module-min/document.js b/dist/module-min/document.js index 227a2f6..f05680d 100644 --- a/dist/module-min/document.js +++ b/dist/module-min/document.js @@ -1 +1 @@ -import{DocumentOptions,DocumentDescriptor,DocumentIndexOptions,StoreOptions}from"./type.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Cache,{searchCache}from"./cache.js";import{is_string,is_object,parse_simple}from"./common.js";import apply_async from"./async.js";import{exportDocument,importDocument}from"./serialize.js";import{KeystoreMap,KeystoreSet}from"./keystore.js";import"./document/add.js";import"./document/search.js";export default function Document(a){if(this.constructor!==Document)return new Document(a);const b=a.document||a.doc||a;let c,d;if(this.tree=[],this.field=[],this.marker=[],this.key=(c=b.key||b.id)&&parse_tree(c,this.marker)||"id",d=a.keystore||0,d&&(this.keystore=d),this.fastupdate=!!a.fastupdate,this.reg=this.fastupdate?d&&!0?new KeystoreMap(d):new Map:d&&!0?new KeystoreSet(d):new Set,this.storetree=(c=b.store||null)&&!0!==c&&[],this.store=c&&(d&&!0?new KeystoreMap(d):new Map),this.cache=(c=a.cache||null)&&new Cache(c),a.cache=!1,this.worker=a.worker,this.index=parse_descriptor.call(this,a,b),(this.tag=null,(c=b.tag)&&("string"==typeof c&&(c=[c]),c.length))){this.tag=new Map,this.tagtree=[],this.tagfield=[];for(let a,b,d=0;da.length?this.addMapper(a,b):(this.matcher||(this.matcher=new Map),this.matcher.set(a,b),this.matcher_str+=(this.matcher_str?"|":"")+a,this.matcher_test=null,this.cache&&this.invalidate(),this)},Encoder.prototype.addStemmer=function(a,b){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(a,b),this.stemmer_str+=(this.stemmer_str?"|":"")+a,this.stemmer_test=null,this.cache&&this.invalidate(),this},Encoder.prototype.addFilter=function(a){return this.filter||(this.filter=new Set),this.filter.add(a),this.cache&&this.invalidate(),this},Encoder.prototype.addMapper=function(a,b){return"object"==typeof a?this.addReplacer(a,b):1this.stemmer.get(a)),a=1),e&&a&&(e.lengththis.matcher.get(a))),e&&this.replacer)for(let a=0;e&&athis.cache_size&&(this.cache_term.clear(),this.cache_term_length=0|this.cache_term_length/1.1)),e&&c.push(e)}return this.finalize&&(c=this.finalize(c)||c),this.cache&&a.length<=this.cache_enc_length&&(this.cache_enc.set(a,c),this.cache_enc.size>this.cache_size&&(this.cache_enc.clear(),this.cache_enc_length=0|this.cache_enc_length/1.1)),c};function clear(a){a.timer=null,a.cache_enc.clear(),a.cache_term.clear()} \ No newline at end of file +import{parse_option}from"./common.js";import normalize_polyfill from"./charset/normalize.js";import{EncoderOptions}from"./type.js";const whitespace=/[^\p{L}\p{N}]+/u,numeric_split_length=/(\d{3})/g,numeric_split_prev_char=/(\D)(\d{3})/g,numeric_split_next_char=/(\d{3})(\D)/g,normalize=/[\u0300-\u036f]/g;export default function Encoder(){if(!this||this.constructor!==Encoder)return new Encoder(...arguments);for(let a=0;aa.length?this.addMapper(a,b):(this.matcher||(this.matcher=new Map),this.matcher.set(a,b),this.matcher_str+=(this.matcher_str?"|":"")+a,this.matcher_test=null,this.cache&&this.invalidate(),this)},Encoder.prototype.addStemmer=function(a,b){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(a,b),this.stemmer_str+=(this.stemmer_str?"|":"")+a,this.stemmer_test=null,this.cache&&this.invalidate(),this},Encoder.prototype.addFilter=function(a){return this.filter||(this.filter=new Set),this.filter.add(a),this.cache&&this.invalidate(),this},Encoder.prototype.addMapper=function(a,b){return"object"==typeof a?this.addReplacer(a,b):1this.stemmer.get(a)),a=1),e&&a&&(e.lengththis.matcher.get(a))),e&&this.replacer)for(let a=0;e&&athis.cache_size&&(this.cache_term.clear(),this.cache_term_length=0|this.cache_term_length/1.1)),e&&c.push(e)}return this.finalize&&(c=this.finalize(c)||c),this.cache&&a.length<=this.cache_enc_length&&(this.cache_enc.set(a,c),this.cache_enc.size>this.cache_size&&(this.cache_enc.clear(),this.cache_enc_length=0|this.cache_enc_length/1.1)),c};function clear(a){a.timer=null,a.cache_enc.clear(),a.cache_term.clear()} \ No newline at end of file diff --git a/dist/module-min/index.js b/dist/module-min/index.js index 06cc57c..5fe0587 100644 --- a/dist/module-min/index.js +++ b/dist/module-min/index.js @@ -1 +1 @@ -import{IndexOptions,ContextOptions}from"./type.js";import Encoder from"./encoder.js";import Cache,{searchCache}from"./cache.js";import Charset from"./charset.js";import{KeystoreMap,KeystoreSet}from"./keystore.js";import{is_array,is_string}from"./common.js";import{exportIndex,importIndex,serialize}from"./serialize.js";import default_encoder from"./charset/latin/default.js";import apply_preset from"./preset.js";import apply_async from"./async.js";import tick from"./profiler.js";import"./index/add.js";import"./index/search.js";import"./index/remove.js";export default function Index(a,b){if(this.constructor!==Index)return new Index(a);!1,a=a?apply_preset(a):{};const c=a.context||{},d=is_string(a.encoder)?Charset[a.encoder]:a.encode||a.encoder||default_encoder;this.encoder=d.encode?d:"object"==typeof d?new Encoder(d):{encode:d},this.compress=a.compress||a.compression||!1;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.fastupdate=!!a.fastupdate,this.score=a.score||null,e=a.keystore||0,e&&(this.keystore=e),this.map=e&&!0?new KeystoreMap(e):new Map,this.ctx=e&&!0?new KeystoreMap(e):new Map,this.reg=b||(this.fastupdate?e&&!0?new KeystoreMap(e):new Map:e&&!0?new KeystoreSet(e):new Set),this.resolution_ctx=c.resolution||1,this.rtl=d.rtl||a.rtl||!1,this.cache=(e=a.cache||null)&&new Cache(e),this.resolve=!1!==a.resolve,(e=a.db)&&(this.db=this.mount(e)),this.commit_auto=!1!==a.commit,this.commit_task=[],this.commit_timer=null}Index.prototype.mount=function(a){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),a.mount(this)},Index.prototype.commit=function(a,b){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.commit(this,a,b)},Index.prototype.destroy=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.destroy()};export function autoCommit(a,b,c){a.commit_timer||(a.commit_timer=setTimeout(function(){a.commit_timer=null,a.db.commit(a,b,c)},0))}Index.prototype.clear=function(){return this.map.clear(),this.ctx.clear(),this.reg.clear(),this.cache&&this.cache.clear(),this.db&&(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[{clear:!0}]),this},Index.prototype.append=function(a,b){return this.add(a,b,!0)},Index.prototype.contain=function(a){return this.db?this.db.has(a):this.reg.has(a)},Index.prototype.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 cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;dc.add(a,b)):this.add(a,b)};function cleanup_index(a){let b=0;if(is_array(a))for(let c,d=0;d { -// const split = res.split(":"); -// split[1] = split[1].split("|").map(ids => ids ? ids.split(",") : null); -// return split; -// }); -// flexsearch.map = new Map(map); -// -// input = input.substring(pos_map + 1); -// if(input){ -// const ctx = input.split(";").map(res => { -// const split = res.split(":"); -// const context = split[0].split("+"); -// const map = new Map([ -// [context[1], split[1].split("|").map(ids => ids ? ids.split(",") : null)] -// ]); -// return [context[0], map] -// }); -// flexsearch.ctx = new Map(ctx); -// } -// } \ No newline at end of file +} \ No newline at end of file diff --git a/dist/module/worker.js b/dist/module/worker.js index 2a23bd3..39ca44d 100644 --- a/dist/module/worker.js +++ b/dist/module/worker.js @@ -11,7 +11,7 @@ let pid = 0; export default function WorkerIndex(options = {}) { - if (this.constructor !== WorkerIndex) { + if (!this || this.constructor !== WorkerIndex) { return new WorkerIndex(options); } diff --git a/src/document.js b/src/document.js index ed6cfdb..4c06d8c 100644 --- a/src/document.js +++ b/src/document.js @@ -38,7 +38,7 @@ import "./document/search.js"; export default function Document(options){ - if(this.constructor !== Document) { + if(!this || this.constructor !== Document) { return new Document(options); } diff --git a/src/encoder.js b/src/encoder.js index b316d47..3b55493 100644 --- a/src/encoder.js +++ b/src/encoder.js @@ -63,7 +63,7 @@ const normalize = "".normalize && /[\u0300-\u036f]/g; // '´`’ʼ., export default function Encoder(options){ - if(this.constructor !== Encoder){ + if(!this || this.constructor !== Encoder){ return new Encoder(...arguments); } diff --git a/src/index.js b/src/index.js index 44739d5..e3deaf8 100644 --- a/src/index.js +++ b/src/index.js @@ -47,7 +47,7 @@ import "./index/remove.js"; export default function Index(options, _register){ - if(this.constructor !== Index){ + if(!this || this.constructor !== Index){ return new Index(options); } diff --git a/src/resolver.js b/src/resolver.js index 2078d6f..75ebd5b 100644 --- a/src/resolver.js +++ b/src/resolver.js @@ -12,7 +12,7 @@ import "./resolve/not.js"; */ export default function Resolver(result){ - if(this.constructor !== Resolver){ + if(!this || this.constructor !== Resolver){ return new Resolver(result); } if(result && result.index){ diff --git a/src/serialize.js b/src/serialize.js index d1780ec..0c655e9 100644 --- a/src/serialize.js +++ b/src/serialize.js @@ -1,81 +1,173 @@ import Index from "./index.js"; import Document from "./document.js"; -import { create_object, is_string } from "./common.js"; +import { is_string } from "./common.js"; -function map_to_json(map){ - const json = []; +const chunk_size_reg = 250000; +const chunk_size_map = 5000; +const chunk_size_ctx = 1000; + +function map_to_json(map, size = 0){ + let chunk = []; + let json = []; + if(size){ + size = chunk_size_map * (chunk_size_reg / size) | 0; + } for(const item of map.entries()){ json.push(item); + if(json.length === size){ + chunk.push(json); + json = []; + } } - return json; + json.length && chunk.push(json); + return chunk; } -function ctx_to_json(ctx){ - const json = []; - for(const item of ctx.entries()){ - json.push(map_to_json(item)); +function json_to_map(json, map){ + map || (map = new Map()); + for(let i = 0, entry; i < json.length; i++) { + entry = json[i]; + map.set(entry[0], entry[1]); } - return json; + return map; +} + +function ctx_to_json(ctx, size = 0){ + let chunk = []; + let json = []; + if(size){ + size = chunk_size_ctx * (chunk_size_reg / size) | 0; + } + for(const item of ctx.entries()){ + const key = item[0]; + const value = item[1]; + json.push([key, map_to_json(value)[0]]); + if(json.length === size){ + chunk.push(json); + json = []; + } + } + json.length && chunk.push(json); + return chunk; +} + +function json_to_ctx(json, ctx){ + ctx || (ctx = new Map()); + for(let i = 0, entry, map; i < json.length; i++) { + entry = json[i]; + map = ctx.get(entry[0]); + ctx.set(entry[0], json_to_map(entry[1], map)); + } + return ctx; } function reg_to_json(reg){ - const json = []; + let chunk = []; + let json = []; for(const key of reg.keys()){ json.push(key); + if(json.length === chunk_size_reg){ + chunk.push(json); + json = []; + } } - return json; + json.length && chunk.push(json); + return chunk; } -function save(callback, field, key, index_doc, index, data){ +function json_to_reg(json, reg){ + reg || (reg = new Set()); + for(let i = 0; i < json.length; i++) { + reg.add(json[i]); + } + return reg; +} - const res = callback(field ? field + "." + key : key, JSON.stringify(data)); +/** + * @this {Index|Document} + */ + +function save(callback, field, key, chunk, index_doc, index_obj, index_prt = 0){ + + const is_arr = chunk && chunk.constructor === Array; + const data = is_arr ? chunk.shift() : chunk; + if(!data){ + return this.export( + callback, + field, + index_doc, + index_obj + 1 + ); + } + + const res = callback( + (field ? field + "." : "") + (index_prt + 1) + "." + key, + JSON.stringify(data) + ); if(res && res["then"]){ const self = this; return res["then"](function(){ - return self.export(callback, field, index_doc, index + 1); + return save.call(self, + callback, + field, + key, + is_arr ? chunk : null, + index_doc, + index_obj, + index_prt + 1 + ); }); } - return this.export(callback, field, index_doc, index + 1); + return save.call(this, + callback, + field, + key, + is_arr ? chunk : null, + index_doc, + index_obj, + index_prt + 1 + ); } /** * @param callback * @param field * @param index_doc - * @param index - * @this {Index|Document} + * @param index_obj + * @this {Index} */ -export function exportIndex(callback, field, index_doc, index = 0){ +export function exportIndex(callback, field, index_doc, index_obj = 0){ - let key, data; + let key, chunk; - switch(index){ + switch(index_obj){ case 0: key = "reg"; - data = reg_to_json(this.reg); + chunk = reg_to_json(this.reg); break; case 1: + // todo key = "cfg"; - data = {}; + chunk = {}; break; case 2: key = "map"; - data = map_to_json(this.map); + chunk = map_to_json(this.map, this.reg.size); break; case 3: key = "ctx"; - data = ctx_to_json(this.ctx); + chunk = ctx_to_json(this.ctx, this.reg.size); break; default: @@ -83,11 +175,18 @@ export function exportIndex(callback, field, index_doc, index = 0){ return; } - return save.call(this, callback, field, key, index_doc, index, data); + return save.call(this, + callback, + field, + key, + chunk, + index_doc, + index_obj + ); } /** - * @this Index + * @this {Index} */ export function importIndex(key, data){ @@ -99,83 +198,90 @@ export function importIndex(key, data){ data = JSON.parse(data); } + key = key.split("."); + if(key[key.length - 1] === "json"){ + key.pop(); + } + key = key.length > 1 ? key[1] : key[0]; + switch(key){ case "cfg": + // todo break; case "reg": // fast update isn't supported by export/import this.fastupdate = false; - this.reg = new Set(data); + this.reg = json_to_reg(data, this.reg); break; case "map": - this.map = new Map(data); + this.map = json_to_map(data, this.map); break; case "ctx": - this.ctx = new Map(data); + this.ctx = json_to_ctx(data, this.ctx); break; } } /** - * @this Document + * @this {Document} */ -export function exportDocument(callback, field, index_doc = 0, index = 0){ +export function exportDocument(callback, field, index_doc = 0, index_obj = 0){ if(index_doc < this.field.length){ const field = this.field[index_doc]; const idx = this.index.get(field); // start from index 1, because document indexes does not additionally store register - const res = idx.export(callback, field, index_doc, index = 1); + const res = idx.export(callback, field, index_doc, index_obj = 1); if(res && res["then"]){ const self = this; return res["then"](function(){ - return self.export(callback, field, index_doc + 1, index = 0); + return self.export(callback, field, index_doc + 1); }); } - return this.export(callback, field, index_doc + 1, index = 0); + return this.export(callback, field, index_doc + 1); } else{ - let key, data; + let key, chunk; - switch(index){ + switch(index_obj){ case 0: key = "reg"; - data = reg_to_json(this.reg); + chunk = reg_to_json(this.reg); field = null; break; case 1: key = "tag"; - data = ctx_to_json(this.tag); + chunk = ctx_to_json(this.tag, this.reg.size); field = null; break; case 2: key = "doc"; - data = map_to_json(this.store); + chunk = map_to_json(this.store); field = null; break; case 3: key = "cfg"; - data = {}; + chunk = {}; field = null; break; @@ -184,12 +290,19 @@ export function exportDocument(callback, field, index_doc = 0, index = 0){ return; } - return save.call(this, callback, field, key, index_doc, index, data); + return save.call(this, + callback, + field, + key, + chunk, + index_doc, + index_obj + ); } } /** - * @this Document + * @this {Document} */ export function importDocument(key, data){ @@ -201,41 +314,50 @@ export function importDocument(key, data){ data = JSON.parse(data); } - switch(key){ + key = key.split("."); + if(key[key.length - 1] === "json"){ + key.pop(); + } + const field = key.length > 2 ? key[0] : ""; + key = key.length > 2 ? key[2] : key[1]; - case "tag": + if(!field){ - this.tagindex = new Map(data); - break; + switch(key){ - case "reg": + case "reg": - // fast update isn't supported by export/import - this.fastupdate = false; - this.reg = new Set(data); + // fast update isn't supported by export/import + this.fastupdate = false; + this.reg = json_to_reg(data, this.reg); - for(let i = 0, idx; i < this.field.length; i++){ - idx = this.index.get(this.field[i]); - idx.fastupdate = false; - idx.reg = this.reg; - } + for(let i = 0, idx; i < this.field.length; i++){ + idx = this.index.get(this.field[i]); + idx.fastupdate = false; + idx.reg = this.reg; + } - break; + break; - case "doc": + case "tag": - this.store = new Map(data); - break; + this.tag = json_to_ctx(data, this.tag); + break; - default: + case "doc": - key = key.split("."); - const field = key[0]; - key = key[1]; + this.store = json_to_map(data, this.store); + break; - if(field && key){ - this.index.get(field).import(key, data); - } + case "cfg": + + break; + + } + } + else{ + + return this.index.get(field).import(key, data); } } @@ -312,88 +434,3 @@ export function serialize(withFunctionWrapper = true){ ? "function inject(index){" + reg + map + ctx + "}" : reg + map + ctx } - -// export function exportSnapshot(flexsearch){ -// -// if(!flexsearch.reg.size) return; -// -// let reg = ''; -// let type = ""; -// for(const key of flexsearch.reg.keys()){ -// type || (type = typeof key); -// reg += (reg ? ',' : '') + (type === "string" ? '"' + key + '"' : key); -// } -// reg = "f.reg=[" + reg + "];"; -// -// let map = ''; -// for(const item of flexsearch.map.entries()){ -// const key = item[0]; -// const value = item[1]; -// let res = ''; -// for(let i = 0, ids; i < value.length; i++){ -// ids = value[i] || ['']; -// let str = ''; -// for(let j = 0; j < ids.length; j++){ -// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]); -// } -// str = "[ -// res += (res ? '|' : '') + str; -// } -// map += (map ? ';' : '') + key + ':' + res; -// } -// -// -// let ctx = ''; -// for(const context of flexsearch.ctx.entries()){ -// const key_ctx = context[0]; -// const value_ctx = context[1]; -// -// for(const item of value_ctx.entries()){ -// const key = item[0]; -// const value = item[1]; -// -// let res = ''; -// for(let i = 0, ids; i < value.length; i++){ -// ids = value[i] || ['']; -// let str = ''; -// for(let j = 0; j < ids.length; j++){ -// str += (str ? ',' : '') + (type === "string" ? '"' + ids[j] + '"' : ids[j]); -// } -// res += (res ? '|' : '') + str; -// } -// ctx += (ctx ? ';' : '') + key_ctx + '+' + key + ':' + res; -// } -// } -// -// return reg + '#' + map + '#' + ctx; -// } -// -// export function importSnapshot(flexsearch, input){ -// -// if(!input) return; -// -// let pos_reg = input.indexOf("#"); -// const reg = input.substring(0, pos_reg).split(","); -// flexsearch.reg = new Set(reg); -// -// let pos_map = input.indexOf("#", pos_reg + 1); -// const map = input.substring(pos_reg + 1, pos_map).split(";").map(res => { -// const split = res.split(":"); -// split[1] = split[1].split("|").map(ids => ids ? ids.split(",") : null); -// return split; -// }); -// flexsearch.map = new Map(map); -// -// input = input.substring(pos_map + 1); -// if(input){ -// const ctx = input.split(";").map(res => { -// const split = res.split(":"); -// const context = split[0].split("+"); -// const map = new Map([ -// [context[1], split[1].split("|").map(ids => ids ? ids.split(",") : null)] -// ]); -// return [context[0], map] -// }); -// flexsearch.ctx = new Map(ctx); -// } -// } diff --git a/src/worker.js b/src/worker.js index e69c36d..4b160f8 100644 --- a/src/worker.js +++ b/src/worker.js @@ -11,7 +11,7 @@ let pid = 0; export default function WorkerIndex(options = {}){ - if(this.constructor !== WorkerIndex) { + if(!this || this.constructor !== WorkerIndex) { return new WorkerIndex(options); } diff --git a/task/build.js b/task/build.js index d653ac8..a72fac4 100644 --- a/task/build.js +++ b/task/build.js @@ -136,6 +136,16 @@ if(release === "lang"){ fs.cpSync("src/", "tmp/", { recursive: true }); fs.copyFileSync("src/db/interface.js", "tmp/db/interface.js"); + // add the eval wrapper + let content = fs.readFileSync("tmp/worker/handler.js", "utf8"); + content = content.replace('options = (await import(filepath))["default"];', '//options = (await import(filepath))["default"];'); + fs.writeFileSync("tmp/worker/handler.js", content); + + // add the eval wrapper + content = fs.readFileSync("tmp/worker.js", "utf8"); + content = content.replace("import.meta.url", '(1,eval)("import.meta.url")'); + fs.writeFileSync("tmp/worker.js", content); + (function next(x, y, z){ if(x < supported_lang.length){ @@ -143,7 +153,6 @@ if(release === "lang"){ (function(lang){ //fs.copyFileSync("src/lang/" + lang + ".js", "tmp/lang/" + lang + ".js"); - //console.log(lang) fs.writeFileSync("tmp/lang.js", `