1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-10-03 00:21:51 +02:00

worker index basic support export/import

This commit is contained in:
Thomas Wilkerling
2025-03-20 09:42:26 +01:00
parent b0311432fd
commit b2c79cfd0e
45 changed files with 3059 additions and 2281 deletions

View File

@@ -1 +1 @@
import Index from"../index.js";import{IndexOptions}from"../type.js";export default(async function(a){a=a.data;const b=self._index,c=a.args,d=a.task;switch(d){case"init":let e=a.options||{},f=e.config;f&&(e=e);const g=a.factory;g?(Function("return "+g)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new Index(e),postMessage({id:a.id});break;default:const h=a.id,i=b[d].apply(b,c);postMessage("search"===d?{id:h,msg:i}:{id:h});}});
import Index from"../index.js";import{IndexOptions}from"../type.js";let index,options;export default(async function(a){a=a.data;const b=a.task,c=a.id;let d=a.args;switch(b){case"init":options=a.options||{};let e=options.config;e&&(options=options);const f=a.factory;f?(Function("return "+f)()(self),index=new self.FlexSearch.Index(options),delete self.FlexSearch):index=new Index(options),postMessage({id:c});break;default:let g;"export"===b&&(d=[options.export]),"import"===b?await options.import.call(index,index):g=index[b].apply(index,d),postMessage("search"===b?{id:c,msg:g}:{id:c});}});