Comparing version 1.0.8 to 1.0.9
@@ -1,7 +0,7 @@ | ||
{"total": {"lines":{"total":99,"covered":99,"skipped":0,"pct":100},"statements":{"total":116,"covered":116,"skipped":0,"pct":100},"functions":{"total":34,"covered":34,"skipped":0,"pct":100},"branches":{"total":32,"covered":32,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}} | ||
{"total": {"lines":{"total":101,"covered":101,"skipped":0,"pct":100},"statements":{"total":118,"covered":118,"skipped":0,"pct":100},"functions":{"total":36,"covered":36,"skipped":0,"pct":100},"branches":{"total":32,"covered":32,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}} | ||
,"/Users/fernandotolentino/workspace/teintinu/pjobs/src/asap.ts": {"lines":{"total":2,"covered":2,"skipped":0,"pct":100},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} | ||
,"/Users/fernandotolentino/workspace/teintinu/pjobs/src/defer.ts": {"lines":{"total":7,"covered":7,"skipped":0,"pct":100},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"statements":{"total":9,"covered":9,"skipped":0,"pct":100},"branches":{"total":2,"covered":2,"skipped":0,"pct":100}} | ||
,"/Users/fernandotolentino/workspace/teintinu/pjobs/src/index.ts": {"lines":{"total":4,"covered":4,"skipped":0,"pct":100},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":5,"covered":5,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} | ||
,"/Users/fernandotolentino/workspace/teintinu/pjobs/src/queue.ts": {"lines":{"total":83,"covered":83,"skipped":0,"pct":100},"functions":{"total":23,"covered":23,"skipped":0,"pct":100},"statements":{"total":96,"covered":96,"skipped":0,"pct":100},"branches":{"total":30,"covered":30,"skipped":0,"pct":100}} | ||
,"/Users/fernandotolentino/workspace/teintinu/pjobs/src/queue.ts": {"lines":{"total":85,"covered":85,"skipped":0,"pct":100},"functions":{"total":25,"covered":25,"skipped":0,"pct":100},"statements":{"total":98,"covered":98,"skipped":0,"pct":100},"branches":{"total":30,"covered":30,"skipped":0,"pct":100}} | ||
,"/Users/fernandotolentino/workspace/teintinu/pjobs/src/sleep.ts": {"lines":{"total":3,"covered":3,"skipped":0,"pct":100},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}} | ||
} |
@@ -13,2 +13,3 @@ // Generated by dts-bundle-generator v6.2.0 | ||
readonly size: number; | ||
readonly running: number; | ||
readonly done: number; | ||
@@ -30,2 +31,3 @@ readonly percent: number; | ||
waitFor(): Promise<void>; | ||
setConcurrency(concurrency: number): void; | ||
forceState(opts: { | ||
@@ -32,0 +34,0 @@ start: number; |
@@ -1,1 +0,1 @@ | ||
var g=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var F=e=>g(e,"__esModule",{value:!0});var z=(e,t)=>{for(var s in t)g(e,s,{get:t[s],enumerable:!0})},J=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D(t))!Q.call(e,o)&&(s||o!=="default")&&g(e,o,{get:()=>t[o],enumerable:!(n=R(t,o))||n.enumerable});return e};var S=(e=>(t,s)=>e&&e.get(t)||(s=J(F({}),t,1),e&&e.set(t,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var k={};z(k,{asap:()=>h,defer:()=>y,queuePromises:()=>j,sleep:()=>q});function q(e){return new Promise(t=>{setTimeout(t,e)})}function y(){let e,t;return{promise:new Promise((n,o)=>{e=n,t=o}),resolve(n){e&&e(n)},reject(n){t&&t(n)}}}function h(e){setTimeout(()=>e(),1)}function j(e){let t=e?.concurrency||1,s=e?.onProgress,n=[],o=0,f=!0,d=Date.now(),u=0,l=0,T=0,a,b=0,v={get size(){return o},get pending(){return n.length},get done(){return o-n.length},get percent(){return Math.round((o-n.length)/o*1e3)/10},get rate(){let r=Date.now();if(r<l)return"-";let i=(r-d)/1e3;return(o-n.length)/i},get timeRemaining(){let r=Date.now();if(r<l)return"-";let i=(r-d)/1e3,c=(o-n.length)/i,m=(o-n.length)/c;if(m<2)return"one second";if(m<50)return m.toFixed(0)+" seconds";if(m<120)return"one minute";let p=m/60;if(p<60)return p.toFixed(0)+" minutes";let P=p/60;return p<120?"one hour":P.toFixed(0)+" hours"}};return{get runned(){return b},state(){return f?"idle":v},enqueue(r){n.push(r),o++,l=Date.now()+1e3,x()},promise(r){let i=y();return this.enqueue(()=>r().then(i.resolve,i.reject)),i.promise},waitFor(){return new Promise((r,i)=>{setTimeout(c,100);function c(){u+n.length===0?(a?i(a):r(),a=void 0):setTimeout(c,100)}})},forceState(r){d=r.start,l=r.canRate,T=r.canRefresh,o=r.size}};function x(){f&&(d=Date.now(),f=!1);let r=Date.now();r>T&&(T=r+1e3,s&&setTimeout(()=>{o>0&&s(v)},1)),n.length?h(w):u<1&&(o=0,s&&h(()=>s("finished")),f=!0,setTimeout(()=>{a=void 0},2e3))}async function w(){for(;u<t;){let r=n.shift();if(!r)break;u++;try{await r()}catch(i){a=i}finally{b++,u--,x()}}}}module.exports=S(k);0&&(module.exports={asap,defer,queuePromises,sleep}); | ||
var g=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var F=r=>g(r,"__esModule",{value:!0});var z=(r,n)=>{for(var i in n)g(r,i,{get:n[i],enumerable:!0})},J=(r,n,i,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of D(n))!Q.call(r,o)&&(i||o!=="default")&&g(r,o,{get:()=>n[o],enumerable:!(t=R(n,o))||t.enumerable});return r};var S=(r=>(n,i)=>r&&r.get(n)||(i=J(F({}),n,1),r&&r.set(n,i),i))(typeof WeakMap!="undefined"?new WeakMap:0);var M={};z(M,{asap:()=>h,defer:()=>b,queuePromises:()=>j,sleep:()=>q});function q(r){return new Promise(n=>{setTimeout(n,r)})}function b(){let r,n;return{promise:new Promise((t,o)=>{r=t,n=o}),resolve(t){r&&r(t)},reject(t){n&&n(t)}}}function h(r){setTimeout(()=>r(),1)}function j(r){let n=Math.max(1,r?.concurrency||1),i=r?.onProgress,t=[],o=0,f=!0,d=Date.now(),u=0,l=0,y=0,a,T=0,v={get size(){return o},get running(){return u},get pending(){return t.length},get done(){return o-t.length},get percent(){return Math.round((o-t.length)/o*1e3)/10},get rate(){let e=Date.now();if(e<l)return"-";let s=(e-d)/1e3;return(o-t.length)/s},get timeRemaining(){let e=Date.now();if(e<l)return"-";let s=(e-d)/1e3,c=(o-t.length)/s,m=(o-t.length)/c;if(m<2)return"one second";if(m<50)return m.toFixed(0)+" seconds";if(m<120)return"one minute";let p=m/60;if(p<60)return p.toFixed(0)+" minutes";let P=p/60;return p<120?"one hour":P.toFixed(0)+" hours"}};return{get runned(){return T},state(){return f?"idle":v},enqueue(e){t.push(e),o++,l=Date.now()+1e3,x()},promise(e){let s=b();return this.enqueue(()=>e().then(s.resolve,s.reject)),s.promise},waitFor(){return new Promise((e,s)=>{setTimeout(c,100);function c(){u+t.length===0?(a?s(a):e(),a=void 0):setTimeout(c,100)}})},setConcurrency(e){n=Math.max(e,1)},forceState(e){d=e.start,l=e.canRate,y=e.canRefresh,o=e.size}};function x(){f&&(d=Date.now(),f=!1);let e=Date.now();e>y&&(y=e+1e3,i&&setTimeout(()=>{o>0&&i(v)},1)),t.length?h(w):u<1&&(o=0,i&&h(()=>i("finished")),f=!0,setTimeout(()=>{a=void 0},2e3))}async function w(){for(;u<n;){let e=t.shift();if(!e)break;u++;try{await e()}catch(s){a=s}finally{T++,u--,x()}}}}module.exports=S(M);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.0.8", | ||
"version": "1.0.9", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -5,3 +5,3 @@ [![Node.js CI](https://github.com/teintinu/pjobs/actions/workflows/test.yml/badge.svg)](https://github.com/teintinu/pjobs/actions/workflows/test.yml) | ||
# pjobs | ||
A simple and efficient queue job executor using promises. And some promise's utilities. | ||
A simple, efficient and small (just 2kb) queue job executor using promises. And some promise's utilities. | ||
@@ -17,3 +17,3 @@ # install | ||
## `queuePromises` | ||
defines an executor for jobs. A job is just a function that returns a Promise. You can also control concurrency and promises. | ||
defines an executor for jobs. A job is just a function that returns a Promise. You can also control concurrency and promises. [Demonstration](https://iptow.csb.app/) | ||
```typescript | ||
@@ -20,0 +20,0 @@ import { queuePromises } from 'pjobs' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
220522
0
1207
0