fix(core): update

This commit is contained in:
Philipp Kunz 2021-09-26 14:45:02 +02:00
parent 8f9b3151d8
commit c367f0f949
9 changed files with 20310 additions and 3785 deletions

24002
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,20 +27,20 @@
},
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
"dependencies": {
"@pushrocks/lik": "^4.0.17",
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartlog": "^2.0.37",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrx": "^2.0.18",
"@pushrocks/smarttime": "^3.0.35",
"@types/cron": "^1.7.2"
"@pushrocks/lik": "^5.0.0",
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartrx": "^2.0.19",
"@pushrocks/smarttime": "^3.0.38",
"@types/cron": "^1.7.3"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.6.4",
"@gitzone/tsbuild": "^2.1.27",
"@gitzone/tsbundle": "^1.0.87",
"@gitzone/tstest": "^1.0.57",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^16.10.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},

View File

@ -1,47 +0,0 @@
import { expect, tap } from '@pushrocks/tapbundle';
import taskbuffer = require('../ts/index');
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartdelay from '@pushrocks/smartdelay';
let myTaskManager: taskbuffer.TaskManager;
let taskRunCounter = 0;
const taskDone = smartpromise.defer();
tap.test('should create an instance of TaskManager', async () => {
myTaskManager = new taskbuffer.TaskManager();
expect(myTaskManager).to.be.instanceof(taskbuffer.TaskManager);
});
tap.test('should run the task as expected', async () => {
let referenceBoolean = false;
myTaskManager.addTask(
new taskbuffer.Task({
name: 'myTask',
taskFunction: async () => {
console.log('Task executed!');
referenceBoolean = true;
taskRunCounter++;
if (taskRunCounter === 10) {
taskDone.resolve();
}
},
})
);
myTaskManager.start();
await myTaskManager.triggerTaskByName('myTask');
// tslint:disable-next-line:no-unused-expression
expect(referenceBoolean).to.be.true;
});
tap.test('should schedule task', async () => {
myTaskManager.scheduleTaskByName('myTask', '* * * * * *');
await taskDone.promise;
myTaskManager.descheduleTaskByName('myTask');
});
tap.test('should stop the taskmanager', async () => {
myTaskManager.stop();
});
tap.start();

View File

@ -8,7 +8,7 @@ export class BufferRunner {
this.task = taskArg;
}
public trigger(x): Promise<any> {
public trigger(x: any): Promise<any> {
if (!(this.bufferCounter >= this.task.bufferMax)) {
this.bufferCounter++;
}
@ -21,8 +21,8 @@ export class BufferRunner {
return returnPromise;
}
private _run(x) {
const recursiveBufferRunner = (x) => {
private _run(x: any) {
const recursiveBufferRunner = (x: any) => {
if (this.bufferCounter >= 0) {
this.task.running = true;
Task.runTask(this.task, { x: x }).then((x) => {

View File

@ -21,7 +21,7 @@ export class CycleCounter {
this.cycleObjectArray.push(cycleObject);
return done.promise;
}
public informOfCycle(x) {
public informOfCycle(x: any) {
const newCycleObjectArray: ICycleObject[] = [];
this.cycleObjectArray.forEach((cycleObjectArg) => {
cycleObjectArg.cycleCounter--;

View File

@ -56,7 +56,7 @@ export class Task {
public static runTask = async (
taskArg: Task | TPreOrAfterTaskFunction,
optionsArg: { x?; touchedTasksArray?: Task[] }
optionsArg: { x?: any; touchedTasksArray?: Task[] }
) => {
const taskToRun = Task.extractTask(taskArg);
const done = plugins.smartpromise.defer();
@ -190,7 +190,7 @@ export class Task {
/**
* trigger the task. Will trigger buffered if this.buffered is true
*/
public trigger(x?): Promise<any> {
public trigger(x?: any): Promise<any> {
if (this.buffered) {
return this.triggerBuffered(x);
} else {
@ -202,7 +202,7 @@ export class Task {
* trigger task unbuffered.
* will actually run the task, not considering any buffered limits.
*/
public triggerUnBuffered(x?): Promise<any> {
public triggerUnBuffered(x?: any): Promise<any> {
return Task.runTask(this, { x: x });
}
@ -210,7 +210,7 @@ export class Task {
* trigger task buffered.
* will simply call task.trigger(), which respects buffering by default
*/
public triggerBuffered(x?): Promise<any> {
public triggerBuffered(x?: any): Promise<any> {
return this.bufferRunner.trigger(x);
}

View File

@ -25,7 +25,7 @@ export class Taskchain extends Task {
// this is the function that gets executed when TaskChain is triggered
const done = plugins.smartpromise.defer(); // this is the starting Deferred object
let taskCounter = 0; // counter for iterating async over the taskArray
const iterateTasks = (x) => {
const iterateTasks = (x: any) => {
if (typeof this.taskArray[taskCounter] !== 'undefined') {
console.log(this.name + ' running: Task' + this.taskArray[taskCounter].name);
this.taskArray[taskCounter].trigger(x).then((x) => {

View File

@ -20,8 +20,8 @@ export class TaskManager {
* checks if a task is already present
* @param taskNameArg
*/
public getTaskByName(taskNameArg): Task {
return this.taskMap.find((itemArg) => {
public getTaskByName(taskNameArg: string): Task {
return this.taskMap.findSync((itemArg) => {
return itemArg.name === taskNameArg;
});
}