1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-08-20 04:41:36 +02:00

add git-ignored file to dist

This commit is contained in:
Thomas Wilkerling
2025-03-12 22:11:36 +01:00
parent 4b9900560a
commit 11c3377e90

45
dist/node/node.mjs vendored Normal file
View File

@@ -0,0 +1,45 @@
import { parentPort } from "worker_threads";
import { join } from "path";
// Test Path
//import Index from "../../src/index.js";
//import { Index } from "../../dist/flexsearch.bundle.module.min.js";
import { Index } from "../flexsearch.bundle.module.min.js";
let index;
parentPort.on("message", async function(data){
/** @type Index */
const args = data["args"];
const task = data["task"];
const id = data["id"];
switch(task){
case "init":
let options = data["options"] || {};
// load extern field configuration
let filepath = options["config"];
if(filepath){
filepath = join("file://", filepath);
options = Object.assign({}, options, (await import(filepath))["default"]);
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(
task === "search"
? { "id": id, "msg": message }
: { "id": id }
);
}
});