fix(core): update
This commit is contained in:
parent
68f7d26d3b
commit
2a39543a75
34
package-lock.json
generated
34
package-lock.json
generated
@ -229,9 +229,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@pushrocks/smartpromise": {
|
"@pushrocks/smartpromise": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.5",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.2.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.5.tgz",
|
||||||
"integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ=="
|
"integrity": "sha512-9kHBWyDFjQ6cV1rseOfge02EH6huh/mrtqxlFoJoxnMaGWf5F8H3UEsskBBUGI6QKE1Bl8evr74AIKWwJ0r/bA=="
|
||||||
},
|
},
|
||||||
"@pushrocks/smartrequest": {
|
"@pushrocks/smartrequest": {
|
||||||
"version": "1.1.23",
|
"version": "1.1.23",
|
||||||
@ -387,9 +387,9 @@
|
|||||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "12.7.4",
|
"version": "12.7.5",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.4.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.5.tgz",
|
||||||
"integrity": "sha512-W0+n1Y+gK/8G2P/piTkBBN38Qc5Q1ZSO6B5H3QmPCUewaiXOo2GCAWZ4ElZCcNhjJuBSUSLGFUJnmlCn5+nxOQ=="
|
"integrity": "sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w=="
|
||||||
},
|
},
|
||||||
"@types/vinyl": {
|
"@types/vinyl": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
@ -641,9 +641,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"cron": {
|
"cron": {
|
||||||
"version": "1.7.1",
|
"version": "1.7.2",
|
||||||
"resolved": "https://verdaccio.lossless.one/cron/-/cron-1.7.1.tgz",
|
"resolved": "https://verdaccio.lossless.one/cron/-/cron-1.7.2.tgz",
|
||||||
"integrity": "sha512-gmMB/pJcqUVs/NklR1sCGlNYM7TizEw+1gebz20BMc/8bTm/r7QUp3ZPSPlG8Z5XRlvb7qhjEjq/+bdIfUCL2A==",
|
"integrity": "sha512-+SaJ2OfeRvfQqwXQ2kgr0Y5pzBR/lijf5OpnnaruwWnmI799JfWr2jN2ItOV9s3A/+TFOt6mxvKzQq5F0Jp6VQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"moment-timezone": "^0.5.x"
|
"moment-timezone": "^0.5.x"
|
||||||
}
|
}
|
||||||
@ -1467,16 +1467,16 @@
|
|||||||
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
|
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
|
||||||
},
|
},
|
||||||
"tslint": {
|
"tslint": {
|
||||||
"version": "5.19.0",
|
"version": "5.20.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.19.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.20.0.tgz",
|
||||||
"integrity": "sha512-1LwwtBxfRJZnUvoS9c0uj8XQtAnyhWr9KlNvDIdB+oXyT+VpsOAaEhEgKi1HrZ8rq0ki/AAnbGSv4KM6/AfVZw==",
|
"integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/code-frame": "^7.0.0",
|
"@babel/code-frame": "^7.0.0",
|
||||||
"builtin-modules": "^1.1.1",
|
"builtin-modules": "^1.1.1",
|
||||||
"chalk": "^2.3.0",
|
"chalk": "^2.3.0",
|
||||||
"commander": "^2.12.1",
|
"commander": "^2.12.1",
|
||||||
"diff": "^3.2.0",
|
"diff": "^4.0.1",
|
||||||
"glob": "^7.1.1",
|
"glob": "^7.1.1",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^3.0.4",
|
||||||
@ -1485,14 +1485,6 @@
|
|||||||
"semver": "^5.3.0",
|
"semver": "^5.3.0",
|
||||||
"tslib": "^1.8.0",
|
"tslib": "^1.8.0",
|
||||||
"tsutils": "^2.29.0"
|
"tsutils": "^2.29.0"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"diff": {
|
|
||||||
"version": "3.5.0",
|
|
||||||
"resolved": "https://verdaccio.lossless.one/diff/-/diff-3.5.0.tgz",
|
|
||||||
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
|
|
||||||
"dev": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tslint-config-prettier": {
|
"tslint-config-prettier": {
|
||||||
|
@ -30,17 +30,17 @@
|
|||||||
"@pushrocks/lik": "^3.0.11",
|
"@pushrocks/lik": "^3.0.11",
|
||||||
"@pushrocks/smartdelay": "^2.0.3",
|
"@pushrocks/smartdelay": "^2.0.3",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@pushrocks/smartlog": "^2.0.19",
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.5",
|
||||||
"@types/cron": "^1.7.1",
|
"@types/cron": "^1.7.1",
|
||||||
"cron": "^1.7.1",
|
"cron": "^1.7.2",
|
||||||
"rxjs": "^6.5.3"
|
"rxjs": "^6.5.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.17",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tstest": "^1.0.24",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"@pushrocks/tapbundle": "^3.0.13",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@types/node": "^12.7.4",
|
"@types/node": "^12.7.5",
|
||||||
"tslint": "^5.19.0",
|
"tslint": "^5.20.0",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import plugins = require('./taskbuffer.plugins');
|
import plugins = require('./taskbuffer.plugins');
|
||||||
import { Task, ITaskFunction } from './taskbuffer.classes.task';
|
import { Task, ITaskFunction } from './taskbuffer.classes.task';
|
||||||
|
|
||||||
export let emptyTaskFunction: ITaskFunction = function(x) {
|
export const emptyTaskFunction: ITaskFunction = function(x) {
|
||||||
let done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
done.resolve();
|
done.resolve();
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
export let isTask = function(taskArg: Task): boolean {
|
export const isTask = (taskArg: Task): boolean => {
|
||||||
if (taskArg instanceof Task && typeof taskArg.taskFunction === 'function') {
|
if (taskArg instanceof Task && typeof taskArg.taskFunction === 'function') {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -15,9 +15,9 @@ export let isTask = function(taskArg: Task): boolean {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export let isTaskTouched = (taskArg: Task, touchedTasksArray: Task[]): boolean => {
|
export const isTaskTouched = (taskArg: Task, touchedTasksArray: Task[]): boolean => {
|
||||||
let result = false;
|
let result = false;
|
||||||
for (let keyArg in touchedTasksArray) {
|
for (const keyArg in touchedTasksArray) {
|
||||||
if (taskArg === touchedTasksArray[keyArg]) {
|
if (taskArg === touchedTasksArray[keyArg]) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
@ -25,8 +25,8 @@ export let isTaskTouched = (taskArg: Task, touchedTasksArray: Task[]): boolean =
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
export let runTask = async (taskArg: Task, optionsArg: { x?; touchedTasksArray?: Task[] }) => {
|
export const runTask = async (taskArg: Task, optionsArg: { x?; touchedTasksArray?: Task[] }) => {
|
||||||
let done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
|
|
||||||
// pay respect to execDelay
|
// pay respect to execDelay
|
||||||
if (taskArg.execDelay) {
|
if (taskArg.execDelay) {
|
||||||
@ -41,35 +41,41 @@ export let runTask = async (taskArg: Task, optionsArg: { x?; touchedTasksArray?:
|
|||||||
});
|
});
|
||||||
|
|
||||||
// handle options
|
// handle options
|
||||||
let options = {
|
const options = {
|
||||||
...{ x: undefined, touchedTasksArray: [] },
|
...{ x: undefined, touchedTasksArray: [] },
|
||||||
...optionsArg
|
...optionsArg
|
||||||
};
|
};
|
||||||
let x = options.x;
|
const x = options.x;
|
||||||
let touchedTasksArray: Task[] = options.touchedTasksArray;
|
const touchedTasksArray: Task[] = options.touchedTasksArray;
|
||||||
|
|
||||||
touchedTasksArray.push(taskArg);
|
touchedTasksArray.push(taskArg);
|
||||||
|
|
||||||
// run the task cascade
|
// run the task cascade
|
||||||
let localDeferred = plugins.smartpromise.defer();
|
const localDeferred = plugins.smartpromise.defer();
|
||||||
localDeferred.promise
|
localDeferred.promise
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
// lets run any preTask
|
||||||
if (taskArg.preTask && !isTaskTouched(taskArg.preTask, touchedTasksArray)) {
|
if (taskArg.preTask && !isTaskTouched(taskArg.preTask, touchedTasksArray)) {
|
||||||
return runTask(taskArg.preTask, { x: x, touchedTasksArray: touchedTasksArray });
|
return runTask(taskArg.preTask, { x, touchedTasksArray });
|
||||||
} else {
|
} else {
|
||||||
let done2 = plugins.smartpromise.defer();
|
const done2 = plugins.smartpromise.defer();
|
||||||
done2.resolve(x);
|
done2.resolve(x);
|
||||||
return done2.promise;
|
return done2.promise;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(x => {
|
.then(async x => {
|
||||||
return taskArg.taskFunction(x);
|
// lets run the main task
|
||||||
|
try {
|
||||||
|
return await taskArg.taskFunction(x);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(x => {
|
.then(x => {
|
||||||
if (taskArg.afterTask && !isTaskTouched(taskArg.afterTask, touchedTasksArray)) {
|
if (taskArg.afterTask && !isTaskTouched(taskArg.afterTask, touchedTasksArray)) {
|
||||||
return runTask(taskArg.afterTask, { x: x, touchedTasksArray: touchedTasksArray });
|
return runTask(taskArg.afterTask, { x: x, touchedTasksArray: touchedTasksArray });
|
||||||
} else {
|
} else {
|
||||||
let done2 = plugins.smartpromise.defer();
|
const done2 = plugins.smartpromise.defer();
|
||||||
done2.resolve(x);
|
done2.resolve(x);
|
||||||
return done2.promise;
|
return done2.promise;
|
||||||
}
|
}
|
||||||
@ -96,8 +102,8 @@ export class CycleCounter {
|
|||||||
this.task = taskArg;
|
this.task = taskArg;
|
||||||
}
|
}
|
||||||
getPromiseForCycle(cycleCountArg: number) {
|
getPromiseForCycle(cycleCountArg: number) {
|
||||||
let done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
let cycleObject: cycleObject = {
|
const cycleObject: cycleObject = {
|
||||||
cycleCounter: cycleCountArg,
|
cycleCounter: cycleCountArg,
|
||||||
deferred: done
|
deferred: done
|
||||||
};
|
};
|
||||||
@ -105,7 +111,7 @@ export class CycleCounter {
|
|||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
informOfCycle(x) {
|
informOfCycle(x) {
|
||||||
let newCycleObjectArray: cycleObject[] = [];
|
const newCycleObjectArray: cycleObject[] = [];
|
||||||
this.cycleObjectArray.forEach(cycleObjectArg => {
|
this.cycleObjectArray.forEach(cycleObjectArg => {
|
||||||
cycleObjectArg.cycleCounter--;
|
cycleObjectArg.cycleCounter--;
|
||||||
if (cycleObjectArg.cycleCounter <= 0) {
|
if (cycleObjectArg.cycleCounter <= 0) {
|
||||||
@ -131,7 +137,7 @@ export class BufferRunner {
|
|||||||
if (!(this.bufferCounter >= this.task.bufferMax)) {
|
if (!(this.bufferCounter >= this.task.bufferMax)) {
|
||||||
this.bufferCounter++;
|
this.bufferCounter++;
|
||||||
}
|
}
|
||||||
let returnPromise: Promise<any> = this.task.cycleCounter.getPromiseForCycle(
|
const returnPromise: Promise<any> = this.task.cycleCounter.getPromiseForCycle(
|
||||||
this.bufferCounter + 1
|
this.bufferCounter + 1
|
||||||
);
|
);
|
||||||
if (!this.running) {
|
if (!this.running) {
|
||||||
@ -141,7 +147,7 @@ export class BufferRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _run(x) {
|
private _run(x) {
|
||||||
let recursiveBufferRunner = x => {
|
const recursiveBufferRunner = x => {
|
||||||
if (this.bufferCounter >= 0) {
|
if (this.bufferCounter >= 0) {
|
||||||
this.running = true;
|
this.running = true;
|
||||||
this.task.running = true;
|
this.task.running = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user