fix(core): update

This commit is contained in:
2021-11-11 19:59:56 +01:00
parent 7bfb145513
commit 1630f6971f
4 changed files with 1308 additions and 1631 deletions

View 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();