Host FlexSearch
This commit is contained in:
35
paige/node_modules/flexsearch/dist/node/node.js
generated
vendored
Normal file
35
paige/node_modules/flexsearch/dist/node/node.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
const { parentPort } = require("worker_threads");
|
||||
const { Index } = require("../flexsearch.bundle.min.js");
|
||||
|
||||
let index;
|
||||
|
||||
parentPort.on("message", function(data){
|
||||
|
||||
/** @type Index */
|
||||
const args = data["args"];
|
||||
const task = data["task"];
|
||||
const id = data["id"];
|
||||
|
||||
switch(task){
|
||||
|
||||
case "init":
|
||||
|
||||
const options = data["options"] || {};
|
||||
const encode = options["encode"];
|
||||
|
||||
options["cache"] = false;
|
||||
|
||||
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(task === "search" ? { "id": id, "msg": message } : { "id": id });
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user