Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fuse.js-worker

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuse.js-worker - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

build/FuseAdapter.d.ts

@@ -9,3 +9,3 @@ import { FuseAdapterOptions, InitializeRequestMessage, SearchRequestMessage, SearchResponseMessage } from './types';

initialize(list: InitializeRequestMessage<T>['payload']['list'], options?: InitializeRequestMessage<T>['payload']['options'], index?: InitializeRequestMessage<T>['payload']['index']): Promise<void>;
search(pattern: SearchRequestMessage['payload']['pattern'], options: SearchRequestMessage['payload']['options']): Promise<SearchResponseMessage<T>['payload']>;
search(pattern: SearchRequestMessage['payload']['pattern'], options?: SearchRequestMessage['payload']['options']): Promise<SearchResponseMessage<T>['payload']>;
terminate(): void;

@@ -12,0 +12,0 @@ private postMessage;

@@ -1,1 +0,1 @@

(()=>{"use strict";var e={467:function(e,t,r){var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function u(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=a(r(565)),l=r(915),s={pollingTime:10},c=function(){function e(e){var t=this;this.idGenerator=l.IdGenerator(),this.resolvedPromises=new Map,this.worker=new u.default,this.options=n(n({},s),e),this.worker.onmessage=function(e){t.resolvedPromises.set(e.data.id,e.data)}}return e.prototype.initialize=function(e,t,r){return o(this,void 0,void 0,(function(){return i(this,(function(n){return this.postMessage({id:this.idGenerator.next().value,type:"initialize-request",payload:{index:r,list:e,options:t}}),[2]}))}))},e.prototype.search=function(e,t){return o(this,void 0,void 0,(function(){var r,n=this;return i(this,(function(o){return r=this.idGenerator.next().value,this.postMessage({id:r,payload:{options:t,pattern:e},type:"search-request"}),[2,new Promise((function(e){l.poll((function(){if(!n.resolvedPromises.has(r))return!0;var t=n.resolvedPromises.get(r);return n.resolvedPromises.delete(r),e(t.payload),!1}),n.options.pollingTime)}))]}))}))},e.prototype.terminate=function(){this.worker.terminate()},e.prototype.postMessage=function(e){this.worker.postMessage(e)},e}();t.default=c},607:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FuseAdapter=void 0;var o=r(467);Object.defineProperty(t,"FuseAdapter",{enumerable:!0,get:function(){return n(o).default}})},660:function(e,t){var r=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e;return r(this,(function(t){switch(t.label){case 0:e=0,t.label=1;case 1:return[4,e++];case 2:return t.sent(),[3,1];case 3:return[2]}}))}},915:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.poll=t.IdGenerator=void 0;var o=r(660);Object.defineProperty(t,"IdGenerator",{enumerable:!0,get:function(){return n(o).default}});var i=r(164);Object.defineProperty(t,"poll",{enumerable:!0,get:function(){return n(i).default}})},164:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var r=self.setInterval((function(){e()||self.clearInterval(r)}),t)}},565:(e,t,r)=>{function n(){return new Worker(r.p+"index.worker.js")}r.r(t),r.d(t,{default:()=>n})}},t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.p="/build/",r(607)})();
(()=>{"use strict";var e={467:function(e,t,r){var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function u(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}l((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=a(r(565)),l=r(915),s={pollingTime:10},c=function(){function e(e){var t=this;this.idGenerator=l.IdGenerator(),this.resolvedPromises=new Map,this.worker=new u.default,this.options=n(n({},s),e),this.worker.onmessage=function(e){t.resolvedPromises.set(e.data.id,e.data)}}return e.prototype.initialize=function(e,t,r){return o(this,void 0,void 0,(function(){return i(this,(function(n){return this.postMessage({id:this.idGenerator.next().value,type:"initialize-request",payload:{index:r,list:e,options:t}}),[2]}))}))},e.prototype.search=function(e,t){return o(this,void 0,void 0,(function(){var r,n=this;return i(this,(function(o){return r=this.idGenerator.next().value,this.postMessage({id:r,payload:{options:t,pattern:e},type:"search-request"}),[2,new Promise((function(e){l.poll((function(){if(!n.resolvedPromises.has(r))return!0;var t=n.resolvedPromises.get(r);return n.resolvedPromises.delete(r),e(t.payload),!1}),n.options.pollingTime)}))]}))}))},e.prototype.terminate=function(){this.worker.terminate()},e.prototype.postMessage=function(e){this.worker.postMessage(e)},e}();t.default=c},607:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FuseAdapter=void 0;var o=r(467);Object.defineProperty(t,"FuseAdapter",{enumerable:!0,get:function(){return n(o).default}})},660:function(e,t){var r=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e;return r(this,(function(t){switch(t.label){case 0:e=0,t.label=1;case 1:return[4,e++];case 2:return t.sent(),[3,1];case 3:return[2]}}))}},915:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.poll=t.IdGenerator=void 0;var o=r(660);Object.defineProperty(t,"IdGenerator",{enumerable:!0,get:function(){return n(o).default}});var i=r(164);Object.defineProperty(t,"poll",{enumerable:!0,get:function(){return n(i).default}})},164:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var r=self.setInterval((function(){e()||self.clearInterval(r)}),t)}},565:(e,t,r)=>{function n(){return new Worker(r.p+"index.worker.js")}r.r(t),r.d(t,{default:()=>n})}},t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.p="/",r(607)})();
{
"name": "fuse.js-worker",
"version": "0.1.0",
"version": "0.1.1",
"description": "Fuse.js in Web Worker for great user experience",

@@ -5,0 +5,0 @@ "keywords": [

@@ -8,1 +8,11 @@ # fuse.js-worker

[Fuse.js](https://fusejs.io/) in [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) for great user experience.
## Motivation
[Fuse.js docs](https://fusejs.io/) state:
> When you want client-side fuzzy searching of small to moderately large data sets.
You have a client-side search. Your data set tends to grow. Or perhaps fuzzy search is used with more and more types of data. At some point Fuse.js becomes a performance issue. Tweaking options can only get you so far. Typing feedback becomes worse. You debounce things. It does not really help. Eventually your app freezes when search is performed. User experience is ruined. You don't want to get rid of fuzzy search and you don't want to move the client-side search to server.
[Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) for the rescue!
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc