Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@bddh/starling-timeout-controller

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bddh/starling-timeout-controller - npm Package Compare versions

Comparing version
1.0.2
to
1.0.3
+1
cjs/node_modules/f...numbers/build/es2019/factories/cache.js
"use strict";exports.createCache=function(t){return function(e,r){return t.set(e,r),r}};
"use strict";var r=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,e=536870912,t=1073741824;exports.createGenerateUniqueNumber=function(a,o){return function(n){var i=o.get(n),u=void 0===i?n.size:i<t?i+1:0;if(!n.has(u))return a(n,u);if(n.size<e){for(;n.has(u);)u=Math.floor(Math.random()*t);return a(n,u)}if(n.size>r)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(u);)u=Math.floor(Math.random()*r);return a(n,u)}};
"use strict";var e=require("./factories/cache.js"),r=require("./factories/generate-unique-number.js"),a=new WeakMap,t=e.createCache(a),u=r.createGenerateUniqueNumber(t,a);exports.generateUniqueNumber=u;
"use strict";exports.isCallNotification=function(t){return void 0!==t.method&&"call"===t.method};
"use strict";exports.isClearResponse=function(e){return null===e.error&&"number"==typeof e.id};
"use strict";var e=require("../../../fast-unique-numbers/build/es2019/module.js"),r=require("./guards/call-notification.js"),t=require("./guards/clear-response.js");exports.load=function(i){var n=new Map([[0,function(){}]]),a=new Map([[0,function(){}]]),o=new Map,s=new Worker(i);s.addEventListener("message",(function(e){var i=e.data;if(r.isCallNotification(i)){var s=i.params,m=s.timerId,d=s.timerType;if("interval"===d){var u=n.get(m);if("number"==typeof u){var l=o.get(u);if(void 0===l||l.timerId!==m||l.timerType!==d)throw new Error("The timer is in an undefined state.")}else{if(void 0===u)throw new Error("The timer is in an undefined state.");u()}}else if("timeout"===d){var f=a.get(m);if("number"==typeof f){var p=o.get(f);if(void 0===p||p.timerId!==m||p.timerType!==d)throw new Error("The timer is in an undefined state.")}else{if(void 0===f)throw new Error("The timer is in an undefined state.");f(),a.delete(m)}}}else{if(!t.isClearResponse(i)){var v=i.error.message;throw new Error(v)}var c=i.id,w=o.get(c);if(void 0===w)throw new Error("The timer is in an undefined state.");var g=w.timerId,h=w.timerType;o.delete(c),"interval"===h?n.delete(g):a.delete(g)}}));return{clearInterval:function(r){var t=e.generateUniqueNumber(o);o.set(t,{timerId:r,timerType:"interval"}),n.set(r,t),s.postMessage({id:t,method:"clear",params:{timerId:r,timerType:"interval"}})},clearTimeout:function(r){var t=e.generateUniqueNumber(o);o.set(t,{timerId:r,timerType:"timeout"}),a.set(r,t),s.postMessage({id:t,method:"clear",params:{timerId:r,timerType:"timeout"}})},setInterval:function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e.generateUniqueNumber(n);return n.set(i,(function(){r(),"function"==typeof n.get(i)&&s.postMessage({id:null,method:"set",params:{delay:t,now:performance.now(),timerId:i,timerType:"interval"}})})),s.postMessage({id:null,method:"set",params:{delay:t,now:performance.now(),timerId:i,timerType:"interval"}}),i},setTimeout:function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e.generateUniqueNumber(a);return a.set(i,r),s.postMessage({id:null,method:"set",params:{delay:t,now:performance.now(),timerId:i,timerType:"timeout"}}),i}}};
"use strict";exports.createLoadOrReturnBroker=function(t,e){var r=null;return function(){if(null!==r)return r;var n=new Blob([e],{type:"application/javascript; charset=utf-8"}),u=URL.createObjectURL(n);return r=t(u),setTimeout((function(){return URL.revokeObjectURL(u)})),r}};
"use strict";var r=require("../../../worker-timers-broker/build/es2019/module.js"),e=require("./factories/load-or-return-broker.js"),t=require("./worker/worker.js"),o=e.createLoadOrReturnBroker(r.load,t.worker);exports.clearInterval=function(r){return o().clearInterval(r)},exports.clearTimeout=function(r){return o().clearTimeout(r)},exports.setInterval=function(){var r;return(r=o()).setInterval.apply(r,arguments)},exports.setTimeout=function(){var r;return(r=o()).setTimeout.apply(r,arguments)};
"use strict";exports.worker='(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error(\'There is no interval scheduled with the given id "\'.concat(t,\'".\'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error(\'The given type "\'.concat(i,\'" is not supported\'));(e=>{const r=t.get(e);if(void 0===r)throw new Error(\'There is no timeout scheduled with the given id "\'.concat(e,\'".\'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error(\'The given method "\'.concat(s.method,\'" is not supported\'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error(\'The given type "\'.concat(d,\'" is not supported\'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();';
var n=function(n){return function(r,t){return n.set(r,t),t}};export{n as createCache};
var r=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,e=536870912,o=1073741824,a=function(a,t){return function(n){var i=t.get(n),u=void 0===i?n.size:i<o?i+1:0;if(!n.has(u))return a(n,u);if(n.size<e){for(;n.has(u);)u=Math.floor(Math.random()*o);return a(n,u)}if(n.size>r)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(u);)u=Math.floor(Math.random()*r);return a(n,u)}};export{a as createGenerateUniqueNumber};
import{createCache as e}from"./factories/cache.js";import{createGenerateUniqueNumber as r}from"./factories/generate-unique-number.js";var a=new WeakMap,o=r(e(a),a);export{o as generateUniqueNumber};
var o=function(o){return void 0!==o.method&&"call"===o.method};export{o as isCallNotification};
var r=function(r){return null===r.error&&"number"==typeof r.id};export{r as isClearResponse};
import{generateUniqueNumber as e}from"../../../fast-unique-numbers/build/es2019/module.js";import{isCallNotification as t}from"./guards/call-notification.js";import{isClearResponse as r}from"./guards/clear-response.js";var i=function(i){var n=new Map([[0,function(){}]]),a=new Map([[0,function(){}]]),o=new Map,s=new Worker(i);s.addEventListener("message",(function(e){var i=e.data;if(t(i)){var s=i.params,m=s.timerId,d=s.timerType;if("interval"===d){var f=n.get(m);if("number"==typeof f){var l=o.get(f);if(void 0===l||l.timerId!==m||l.timerType!==d)throw new Error("The timer is in an undefined state.")}else{if(void 0===f)throw new Error("The timer is in an undefined state.");f()}}else if("timeout"===d){var p=a.get(m);if("number"==typeof p){var u=o.get(p);if(void 0===u||u.timerId!==m||u.timerType!==d)throw new Error("The timer is in an undefined state.")}else{if(void 0===p)throw new Error("The timer is in an undefined state.");p(),a.delete(m)}}}else{if(!r(i)){var v=i.error.message;throw new Error(v)}var w=i.id,c=o.get(w);if(void 0===c)throw new Error("The timer is in an undefined state.");var h=c.timerId,T=c.timerType;o.delete(w),"interval"===T?n.delete(h):a.delete(h)}}));return{clearInterval:function(t){var r=e(o);o.set(r,{timerId:t,timerType:"interval"}),n.set(t,r),s.postMessage({id:r,method:"clear",params:{timerId:t,timerType:"interval"}})},clearTimeout:function(t){var r=e(o);o.set(r,{timerId:t,timerType:"timeout"}),a.set(t,r),s.postMessage({id:r,method:"clear",params:{timerId:t,timerType:"timeout"}})},setInterval:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e(n);return n.set(i,(function(){t(),"function"==typeof n.get(i)&&s.postMessage({id:null,method:"set",params:{delay:r,now:performance.now(),timerId:i,timerType:"interval"}})})),s.postMessage({id:null,method:"set",params:{delay:r,now:performance.now(),timerId:i,timerType:"interval"}}),i},setTimeout:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e(a);return a.set(i,t),s.postMessage({id:null,method:"set",params:{delay:r,now:performance.now(),timerId:i,timerType:"timeout"}}),i}}};export{i as load};
var t=function(t,e){var r=null;return function(){if(null!==r)return r;var n=new Blob([e],{type:"application/javascript; charset=utf-8"}),u=URL.createObjectURL(n);return r=t(u),setTimeout((function(){return URL.revokeObjectURL(u)})),r}};export{t as createLoadOrReturnBroker};
import{load as r}from"../../../worker-timers-broker/build/es2019/module.js";import{createLoadOrReturnBroker as e}from"./factories/load-or-return-broker.js";import{worker as o}from"./worker/worker.js";var t=e(r,o),n=function(r){return t().clearInterval(r)},u=function(r){return t().clearTimeout(r)},i=function(){var r;return(r=t()).setInterval.apply(r,arguments)},a=function(){var r;return(r=t()).setTimeout.apply(r,arguments)};export{n as clearInterval,u as clearTimeout,i as setInterval,a as setTimeout};
var e='(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error(\'There is no interval scheduled with the given id "\'.concat(t,\'".\'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error(\'The given type "\'.concat(i,\'" is not supported\'));(e=>{const r=t.get(e);if(void 0===r)throw new Error(\'There is no timeout scheduled with the given id "\'.concat(e,\'".\'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error(\'The given method "\'.concat(s.method,\'" is not supported\'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error(\'The given type "\'.concat(d,\'" is not supported\'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();';export{e as worker};
MIT License
Copyright (c) zhangyibo02@baidu.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+3
-2
{
"name": "@bddh/starling-timeout-controller",
"version": "1.0.2",
"version": "1.0.3",
"description": "TimeoutController",

@@ -33,3 +33,4 @@ "keywords": [

"@bddh/starling-interval": "^1.0.4"
}
},
"gitHead": "025e48778fe8f7e6224878919d0366f5fbd34bfb"
}