site/node_modules/flexsearch/dist/module-min/worker/node.js

1 line
428 B
JavaScript
Raw Normal View History

2024-10-14 06:09:33 +00:00
const{parentPort}=require("worker_threads"),{Index}=require("../flexsearch.bundle.min.js");let index;parentPort.on("message",function(a){const b=a.args,c=a.task,d=a.id;switch(c){case"init":const e=a.options||{},f=e.encode;e.cache=!1,f&&0===f.indexOf("function")&&(e.encode=new Function("return "+f)()),index=new Index(e);break;default:const g=index[c].apply(index,b);parentPort.postMessage("search"===c?{id:d,msg:g}:{id:d});}});