@merchise/action-queue
Advanced tools
@@ -441,3 +441,3 @@ class ActionQueue { | ||
| export { | ||
| ActionQueue | ||
| ActionQueue as default | ||
| }; |
@@ -381,3 +381,3 @@ class u { | ||
| export { | ||
| u as ActionQueue | ||
| u as default | ||
| }; |
| (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.ActionQueue = {})); | ||
| })(this, function(exports2) { | ||
| typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.ActionQueue = factory()); | ||
| })(this, function() { | ||
| "use strict"; | ||
@@ -444,4 +444,3 @@ class ActionQueue { | ||
| } | ||
| exports2.ActionQueue = ActionQueue; | ||
| Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" }); | ||
| return ActionQueue; | ||
| }); |
@@ -1,1 +0,1 @@ | ||
| (function(h,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(h=typeof globalThis<"u"?globalThis:h||self,_(h.ActionQueue={}))})(this,function(h){"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:()=>{}},s;this._options.createPromises?s=new Promise(function(u,r){n.resolve=u,n.reject=r}):s=void 0;let o={fn:e,connectors:n,extra:t,external_promise:s,inner_promise:void 0,cancelled:!1,cancel:()=>{this._cancel_action(o)}};return o}replace(e,...t){return this.clear(),this.append(e,...t)}replace_pending(e,...t){let n=this._queue.concat();for(this._queue.splice(0,this._queue.length);n.length>0;){let s=n.shift();this._cancel_action(s)}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(s){let{extra:o,cancel:u,external_promise:r}=s;return{args:o,cancel:u,promise:r}};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,cancelled:s}=e;if(s){this._run();return}let o=t();e.inner_promise=o;let u=this._acquire(e),r=this;o.then(function(...l){r._release(u);try{n.resolve(...l)}catch(i){console.error(i)}l.length==1&&typeof l[0]>"u"&&(l=[]);let a=e.extra||[];if(r._rolling!==null){let i=r._rolling.resolve;if(typeof i<"u"&&i!==null)try{i.apply(r,l.concat(a))}catch(c){console.error(c)}r._rolling=null}r._thens.forEach(function(i){try{i.apply(r,l.concat(a))}catch(c){console.error(c)}}),r._finallys.forEach(function(i){try{i.apply(r,l.concat(a))}catch(c){console.error(c)}}),r._run()}).catch(function(...l){r._release(u);try{n.reject(...l)}catch(i){console.error(i)}l.length==1&&typeof l[0]>"u"&&(l=[]);let a=e.extra||[];if(r._rolling!==null){let i=r._rolling.reject;if(typeof i<"u"&&i!==null)try{i.apply(r,l.concat(a))}catch(c){console.error(c)}r._rolling=null}r._catchs.forEach(function(i){try{i.apply(r,l.concat(a))}catch(c){console.error(c)}}),r._finallys.forEach(function(i){try{i.apply(r,l.concat(a))}catch(c){console.error(c)}}),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){e.cancelled=!0;let t=e.extra,n=this;if(this._cancels.forEach(function(s){try{s.apply(n,t)}catch(o){console.error(o)}}),this._options.rejectCanceled)try{e.connectors.reject(new Error("Action was cancelled"))}catch(s){console.error(s)}this._finallys.forEach(function(s){try{s.apply(n,t)}catch(o){console.error(o)}})}_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)}}h.ActionQueue=_,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}); | ||
| (function(u,_){typeof exports=="object"&&typeof module<"u"?module.exports=_():typeof define=="function"&&define.amd?define(_):(u=typeof globalThis<"u"?globalThis:u||self,u.ActionQueue=_())})(this,function(){"use strict";class u{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:()=>{}},s;this._options.createPromises?s=new Promise(function(h,r){n.resolve=h,n.reject=r}):s=void 0;let c={fn:e,connectors:n,extra:t,external_promise:s,inner_promise:void 0,cancelled:!1,cancel:()=>{this._cancel_action(c)}};return c}replace(e,...t){return this.clear(),this.append(e,...t)}replace_pending(e,...t){let n=this._queue.concat();for(this._queue.splice(0,this._queue.length);n.length>0;){let s=n.shift();this._cancel_action(s)}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(s){let{extra:c,cancel:h,external_promise:r}=s;return{args:c,cancel:h,promise:r}};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,cancelled:s}=e;if(s){this._run();return}let c=t();e.inner_promise=c;let h=this._acquire(e),r=this;c.then(function(...l){r._release(h);try{n.resolve(...l)}catch(i){console.error(i)}l.length==1&&typeof l[0]>"u"&&(l=[]);let a=e.extra||[];if(r._rolling!==null){let i=r._rolling.resolve;if(typeof i<"u"&&i!==null)try{i.apply(r,l.concat(a))}catch(o){console.error(o)}r._rolling=null}r._thens.forEach(function(i){try{i.apply(r,l.concat(a))}catch(o){console.error(o)}}),r._finallys.forEach(function(i){try{i.apply(r,l.concat(a))}catch(o){console.error(o)}}),r._run()}).catch(function(...l){r._release(h);try{n.reject(...l)}catch(i){console.error(i)}l.length==1&&typeof l[0]>"u"&&(l=[]);let a=e.extra||[];if(r._rolling!==null){let i=r._rolling.reject;if(typeof i<"u"&&i!==null)try{i.apply(r,l.concat(a))}catch(o){console.error(o)}r._rolling=null}r._catchs.forEach(function(i){try{i.apply(r,l.concat(a))}catch(o){console.error(o)}}),r._finallys.forEach(function(i){try{i.apply(r,l.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){e.cancelled=!0;let t=e.extra,n=this;if(this._cancels.forEach(function(s){try{s.apply(n,t)}catch(c){console.error(c)}}),this._options.rejectCanceled)try{e.connectors.reject(new Error("Action was cancelled"))}catch(s){console.error(s)}this._finallys.forEach(function(s){try{s.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)}}return u}); |
+1
-1
| { | ||
| "name": "@merchise/action-queue", | ||
| "version": "4.4.1", | ||
| "version": "5.0.0", | ||
| "description": "A coordinated queue of actions", | ||
@@ -5,0 +5,0 @@ "files": [ |
+1
-1
@@ -1,2 +0,2 @@ | ||
| export class ActionQueue { | ||
| export default class ActionQueue { | ||
| constructor(options) { | ||
@@ -3,0 +3,0 @@ if (typeof options !== "undefined") { |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
63367
-0.26%1737
-0.12%