1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-10-01 15:46:40 +02:00

fix imports

This commit is contained in:
Thomas Wilkerling
2025-03-12 15:07:16 +01:00
parent 59e95a2951
commit 4fe11882ca
53 changed files with 1918 additions and 1843 deletions

View File

@@ -7,43 +7,35 @@ const { parentPort } = require("worker_threads"),
let index;
parentPort.on("message", function (data) {
parentPort.on("message", async function (data) {
/** @type Index */
const args = data.args,
task = data.task,
id = data.id;
/** @type Index */
const args = data.args,
task = data.task,
id = data.id;
switch (task) {
switch (task) {
case "init":
let options = data.options || {},
filepath = options.config;
case "init":
let options = data.options || {},
filepath = options.config;
// load extern field configuration
// load extern field configuration
// if(filepath && filepath[0] !== "/" && filepath[0] !== "\\"){
// // current working directory
// const dir = process.cwd();
// filepath = join(dir, filepath);
// }
if (filepath) {
options = require(filepath);
}
// deprecated:
// const encode = options["encode"];
// if(encode && (encode.indexOf("function") === 0)){
// options["encode"] = new Function("return " + encode)();
// }
index = new Index(options);
break;
default:
const message = index[task].apply(index, args);
parentPort.postMessage("search" === task ? { id: id, msg: message } : { id: id });
if (filepath) {
options = Object.assign({}, options, require(filepath));
delete options.worker;
}
index = new Index(options);
//index.db && await index.db;
parentPort.postMessage({ id: id });
break;
default:
const message = index[task].apply(index, args);
parentPort.postMessage("search" === task ? { id: id, msg: message } : { id: id });
}
});