docs.foss.global/docs/.vitepress/cache/deps/vitepress___minisearch.js.map
2025-01-24 02:39:54 +01:00

8 lines
142 KiB
Plaintext

{
"version": 3,
"sources": ["../../../../node_modules/.pnpm/minisearch@7.1.1/node_modules/minisearch/node_modules/tslib/tslib.es6.js", "../../../../node_modules/.pnpm/minisearch@7.1.1/node_modules/minisearch/src/SearchableMap/TreeIterator.ts", "../../../../node_modules/.pnpm/minisearch@7.1.1/node_modules/minisearch/src/SearchableMap/fuzzySearch.ts", "../../../../node_modules/.pnpm/minisearch@7.1.1/node_modules/minisearch/src/SearchableMap/SearchableMap.ts", "../../../../node_modules/.pnpm/minisearch@7.1.1/node_modules/minisearch/src/MiniSearch.ts"],
"sourcesContent": ["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n function next() {\r\n while (env.stack.length) {\r\n var rec = env.stack.pop();\r\n try {\r\n var result = rec.dispose && rec.dispose.call(rec.value);\r\n if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n};\r\n", "import type { RadixTree, Entry, LeafType } from './types'\n\n/** @ignore */\nconst ENTRIES = 'ENTRIES'\n\n/** @ignore */\nconst KEYS = 'KEYS'\n\n/** @ignore */\nconst VALUES = 'VALUES'\n\n/** @ignore */\nconst LEAF = '' as LeafType\n\ninterface Iterators<T> {\n ENTRIES: Entry<T>\n KEYS: string\n VALUES: T\n}\n\ntype Kind<T> = keyof Iterators<T>\ntype Result<T, K extends keyof Iterators<T>> = Iterators<T>[K]\n\ntype IteratorPath<T> = {\n node: RadixTree<T>,\n keys: string[]\n}[]\n\nexport type IterableSet<T> = {\n _tree: RadixTree<T>,\n _prefix: string\n}\n\n/**\n * @private\n */\nclass TreeIterator<T, K extends Kind<T>> implements Iterator<Result<T, K>> {\n set: IterableSet<T>\n _type: K\n _path: IteratorPath<T>\n\n constructor (set: IterableSet<T>, type: K) {\n const node = set._tree\n const keys = Array.from(node.keys())\n this.set = set\n this._type = type\n this._path = keys.length > 0 ? [{ node, keys }] : []\n }\n\n next (): IteratorResult<Result<T, K>> {\n const value = this.dive()\n this.backtrack()\n return value\n }\n\n dive (): IteratorResult<Result<T, K>> {\n if (this._path.length === 0) { return { done: true, value: undefined } }\n const { node, keys } = last(this._path)!\n if (last(keys) === LEAF) { return { done: false, value: this.result() } }\n\n const child = node.get(last(keys)!)!\n this._path.push({ node: child, keys: Array.from(child.keys()) })\n return this.dive()\n }\n\n backtrack (): void {\n if (this._path.length === 0) { return }\n const keys = last(this._path)!.keys\n keys.pop()\n if (keys.length > 0) { return }\n this._path.pop()\n this.backtrack()\n }\n\n key (): string {\n return this.set._prefix + this._path\n .map(({ keys }) => last(keys))\n .filter(key => key !== LEAF)\n .join('')\n }\n\n value (): T {\n return last(this._path)!.node.get(LEAF)!\n }\n\n result (): Result<T, K> {\n switch (this._type) {\n case VALUES: return this.value() as Result<T, K>\n case KEYS: return this.key() as Result<T, K>\n default: return [this.key(), this.value()] as Result<T, K>\n }\n }\n\n [Symbol.iterator] () {\n return this\n }\n}\n\nconst last = <T>(array: T[]): T | undefined => {\n return array[array.length - 1]\n}\n\nexport { TreeIterator, ENTRIES, KEYS, VALUES, LEAF }\n", "/* eslint-disable no-labels */\nimport { LEAF } from './TreeIterator'\nimport type { RadixTree } from './types'\n\nexport type FuzzyResult<T> = [T, number]\n\nexport type FuzzyResults<T> = Map<string, FuzzyResult<T>>\n\n/**\n * @ignore\n */\nexport const fuzzySearch = <T = any>(node: RadixTree<T>, query: string, maxDistance: number): FuzzyResults<T> => {\n const results: FuzzyResults<T> = new Map()\n if (query === undefined) return results\n\n // Number of columns in the Levenshtein matrix.\n const n = query.length + 1\n\n // Matching terms can never be longer than N + maxDistance.\n const m = n + maxDistance\n\n // Fill first matrix row and column with numbers: 0 1 2 3 ...\n const matrix = new Uint8Array(m * n).fill(maxDistance + 1)\n for (let j = 0; j < n; ++j) matrix[j] = j\n for (let i = 1; i < m; ++i) matrix[i * n] = i\n\n recurse(\n node,\n query,\n maxDistance,\n results,\n matrix,\n 1,\n n,\n ''\n )\n\n return results\n}\n\n// Modified version of http://stevehanov.ca/blog/?id=114\n\n// This builds a Levenshtein matrix for a given query and continuously updates\n// it for nodes in the radix tree that fall within the given maximum edit\n// distance. Keeping the same matrix around is beneficial especially for larger\n// edit distances.\n//\n// k a t e <-- query\n// 0 1 2 3 4\n// c 1 1 2 3 4\n// a 2 2 1 2 3\n// t 3 3 2 1 [2] <-- edit distance\n// ^\n// ^ term in radix tree, rows are added and removed as needed\n\nconst recurse = <T = any>(\n node: RadixTree<T>,\n query: string,\n maxDistance: number,\n results: FuzzyResults<T>,\n matrix: Uint8Array,\n m: number,\n n: number,\n prefix: string\n): void => {\n const offset = m * n\n\n key: for (const key of node.keys()) {\n if (key === LEAF) {\n // We've reached a leaf node. Check if the edit distance acceptable and\n // store the result if it is.\n const distance = matrix[offset - 1]\n if (distance <= maxDistance) {\n results.set(prefix, [node.get(key)!, distance])\n }\n } else {\n // Iterate over all characters in the key. Update the Levenshtein matrix\n // and check if the minimum distance in the last row is still within the\n // maximum edit distance. If it is, we can recurse over all child nodes.\n let i = m\n for (let pos = 0; pos < key.length; ++pos, ++i) {\n const char = key[pos]\n const thisRowOffset = n * i\n const prevRowOffset = thisRowOffset - n\n\n // Set the first column based on the previous row, and initialize the\n // minimum distance in the current row.\n let minDistance = matrix[thisRowOffset]\n\n const jmin = Math.max(0, i - maxDistance - 1)\n const jmax = Math.min(n - 1, i + maxDistance)\n\n // Iterate over remaining columns (characters in the query).\n for (let j = jmin; j < jmax; ++j) {\n const different = char !== query[j]\n\n // It might make sense to only read the matrix positions used for\n // deletion/insertion if the characters are different. But we want to\n // avoid conditional reads for performance reasons.\n const rpl = matrix[prevRowOffset + j] + +different\n const del = matrix[prevRowOffset + j + 1] + 1\n const ins = matrix[thisRowOffset + j] + 1\n\n const dist = matrix[thisRowOffset + j + 1] = Math.min(rpl, del, ins)\n\n if (dist < minDistance) minDistance = dist\n }\n\n // Because distance will never decrease, we can stop. There will be no\n // matching child nodes.\n if (minDistance > maxDistance) {\n continue key\n }\n }\n\n recurse(\n node.get(key)!,\n query,\n maxDistance,\n results,\n matrix,\n i,\n n,\n prefix + key\n )\n }\n }\n}\n\nexport default fuzzySearch\n", "/* eslint-disable no-labels */\nimport { TreeIterator, ENTRIES, KEYS, VALUES, LEAF } from './TreeIterator'\nimport fuzzySearch, { type FuzzyResults } from './fuzzySearch'\nimport type { RadixTree, Entry, Path } from './types'\n\n/**\n * A class implementing the same interface as a standard JavaScript\n * [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\n * with string keys, but adding support for efficiently searching entries with\n * prefix or fuzzy search. This class is used internally by {@link MiniSearch}\n * as the inverted index data structure. The implementation is a radix tree\n * (compressed prefix tree).\n *\n * Since this class can be of general utility beyond _MiniSearch_, it is\n * exported by the `minisearch` package and can be imported (or required) as\n * `minisearch/SearchableMap`.\n *\n * @typeParam T The type of the values stored in the map.\n */\nexport default class SearchableMap<T = any> {\n /**\n * @internal\n */\n _tree: RadixTree<T>\n\n /**\n * @internal\n */\n _prefix: string\n\n private _size: number | undefined = undefined\n\n /**\n * The constructor is normally called without arguments, creating an empty\n * map. In order to create a {@link SearchableMap} from an iterable or from an\n * object, check {@link SearchableMap.from} and {@link\n * SearchableMap.fromObject}.\n *\n * The constructor arguments are for internal use, when creating derived\n * mutable views of a map at a prefix.\n */\n constructor (tree: RadixTree<T> = new Map(), prefix = '') {\n this._tree = tree\n this._prefix = prefix\n }\n\n /**\n * Creates and returns a mutable view of this {@link SearchableMap},\n * containing only entries that share the given prefix.\n *\n * ### Usage:\n *\n * ```javascript\n * let map = new SearchableMap()\n * map.set(\"unicorn\", 1)\n * map.set(\"universe\", 2)\n * map.set(\"university\", 3)\n * map.set(\"unique\", 4)\n * map.set(\"hello\", 5)\n *\n * let uni = map.atPrefix(\"uni\")\n * uni.get(\"unique\") // => 4\n * uni.get(\"unicorn\") // => 1\n * uni.get(\"hello\") // => undefined\n *\n * let univer = map.atPrefix(\"univer\")\n * univer.get(\"unique\") // => undefined\n * univer.get(\"universe\") // => 2\n * univer.get(\"university\") // => 3\n * ```\n *\n * @param prefix The prefix\n * @return A {@link SearchableMap} representing a mutable view of the original\n * Map at the given prefix\n */\n atPrefix (prefix: string): SearchableMap<T> {\n if (!prefix.startsWith(this._prefix)) { throw new Error('Mismatched prefix') }\n\n const [node, path] = trackDown(this._tree, prefix.slice(this._prefix.length))\n\n if (node === undefined) {\n const [parentNode, key] = last(path)\n\n for (const k of parentNode!.keys()) {\n if (k !== LEAF && k.startsWith(key)) {\n const node = new Map()\n node.set(k.slice(key.length), parentNode!.get(k)!)\n return new SearchableMap(node, prefix)\n }\n }\n }\n\n return new SearchableMap<T>(node, prefix)\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear\n */\n clear (): void {\n this._size = undefined\n this._tree.clear()\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete\n * @param key Key to delete\n */\n delete (key: string): void {\n this._size = undefined\n return remove(this._tree, key)\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries\n * @return An iterator iterating through `[key, value]` entries.\n */\n entries () {\n return new TreeIterator(this, ENTRIES)\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach\n * @param fn Iteration function\n */\n forEach (fn: (key: string, value: T, map: SearchableMap) => void): void {\n for (const [key, value] of this) {\n fn(key, value, this)\n }\n }\n\n /**\n * Returns a Map of all the entries that have a key within the given edit\n * distance from the search key. The keys of the returned Map are the matching\n * keys, while the values are two-element arrays where the first element is\n * the value associated to the key, and the second is the edit distance of the\n * key to the search key.\n *\n * ### Usage:\n *\n * ```javascript\n * let map = new SearchableMap()\n * map.set('hello', 'world')\n * map.set('hell', 'yeah')\n * map.set('ciao', 'mondo')\n *\n * // Get all entries that match the key 'hallo' with a maximum edit distance of 2\n * map.fuzzyGet('hallo', 2)\n * // => Map(2) { 'hello' => ['world', 1], 'hell' => ['yeah', 2] }\n *\n * // In the example, the \"hello\" key has value \"world\" and edit distance of 1\n * // (change \"e\" to \"a\"), the key \"hell\" has value \"yeah\" and edit distance of 2\n * // (change \"e\" to \"a\", delete \"o\")\n * ```\n *\n * @param key The search key\n * @param maxEditDistance The maximum edit distance (Levenshtein)\n * @return A Map of the matching keys to their value and edit distance\n */\n fuzzyGet (key: string, maxEditDistance: number): FuzzyResults<T> {\n return fuzzySearch<T>(this._tree, key, maxEditDistance)\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get\n * @param key Key to get\n * @return Value associated to the key, or `undefined` if the key is not\n * found.\n */\n get (key: string): T | undefined {\n const node = lookup<T>(this._tree, key)\n return node !== undefined ? node.get(LEAF) : undefined\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has\n * @param key Key\n * @return True if the key is in the map, false otherwise\n */\n has (key: string): boolean {\n const node = lookup(this._tree, key)\n return node !== undefined && node.has(LEAF)\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys\n * @return An `Iterable` iterating through keys\n */\n keys () {\n return new TreeIterator(this, KEYS)\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set\n * @param key Key to set\n * @param value Value to associate to the key\n * @return The {@link SearchableMap} itself, to allow chaining\n */\n set (key: string, value: T): SearchableMap<T> {\n if (typeof key !== 'string') { throw new Error('key must be a string') }\n this._size = undefined\n const node = createPath(this._tree, key)\n node.set(LEAF, value)\n return this\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size\n */\n get size (): number {\n if (this._size) { return this._size }\n /** @ignore */\n this._size = 0\n\n const iter = this.entries()\n while (!iter.next().done) this._size! += 1\n\n return this._size\n }\n\n /**\n * Updates the value at the given key using the provided function. The function\n * is called with the current value at the key, and its return value is used as\n * the new value to be set.\n *\n * ### Example:\n *\n * ```javascript\n * // Increment the current value by one\n * searchableMap.update('somekey', (currentValue) => currentValue == null ? 0 : currentValue + 1)\n * ```\n *\n * If the value at the given key is or will be an object, it might not require\n * re-assignment. In that case it is better to use `fetch()`, because it is\n * faster.\n *\n * @param key The key to update\n * @param fn The function used to compute the new value from the current one\n * @return The {@link SearchableMap} itself, to allow chaining\n */\n update (key: string, fn: (value: T | undefined) => T): SearchableMap<T> {\n if (typeof key !== 'string') { throw new Error('key must be a string') }\n this._size = undefined\n const node = createPath(this._tree, key)\n node.set(LEAF, fn(node.get(LEAF)))\n return this\n }\n\n /**\n * Fetches the value of the given key. If the value does not exist, calls the\n * given function to create a new value, which is inserted at the given key\n * and subsequently returned.\n *\n * ### Example:\n *\n * ```javascript\n * const map = searchableMap.fetch('somekey', () => new Map())\n * map.set('foo', 'bar')\n * ```\n *\n * @param key The key to update\n * @param initial A function that creates a new value if the key does not exist\n * @return The existing or new value at the given key\n */\n fetch (key: string, initial: () => T): T {\n if (typeof key !== 'string') { throw new Error('key must be a string') }\n this._size = undefined\n const node = createPath(this._tree, key)\n\n let value = node.get(LEAF)\n if (value === undefined) {\n node.set(LEAF, value = initial())\n }\n\n return value\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values\n * @return An `Iterable` iterating through values.\n */\n values () {\n return new TreeIterator(this, VALUES)\n }\n\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/@@iterator\n */\n [Symbol.iterator] () {\n return this.entries()\n }\n\n /**\n * Creates a {@link SearchableMap} from an `Iterable` of entries\n *\n * @param entries Entries to be inserted in the {@link SearchableMap}\n * @return A new {@link SearchableMap} with the given entries\n */\n static from<T = any> (entries: Iterable<Entry<T>> | Entry<T>[]) {\n const tree = new SearchableMap()\n for (const [key, value] of entries) {\n tree.set(key, value)\n }\n return tree\n }\n\n /**\n * Creates a {@link SearchableMap} from the iterable properties of a JavaScript object\n *\n * @param object Object of entries for the {@link SearchableMap}\n * @return A new {@link SearchableMap} with the given entries\n */\n static fromObject<T = any> (object: { [key: string]: T }) {\n return SearchableMap.from<T>(Object.entries(object))\n }\n}\n\nconst trackDown = <T = any>(tree: RadixTree<T> | undefined, key: string, path: Path<T> = []): [RadixTree<T> | undefined, Path<T>] => {\n if (key.length === 0 || tree == null) { return [tree, path] }\n\n for (const k of tree.keys()) {\n if (k !== LEAF && key.startsWith(k)) {\n path.push([tree, k]) // performance: update in place\n return trackDown(tree.get(k)!, key.slice(k.length), path)\n }\n }\n\n path.push([tree, key]) // performance: update in place\n return trackDown(undefined, '', path)\n}\n\nconst lookup = <T = any>(tree: RadixTree<T>, key: string): RadixTree<T> | undefined => {\n if (key.length === 0 || tree == null) { return tree }\n\n for (const k of tree.keys()) {\n if (k !== LEAF && key.startsWith(k)) {\n return lookup(tree.get(k)!, key.slice(k.length))\n }\n }\n}\n\n// Create a path in the radix tree for the given key, and returns the deepest\n// node. This function is in the hot path for indexing. It avoids unnecessary\n// string operations and recursion for performance.\nconst createPath = <T = any>(node: RadixTree<T>, key: string): RadixTree<T> => {\n const keyLength = key.length\n\n outer: for (let pos = 0; node && pos < keyLength;) {\n for (const k of node.keys()) {\n // Check whether this key is a candidate: the first characters must match.\n if (k !== LEAF && key[pos] === k[0]) {\n const len = Math.min(keyLength - pos, k.length)\n\n // Advance offset to the point where key and k no longer match.\n let offset = 1\n while (offset < len && key[pos + offset] === k[offset]) ++offset\n\n const child = node.get(k)!\n if (offset === k.length) {\n // The existing key is shorter than the key we need to create.\n node = child\n } else {\n // Partial match: we need to insert an intermediate node to contain\n // both the existing subtree and the new node.\n const intermediate = new Map()\n intermediate.set(k.slice(offset), child)\n node.set(key.slice(pos, pos + offset), intermediate)\n node.delete(k)\n node = intermediate\n }\n\n pos += offset\n continue outer\n }\n }\n\n // Create a final child node to contain the final suffix of the key.\n const child = new Map()\n node.set(key.slice(pos), child)\n return child\n }\n\n return node\n}\n\nconst remove = <T = any>(tree: RadixTree<T>, key: string): void => {\n const [node, path] = trackDown(tree, key)\n if (node === undefined) { return }\n node.delete(LEAF)\n\n if (node.size === 0) {\n cleanup(path)\n } else if (node.size === 1) {\n const [key, value] = node.entries().next().value\n merge(path, key, value)\n }\n}\n\nconst cleanup = <T = any>(path: Path<T>): void => {\n if (path.length === 0) { return }\n\n const [node, key] = last(path)\n node!.delete(key)\n\n if (node!.size === 0) {\n cleanup(path.slice(0, -1))\n } else if (node!.size === 1) {\n const [key, value] = node!.entries().next().value\n if (key !== LEAF) {\n merge(path.slice(0, -1), key, value)\n }\n }\n}\n\nconst merge = <T = any>(path: Path<T>, key: string, value: RadixTree<T>): void => {\n if (path.length === 0) { return }\n\n const [node, nodeKey] = last(path)\n node!.set(nodeKey + key, value)\n node!.delete(nodeKey)\n}\n\nconst last = <T = any>(array: T[]): T => {\n return array[array.length - 1]\n}\n", "import SearchableMap from './SearchableMap/SearchableMap'\n\nexport type LowercaseCombinationOperator = 'or' | 'and' | 'and_not'\nexport type CombinationOperator = LowercaseCombinationOperator | Uppercase<LowercaseCombinationOperator> | Capitalize<LowercaseCombinationOperator>\n\nconst OR: LowercaseCombinationOperator = 'or'\nconst AND: LowercaseCombinationOperator = 'and'\nconst AND_NOT: LowercaseCombinationOperator = 'and_not'\n\n/**\n * Search options to customize the search behavior.\n */\nexport type SearchOptions = {\n /**\n * Names of the fields to search in. If omitted, all fields are searched.\n */\n fields?: string[],\n\n /**\n * Function used to filter search results, for example on the basis of stored\n * fields. It takes as argument each search result and should return a boolean\n * to indicate if the result should be kept or not.\n */\n filter?: (result: SearchResult) => boolean,\n\n /**\n * Key-value object of field names to boosting values. By default, fields are\n * assigned a boosting factor of 1. If one assigns to a field a boosting value\n * of 2, a result that matches the query in that field is assigned a score\n * twice as high as a result matching the query in another field, all else\n * being equal.\n */\n boost?: { [fieldName: string]: number },\n\n /**\n * Function to calculate a boost factor for each term.\n *\n * This function, if provided, is called for each query term (as split by\n * `tokenize` and processed by `processTerm`). The arguments passed to the\n * function are the query term, the positional index of the term in the query,\n * and the array of all query terms. It is expected to return a numeric boost\n * factor for the term. A factor lower than 1 reduces the importance of the\n * term, a factor greater than 1 increases it. A factor of exactly 1 is\n * neutral, and does not affect the term's importance.\n */\n boostTerm?: (term: string, i: number, terms: string[]) => number,\n\n /**\n * Relative weights to assign to prefix search results and fuzzy search\n * results. Exact matches are assigned a weight of 1.\n */\n weights?: { fuzzy: number, prefix: number },\n\n /**\n * Function to calculate a boost factor for documents. It takes as arguments\n * the document ID, and a term that matches the search in that document, and\n * the value of the stored fields for the document (if any). It should return\n * a boosting factor: a number higher than 1 increases the computed score, a\n * number lower than 1 decreases the score, and a falsy value skips the search\n * result completely.\n */\n boostDocument?: (documentId: any, term: string, storedFields?: Record<string, unknown>) => number,\n\n /**\n * Controls whether to perform prefix search. It can be a simple boolean, or a\n * function.\n *\n * If a boolean is passed, prefix search is performed if true.\n *\n * If a function is passed, it is called upon search with a search term, the\n * positional index of that search term in the tokenized search query, and the\n * tokenized search query. The function should return a boolean to indicate\n * whether to perform prefix search for that search term.\n */\n prefix?: boolean | ((term: string, index: number, terms: string[]) => boolean),\n\n /**\n * Controls whether to perform fuzzy search. It can be a simple boolean, or a\n * number, or a function.\n *\n * If a boolean is given, fuzzy search with a default fuzziness parameter is\n * performed if true.\n *\n * If a number higher or equal to 1 is given, fuzzy search is performed, with\n * a maximum edit distance (Levenshtein) equal to the number.\n *\n * If a number between 0 and 1 is given, fuzzy search is performed within a\n * maximum edit distance corresponding to that fraction of the term length,\n * approximated to the nearest integer. For example, 0.2 would mean an edit\n * distance of 20% of the term length, so 1 character in a 5-characters term.\n * The calculated fuzziness value is limited by the `maxFuzzy` option, to\n * prevent slowdown for very long queries.\n *\n * If a function is passed, the function is called upon search with a search\n * term, a positional index of that term in the tokenized search query, and\n * the tokenized search query. It should return a boolean or a number, with\n * the meaning documented above.\n */\n fuzzy?: boolean | number | ((term: string, index: number, terms: string[]) => boolean | number),\n\n /**\n * Controls the maximum fuzziness when using a fractional fuzzy value. This is\n * set to 6 by default. Very high edit distances usually don't produce\n * meaningful results, but can excessively impact search performance.\n */\n maxFuzzy?: number,\n\n /**\n * The operand to combine partial results for each term. By default it is\n * \"OR\", so results matching _any_ of the search terms are returned by a\n * search. If \"AND\" is given, only results matching _all_ the search terms are\n * returned by a search.\n */\n combineWith?: CombinationOperator,\n\n /**\n * Function to tokenize the search query. By default, the same tokenizer used\n * for indexing is used also for search.\n *\n * @remarks This function is called after `extractField` extracts a truthy\n * value from a field. This function is then expected to split the extracted\n * `text` document into tokens (more commonly referred to as \"terms\" in this\n * context). The resulting split might be simple, like for example on word\n * boundaries, or it might be more complex, taking into account certain\n * encoding, or parsing needs, or even just special cases. Think about how one\n * might need to go about indexing the term \"short-term\". You would likely\n * want to treat this case specially, and return two terms instead, `[\n * \"short\", \"term\" ]`.\n *\n * Or, you could let such a case be handled by the `processTerm` function,\n * which is designed to turn each token/term into whole terms or sub-terms. In\n * any case, the purpose of this function is to split apart the provided\n * `text` document into parts that can be processed by the `processTerm`\n * function.\n */\n tokenize?: (text: string) => string[],\n\n /**\n * Function to process or normalize terms in the search query. By default, the\n * same term processor used for indexing is used also for search.\n *\n * @remarks\n * During the document indexing phase, the first step is to call the\n * `extractField` function to fetch the requested value/field from the\n * document. This is then passed off to the `tokenize` function, which will\n * break apart each value into \"terms\". These terms are then individually\n * passed through this function to compute each term individually. A term\n * might for example be something like \"lbs\", in which case one would likely\n * want to return `[ \"lbs\", \"lb\", \"pound\", \"pounds\" ]`. You may also return\n * just a single string, or a falsy value if you would like to skip indexing\n * entirely for a specific term.\n *\n * Truthy return value(s) are then fed to the indexer as positive matches for\n * this document. In our example above, all four of the `[ \"lbs\", \"lb\",\n * \"pound\", \"pounds\" ]` terms would be added to the indexing engine, matching\n * against the current document being computed.\n *\n * *Note: Whatever values are returned from this function will receive no\n * further processing before being indexed. This means for example, if you\n * include whitespace at the beginning or end of a word, it will also be\n * indexed that way, with the included whitespace.*\n */\n processTerm?: (term: string) => string | string[] | null | undefined | false\n\n /**\n * BM25+ algorithm parameters. Customizing these is almost never necessary,\n * and finetuning them requires an understanding of the BM25 scoring model. In\n * most cases, it is best to omit this option to use defaults, and instead use\n * boosting to tweak scoring for specific use cases.\n */\n bm25?: BM25Params\n}\n\ntype SearchOptionsWithDefaults = SearchOptions & {\n boost: { [fieldName: string]: number },\n\n weights: { fuzzy: number, prefix: number },\n\n prefix: boolean | ((term: string, index: number, terms: string[]) => boolean),\n\n fuzzy: boolean | number | ((term: string, index: number, terms: string[]) => boolean | number),\n\n maxFuzzy: number,\n\n combineWith: CombinationOperator\n\n bm25: BM25Params\n}\n\n/**\n * Configuration options passed to the {@link MiniSearch} constructor\n *\n * @typeParam T The type of documents being indexed.\n */\nexport type Options<T = any> = {\n /**\n * Names of the document fields to be indexed.\n */\n fields: string[],\n\n /**\n * Name of the ID field, uniquely identifying a document.\n */\n idField?: string,\n\n /**\n * Names of fields to store, so that search results would include them. By\n * default none, so results would only contain the id field.\n */\n storeFields?: string[],\n\n /**\n * Function used to extract the value of each field in documents. By default,\n * the documents are assumed to be plain objects with field names as keys,\n * but by specifying a custom `extractField` function one can completely\n * customize how the fields are extracted.\n *\n * The function takes as arguments the document, and the name of the field to\n * extract from it. It should return the field value as a string.\n *\n * @remarks\n * The returned string is fed into the `tokenize` function to split it up\n * into tokens.\n */\n extractField?: (document: T, fieldName: string) => string,\n\n /**\n * Function used to split a field value into individual terms to be indexed.\n * The default tokenizer separates terms by space or punctuation, but a\n * custom tokenizer can be provided for custom logic.\n *\n * The function takes as arguments string to tokenize, and the name of the\n * field it comes from. It should return the terms as an array of strings.\n * When used for tokenizing a search query instead of a document field, the\n * `fieldName` is undefined.\n *\n * @remarks\n * This function is called after `extractField` extracts a truthy value from a\n * field. This function is then expected to split the extracted `text` document\n * into tokens (more commonly referred to as \"terms\" in this context). The resulting\n * split might be simple, like for example on word boundaries, or it might be more\n * complex, taking into account certain encoding, or parsing needs, or even just\n * special cases. Think about how one might need to go about indexing the term\n * \"short-term\". You would likely want to treat this case specially, and return two\n * terms instead, `[ \"short\", \"term\" ]`.\n *\n * Or, you could let such a case be handled by the `processTerm` function,\n * which is designed to turn each token/term into whole terms or sub-terms. In any\n * case, the purpose of this function is to split apart the provided `text` document\n * into parts that can be processed by the `processTerm` function.\n */\n tokenize?: (text: string, fieldName?: string) => string[],\n\n /**\n * Function used to process a term before indexing or search. This can be\n * used for normalization (such as stemming). By default, terms are\n * downcased, and otherwise no other normalization is performed.\n *\n * The function takes as arguments a term to process, and the name of the\n * field it comes from. It should return the processed term as a string, or a\n * falsy value to reject the term entirely.\n *\n * It can also return an array of strings, in which case each string in the\n * returned array is indexed as a separate term.\n *\n * @remarks\n * During the document indexing phase, the first step is to call the `extractField`\n * function to fetch the requested value/field from the document. This is then\n * passed off to the `tokenizer`, which will break apart each value into \"terms\".\n * These terms are then individually passed through the `processTerm` function\n * to compute each term individually. A term might for example be something\n * like \"lbs\", in which case one would likely want to return\n * `[ \"lbs\", \"lb\", \"pound\", \"pounds\" ]`. You may also return a single string value,\n * or a falsy value if you would like to skip indexing entirely for a specific term.\n *\n * Truthy return value(s) are then fed to the indexer as positive matches for this\n * document. In our example above, all four of the `[ \"lbs\", \"lb\", \"pound\", \"pounds\" ]`\n * terms would be added to the indexing engine, matching against the current document\n * being computed.\n *\n * *Note: Whatever values are returned from this function will receive no further\n * processing before being indexed. This means for example, if you include whitespace\n * at the beginning or end of a word, it will also be indexed that way, with the\n * included whitespace.*\n */\n processTerm?: (term: string, fieldName?: string) => string | string[] | null | undefined | false,\n\n /**\n * Function called to log messages. Arguments are a log level ('debug',\n * 'info', 'warn', or 'error'), a log message, and an optional string code\n * that identifies the reason for the log.\n *\n * The default implementation uses `console`, if defined.\n */\n logger?: (level: LogLevel, message: string, code?: string) => void\n\n /**\n * If `true` (the default), vacuuming is performed automatically as soon as\n * {@link MiniSearch#discard} is called a certain number of times, cleaning up\n * obsolete references from the index. If `false`, no automatic vacuuming is\n * performed. Custom settings controlling auto vacuuming thresholds, as well\n * as batching behavior, can be passed as an object (see the {@link\n * AutoVacuumOptions} type).\n */\n autoVacuum?: boolean | AutoVacuumOptions\n\n /**\n * Default search options (see the {@link SearchOptions} type and the {@link\n * MiniSearch#search} method for details)\n */\n searchOptions?: SearchOptions,\n\n /**\n * Default auto suggest options (see the {@link SearchOptions} type and the\n * {@link MiniSearch#autoSuggest} method for details)\n */\n autoSuggestOptions?: SearchOptions\n}\n\ntype OptionsWithDefaults<T = any> = Options<T> & {\n storeFields: string[]\n\n idField: string\n\n extractField: (document: T, fieldName: string) => string\n\n tokenize: (text: string, fieldName: string) => string[]\n\n processTerm: (term: string, fieldName: string) => string | string[] | null | undefined | false\n\n logger: (level: LogLevel, message: string, code?: string) => void\n\n autoVacuum: false | AutoVacuumOptions\n\n searchOptions: SearchOptionsWithDefaults\n\n autoSuggestOptions: SearchOptions\n}\n\ntype LogLevel = 'debug' | 'info' | 'warn' | 'error'\n\n/**\n * The type of auto-suggestions\n */\nexport type Suggestion = {\n /**\n * The suggestion\n */\n suggestion: string,\n\n /**\n * Suggestion as an array of terms\n */\n terms: string[],\n\n /**\n * Score for the suggestion\n */\n score: number\n}\n\n/**\n * Match information for a search result. It is a key-value object where keys\n * are terms that matched, and values are the list of fields that the term was\n * found in.\n */\nexport type MatchInfo = {\n [term: string]: string[]\n}\n\n/**\n * Type of the search results. Each search result indicates the document ID, the\n * terms that matched, the match information, the score, and all the stored\n * fields.\n */\nexport type SearchResult = {\n /**\n * The document ID\n */\n id: any,\n\n /**\n * List of document terms that matched. For example, if a prefix search for\n * `\"moto\"` matches `\"motorcycle\"`, `terms` will contain `\"motorcycle\"`.\n */\n terms: string[],\n\n /**\n * List of query terms that matched. For example, if a prefix search for\n * `\"moto\"` matches `\"motorcycle\"`, `queryTerms` will contain `\"moto\"`.\n */\n queryTerms: string[],\n\n /**\n * Score of the search results\n */\n score: number,\n\n /**\n * Match information, see {@link MatchInfo}\n */\n match: MatchInfo,\n\n /**\n * Stored fields\n */\n [key: string]: any\n}\n\n/**\n * @ignore\n */\nexport type AsPlainObject = {\n documentCount: number,\n nextId: number,\n documentIds: { [shortId: string]: any }\n fieldIds: { [fieldName: string]: number }\n fieldLength: { [shortId: string]: number[] }\n averageFieldLength: number[],\n storedFields: { [shortId: string]: any }\n dirtCount?: number,\n index: [string, { [fieldId: string]: SerializedIndexEntry }][]\n serializationVersion: number\n}\n\nexport type QueryCombination = SearchOptions & { queries: Query[] }\n\n/**\n * Wildcard query, used to match all terms\n */\nexport type Wildcard = typeof MiniSearch.wildcard\n\n/**\n * Search query expression, either a query string or an expression tree\n * combining several queries with a combination of AND or OR.\n */\nexport type Query = QueryCombination | string | Wildcard\n\n/**\n * Options to control vacuuming behavior.\n *\n * Vacuuming cleans up document references made obsolete by {@link\n * MiniSearch.discard} from the index. On large indexes, vacuuming is\n * potentially costly, because it has to traverse the whole inverted index.\n * Therefore, in order to dilute this cost so it does not negatively affects the\n * application, vacuuming is performed in batches, with a delay between each\n * batch. These options are used to configure the batch size and the delay\n * between batches.\n */\nexport type VacuumOptions = {\n /**\n * Size of each vacuuming batch (the number of terms in the index that will be\n * traversed in each batch). Defaults to 1000.\n */\n batchSize?: number,\n\n /**\n * Wait time between each vacuuming batch in milliseconds. Defaults to 10.\n */\n batchWait?: number\n}\n\n/**\n * Sets minimum thresholds for `dirtCount` and `dirtFactor` that trigger an\n * automatic vacuuming.\n */\nexport type VacuumConditions = {\n /**\n * Minimum `dirtCount` (number of discarded documents since the last vacuuming)\n * under which auto vacuum is not triggered. It defaults to 20.\n */\n minDirtCount?: number\n\n /**\n * Minimum `dirtFactor` (proportion of discarded documents over the total)\n * under which auto vacuum is not triggered. It defaults to 0.1.\n */\n minDirtFactor?: number,\n}\n\n/**\n * Options to control auto vacuum behavior. When discarding a document with\n * {@link MiniSearch#discard}, a vacuuming operation is automatically started if\n * the `dirtCount` and `dirtFactor` are above the `minDirtCount` and\n * `minDirtFactor` thresholds defined by this configuration. See {@link\n * VacuumConditions} for details on these.\n *\n * Also, `batchSize` and `batchWait` can be specified, controlling batching\n * behavior (see {@link VacuumOptions}).\n */\nexport type AutoVacuumOptions = VacuumOptions & VacuumConditions\n\ntype QuerySpec = {\n prefix: boolean,\n fuzzy: number | boolean,\n term: string,\n termBoost: number\n}\n\ntype DocumentTermFreqs = Map<number, number>\ntype FieldTermData = Map<number, DocumentTermFreqs>\n\ninterface RawResultValue {\n // Intermediate score, before applying the final score based on number of\n // matched terms.\n score: number,\n\n // Set of all query terms that were matched. They may not be present in the\n // text exactly in the case of prefix/fuzzy matches. We must check for\n // uniqueness before adding a new term. This is much faster than using a set,\n // because the number of elements is relatively small.\n terms: string[],\n\n // All terms that were found in the content, including the fields in which\n // they were present. This object will be provided as part of the final search\n // results.\n match: MatchInfo,\n}\n\ntype RawResult = Map<number, RawResultValue>\n\n/**\n * {@link MiniSearch} is the main entrypoint class, implementing a full-text\n * search engine in memory.\n *\n * @typeParam T The type of the documents being indexed.\n *\n * ### Basic example:\n *\n * ```javascript\n * const documents = [\n * {\n * id: 1,\n * title: 'Moby Dick',\n * text: 'Call me Ishmael. Some years ago...',\n * category: 'fiction'\n * },\n * {\n * id: 2,\n * title: 'Zen and the Art of Motorcycle Maintenance',\n * text: 'I can see by my watch...',\n * category: 'fiction'\n * },\n * {\n * id: 3,\n * title: 'Neuromancer',\n * text: 'The sky above the port was...',\n * category: 'fiction'\n * },\n * {\n * id: 4,\n * title: 'Zen and the Art of Archery',\n * text: 'At first sight it must seem...',\n * category: 'non-fiction'\n * },\n * // ...and more\n * ]\n *\n * // Create a search engine that indexes the 'title' and 'text' fields for\n * // full-text search. Search results will include 'title' and 'category' (plus the\n * // id field, that is always stored and returned)\n * const miniSearch = new MiniSearch({\n * fields: ['title', 'text'],\n * storeFields: ['title', 'category']\n * })\n *\n * // Add documents to the index\n * miniSearch.addAll(documents)\n *\n * // Search for documents:\n * let results = miniSearch.search('zen art motorcycle')\n * // => [\n * // { id: 2, title: 'Zen and the Art of Motorcycle Maintenance', category: 'fiction', score: 2.77258 },\n * // { id: 4, title: 'Zen and the Art of Archery', category: 'non-fiction', score: 1.38629 }\n * // ]\n * ```\n */\nexport default class MiniSearch<T = any> {\n protected _options: OptionsWithDefaults<T>\n protected _index: SearchableMap<FieldTermData>\n protected _documentCount: number\n protected _documentIds: Map<number, any>\n protected _idToShortId: Map<any, number>\n protected _fieldIds: { [key: string]: number }\n protected _fieldLength: Map<number, number[]>\n protected _avgFieldLength: number[]\n protected _nextId: number\n protected _storedFields: Map<number, Record<string, unknown>>\n protected _dirtCount: number\n private _currentVacuum: Promise<void> | null\n private _enqueuedVacuum: Promise<void> | null\n private _enqueuedVacuumConditions: VacuumConditions | undefined\n\n /**\n * The special wildcard symbol that can be passed to {@link MiniSearch#search}\n * to match all documents\n */\n static readonly wildcard: unique symbol = Symbol('*')\n\n /**\n * @param options Configuration options\n *\n * ### Examples:\n *\n * ```javascript\n * // Create a search engine that indexes the 'title' and 'text' fields of your\n * // documents:\n * const miniSearch = new MiniSearch({ fields: ['title', 'text'] })\n * ```\n *\n * ### ID Field:\n *\n * ```javascript\n * // Your documents are assumed to include a unique 'id' field, but if you want\n * // to use a different field for document identification, you can set the\n * // 'idField' option:\n * const miniSearch = new MiniSearch({ idField: 'key', fields: ['title', 'text'] })\n * ```\n *\n * ### Options and defaults:\n *\n * ```javascript\n * // The full set of options (here with their default value) is:\n * const miniSearch = new MiniSearch({\n * // idField: field that uniquely identifies a document\n * idField: 'id',\n *\n * // extractField: function used to get the value of a field in a document.\n * // By default, it assumes the document is a flat object with field names as\n * // property keys and field values as string property values, but custom logic\n * // can be implemented by setting this option to a custom extractor function.\n * extractField: (document, fieldName) => document[fieldName],\n *\n * // tokenize: function used to split fields into individual terms. By\n * // default, it is also used to tokenize search queries, unless a specific\n * // `tokenize` search option is supplied. When tokenizing an indexed field,\n * // the field name is passed as the second argument.\n * tokenize: (string, _fieldName) => string.split(SPACE_OR_PUNCTUATION),\n *\n * // processTerm: function used to process each tokenized term before\n * // indexing. It can be used for stemming and normalization. Return a falsy\n * // value in order to discard a term. By default, it is also used to process\n * // search queries, unless a specific `processTerm` option is supplied as a\n * // search option. When processing a term from a indexed field, the field\n * // name is passed as the second argument.\n * processTerm: (term, _fieldName) => term.toLowerCase(),\n *\n * // searchOptions: default search options, see the `search` method for\n * // details\n * searchOptions: undefined,\n *\n * // fields: document fields to be indexed. Mandatory, but not set by default\n * fields: undefined\n *\n * // storeFields: document fields to be stored and returned as part of the\n * // search results.\n * storeFields: []\n * })\n * ```\n */\n constructor (options: Options<T>) {\n if (options?.fields == null) {\n throw new Error('MiniSearch: option \"fields\" must be provided')\n }\n\n const autoVacuum = (options.autoVacuum == null || options.autoVacuum === true) ? defaultAutoVacuumOptions : options.autoVacuum\n\n this._options = {\n ...defaultOptions,\n ...options,\n autoVacuum,\n searchOptions: { ...defaultSearchOptions, ...(options.searchOptions || {}) },\n autoSuggestOptions: { ...defaultAutoSuggestOptions, ...(options.autoSuggestOptions || {}) }\n }\n\n this._index = new SearchableMap()\n\n this._documentCount = 0\n\n this._documentIds = new Map()\n\n this._idToShortId = new Map()\n\n // Fields are defined during initialization, don't change, are few in\n // number, rarely need iterating over, and have string keys. Therefore in\n // this case an object is a better candidate than a Map to store the mapping\n // from field key to ID.\n this._fieldIds = {}\n\n this._fieldLength = new Map()\n\n this._avgFieldLength = []\n\n this._nextId = 0\n\n this._storedFields = new Map()\n\n this._dirtCount = 0\n\n this._currentVacuum = null\n\n this._enqueuedVacuum = null\n this._enqueuedVacuumConditions = defaultVacuumConditions\n\n this.addFields(this._options.fields)\n }\n\n /**\n * Adds a document to the index\n *\n * @param document The document to be indexed\n */\n add (document: T): void {\n const { extractField, tokenize, processTerm, fields, idField } = this._options\n const id = extractField(document, idField)\n if (id == null) {\n throw new Error(`MiniSearch: document does not have ID field \"${idField}\"`)\n }\n\n if (this._idToShortId.has(id)) {\n throw new Error(`MiniSearch: duplicate ID ${id}`)\n }\n\n const shortDocumentId = this.addDocumentId(id)\n this.saveStoredFields(shortDocumentId, document)\n\n for (const field of fields) {\n const fieldValue = extractField(document, field)\n if (fieldValue == null) continue\n\n const tokens = tokenize(fieldValue.toString(), field)\n const fieldId = this._fieldIds[field]\n\n const uniqueTerms = new Set(tokens).size\n this.addFieldLength(shortDocumentId, fieldId, this._documentCount - 1, uniqueTerms)\n\n for (const term of tokens) {\n const processedTerm = processTerm(term, field)\n if (Array.isArray(processedTerm)) {\n for (const t of processedTerm) {\n this.addTerm(fieldId, shortDocumentId, t)\n }\n } else if (processedTerm) {\n this.addTerm(fieldId, shortDocumentId, processedTerm)\n }\n }\n }\n }\n\n /**\n * Adds all the given documents to the index\n *\n * @param documents An array of documents to be indexed\n */\n addAll (documents: readonly T[]): void {\n for (const document of documents) this.add(document)\n }\n\n /**\n * Adds all the given documents to the index asynchronously.\n *\n * Returns a promise that resolves (to `undefined`) when the indexing is done.\n * This method is useful when index many documents, to avoid blocking the main\n * thread. The indexing is performed asynchronously and in chunks.\n *\n * @param documents An array of documents to be indexed\n * @param options Configuration options\n * @return A promise resolving to `undefined` when the indexing is done\n */\n addAllAsync (documents: readonly T[], options: { chunkSize?: number } = {}): Promise<void> {\n const { chunkSize = 10 } = options\n const acc: { chunk: T[], promise: Promise<void> } = { chunk: [], promise: Promise.resolve() }\n\n const { chunk, promise } = documents.reduce(({ chunk, promise }, document: T, i: number) => {\n chunk.push(document)\n if ((i + 1) % chunkSize === 0) {\n return {\n chunk: [],\n promise: promise\n .then(() => new Promise(resolve => setTimeout(resolve, 0)))\n .then(() => this.addAll(chunk))\n }\n } else {\n return { chunk, promise }\n }\n }, acc)\n\n return promise.then(() => this.addAll(chunk))\n }\n\n /**\n * Removes the given document from the index.\n *\n * The document to remove must NOT have changed between indexing and removal,\n * otherwise the index will be corrupted.\n *\n * This method requires passing the full document to be removed (not just the\n * ID), and immediately removes the document from the inverted index, allowing\n * memory to be released. A convenient alternative is {@link\n * MiniSearch#discard}, which needs only the document ID, and has the same\n * visible effect, but delays cleaning up the index until the next vacuuming.\n *\n * @param document The document to be removed\n */\n remove (document: T): void {\n const { tokenize, processTerm, extractField, fields, idField } = this._options\n const id = extractField(document, idField)\n\n if (id == null) {\n throw new Error(`MiniSearch: document does not have ID field \"${idField}\"`)\n }\n\n const shortId = this._idToShortId.get(id)\n\n if (shortId == null) {\n throw new Error(`MiniSearch: cannot remove document with ID ${id}: it is not in the index`)\n }\n\n for (const field of fields) {\n const fieldValue = extractField(document, field)\n if (fieldValue == null) continue\n\n const tokens = tokenize(fieldValue.toString(), field)\n const fieldId = this._fieldIds[field]\n\n const uniqueTerms = new Set(tokens).size\n this.removeFieldLength(shortId, fieldId, this._documentCount, uniqueTerms)\n\n for (const term of tokens) {\n const processedTerm = processTerm(term, field)\n if (Array.isArray(processedTerm)) {\n for (const t of processedTerm) {\n this.removeTerm(fieldId, shortId, t)\n }\n } else if (processedTerm) {\n this.removeTerm(fieldId, shortId, processedTerm)\n }\n }\n }\n\n this._storedFields.delete(shortId)\n this._documentIds.delete(shortId)\n this._idToShortId.delete(id)\n this._fieldLength.delete(shortId)\n this._documentCount -= 1\n }\n\n /**\n * Removes all the given documents from the index. If called with no arguments,\n * it removes _all_ documents from the index.\n *\n * @param documents The documents to be removed. If this argument is omitted,\n * all documents are removed. Note that, for removing all documents, it is\n * more efficient to call this method with no arguments than to pass all\n * documents.\n */\n removeAll (documents?: readonly T[]): void {\n if (documents) {\n for (const document of documents) this.remove(document)\n } else if (arguments.length > 0) {\n throw new Error('Expected documents to be present. Omit the argument to remove all documents.')\n } else {\n this._index = new SearchableMap()\n this._documentCount = 0\n this._documentIds = new Map()\n this._idToShortId = new Map()\n this._fieldLength = new Map()\n this._avgFieldLength = []\n this._storedFields = new Map()\n this._nextId = 0\n }\n }\n\n /**\n * Discards the document with the given ID, so it won't appear in search results\n *\n * It has the same visible effect of {@link MiniSearch.remove} (both cause the\n * document to stop appearing in searches), but a different effect on the\n * internal data structures:\n *\n * - {@link MiniSearch#remove} requires passing the full document to be\n * removed as argument, and removes it from the inverted index immediately.\n *\n * - {@link MiniSearch#discard} instead only needs the document ID, and\n * works by marking the current version of the document as discarded, so it\n * is immediately ignored by searches. This is faster and more convenient\n * than {@link MiniSearch#remove}, but the index is not immediately\n * modified. To take care of that, vacuuming is performed after a certain\n * number of documents are discarded, cleaning up the index and allowing\n * memory to be released.\n *\n * After discarding a document, it is possible to re-add a new version, and\n * only the new version will appear in searches. In other words, discarding\n * and re-adding a document works exactly like removing and re-adding it. The\n * {@link MiniSearch.replace} method can also be used to replace a document\n * with a new version.\n *\n * #### Details about vacuuming\n *\n * Repetite calls to this method would leave obsolete document references in\n * the index, invisible to searches. Two mechanisms take care of cleaning up:\n * clean up during search, and vacuuming.\n *\n * - Upon search, whenever a discarded ID is found (and ignored for the\n * results), references to the discarded document are removed from the\n * inverted index entries for the search terms. This ensures that subsequent\n * searches for the same terms do not need to skip these obsolete references\n * again.\n *\n * - In addition, vacuuming is performed automatically by default (see the\n * `autoVacuum` field in {@link Options}) after a certain number of\n * documents are discarded. Vacuuming traverses all terms in the index,\n * cleaning up all references to discarded documents. Vacuuming can also be\n * triggered manually by calling {@link MiniSearch#vacuum}.\n *\n * @param id The ID of the document to be discarded\n */\n discard (id: any): void {\n const shortId = this._idToShortId.get(id)\n\n if (shortId == null) {\n throw new Error(`MiniSearch: cannot discard document with ID ${id}: it is not in the index`)\n }\n\n this._idToShortId.delete(id)\n this._documentIds.delete(shortId)\n this._storedFields.delete(shortId)\n\n ;(this._fieldLength.get(shortId) || []).forEach((fieldLength, fieldId) => {\n this.removeFieldLength(shortId, fieldId, this._documentCount, fieldLength)\n })\n\n this._fieldLength.delete(shortId)\n\n this._documentCount -= 1\n this._dirtCount += 1\n\n this.maybeAutoVacuum()\n }\n\n private maybeAutoVacuum (): void {\n if (this._options.autoVacuum === false) { return }\n\n const { minDirtFactor, minDirtCount, batchSize, batchWait } = this._options.autoVacuum\n this.conditionalVacuum({ batchSize, batchWait }, { minDirtCount, minDirtFactor })\n }\n\n /**\n * Discards the documents with the given IDs, so they won't appear in search\n * results\n *\n * It is equivalent to calling {@link MiniSearch#discard} for all the given\n * IDs, but with the optimization of triggering at most one automatic\n * vacuuming at the end.\n *\n * Note: to remove all documents from the index, it is faster and more\n * convenient to call {@link MiniSearch.removeAll} with no argument, instead\n * of passing all IDs to this method.\n */\n discardAll (ids: readonly any[]): void {\n const autoVacuum = this._options.autoVacuum\n\n try {\n this._options.autoVacuum = false\n\n for (const id of ids) {\n this.discard(id)\n }\n } finally {\n this._options.autoVacuum = autoVacuum\n }\n\n this.maybeAutoVacuum()\n }\n\n /**\n * It replaces an existing document with the given updated version\n *\n * It works by discarding the current version and adding the updated one, so\n * it is functionally equivalent to calling {@link MiniSearch#discard}\n * followed by {@link MiniSearch#add}. The ID of the updated document should\n * be the same as the original one.\n *\n * Since it uses {@link MiniSearch#discard} internally, this method relies on\n * vacuuming to clean up obsolete document references from the index, allowing\n * memory to be released (see {@link MiniSearch#discard}).\n *\n * @param updatedDocument The updated document to replace the old version\n * with\n */\n replace (updatedDocument: T): void {\n const { idField, extractField } = this._options\n const id = extractField(updatedDocument, idField)\n\n this.discard(id)\n this.add(updatedDocument)\n }\n\n /**\n * Triggers a manual vacuuming, cleaning up references to discarded documents\n * from the inverted index\n *\n * Vacuuming is only useful for applications that use the {@link\n * MiniSearch#discard} or {@link MiniSearch#replace} methods.\n *\n * By default, vacuuming is performed automatically when needed (controlled by\n * the `autoVacuum` field in {@link Options}), so there is usually no need to\n * call this method, unless one wants to make sure to perform vacuuming at a\n * specific moment.\n *\n * Vacuuming traverses all terms in the inverted index in batches, and cleans\n * up references to discarded documents from the posting list, allowing memory\n * to be released.\n *\n * The method takes an optional object as argument with the following keys:\n *\n * - `batchSize`: the size of each batch (1000 by default)\n *\n * - `batchWait`: the number of milliseconds to wait between batches (10 by\n * default)\n *\n * On large indexes, vacuuming could have a non-negligible cost: batching\n * avoids blocking the thread for long, diluting this cost so that it is not\n * negatively affecting the application. Nonetheless, this method should only\n * be called when necessary, and relying on automatic vacuuming is usually\n * better.\n *\n * It returns a promise that resolves (to undefined) when the clean up is\n * completed. If vacuuming is already ongoing at the time this method is\n * called, a new one is enqueued immediately after the ongoing one, and a\n * corresponding promise is returned. However, no more than one vacuuming is\n * enqueued on top of the ongoing one, even if this method is called more\n * times (enqueuing multiple ones would be useless).\n *\n * @param options Configuration options for the batch size and delay. See\n * {@link VacuumOptions}.\n */\n vacuum (options: VacuumOptions = {}): Promise<void> {\n return this.conditionalVacuum(options)\n }\n\n private conditionalVacuum (options: VacuumOptions, conditions?: VacuumConditions): Promise<void> {\n // If a vacuum is already ongoing, schedule another as soon as it finishes,\n // unless there's already one enqueued. If one was already enqueued, do not\n // enqueue another on top, but make sure that the conditions are the\n // broadest.\n if (this._currentVacuum) {\n this._enqueuedVacuumConditions = this._enqueuedVacuumConditions && conditions\n if (this._enqueuedVacuum != null) { return this._enqueuedVacuum }\n\n this._enqueuedVacuum = this._currentVacuum.then(() => {\n const conditions = this._enqueuedVacuumConditions\n this._enqueuedVacuumConditions = defaultVacuumConditions\n return this.performVacuuming(options, conditions)\n })\n return this._enqueuedVacuum\n }\n\n if (this.vacuumConditionsMet(conditions) === false) { return Promise.resolve() }\n\n this._currentVacuum = this.performVacuuming(options)\n return this._currentVacuum\n }\n\n private async performVacuuming (options: VacuumOptions, conditions?: VacuumConditions): Promise<void> {\n const initialDirtCount = this._dirtCount\n\n if (this.vacuumConditionsMet(conditions)) {\n const batchSize = options.batchSize || defaultVacuumOptions.batchSize\n const batchWait = options.batchWait || defaultVacuumOptions.batchWait\n let i = 1\n\n for (const [term, fieldsData] of this._index) {\n for (const [fieldId, fieldIndex] of fieldsData) {\n for (const [shortId] of fieldIndex) {\n if (this._documentIds.has(shortId)) { continue }\n\n if (fieldIndex.size <= 1) {\n fieldsData.delete(fieldId)\n } else {\n fieldIndex.delete(shortId)\n }\n }\n }\n\n if (this._index.get(term)!.size === 0) {\n this._index.delete(term)\n }\n\n if (i % batchSize === 0) {\n await new Promise((resolve) => setTimeout(resolve, batchWait))\n }\n\n i += 1\n }\n\n this._dirtCount -= initialDirtCount\n }\n\n // Make the next lines always async, so they execute after this function returns\n await null\n\n this._currentVacuum = this._enqueuedVacuum\n this._enqueuedVacuum = null\n }\n\n private vacuumConditionsMet (conditions?: VacuumConditions) {\n if (conditions == null) { return true }\n\n let { minDirtCount, minDirtFactor } = conditions\n minDirtCount = minDirtCount || defaultAutoVacuumOptions.minDirtCount\n minDirtFactor = minDirtFactor || defaultAutoVacuumOptions.minDirtFactor\n\n return this.dirtCount >= minDirtCount && this.dirtFactor >= minDirtFactor\n }\n\n /**\n * Is `true` if a vacuuming operation is ongoing, `false` otherwise\n */\n get isVacuuming (): boolean {\n return this._currentVacuum != null\n }\n\n /**\n * The number of documents discarded since the most recent vacuuming\n */\n get dirtCount (): number {\n return this._dirtCount\n }\n\n /**\n * A number between 0 and 1 giving an indication about the proportion of\n * documents that are discarded, and can therefore be cleaned up by vacuuming.\n * A value close to 0 means that the index is relatively clean, while a higher\n * value means that the index is relatively dirty, and vacuuming could release\n * memory.\n */\n get dirtFactor (): number {\n return this._dirtCount / (1 + this._documentCount + this._dirtCount)\n }\n\n /**\n * Returns `true` if a document with the given ID is present in the index and\n * available for search, `false` otherwise\n *\n * @param id The document ID\n */\n has (id: any): boolean {\n return this._idToShortId.has(id)\n }\n\n /**\n * Returns the stored fields (as configured in the `storeFields` constructor\n * option) for the given document ID. Returns `undefined` if the document is\n * not present in the index.\n *\n * @param id The document ID\n */\n getStoredFields (id: any): Record<string, unknown> | undefined {\n const shortId = this._idToShortId.get(id)\n\n if (shortId == null) { return undefined }\n\n return this._storedFields.get(shortId)\n }\n\n /**\n * Search for documents matching the given search query.\n *\n * The result is a list of scored document IDs matching the query, sorted by\n * descending score, and each including data about which terms were matched and\n * in which fields.\n *\n * ### Basic usage:\n *\n * ```javascript\n * // Search for \"zen art motorcycle\" with default options: terms have to match\n * // exactly, and individual terms are joined with OR\n * miniSearch.search('zen art motorcycle')\n * // => [ { id: 2, score: 2.77258, match: { ... } }, { id: 4, score: 1.38629, match: { ... } } ]\n * ```\n *\n * ### Restrict search to specific fields:\n *\n * ```javascript\n * // Search only in the 'title' field\n * miniSearch.search('zen', { fields: ['title'] })\n * ```\n *\n * ### Field boosting:\n *\n * ```javascript\n * // Boost a field\n * miniSearch.search('zen', { boost: { title: 2 } })\n * ```\n *\n * ### Prefix search:\n *\n * ```javascript\n * // Search for \"moto\" with prefix search (it will match documents\n * // containing terms that start with \"moto\" or \"neuro\")\n * miniSearch.search('moto neuro', { prefix: true })\n * ```\n *\n * ### Fuzzy search:\n *\n * ```javascript\n * // Search for \"ismael\" with fuzzy search (it will match documents containing\n * // terms similar to \"ismael\", with a maximum edit distance of 0.2 term.length\n * // (rounded to nearest integer)\n * miniSearch.search('ismael', { fuzzy: 0.2 })\n * ```\n *\n * ### Combining strategies:\n *\n * ```javascript\n * // Mix of exact match, prefix search, and fuzzy search\n * miniSearch.search('ismael mob', {\n * prefix: true,\n * fuzzy: 0.2\n * })\n * ```\n *\n * ### Advanced prefix and fuzzy search:\n *\n * ```javascript\n * // Perform fuzzy and prefix search depending on the search term. Here\n * // performing prefix and fuzzy search only on terms longer than 3 characters\n * miniSearch.search('ismael mob', {\n * prefix: term => term.length > 3\n * fuzzy: term => term.length > 3 ? 0.2 : null\n * })\n * ```\n *\n * ### Combine with AND:\n *\n * ```javascript\n * // Combine search terms with AND (to match only documents that contain both\n * // \"motorcycle\" and \"art\")\n * miniSearch.search('motorcycle art', { combineWith: 'AND' })\n * ```\n *\n * ### Combine with AND_NOT:\n *\n * There is also an AND_NOT combinator, that finds documents that match the\n * first term, but do not match any of the other terms. This combinator is\n * rarely useful with simple queries, and is meant to be used with advanced\n * query combinations (see later for more details).\n *\n * ### Filtering results:\n *\n * ```javascript\n * // Filter only results in the 'fiction' category (assuming that 'category'\n * // is a stored field)\n * miniSearch.search('motorcycle art', {\n * filter: (result) => result.category === 'fiction'\n * })\n * ```\n *\n * ### Wildcard query\n *\n * Searching for an empty string (assuming the default tokenizer) returns no\n * results. Sometimes though, one needs to match all documents, like in a\n * \"wildcard\" search. This is possible by passing the special value\n * {@link MiniSearch.wildcard} as the query:\n *\n * ```javascript\n * // Return search results for all documents\n * miniSearch.search(MiniSearch.wildcard)\n * ```\n *\n * Note that search options such as `filter` and `boostDocument` are still\n * applied, influencing which results are returned, and their order:\n *\n * ```javascript\n * // Return search results for all documents in the 'fiction' category\n * miniSearch.search(MiniSearch.wildcard, {\n * filter: (result) => result.category === 'fiction'\n * })\n * ```\n *\n * ### Advanced combination of queries:\n *\n * It is possible to combine different subqueries with OR, AND, and AND_NOT,\n * and even with different search options, by passing a query expression\n * tree object as the first argument, instead of a string.\n *\n * ```javascript\n * // Search for documents that contain \"zen\" and (\"motorcycle\" or \"archery\")\n * miniSearch.search({\n * combineWith: 'AND',\n * queries: [\n * 'zen',\n * {\n * combineWith: 'OR',\n * queries: ['motorcycle', 'archery']\n * }\n * ]\n * })\n *\n * // Search for documents that contain (\"apple\" or \"pear\") but not \"juice\" and\n * // not \"tree\"\n * miniSearch.search({\n * combineWith: 'AND_NOT',\n * queries: [\n * {\n * combineWith: 'OR',\n * queries: ['apple', 'pear']\n * },\n * 'juice',\n * 'tree'\n * ]\n * })\n * ```\n *\n * Each node in the expression tree can be either a string, or an object that\n * supports all {@link SearchOptions} fields, plus a `queries` array field for\n * subqueries.\n *\n * Note that, while this can become complicated to do by hand for complex or\n * deeply nested queries, it provides a formalized expression tree API for\n * external libraries that implement a parser for custom query languages.\n *\n * @param query Search query\n * @param searchOptions Search options. Each option, if not given, defaults to the corresponding value of `searchOptions` given to the constructor, or to the library default.\n */\n search (query: Query, searchOptions: SearchOptions = {}): SearchResult[] {\n const { searchOptions: globalSearchOptions } = this._options\n const searchOptionsWithDefaults: SearchOptionsWithDefaults = { ...globalSearchOptions, ...searchOptions }\n\n const rawResults = this.executeQuery(query, searchOptions)\n const results = []\n\n for (const [docId, { score, terms, match }] of rawResults) {\n // terms are the matched query terms, which will be returned to the user\n // as queryTerms. The quality is calculated based on them, as opposed to\n // the matched terms in the document (which can be different due to\n // prefix and fuzzy match)\n const quality = terms.length || 1\n\n const result = {\n id: this._documentIds.get(docId),\n score: score * quality,\n terms: Object.keys(match),\n queryTerms: terms,\n match\n }\n\n Object.assign(result, this._storedFields.get(docId))\n if (searchOptionsWithDefaults.filter == null || searchOptionsWithDefaults.filter(result)) {\n results.push(result)\n }\n }\n\n // If it's a wildcard query, and no document boost is applied, skip sorting\n // the results, as all results have the same score of 1\n if (query === MiniSearch.wildcard && searchOptionsWithDefaults.boostDocument == null) {\n return results\n }\n\n results.sort(byScore)\n return results\n }\n\n /**\n * Provide suggestions for the given search query\n *\n * The result is a list of suggested modified search queries, derived from the\n * given search query, each with a relevance score, sorted by descending score.\n *\n * By default, it uses the same options used for search, except that by\n * default it performs prefix search on the last term of the query, and\n * combine terms with `'AND'` (requiring all query terms to match). Custom\n * options can be passed as a second argument. Defaults can be changed upon\n * calling the {@link MiniSearch} constructor, by passing a\n * `autoSuggestOptions` option.\n *\n * ### Basic usage:\n *\n * ```javascript\n * // Get suggestions for 'neuro':\n * miniSearch.autoSuggest('neuro')\n * // => [ { suggestion: 'neuromancer', terms: [ 'neuromancer' ], score: 0.46240 } ]\n * ```\n *\n * ### Multiple words:\n *\n * ```javascript\n * // Get suggestions for 'zen ar':\n * miniSearch.autoSuggest('zen ar')\n * // => [\n * // { suggestion: 'zen archery art', terms: [ 'zen', 'archery', 'art' ], score: 1.73332 },\n * // { suggestion: 'zen art', terms: [ 'zen', 'art' ], score: 1.21313 }\n * // ]\n * ```\n *\n * ### Fuzzy suggestions:\n *\n * ```javascript\n * // Correct spelling mistakes using fuzzy search:\n * miniSearch.autoSuggest('neromancer', { fuzzy: 0.2 })\n * // => [ { suggestion: 'neuromancer', terms: [ 'neuromancer' ], score: 1.03998 } ]\n * ```\n *\n * ### Filtering:\n *\n * ```javascript\n * // Get suggestions for 'zen ar', but only within the 'fiction' category\n * // (assuming that 'category' is a stored field):\n * miniSearch.autoSuggest('zen ar', {\n * filter: (result) => result.category === 'fiction'\n * })\n * // => [\n * // { suggestion: 'zen archery art', terms: [ 'zen', 'archery', 'art' ], score: 1.73332 },\n * // { suggestion: 'zen art', terms: [ 'zen', 'art' ], score: 1.21313 }\n * // ]\n * ```\n *\n * @param queryString Query string to be expanded into suggestions\n * @param options Search options. The supported options and default values\n * are the same as for the {@link MiniSearch#search} method, except that by\n * default prefix search is performed on the last term in the query, and terms\n * are combined with `'AND'`.\n * @return A sorted array of suggestions sorted by relevance score.\n */\n autoSuggest (queryString: string, options: SearchOptions = {}): Suggestion[] {\n options = { ...this._options.autoSuggestOptions, ...options }\n\n const suggestions: Map<string, Omit<Suggestion, 'suggestion'> & { count: number }> = new Map()\n\n for (const { score, terms } of this.search(queryString, options)) {\n const phrase = terms.join(' ')\n const suggestion = suggestions.get(phrase)\n if (suggestion != null) {\n suggestion.score += score\n suggestion.count += 1\n } else {\n suggestions.set(phrase, { score, terms, count: 1 })\n }\n }\n\n const results = []\n for (const [suggestion, { score, terms, count }] of suggestions) {\n results.push({ suggestion, terms, score: score / count })\n }\n\n results.sort(byScore)\n return results\n }\n\n /**\n * Total number of documents available to search\n */\n get documentCount (): number {\n return this._documentCount\n }\n\n /**\n * Number of terms in the index\n */\n get termCount (): number {\n return this._index.size\n }\n\n /**\n * Deserializes a JSON index (serialized with `JSON.stringify(miniSearch)`)\n * and instantiates a MiniSearch instance. It should be given the same options\n * originally used when serializing the index.\n *\n * ### Usage:\n *\n * ```javascript\n * // If the index was serialized with:\n * let miniSearch = new MiniSearch({ fields: ['title', 'text'] })\n * miniSearch.addAll(documents)\n *\n * const json = JSON.stringify(miniSearch)\n * // It can later be deserialized like this:\n * miniSearch = MiniSearch.loadJSON(json, { fields: ['title', 'text'] })\n * ```\n *\n * @param json JSON-serialized index\n * @param options configuration options, same as the constructor\n * @return An instance of MiniSearch deserialized from the given JSON.\n */\n static loadJSON<T = any> (json: string, options: Options<T>): MiniSearch<T> {\n if (options == null) {\n throw new Error('MiniSearch: loadJSON should be given the same options used when serializing the index')\n }\n return this.loadJS(JSON.parse(json), options)\n }\n\n /**\n * Async equivalent of {@link MiniSearch.loadJSON}\n *\n * This function is an alternative to {@link MiniSearch.loadJSON} that returns\n * a promise, and loads the index in batches, leaving pauses between them to avoid\n * blocking the main thread. It tends to be slower than the synchronous\n * version, but does not block the main thread, so it can be a better choice\n * when deserializing very large indexes.\n *\n * @param json JSON-serialized index\n * @param options configuration options, same as the constructor\n * @return A Promise that will resolve to an instance of MiniSearch deserialized from the given JSON.\n */\n static async loadJSONAsync<T = any> (json: string, options: Options<T>): Promise<MiniSearch<T>> {\n if (options == null) {\n throw new Error('MiniSearch: loadJSON should be given the same options used when serializing the index')\n }\n return this.loadJSAsync(JSON.parse(json), options)\n }\n\n /**\n * Returns the default value of an option. It will throw an error if no option\n * with the given name exists.\n *\n * @param optionName Name of the option\n * @return The default value of the given option\n *\n * ### Usage:\n *\n * ```javascript\n * // Get default tokenizer\n * MiniSearch.getDefault('tokenize')\n *\n * // Get default term processor\n * MiniSearch.getDefault('processTerm')\n *\n * // Unknown options will throw an error\n * MiniSearch.getDefault('notExisting')\n * // => throws 'MiniSearch: unknown option \"notExisting\"'\n * ```\n */\n static getDefault (optionName: string): any {\n if (defaultOptions.hasOwnProperty(optionName)) {\n return getOwnProperty(defaultOptions, optionName)\n } else {\n throw new Error(`MiniSearch: unknown option \"${optionName}\"`)\n }\n }\n\n /**\n * @ignore\n */\n static loadJS<T = any> (js: AsPlainObject, options: Options<T>): MiniSearch<T> {\n const {\n index,\n documentIds,\n fieldLength,\n storedFields,\n serializationVersion\n } = js\n\n const miniSearch = this.instantiateMiniSearch(js, options)\n\n miniSearch._documentIds = objectToNumericMap(documentIds)\n miniSearch._fieldLength = objectToNumericMap(fieldLength)\n miniSearch._storedFields = objectToNumericMap(storedFields)\n\n for (const [shortId, id] of miniSearch._documentIds) {\n miniSearch._idToShortId.set(id, shortId)\n }\n\n for (const [term, data] of index) {\n const dataMap = new Map() as FieldTermData\n\n for (const fieldId of Object.keys(data)) {\n let indexEntry = data[fieldId]\n\n // Version 1 used to nest the index entry inside a field called ds\n if (serializationVersion === 1) {\n indexEntry = indexEntry.ds as unknown as SerializedIndexEntry\n }\n\n dataMap.set(parseInt(fieldId, 10), objectToNumericMap(indexEntry) as DocumentTermFreqs)\n }\n\n miniSearch._index.set(term, dataMap)\n }\n\n return miniSearch\n }\n\n /**\n * @ignore\n */\n static async loadJSAsync<T = any> (js: AsPlainObject, options: Options<T>): Promise<MiniSearch<T>> {\n const {\n index,\n documentIds,\n fieldLength,\n storedFields,\n serializationVersion\n } = js\n\n const miniSearch = this.instantiateMiniSearch(js, options)\n\n miniSearch._documentIds = await objectToNumericMapAsync(documentIds)\n miniSearch._fieldLength = await objectToNumericMapAsync(fieldLength)\n miniSearch._storedFields = await objectToNumericMapAsync(storedFields)\n\n for (const [shortId, id] of miniSearch._documentIds) {\n miniSearch._idToShortId.set(id, shortId)\n }\n\n let count = 0\n for (const [term, data] of index) {\n const dataMap = new Map() as FieldTermData\n\n for (const fieldId of Object.keys(data)) {\n let indexEntry = data[fieldId]\n\n // Version 1 used to nest the index entry inside a field called ds\n if (serializationVersion === 1) {\n indexEntry = indexEntry.ds as unknown as SerializedIndexEntry\n }\n\n dataMap.set(parseInt(fieldId, 10), await objectToNumericMapAsync(indexEntry) as DocumentTermFreqs)\n }\n\n if (++count % 1000 === 0) await wait(0)\n miniSearch._index.set(term, dataMap)\n }\n\n return miniSearch\n }\n\n /**\n * @ignore\n */\n private static instantiateMiniSearch<T = any> (js: AsPlainObject, options: Options<T>): MiniSearch<T> {\n const {\n documentCount,\n nextId,\n fieldIds,\n averageFieldLength,\n dirtCount,\n serializationVersion\n } = js\n\n if (serializationVersion !== 1 && serializationVersion !== 2) {\n throw new Error('MiniSearch: cannot deserialize an index created with an incompatible version')\n }\n\n const miniSearch = new MiniSearch(options)\n\n miniSearch._documentCount = documentCount\n miniSearch._nextId = nextId\n miniSearch._idToShortId = new Map<any, number>()\n miniSearch._fieldIds = fieldIds\n miniSearch._avgFieldLength = averageFieldLength\n miniSearch._dirtCount = dirtCount || 0\n miniSearch._index = new SearchableMap()\n\n return miniSearch\n }\n\n /**\n * @ignore\n */\n private executeQuery (query: Query, searchOptions: SearchOptions = {}): RawResult {\n if (query === MiniSearch.wildcard) {\n return this.executeWildcardQuery(searchOptions)\n }\n\n if (typeof query !== 'string') {\n const options = { ...searchOptions, ...query, queries: undefined }\n const results = query.queries.map((subquery) => this.executeQuery(subquery, options))\n return this.combineResults(results, options.combineWith)\n }\n\n const { tokenize, processTerm, searchOptions: globalSearchOptions } = this._options\n const options = { tokenize, processTerm, ...globalSearchOptions, ...searchOptions }\n const { tokenize: searchTokenize, processTerm: searchProcessTerm } = options\n const terms = searchTokenize(query)\n .flatMap((term: string) => searchProcessTerm(term))\n .filter((term) => !!term) as string[]\n const queries: QuerySpec[] = terms.map(termToQuerySpec(options))\n const results = queries.map(query => this.executeQuerySpec(query, options))\n\n return this.combineResults(results, options.combineWith)\n }\n\n /**\n * @ignore\n */\n private executeQuerySpec (query: QuerySpec, searchOptions: SearchOptions): RawResult {\n const options: SearchOptionsWithDefaults = { ...this._options.searchOptions, ...searchOptions }\n\n const boosts = (options.fields || this._options.fields).reduce((boosts, field) =>\n ({ ...boosts, [field]: getOwnProperty(options.boost, field) || 1 }), {})\n\n const {\n boostDocument,\n weights,\n maxFuzzy,\n bm25: bm25params\n } = options\n\n const { fuzzy: fuzzyWeight, prefix: prefixWeight } = { ...defaultSearchOptions.weights, ...weights }\n\n const data = this._index.get(query.term)\n const results = this.termResults(query.term, query.term, 1, query.termBoost, data, boosts, boostDocument, bm25params)\n\n let prefixMatches\n let fuzzyMatches\n\n if (query.prefix) {\n prefixMatches = this._index.atPrefix(query.term)\n }\n\n if (query.fuzzy) {\n const fuzzy = (query.fuzzy === true) ? 0.2 : query.fuzzy\n const maxDistance = fuzzy < 1 ? Math.min(maxFuzzy, Math.round(query.term.length * fuzzy)) : fuzzy\n if (maxDistance) fuzzyMatches = this._index.fuzzyGet(query.term, maxDistance)\n }\n\n if (prefixMatches) {\n for (const [term, data] of prefixMatches) {\n const distance = term.length - query.term.length\n if (!distance) { continue } // Skip exact match.\n\n // Delete the term from fuzzy results (if present) if it is also a\n // prefix result. This entry will always be scored as a prefix result.\n fuzzyMatches?.delete(term)\n\n // Weight gradually approaches 0 as distance goes to infinity, with the\n // weight for the hypothetical distance 0 being equal to prefixWeight.\n // The rate of change is much lower than that of fuzzy matches to\n // account for the fact that prefix matches stay more relevant than\n // fuzzy matches for longer distances.\n const weight = prefixWeight * term.length / (term.length + 0.3 * distance)\n this.termResults(query.term, term, weight, query.termBoost, data, boosts, boostDocument, bm25params, results)\n }\n }\n\n if (fuzzyMatches) {\n for (const term of fuzzyMatches.keys()) {\n const [data, distance] = fuzzyMatches.get(term)!\n if (!distance) { continue } // Skip exact match.\n\n // Weight gradually approaches 0 as distance goes to infinity, with the\n // weight for the hypothetical distance 0 being equal to fuzzyWeight.\n const weight = fuzzyWeight * term.length / (term.length + distance)\n this.termResults(query.term, term, weight, query.termBoost, data, boosts, boostDocument, bm25params, results)\n }\n }\n\n return results\n }\n\n /**\n * @ignore\n */\n private executeWildcardQuery (searchOptions: SearchOptions): RawResult {\n const results = new Map() as RawResult\n const options: SearchOptionsWithDefaults = { ...this._options.searchOptions, ...searchOptions }\n\n for (const [shortId, id] of this._documentIds) {\n const score = options.boostDocument ? options.boostDocument(id, '', this._storedFields.get(shortId)) : 1\n results.set(shortId, {\n score,\n terms: [],\n match: {}\n })\n }\n\n return results\n }\n\n /**\n * @ignore\n */\n private combineResults (results: RawResult[], combineWith: CombinationOperator = OR): RawResult {\n if (results.length === 0) { return new Map() }\n const operator = combineWith.toLowerCase()\n const combinator = (combinators as Record<string, CombinatorFunction>)[operator]\n\n if (!combinator) {\n throw new Error(`Invalid combination operator: ${combineWith}`)\n }\n\n return results.reduce(combinator) || new Map()\n }\n\n /**\n * Allows serialization of the index to JSON, to possibly store it and later\n * deserialize it with {@link MiniSearch.loadJSON}.\n *\n * Normally one does not directly call this method, but rather call the\n * standard JavaScript `JSON.stringify()` passing the {@link MiniSearch}\n * instance, and JavaScript will internally call this method. Upon\n * deserialization, one must pass to {@link MiniSearch.loadJSON} the same\n * options used to create the original instance that was serialized.\n *\n * ### Usage:\n *\n * ```javascript\n * // Serialize the index:\n * let miniSearch = new MiniSearch({ fields: ['title', 'text'] })\n * miniSearch.addAll(documents)\n * const json = JSON.stringify(miniSearch)\n *\n * // Later, to deserialize it:\n * miniSearch = MiniSearch.loadJSON(json, { fields: ['title', 'text'] })\n * ```\n *\n * @return A plain-object serializable representation of the search index.\n */\n toJSON (): AsPlainObject {\n const index: [string, { [key: string]: SerializedIndexEntry }][] = []\n\n for (const [term, fieldIndex] of this._index) {\n const data: { [key: string]: SerializedIndexEntry } = {}\n\n for (const [fieldId, freqs] of fieldIndex) {\n data[fieldId] = Object.fromEntries(freqs)\n }\n\n index.push([term, data])\n }\n\n return {\n documentCount: this._documentCount,\n nextId: this._nextId,\n documentIds: Object.fromEntries(this._documentIds),\n fieldIds: this._fieldIds,\n fieldLength: Object.fromEntries(this._fieldLength),\n averageFieldLength: this._avgFieldLength,\n storedFields: Object.fromEntries(this._storedFields),\n dirtCount: this._dirtCount,\n index,\n serializationVersion: 2\n }\n }\n\n /**\n * @ignore\n */\n private termResults (\n sourceTerm: string,\n derivedTerm: string,\n termWeight: number,\n termBoost: number,\n fieldTermData: FieldTermData | undefined,\n fieldBoosts: { [field: string]: number },\n boostDocumentFn: ((id: any, term: string, storedFields?: Record<string, unknown>) => number) | undefined,\n bm25params: BM25Params,\n results: RawResult = new Map()\n ): RawResult {\n if (fieldTermData == null) return results\n\n for (const field of Object.keys(fieldBoosts)) {\n const fieldBoost = fieldBoosts[field]\n const fieldId = this._fieldIds[field]\n\n const fieldTermFreqs = fieldTermData.get(fieldId)\n if (fieldTermFreqs == null) continue\n\n let matchingFields = fieldTermFreqs.size\n const avgFieldLength = this._avgFieldLength[fieldId]\n\n for (const docId of fieldTermFreqs.keys()) {\n if (!this._documentIds.has(docId)) {\n this.removeTerm(fieldId, docId, derivedTerm)\n matchingFields -= 1\n continue\n }\n\n const docBoost = boostDocumentFn ? boostDocumentFn(this._documentIds.get(docId), derivedTerm, this._storedFields.get(docId)) : 1\n if (!docBoost) continue\n\n const termFreq = fieldTermFreqs.get(docId)!\n const fieldLength = this._fieldLength.get(docId)![fieldId]\n\n // NOTE: The total number of fields is set to the number of documents\n // `this._documentCount`. It could also make sense to use the number of\n // documents where the current field is non-blank as a normalization\n // factor. This will make a difference in scoring if the field is rarely\n // present. This is currently not supported, and may require further\n // analysis to see if it is a valid use case.\n const rawScore = calcBM25Score(termFreq, matchingFields, this._documentCount, fieldLength, avgFieldLength, bm25params)\n const weightedScore = termWeight * termBoost * fieldBoost * docBoost * rawScore\n\n const result = results.get(docId)\n if (result) {\n result.score += weightedScore\n assignUniqueTerm(result.terms, sourceTerm)\n const match = getOwnProperty(result.match, derivedTerm)\n if (match) {\n match.push(field)\n } else {\n result.match[derivedTerm] = [field]\n }\n } else {\n results.set(docId, {\n score: weightedScore,\n terms: [sourceTerm],\n match: { [derivedTerm]: [field] }\n })\n }\n }\n }\n\n return results\n }\n\n /**\n * @ignore\n */\n private addTerm (fieldId: number, documentId: number, term: string): void {\n const indexData = this._index.fetch(term, createMap)\n\n let fieldIndex = indexData.get(fieldId)\n if (fieldIndex == null) {\n fieldIndex = new Map()\n fieldIndex.set(documentId, 1)\n indexData.set(fieldId, fieldIndex)\n } else {\n const docs = fieldIndex.get(documentId)\n fieldIndex.set(documentId, (docs || 0) + 1)\n }\n }\n\n /**\n * @ignore\n */\n private removeTerm (fieldId: number, documentId: number, term: string): void {\n if (!this._index.has(term)) {\n this.warnDocumentChanged(documentId, fieldId, term)\n return\n }\n\n const indexData = this._index.fetch(term, createMap)\n\n const fieldIndex = indexData.get(fieldId)\n if (fieldIndex == null || fieldIndex.get(documentId) == null) {\n this.warnDocumentChanged(documentId, fieldId, term)\n } else if (fieldIndex.get(documentId)! <= 1) {\n if (fieldIndex.size <= 1) {\n indexData.delete(fieldId)\n } else {\n fieldIndex.delete(documentId)\n }\n } else {\n fieldIndex.set(documentId, fieldIndex.get(documentId)! - 1)\n }\n\n if (this._index.get(term)!.size === 0) {\n this._index.delete(term)\n }\n }\n\n /**\n * @ignore\n */\n private warnDocumentChanged (shortDocumentId: number, fieldId: number, term: string): void {\n for (const fieldName of Object.keys(this._fieldIds)) {\n if (this._fieldIds[fieldName] === fieldId) {\n this._options.logger('warn', `MiniSearch: document with ID ${this._documentIds.get(shortDocumentId)} has changed before removal: term \"${term}\" was not present in field \"${fieldName}\". Removing a document after it has changed can corrupt the index!`, 'version_conflict')\n return\n }\n }\n }\n\n /**\n * @ignore\n */\n private addDocumentId (documentId: any): number {\n const shortDocumentId = this._nextId\n this._idToShortId.set(documentId, shortDocumentId)\n this._documentIds.set(shortDocumentId, documentId)\n this._documentCount += 1\n this._nextId += 1\n return shortDocumentId\n }\n\n /**\n * @ignore\n */\n private addFields (fields: string[]): void {\n for (let i = 0; i < fields.length; i++) {\n this._fieldIds[fields[i]] = i\n }\n }\n\n /**\n * @ignore\n */\n private addFieldLength (documentId: number, fieldId: number, count: number, length: number): void {\n let fieldLengths = this._fieldLength.get(documentId)\n if (fieldLengths == null) this._fieldLength.set(documentId, fieldLengths = [])\n fieldLengths[fieldId] = length\n\n const averageFieldLength = this._avgFieldLength[fieldId] || 0\n const totalFieldLength = (averageFieldLength * count) + length\n this._avgFieldLength[fieldId] = totalFieldLength / (count + 1)\n }\n\n /**\n * @ignore\n */\n private removeFieldLength (documentId: number, fieldId: number, count: number, length: number): void {\n if (count === 1) {\n this._avgFieldLength[fieldId] = 0\n return\n }\n const totalFieldLength = (this._avgFieldLength[fieldId] * count) - length\n this._avgFieldLength[fieldId] = totalFieldLength / (count - 1)\n }\n\n /**\n * @ignore\n */\n private saveStoredFields (documentId: number, doc: T): void {\n const { storeFields, extractField } = this._options\n if (storeFields == null || storeFields.length === 0) { return }\n\n let documentFields = this._storedFields.get(documentId)\n if (documentFields == null) this._storedFields.set(documentId, documentFields = {})\n\n for (const fieldName of storeFields) {\n const fieldValue = extractField(doc, fieldName)\n if (fieldValue !== undefined) documentFields[fieldName] = fieldValue\n }\n }\n}\n\nconst getOwnProperty = (object: any, property: string) =>\n Object.prototype.hasOwnProperty.call(object, property) ? object[property] : undefined\n\ntype CombinatorFunction = (a: RawResult, b: RawResult) => RawResult\n\nconst combinators: Record<LowercaseCombinationOperator, CombinatorFunction> = {\n [OR]: (a: RawResult, b: RawResult) => {\n for (const docId of b.keys()) {\n const existing = a.get(docId)\n if (existing == null) {\n a.set(docId, b.get(docId)!)\n } else {\n const { score, terms, match } = b.get(docId)!\n existing.score = existing.score + score\n existing.match = Object.assign(existing.match, match)\n assignUniqueTerms(existing.terms, terms)\n }\n }\n\n return a\n },\n [AND]: (a: RawResult, b: RawResult) => {\n const combined = new Map()\n\n for (const docId of b.keys()) {\n const existing = a.get(docId)\n if (existing == null) continue\n\n const { score, terms, match } = b.get(docId)!\n assignUniqueTerms(existing.terms, terms)\n combined.set(docId, {\n score: existing.score + score,\n terms: existing.terms,\n match: Object.assign(existing.match, match)\n })\n }\n\n return combined\n },\n [AND_NOT]: (a: RawResult, b: RawResult) => {\n for (const docId of b.keys()) a.delete(docId)\n return a\n }\n}\n\n/**\n * Parameters of the BM25+ scoring algorithm. Customizing these is almost never\n * necessary, and finetuning them requires an understanding of the BM25 scoring\n * model.\n *\n * Some information about BM25 (and BM25+) can be found at these links:\n *\n * - https://en.wikipedia.org/wiki/Okapi_BM25\n * - https://opensourceconnections.com/blog/2015/10/16/bm25-the-next-generation-of-lucene-relevation/\n */\nexport type BM25Params = {\n /** Term frequency saturation point.\n *\n * Recommended values are between `1.2` and `2`. Higher values increase the\n * difference in score between documents with higher and lower term\n * frequencies. Setting this to `0` or a negative value is invalid. Defaults\n * to `1.2`\n */\n k: number,\n\n /**\n * Length normalization impact.\n *\n * Recommended values are around `0.75`. Higher values increase the weight\n * that field length has on scoring. Setting this to `0` (not recommended)\n * means that the field length has no effect on scoring. Negative values are\n * invalid. Defaults to `0.7`.\n */\n b: number,\n\n /**\n * BM25+ frequency normalization lower bound (usually called δ).\n *\n * Recommended values are between `0.5` and `1`. Increasing this parameter\n * increases the minimum relevance of one occurrence of a search term\n * regardless of its (possibly very long) field length. Negative values are\n * invalid. Defaults to `0.5`.\n */\n d: number\n}\n\nconst defaultBM25params: BM25Params = { k: 1.2, b: 0.7, d: 0.5 }\n\nconst calcBM25Score = (\n termFreq: number,\n matchingCount: number,\n totalCount: number,\n fieldLength: number,\n avgFieldLength: number,\n bm25params: BM25Params\n): number => {\n const { k, b, d } = bm25params\n const invDocFreq = Math.log(1 + (totalCount - matchingCount + 0.5) / (matchingCount + 0.5))\n return invDocFreq * (d + termFreq * (k + 1) / (termFreq + k * (1 - b + b * fieldLength / avgFieldLength)))\n}\n\nconst termToQuerySpec = (options: SearchOptions) => (term: string, i: number, terms: string[]): QuerySpec => {\n const fuzzy = (typeof options.fuzzy === 'function')\n ? options.fuzzy(term, i, terms)\n : (options.fuzzy || false)\n const prefix = (typeof options.prefix === 'function')\n ? options.prefix(term, i, terms)\n : (options.prefix === true)\n const termBoost = (typeof options.boostTerm === 'function')\n ? options.boostTerm(term, i, terms)\n : 1\n return { term, fuzzy, prefix, termBoost }\n}\n\nconst defaultOptions = {\n idField: 'id',\n extractField: (document: any, fieldName: string) => document[fieldName],\n tokenize: (text: string) => text.split(SPACE_OR_PUNCTUATION),\n processTerm: (term: string) => term.toLowerCase(),\n fields: undefined,\n searchOptions: undefined,\n storeFields: [],\n logger: (level: LogLevel, message: string): void => {\n if (typeof console?.[level] === 'function') console[level](message)\n },\n autoVacuum: true\n}\n\nconst defaultSearchOptions = {\n combineWith: OR,\n prefix: false,\n fuzzy: false,\n maxFuzzy: 6,\n boost: {},\n weights: { fuzzy: 0.45, prefix: 0.375 },\n bm25: defaultBM25params\n}\n\nconst defaultAutoSuggestOptions = {\n combineWith: AND,\n prefix: (term: string, i: number, terms: string[]): boolean =>\n i === terms.length - 1\n}\n\nconst defaultVacuumOptions = { batchSize: 1000, batchWait: 10 }\nconst defaultVacuumConditions = { minDirtFactor: 0.1, minDirtCount: 20 }\n\nconst defaultAutoVacuumOptions = { ...defaultVacuumOptions, ...defaultVacuumConditions }\n\nconst assignUniqueTerm = (target: string[], term: string): void => {\n // Avoid adding duplicate terms.\n if (!target.includes(term)) target.push(term)\n}\n\nconst assignUniqueTerms = (target: string[], source: readonly string[]): void => {\n for (const term of source) {\n // Avoid adding duplicate terms.\n if (!target.includes(term)) target.push(term)\n }\n}\n\ntype Scored = { score: number }\nconst byScore = ({ score: a }: Scored, { score: b }: Scored) => b - a\n\nconst createMap = () => new Map()\n\ninterface SerializedIndexEntry {\n [key: string]: number\n}\n\nconst objectToNumericMap = <T>(object: { [key: string]: T }): Map<number, T> => {\n const map = new Map()\n\n for (const key of Object.keys(object)) {\n map.set(parseInt(key, 10), object[key])\n }\n\n return map\n}\n\nconst objectToNumericMapAsync = async <T>(object: { [key: string]: T }): Promise<Map<number, T>> => {\n const map = new Map()\n\n let count = 0\n for (const key of Object.keys(object)) {\n map.set(parseInt(key, 10), object[key])\n if (++count % 1000 === 0) {\n await wait(0)\n }\n }\n\n return map\n}\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n// This regular expression matches any Unicode space, newline, or punctuation\n// character\nconst SPACE_OR_PUNCTUATION = /[\\n\\r\\p{Z}\\p{P}]+/u\n"],
"mappings": ";AAkHO,SAAS,UA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