fix(core): update
This commit is contained in:
parent
8f9b3151d8
commit
c367f0f949
24002
package-lock.json
generated
24002
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
24
package.json
24
package.json
@ -27,20 +27,20 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
|
"homepage": "https://gitlab.com/pushrocks/taskbuffer#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^4.0.17",
|
"@pushrocks/lik": "^5.0.0",
|
||||||
"@pushrocks/smartdelay": "^2.0.10",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/smartlog": "^2.0.37",
|
"@pushrocks/smartlog": "^2.0.44",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.1.6",
|
||||||
"@pushrocks/smartrx": "^2.0.18",
|
"@pushrocks/smartrx": "^2.0.19",
|
||||||
"@pushrocks/smarttime": "^3.0.35",
|
"@pushrocks/smarttime": "^3.0.38",
|
||||||
"@types/cron": "^1.7.2"
|
"@types/cron": "^1.7.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.27",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@gitzone/tsbundle": "^1.0.87",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tstest": "^1.0.57",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.6.4",
|
"@types/node": "^16.10.1",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
|
@ -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();
|
|
@ -8,7 +8,7 @@ export class BufferRunner {
|
|||||||
this.task = taskArg;
|
this.task = taskArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public trigger(x): Promise<any> {
|
public trigger(x: any): Promise<any> {
|
||||||
if (!(this.bufferCounter >= this.task.bufferMax)) {
|
if (!(this.bufferCounter >= this.task.bufferMax)) {
|
||||||
this.bufferCounter++;
|
this.bufferCounter++;
|
||||||
}
|
}
|
||||||
@ -21,8 +21,8 @@ export class BufferRunner {
|
|||||||
return returnPromise;
|
return returnPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _run(x) {
|
private _run(x: any) {
|
||||||
const recursiveBufferRunner = (x) => {
|
const recursiveBufferRunner = (x: any) => {
|
||||||
if (this.bufferCounter >= 0) {
|
if (this.bufferCounter >= 0) {
|
||||||
this.task.running = true;
|
this.task.running = true;
|
||||||
Task.runTask(this.task, { x: x }).then((x) => {
|
Task.runTask(this.task, { x: x }).then((x) => {
|
||||||
|
@ -21,7 +21,7 @@ export class CycleCounter {
|
|||||||
this.cycleObjectArray.push(cycleObject);
|
this.cycleObjectArray.push(cycleObject);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
public informOfCycle(x) {
|
public informOfCycle(x: any) {
|
||||||
const newCycleObjectArray: ICycleObject[] = [];
|
const newCycleObjectArray: ICycleObject[] = [];
|
||||||
this.cycleObjectArray.forEach((cycleObjectArg) => {
|
this.cycleObjectArray.forEach((cycleObjectArg) => {
|
||||||
cycleObjectArg.cycleCounter--;
|
cycleObjectArg.cycleCounter--;
|
||||||
|
@ -56,7 +56,7 @@ export class Task {
|
|||||||
|
|
||||||
public static runTask = async (
|
public static runTask = async (
|
||||||
taskArg: Task | TPreOrAfterTaskFunction,
|
taskArg: Task | TPreOrAfterTaskFunction,
|
||||||
optionsArg: { x?; touchedTasksArray?: Task[] }
|
optionsArg: { x?: any; touchedTasksArray?: Task[] }
|
||||||
) => {
|
) => {
|
||||||
const taskToRun = Task.extractTask(taskArg);
|
const taskToRun = Task.extractTask(taskArg);
|
||||||
const done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
@ -190,7 +190,7 @@ export class Task {
|
|||||||
/**
|
/**
|
||||||
* trigger the task. Will trigger buffered if this.buffered is true
|
* 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) {
|
if (this.buffered) {
|
||||||
return this.triggerBuffered(x);
|
return this.triggerBuffered(x);
|
||||||
} else {
|
} else {
|
||||||
@ -202,7 +202,7 @@ export class Task {
|
|||||||
* trigger task unbuffered.
|
* trigger task unbuffered.
|
||||||
* will actually run the task, not considering any buffered limits.
|
* 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 });
|
return Task.runTask(this, { x: x });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ export class Task {
|
|||||||
* trigger task buffered.
|
* trigger task buffered.
|
||||||
* will simply call task.trigger(), which respects buffering by default
|
* 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);
|
return this.bufferRunner.trigger(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ export class Taskchain extends Task {
|
|||||||
// this is the function that gets executed when TaskChain is triggered
|
// this is the function that gets executed when TaskChain is triggered
|
||||||
const done = plugins.smartpromise.defer(); // this is the starting Deferred object
|
const done = plugins.smartpromise.defer(); // this is the starting Deferred object
|
||||||
let taskCounter = 0; // counter for iterating async over the taskArray
|
let taskCounter = 0; // counter for iterating async over the taskArray
|
||||||
const iterateTasks = (x) => {
|
const iterateTasks = (x: any) => {
|
||||||
if (typeof this.taskArray[taskCounter] !== 'undefined') {
|
if (typeof this.taskArray[taskCounter] !== 'undefined') {
|
||||||
console.log(this.name + ' running: Task' + this.taskArray[taskCounter].name);
|
console.log(this.name + ' running: Task' + this.taskArray[taskCounter].name);
|
||||||
this.taskArray[taskCounter].trigger(x).then((x) => {
|
this.taskArray[taskCounter].trigger(x).then((x) => {
|
||||||
|
@ -20,8 +20,8 @@ export class TaskManager {
|
|||||||
* checks if a task is already present
|
* checks if a task is already present
|
||||||
* @param taskNameArg
|
* @param taskNameArg
|
||||||
*/
|
*/
|
||||||
public getTaskByName(taskNameArg): Task {
|
public getTaskByName(taskNameArg: string): Task {
|
||||||
return this.taskMap.find((itemArg) => {
|
return this.taskMap.findSync((itemArg) => {
|
||||||
return itemArg.name === taskNameArg;
|
return itemArg.name === taskNameArg;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user