fix(core): update
This commit is contained in:
parent
7bfb145513
commit
1630f6971f
2875
package-lock.json
generated
2875
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -32,15 +32,15 @@
|
||||
"@pushrocks/smartlog": "^2.0.44",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smartrx": "^2.0.19",
|
||||
"@pushrocks/smarttime": "^3.0.38",
|
||||
"@pushrocks/smarttime": "^3.0.43",
|
||||
"@types/cron": "^1.7.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.27",
|
||||
"@gitzone/tsbundle": "^1.0.87",
|
||||
"@gitzone/tstest": "^1.0.57",
|
||||
"@gitzone/tsbuild": "^2.1.28",
|
||||
"@gitzone/tsbundle": "^1.0.88",
|
||||
"@gitzone/tstest": "^1.0.60",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/node": "^16.10.1",
|
||||
"@types/node": "^16.11.7",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
|
52
test/test.8.bufferedrun.ts
Normal file
52
test/test.8.bufferedrun.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as taskbuffer from '../ts';
|
||||
|
||||
let counter1 = 0;
|
||||
let counter2 = 0;
|
||||
let counter3 = 0;
|
||||
|
||||
tap.test('should run buffered', async (tools) => {
|
||||
const task = new taskbuffer.Task({
|
||||
name: 'a buffered task',
|
||||
taskFunction: async () => {
|
||||
counter1++;
|
||||
await tools.delayFor(2000);
|
||||
console.log(`task 1 ran ${counter1} times`);
|
||||
},
|
||||
buffered: true,
|
||||
bufferMax: 1,
|
||||
afterTask: () => {
|
||||
return task2;
|
||||
}
|
||||
});
|
||||
const task2 = new taskbuffer.Task({
|
||||
name: 'a buffered task',
|
||||
taskFunction: async () => {
|
||||
counter2++;
|
||||
await tools.delayFor(2000);
|
||||
console.log(`task2 ran ${counter2} times`);
|
||||
},
|
||||
buffered: true,
|
||||
bufferMax: 1,
|
||||
afterTask: () => {
|
||||
return task3;
|
||||
}
|
||||
});
|
||||
const task3 = new taskbuffer.Task({
|
||||
name: 'a buffered task',
|
||||
taskFunction: async () => {
|
||||
counter3++;
|
||||
await tools.delayFor(2000);
|
||||
console.log(`task3 ran ${counter3} times`);
|
||||
},
|
||||
buffered: true,
|
||||
bufferMax: 1
|
||||
});
|
||||
while(counter1 < 10) {
|
||||
await tools.delayFor(5000);
|
||||
task.trigger();
|
||||
}
|
||||
})
|
||||
|
||||
tap.start();
|
@ -208,7 +208,7 @@ export class Task {
|
||||
|
||||
/**
|
||||
* trigger task buffered.
|
||||
* will simply call task.trigger(), which respects buffering by default
|
||||
* note: .trigger() also calls this function
|
||||
*/
|
||||
public triggerBuffered(x?: any): Promise<any> {
|
||||
return this.bufferRunner.trigger(x);
|
||||
|
Loading…
Reference in New Issue
Block a user