mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-10-03 16:41:50 +02:00
1 line
555 B
JavaScript
1 line
555 B
JavaScript
const{parentPort}=require("worker_threads"),{Index}=require("flexsearch");let index,options;parentPort.on("message",async function(a){const b=a.task,c=a.id;let d=a.args;switch(b){case"init":options=a.options||{};let e=options.config;e&&(options=Object.assign({},options,require(e)),delete options.worker),index=new Index(options),parentPort.postMessage({id:c});break;default:let f;"export"===b&&(d=[options.export]),"import"===b?await options.import.call(index,index):f=index[b].apply(index,d),parentPort.postMessage("search"===b?{id:c,msg:f}:{id:c});}}); |