@stacksjs/queue 0.64.6 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -4
- package/package.json +9 -14
- package/dist/index.js.map +0 -10
- package/src/index.ts +0 -23
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JobOptions } from "@stacksjs/types";
|
|
2
|
+
export declare class Job {
|
|
3
|
+
name: JobOptions["name"];
|
|
4
|
+
description: JobOptions["description"];
|
|
5
|
+
action?: JobOptions["action"];
|
|
6
|
+
handle?: JobOptions["handle"];
|
|
7
|
+
rate: JobOptions["rate"];
|
|
8
|
+
tries: JobOptions["tries"];
|
|
9
|
+
backoff: JobOptions["backoff"];
|
|
10
|
+
enabled: JobOptions["enabled"];
|
|
11
|
+
constructor({ name, description, handle, rate, tries, backoff, action, enabled }: JobOptions);
|
|
12
|
+
}
|
|
13
|
+
export { DeferQueue } from "@poppinss/defer";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//# debugId=38CFA3AA5092CC4B64756E2164756E21
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
var H=Object.create;var{getPrototypeOf:v,defineProperty:D,getOwnPropertyNames:g}=Object;var y=Object.prototype.hasOwnProperty;var x=(J,O,z)=>{z=J!=null?H(v(J)):{};let I=O||!J||!J.__esModule?D(z,"default",{value:J,enumerable:!0}):z;for(let m of g(J))if(!y.call(I,m))D(I,m,{get:()=>J[m],enumerable:!0});return I};var N=(J,O)=>()=>(O||J((O={exports:{}}).exports,O),O.exports);var C=N((l,h)=>{function i(J){var O=new J,z=O;function I(){var B=O;if(B.next)O=B.next;else O=new J,z=O;return B.next=null,B}function m(B){z.next=B,z=B}return{get:I,release:m}}h.exports=i});var j=N((t,A)=>{var _=C();function b(J,O,z){if(typeof J==="function")z=O,O=J,J=null;if(!(z>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");var I=_(k),m=null,B=null,F=0,$=null,K={push:P,drain:X,saturated:X,pause:Z,paused:!1,get concurrency(){return z},set concurrency(G){if(!(G>=1))throw new Error("fastqueue concurrency must be equal to or greater than 1");if(z=G,K.paused)return;for(;m&&F<z;)F++,U()},running:W,resume:M,idle:L,length:V,getQueue:Y,unshift:p,empty:X,kill:T,killAndDrain:Q,error:w};return K;function W(){return F}function Z(){K.paused=!0}function V(){var G=m,S=0;while(G)G=G.next,S++;return S}function Y(){var G=m,S=[];while(G)S.push(G.value),G=G.next;return S}function M(){if(!K.paused)return;if(K.paused=!1,m===null){F++,U();return}for(;m&&F<z;)F++,U()}function L(){return F===0&&K.length()===0}function P(G,S){var E=I.get();if(E.context=J,E.release=U,E.value=G,E.callback=S||X,E.errorHandler=$,F>=z||K.paused)if(B)B.next=E,B=E;else m=E,B=E,K.saturated();else F++,O.call(J,E.value,E.worked)}function p(G,S){var E=I.get();if(E.context=J,E.release=U,E.value=G,E.callback=S||X,E.errorHandler=$,F>=z||K.paused)if(m)E.next=m,m=E;else m=E,B=E,K.saturated();else F++,O.call(J,E.value,E.worked)}function U(G){if(G)I.release(G);var S=m;if(S&&F<=z)if(!K.paused){if(B===m)B=null;if(m=S.next,S.next=null,O.call(J,S.value,S.worked),B===null)K.empty()}else F--;else if(--F===0)K.drain()}function T(){m=null,B=null,K.drain=X}function Q(){m=null,B=null,K.drain(),K.drain=X}function w(G){$=G}}function X(){}function k(){this.value=null,this.callback=X,this.next=null,this.release=X,this.context=null,this.errorHandler=null;var J=this;this.worked=function O(z,I){var{callback:m,errorHandler:B,value:F}=J;if(J.value=null,J.callback=X,J.errorHandler)B(z,F);m.call(J.context,z,I),J.release(J)}}function q(J,O,z){if(typeof J==="function")z=O,O=J,J=null;function I(Z,V){O.call(this,Z).then(function(Y){V(null,Y)},V)}var m=b(J,I,z),B=m.push,F=m.unshift;return m.push=$,m.unshift=K,m.drained=W,m;function $(Z){var V=new Promise(function(Y,M){B(Z,function(L,P){if(L){M(L);return}Y(P)})});return V.catch(X),V}function K(Z){var V=new Promise(function(Y,M){F(Z,function(L,P){if(L){M(L);return}Y(P)})});return V.catch(X),V}function W(){if(m.idle())return new Promise(function(Y){Y()});var Z=m.drain,V=new Promise(function(Y){m.drain=function(){Z(),Y()}});return V}}A.exports=b;A.exports.promise=q});var R=x(j(),1),d=class{resolve;reject;promise=new Promise((J,O)=>{this.reject=O,this.resolve=J})},f=class{#O;#J;#m=[];#z=(J,O)=>{let z=this.#m.shift();if(J){if(this.onError)this.onError(J,O);if(z)z.resolve({status:"rejected",reason:J});return}if(this.taskCompleted)this.taskCompleted(O);if(z)z.resolve({status:"fulfilled",value:O})};onError;taskCompleted;taskAdded;get drained(){return this.#J.drain}set drained(J){this.#O=J,this.#J.drain=J}constructor(J){this.#J=R.default(async(O,z)=>{try{let I=await(typeof O==="function"?O():O.run());z(null,{name:O.name,response:I})}catch(I){z(I,{name:O.name})}},J?.concurrency??10)}createNotifier(){let J=new d;return this.#m.push(J),J.promise}push(J){if(this.taskAdded)this.taskAdded(J);return this.#J.push(J,this.#z),this}unshift(J){if(this.taskAdded)this.taskAdded(J);return this.#J.unshift(J,this.#z),this}pause(){this.#J.pause()}resume(){this.#J.resume()}isIdle(){return this.#J.idle()}size(){return this.#J.length()}kill(){if(this.#J.killAndDrain(),this.#O)this.#J.drain=this.#O}};class s{name;description;action;handle;rate;tries;backoff;enabled;constructor({name:J,description:O,handle:z,rate:I,tries:m,backoff:B,action:F,enabled:$}){this.name=J,this.description=O,this.handle=z,this.rate=I,this.action=F,this.tries=m,this.backoff=B,this.enabled=$}}export{s as Job,f as DeferQueue};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/queue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.67.0",
|
|
5
5
|
"description": "The Stacks Queue system.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
|
+
"contributors": ["Chris Breuer <chris@stacksjs.org>"],
|
|
7
8
|
"license": "MIT",
|
|
8
9
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
9
10
|
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/queue#readme",
|
|
@@ -27,30 +28,24 @@
|
|
|
27
28
|
],
|
|
28
29
|
"exports": {
|
|
29
30
|
".": {
|
|
30
|
-
"bun": "./src/index.ts",
|
|
31
31
|
"import": "./dist/index.js"
|
|
32
32
|
},
|
|
33
33
|
"./*": {
|
|
34
|
-
"bun": "./src/*",
|
|
35
34
|
"import": "./dist/*"
|
|
36
35
|
}
|
|
37
36
|
},
|
|
38
37
|
"module": "dist/index.js",
|
|
39
38
|
"types": "dist/index.d.ts",
|
|
40
|
-
"
|
|
41
|
-
"Chris Breuer <chris@stacksjs.org>"
|
|
42
|
-
],
|
|
43
|
-
"files": [
|
|
44
|
-
"README.md",
|
|
45
|
-
"dist",
|
|
46
|
-
"src"
|
|
47
|
-
],
|
|
39
|
+
"files": ["README.md", "dist"],
|
|
48
40
|
"scripts": {
|
|
49
|
-
"build": "bun
|
|
50
|
-
"typecheck": "bun
|
|
41
|
+
"build": "bun build.ts",
|
|
42
|
+
"typecheck": "bun tsc --noEmit",
|
|
51
43
|
"prepublishOnly": "bun run build"
|
|
52
44
|
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@poppinss/defer": "^1.1.0"
|
|
47
|
+
},
|
|
53
48
|
"devDependencies": {
|
|
54
|
-
"@stacksjs/development": "
|
|
49
|
+
"@stacksjs/development": "0.67.0"
|
|
55
50
|
}
|
|
56
51
|
}
|
package/dist/index.js.map
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { JobOptions } from '@stacksjs/types'\n\nexport class Job {\n name: JobOptions['name']\n description: JobOptions['description']\n action?: JobOptions['action']\n handle?: JobOptions['handle']\n rate: JobOptions['rate']\n tries: JobOptions['tries']\n backoff: JobOptions['backoff']\n enabled: JobOptions['enabled']\n\n constructor({ name, description, handle, rate, tries, backoff, action, enabled }: JobOptions) {\n this.name = name\n this.description = description\n this.handle = handle\n this.rate = rate\n this.action = action\n this.tries = tries\n this.backoff = backoff\n this.enabled = enabled\n }\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";AAEO,MAAM,CAAI,CACf,KACA,YACA,OACA,OACA,KACA,MACA,QACA,QAEA,WAAW,EAAG,OAAM,cAAa,SAAQ,OAAM,QAAO,UAAS,SAAQ,WAAuB,CAC5F,KAAK,KAAO,EACZ,KAAK,YAAc,EACnB,KAAK,OAAS,EACd,KAAK,KAAO,EACZ,KAAK,OAAS,EACd,KAAK,MAAQ,EACb,KAAK,QAAU,EACf,KAAK,QAAU,EAEnB",
|
|
8
|
-
"debugId": "38CFA3AA5092CC4B64756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { JobOptions } from '@stacksjs/types'
|
|
2
|
-
|
|
3
|
-
export class Job {
|
|
4
|
-
name: JobOptions['name']
|
|
5
|
-
description: JobOptions['description']
|
|
6
|
-
action?: JobOptions['action']
|
|
7
|
-
handle?: JobOptions['handle']
|
|
8
|
-
rate: JobOptions['rate']
|
|
9
|
-
tries: JobOptions['tries']
|
|
10
|
-
backoff: JobOptions['backoff']
|
|
11
|
-
enabled: JobOptions['enabled']
|
|
12
|
-
|
|
13
|
-
constructor({ name, description, handle, rate, tries, backoff, action, enabled }: JobOptions) {
|
|
14
|
-
this.name = name
|
|
15
|
-
this.description = description
|
|
16
|
-
this.handle = handle
|
|
17
|
-
this.rate = rate
|
|
18
|
-
this.action = action
|
|
19
|
-
this.tries = tries
|
|
20
|
-
this.backoff = backoff
|
|
21
|
-
this.enabled = enabled
|
|
22
|
-
}
|
|
23
|
-
}
|