Comparing version 1.1.2 to 1.1.3
@@ -21,8 +21,7 @@ // Generated by dts-bundle-generator v6.2.0 | ||
concurrency?: number; | ||
onProgress?: (status: "finished" | QueueState) => void; | ||
onProgress?: (status: "idle" | QueueState) => void; | ||
} | ||
export declare type Job<T> = () => Promise<T>; | ||
export interface QueuePromises { | ||
readonly runned: number; | ||
state(): "idle" | "finished" | QueueState; | ||
state(): "idle" | QueueState; | ||
enqueue<T>(item: Job<T>): void; | ||
@@ -37,2 +36,3 @@ promise<T>(item: Job<T>): Promise<T>; | ||
size: number; | ||
runned: number; | ||
}): void; | ||
@@ -39,0 +39,0 @@ } |
@@ -1,1 +0,1 @@ | ||
var T=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var z=e=>T(e,"__esModule",{value:!0});var J=(e,n)=>{for(var i in n)T(e,i,{get:n[i],enumerable:!0})},q=(e,n,i,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of F(n))!S.call(e,o)&&(i||o!=="default")&&T(e,o,{get:()=>n[o],enumerable:!(t=Q(n,o))||t.enumerable});return e};var j=(e=>(n,i)=>e&&e.get(n)||(i=q(z({}),n,1),e&&e.set(n,i),i))(typeof WeakMap!="undefined"?new WeakMap:0);var C={};J(C,{asap:()=>f,defer:()=>v,queuePromises:()=>k,sleep:()=>M});function M(e){return new Promise(n=>{setTimeout(n,e)})}function v(){let e,n;return{promise:new Promise((t,o)=>{e=t,n=o}),resolve(t){e&&e(t)},reject(t){n&&n(t)}}}function f(e){setTimeout(()=>e(),1)}function k(e){let n=Math.max(1,e?.concurrency||1),i=e?.onProgress,t=[],o=0,d=!0,l=Date.now(),a=0,p=0,h=0,c,x=0;return{get runned(){return x},state(){return d?"idle":P()},enqueue(r){t.push(r),o++,p=Date.now()+1e3,b()},promise(r){let u=v();return this.enqueue(()=>r().then(u.resolve,u.reject)),u.promise},waitFor(){return new Promise((r,u)=>{setTimeout(s,100);function s(){a+t.length===0?(c?u(c):r(),c=void 0):setTimeout(s,100)}})},setConcurrency(r){n=Math.max(r,1),b()},forceState(r){l=r.start,p=r.canRate,h=r.canRefresh,o=r.size}};function b(){d&&(l=Date.now(),d=!1);let r=Date.now();r>h&&(h=r+1e3,i&&f(()=>{o>0&&i(P())})),t.length?f(R):a<1&&(o=0,i&&f(()=>i("finished")),d=!0,setTimeout(()=>{c=void 0},2e3))}function R(){for(;a<n;){let r=t.shift();if(!r)break;a++,r().catch(u=>{c=u}).finally(async()=>{x++,a--,b()})}}function P(){return{get size(){return o},get running(){return a},get pending(){return t.length},get done(){return o-t.length},get percent(){return Math.round((o-t.length)/o*1e3)/10},get rate(){return r()},get timeRemaining(){return u()}};function r(){let s=Date.now();if(s<p)return"-";let y=(s-l)/1e3;return(o-t.length)/y}function u(){let s=Date.now();if(s<p)return"-";let y=(s-l)/1e3,w=(o-t.length)/y,m=(o-t.length)/w;if(m<2)return"one second";if(m<50)return m.toFixed(0)+" seconds";if(m<120)return"one minute";let g=m/60;if(g<60)return g.toFixed(0)+" minutes";let D=g/60;return g<120?"one hour":D.toFixed(0)+" hours"}}}module.exports=j(C);0&&(module.exports={asap,defer,queuePromises,sleep}); | ||
var x=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var q=e=>x(e,"__esModule",{value:!0});var j=(e,r)=>{for(var i in r)x(e,i,{get:r[i],enumerable:!0})},M=(e,r,i,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of J(r))!S.call(e,o)&&(i||o!=="default")&&x(e,o,{get:()=>r[o],enumerable:!(t=F(r,o))||t.enumerable});return e};var k=(e=>(r,i)=>e&&e.get(r)||(i=M(q({}),r,1),e&&e.set(r,i),i))(typeof WeakMap!="undefined"?new WeakMap:0);var A={};j(A,{asap:()=>w,defer:()=>P,queuePromises:()=>O,sleep:()=>C});function C(e){return new Promise(r=>{setTimeout(r,e)})}function P(){let e,r;return{promise:new Promise((t,o)=>{e=t,r=o}),resolve(t){e&&e(t)},reject(t){r&&r(t)}}}function w(e){setTimeout(()=>e(),1)}function O(e){let r=Math.max(1,e?.concurrency||1),i=e?.onProgress,t=[],o=0,f=!0,u=[],m=0,T=0,y,h=0,p,d=0;return{state(){return f?"idle":D()},enqueue(n){t.push(n),o++,T=Date.now()+1e3,v()},promise(n){let s=P();return this.enqueue(()=>n().then(s.resolve,s.reject)),s.promise},waitFor(){return new Promise((n,s)=>{setTimeout(a,100);function a(){f?(p?s(p):n(),p=void 0):setTimeout(a,100)}})},setConcurrency(n){r=Math.max(n,1),v()},forceState(n){u=[[n.start,0]],T=n.canRate,o=n.size,d=n.runned}};function v(){f&&(u=[[Date.now(),0]],f=!1),t.length?R():m<1?(o=0,d=0,f=!0,b(),setTimeout(()=>{p=void 0},2e3)):b()}function b(){f||Date.now()>h?w(n):(y&&clearTimeout(y),y=setTimeout(b,1e3));function n(){Date.now()<h||i&&(h=Date.now()+1e3,o>0?i(D()):i("idle"))}}function R(){for(;m<r;){let n=t.shift();if(!n)break;m++,b(),n().catch(s=>{p=s}).finally(async()=>{d++,m--,b(),v()})}}function D(){return{get size(){return o},get running(){return m},get pending(){return t.length},get done(){return d},get percent(){return Math.round(d/o*1e3)/10},get rate(){return n()||"-"},get timeRemaining(){return s()}};function n(){let a=Date.now();if(a<T)return!1;let c=d+m,l=u[0][1],g=c-l;if(g<=0)return!1;for(u.push([a,c]);u.length>30;)u=u.slice(u.length-30);let Q=u[0][0],z=(a-Q)/1e3;return g/z}function s(){let a=n();if(a===!1)return"-";let c=(m+t.length)/a;if(c<2)return"one second";if(c<50)return c.toFixed(0)+" seconds";if(c<120)return"one minute";let l=c/60;if(l<60)return l.toFixed(0)+" minutes";let g=l/60;return l<120?"one hour":g.toFixed(0)+" hours"}}}module.exports=k(A);0&&(module.exports={asap,defer,queuePromises,sleep}); |
{ | ||
"name": "pjobs", | ||
"description": "A simple and efficient queue job executor using promises. And some promise's utilities.", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42388
6
77
1