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

@merchise/action-queue

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@merchise/action-queue - npm Package Compare versions

Comparing version
4.2.0
to
4.3.0
+1
-1
dist/action-queue.umd.js
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["action-queue"] = {}));
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@merchise/action-queue"] = {}));
})(this, function(exports2) {

@@ -4,0 +4,0 @@ "use strict";

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

(function(u,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(u=typeof globalThis<"u"?globalThis:u||self,_(u["action-queue"]={}))})(this,function(u){"use strict";class _{constructor(e){typeof e<"u"?this._options={createPromises:typeof e.createPromises=="boolean"?e.createPromises:!0,rejectCanceled:typeof e.rejectCanceled=="boolean"?e.rejectCanceled:!0,workers:typeof e.workers=="number"&&e.workers>1?e.workers:1}:this._options={createPromises:!0,workers:1,rejectCanceled:!0},this._thens=[],this._catchs=[],this._finallys=[],this._cancels=[],this._paused=!1,this._queue=[],this._rolling=null,this._workers={},this._idle=new Set,[...Array(this._options.workers).keys()].map(t=>this._idle.add(t))}then(e){this._thens.push(e)}catch(e){this._catchs.push(e)}finally(e){this._finallys.push(e)}oncancel(e){this._cancels.push(e)}prepend(e,...t){let n=this._build_action(e,t);return this._queue.splice(0,0,n),this._run(),n.external_promise}append(e,...t){let n=this._build_action(e,t);return this._queue.push(n),this._run(),n.external_promise}_build_action(e,t){let n={resolve:()=>{},reject:()=>{}},l;this._options.createPromises?l=new Promise(function(h,f){n.resolve=h,n.reject=f}):l=void 0;let c={fn:e,connectors:n,extra:t,external_promise:l,inner_promise:void 0,cancelled:!1,cancel:()=>{this._cancel_action(c)}};return c}replace(e,...t){return this.clear(),this.append(e,...t)}clear(){let e=this._queue.concat();for(this._queue.splice(0,this._queue.length),this._cancel_running();e.length>0;){let t=e.shift();this._cancel_action(t)}}length(){return this._queue.length+this.running()}running(){return this._options.workers-this._idle.size}busy(){return this.length()>0}promise(){return this._rolling===null&&this._setup_rolling_promise(),this._rolling.promise}paused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1,this._run()}info(){let e=function(l){let{promise:c,extra:h}=l;return{args:h,cancel:l.cancel,promise:l.external_promise}};const t=Object.values(this._workers),n=[].concat(this._queue);return{running:t.map(e),pending:n.map(e)}}_setup_rolling_promise(){let e=this;e._rolling={promise:null,resolve:null,reject:null},e._rolling.promise=new Promise(function(t,n){e._rolling.resolve=t,e._rolling.reject=n})}_run(){if(!this.paused()&&this._idle.size>0&&this._queue.length>0){let e=this._queue.shift(),{fn:t,connectors:n,extra:l,cancelled:c}=e;if(c){this._run();return}let h=t();e.inner_promise=h;let f=this._acquire(e),r=this;h.then(function(...s){r._release(f);try{n.resolve(...s)}catch(i){console.error(i)}s.length==1&&typeof s[0]>"u"&&(s=[]);let a=e.extra||[];if(r._rolling!==null){let i=r._rolling.resolve;if(typeof i<"u"&&i!==null)try{i.apply(r,s.concat(a))}catch(o){console.error(o)}r._rolling=null}r._thens.forEach(function(i){try{i.apply(r,s.concat(a))}catch(o){console.error(o)}}),r._finallys.forEach(function(i){try{i.apply(r,s.concat(a))}catch(o){console.error(o)}}),r._run()}).catch(function(...s){r._release(f);try{n.reject(...s)}catch(i){console.error(i)}s.length==1&&typeof s[0]>"u"&&(s=[]);let a=e.extra||[];if(r._rolling!==null){let i=r._rolling.reject;if(typeof i<"u"&&i!==null)try{i.apply(r,s.concat(a))}catch(o){console.error(o)}r._rolling=null}r._catchs.forEach(function(i){try{i.apply(r,s.concat(a))}catch(o){console.error(o)}}),r._finallys.forEach(function(i){try{i.apply(r,s.concat(a))}catch(o){console.error(o)}}),r._run()}),r._run()}}_cancel_running(){for(const e of Object.values(this._workers)){let t=e.inner_promise;try{typeof t.cancel=="function"?t.cancel():typeof t.abort=="function"&&t.abort()}catch(n){console.error(n)}this._cancel_action(e)}this._workers={},this._idle=new Set,[...Array(this._options.workers).keys()].map(e=>this._idle.add(e))}_cancel_action(e){if(e.cancelled=!0,this._options.rejectCanceled)try{e.connectors.reject(new Error("Action was cancelled"))}catch(l){console.error(l)}let t=e.extra,n=this;this._cancels.forEach(function(l){try{l.apply(n,t)}catch(c){console.error(c)}}),this._finallys.forEach(function(l){try{l.apply(n,t)}catch(c){console.error(c)}})}_acquire(e){let n=this._idle.values().next().value;return this._idle.delete(n),this._workers[n]=e,n}_release(e){delete this._workers[e],this._idle.add(e)}}u.ActionQueue=_,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
(function(u,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(u=typeof globalThis<"u"?globalThis:u||self,_(u["@merchise/action-queue"]={}))})(this,function(u){"use strict";class _{constructor(e){typeof e<"u"?this._options={createPromises:typeof e.createPromises=="boolean"?e.createPromises:!0,rejectCanceled:typeof e.rejectCanceled=="boolean"?e.rejectCanceled:!0,workers:typeof e.workers=="number"&&e.workers>1?e.workers:1}:this._options={createPromises:!0,workers:1,rejectCanceled:!0},this._thens=[],this._catchs=[],this._finallys=[],this._cancels=[],this._paused=!1,this._queue=[],this._rolling=null,this._workers={},this._idle=new Set,[...Array(this._options.workers).keys()].map(t=>this._idle.add(t))}then(e){this._thens.push(e)}catch(e){this._catchs.push(e)}finally(e){this._finallys.push(e)}oncancel(e){this._cancels.push(e)}prepend(e,...t){let n=this._build_action(e,t);return this._queue.splice(0,0,n),this._run(),n.external_promise}append(e,...t){let n=this._build_action(e,t);return this._queue.push(n),this._run(),n.external_promise}_build_action(e,t){let n={resolve:()=>{},reject:()=>{}},l;this._options.createPromises?l=new Promise(function(h,f){n.resolve=h,n.reject=f}):l=void 0;let c={fn:e,connectors:n,extra:t,external_promise:l,inner_promise:void 0,cancelled:!1,cancel:()=>{this._cancel_action(c)}};return c}replace(e,...t){return this.clear(),this.append(e,...t)}clear(){let e=this._queue.concat();for(this._queue.splice(0,this._queue.length),this._cancel_running();e.length>0;){let t=e.shift();this._cancel_action(t)}}length(){return this._queue.length+this.running()}running(){return this._options.workers-this._idle.size}busy(){return this.length()>0}promise(){return this._rolling===null&&this._setup_rolling_promise(),this._rolling.promise}paused(){return this._paused}pause(){this._paused=!0}resume(){this._paused=!1,this._run()}info(){let e=function(l){let{promise:c,extra:h}=l;return{args:h,cancel:l.cancel,promise:l.external_promise}};const t=Object.values(this._workers),n=[].concat(this._queue);return{running:t.map(e),pending:n.map(e)}}_setup_rolling_promise(){let e=this;e._rolling={promise:null,resolve:null,reject:null},e._rolling.promise=new Promise(function(t,n){e._rolling.resolve=t,e._rolling.reject=n})}_run(){if(!this.paused()&&this._idle.size>0&&this._queue.length>0){let e=this._queue.shift(),{fn:t,connectors:n,extra:l,cancelled:c}=e;if(c){this._run();return}let h=t();e.inner_promise=h;let f=this._acquire(e),r=this;h.then(function(...s){r._release(f);try{n.resolve(...s)}catch(i){console.error(i)}s.length==1&&typeof s[0]>"u"&&(s=[]);let a=e.extra||[];if(r._rolling!==null){let i=r._rolling.resolve;if(typeof i<"u"&&i!==null)try{i.apply(r,s.concat(a))}catch(o){console.error(o)}r._rolling=null}r._thens.forEach(function(i){try{i.apply(r,s.concat(a))}catch(o){console.error(o)}}),r._finallys.forEach(function(i){try{i.apply(r,s.concat(a))}catch(o){console.error(o)}}),r._run()}).catch(function(...s){r._release(f);try{n.reject(...s)}catch(i){console.error(i)}s.length==1&&typeof s[0]>"u"&&(s=[]);let a=e.extra||[];if(r._rolling!==null){let i=r._rolling.reject;if(typeof i<"u"&&i!==null)try{i.apply(r,s.concat(a))}catch(o){console.error(o)}r._rolling=null}r._catchs.forEach(function(i){try{i.apply(r,s.concat(a))}catch(o){console.error(o)}}),r._finallys.forEach(function(i){try{i.apply(r,s.concat(a))}catch(o){console.error(o)}}),r._run()}),r._run()}}_cancel_running(){for(const e of Object.values(this._workers)){let t=e.inner_promise;try{typeof t.cancel=="function"?t.cancel():typeof t.abort=="function"&&t.abort()}catch(n){console.error(n)}this._cancel_action(e)}this._workers={},this._idle=new Set,[...Array(this._options.workers).keys()].map(e=>this._idle.add(e))}_cancel_action(e){if(e.cancelled=!0,this._options.rejectCanceled)try{e.connectors.reject(new Error("Action was cancelled"))}catch(l){console.error(l)}let t=e.extra,n=this;this._cancels.forEach(function(l){try{l.apply(n,t)}catch(c){console.error(c)}}),this._finallys.forEach(function(l){try{l.apply(n,t)}catch(c){console.error(c)}})}_acquire(e){let n=this._idle.values().next().value;return this._idle.delete(n),this._workers[n]=e,n}_release(e){delete this._workers[e],this._idle.add(e)}}u.ActionQueue=_,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
{
"name": "@merchise/action-queue",
"version": "4.2.0",
"version": "4.3.0",
"description": "A coordinated queue of actions",

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