1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-10-01 07:36:40 +02:00
Files
flexsearch/dist/module/worker/node.js
Thomas Wilkerling 0c2ce73ce2 bundle v0.7.0
2021-06-06 00:30:12 +02:00

1 line
424 B
JavaScript

const{parentPort}=require("worker_threads"),{Index}=require("../flexsearch.bundle.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});}});