async-queue-runner 0.7.0 → 0.9.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/_cjs/package.json +4 -4
- package/_cjs/queue.js +3 -3
- package/_esm/package.json +4 -4
- package/_esm/queue.js +3 -3
- package/_types/runner.d.ts +2 -2
- package/_types/types.d.ts +1 -0
- package/_types/utils.d.ts +3 -9
- package/package.json +1 -1
package/_cjs/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "commonjs"
|
|
3
|
-
}
|
|
4
|
-
|
|
1
|
+
{
|
|
2
|
+
"type": "commonjs"
|
|
3
|
+
}
|
|
4
|
+
|
package/_cjs/queue.js
CHANGED
|
@@ -8,15 +8,15 @@ class AsyncQueue {
|
|
|
8
8
|
end;
|
|
9
9
|
loopAction = false;
|
|
10
10
|
context = {
|
|
11
|
-
push: this.push,
|
|
11
|
+
push: (actions) => this.push(actions),
|
|
12
12
|
stop: () => { this.loopAction = false; },
|
|
13
13
|
extend: (obj) => Object.assign(this.context, obj),
|
|
14
|
+
name: this.name,
|
|
14
15
|
};
|
|
15
16
|
constructor(opts) {
|
|
16
17
|
this.queue = opts.actions;
|
|
17
18
|
this.name = opts.name;
|
|
18
19
|
this.end = opts.end;
|
|
19
|
-
this.push = this.push.bind(this);
|
|
20
20
|
}
|
|
21
21
|
async delay(timeout) {
|
|
22
22
|
return new Promise((res) => setTimeout(res, timeout));
|
|
@@ -38,7 +38,7 @@ class AsyncQueue {
|
|
|
38
38
|
this.end();
|
|
39
39
|
}
|
|
40
40
|
catch (e) {
|
|
41
|
-
console.log(`Queue(${this.name} failed`);
|
|
41
|
+
console.log(`Queue(${this.name}) failed`);
|
|
42
42
|
console.error(e);
|
|
43
43
|
}
|
|
44
44
|
}
|
package/_esm/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "module"
|
|
3
|
-
}
|
|
4
|
-
|
|
1
|
+
{
|
|
2
|
+
"type": "module"
|
|
3
|
+
}
|
|
4
|
+
|
package/_esm/queue.js
CHANGED
|
@@ -5,15 +5,15 @@ export class AsyncQueue {
|
|
|
5
5
|
end;
|
|
6
6
|
loopAction = false;
|
|
7
7
|
context = {
|
|
8
|
-
push: this.push,
|
|
8
|
+
push: (actions) => this.push(actions),
|
|
9
9
|
stop: () => { this.loopAction = false; },
|
|
10
10
|
extend: (obj) => Object.assign(this.context, obj),
|
|
11
|
+
name: this.name,
|
|
11
12
|
};
|
|
12
13
|
constructor(opts) {
|
|
13
14
|
this.queue = opts.actions;
|
|
14
15
|
this.name = opts.name;
|
|
15
16
|
this.end = opts.end;
|
|
16
|
-
this.push = this.push.bind(this);
|
|
17
17
|
}
|
|
18
18
|
async delay(timeout) {
|
|
19
19
|
return new Promise((res) => setTimeout(res, timeout));
|
|
@@ -35,7 +35,7 @@ export class AsyncQueue {
|
|
|
35
35
|
this.end();
|
|
36
36
|
}
|
|
37
37
|
catch (e) {
|
|
38
|
-
console.log(`Queue(${this.name} failed`);
|
|
38
|
+
console.log(`Queue(${this.name}) failed`);
|
|
39
39
|
console.error(e);
|
|
40
40
|
}
|
|
41
41
|
}
|
package/_types/runner.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueueAction } from "./types.js";
|
|
2
2
|
export type EndListener = (name: string, size: number) => void;
|
|
3
3
|
export declare class QueueRunner {
|
|
4
4
|
queues: Map<any, any>;
|
|
5
5
|
listeners: EndListener[];
|
|
6
|
-
add(actions:
|
|
6
|
+
add(actions: QueueAction[], context?: object, name?: string): void;
|
|
7
7
|
addEndListener(listener: EndListener): void;
|
|
8
8
|
endEvent(name: string): void;
|
|
9
9
|
getName(): string;
|
package/_types/types.d.ts
CHANGED
package/_types/utils.d.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { Action } from "./action.js";
|
|
2
|
-
import { Branches,
|
|
2
|
+
import { Branches, IAction } from "./types.js";
|
|
3
3
|
export declare class Delay extends Action<null> {
|
|
4
4
|
execute(): Promise<void>;
|
|
5
5
|
}
|
|
6
6
|
export declare const util: {
|
|
7
7
|
delay(timeout: number): Delay;
|
|
8
|
-
if<C>(condition: (context: C) => Promise<boolean> | boolean, branches: Branches):
|
|
9
|
-
|
|
10
|
-
delay: number;
|
|
11
|
-
};
|
|
12
|
-
valid<C_1>(validator: (context: C_1) => Promise<boolean> | boolean, actions: IAction[]): {
|
|
13
|
-
execute(context: C_1 & QueueContext): Promise<void>;
|
|
14
|
-
delay: number;
|
|
15
|
-
};
|
|
8
|
+
if<C>(condition: (context: C) => Promise<boolean> | boolean, branches: Branches): IAction;
|
|
9
|
+
valid<C_1>(validator: (context: C_1) => Promise<boolean> | boolean, actions: IAction[]): IAction;
|
|
16
10
|
};
|