Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coya/task-manager

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coya/task-manager - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

34

js/TaskManager.js

@@ -77,3 +77,3 @@ "use strict";

if (timeDiff > 0) {
this.logs.info('Waiting ' + timeDiff + ' milliseconds until the next execution...');
this._logs.info('Waiting ' + timeDiff + ' milliseconds until the next execution...');
setTimeout(this.processSynchronousTasks.bind(this), timeDiff);

@@ -87,6 +87,6 @@ return;

if (result && result.stop)
this.logs.info('Task "' + task.name + '" stopped and removed from the tasks list.');
this._logs.info('Task "' + task.name + '" stopped and removed from the tasks list.');
else if (result && result.stopAll) {
this._tasks = [];
this.logs.info('All tasks have been stopped and removed from the tasks list.');
this._logs.info('All tasks have been stopped and removed from the tasks list.');
}

@@ -100,6 +100,6 @@ else

if ((error && error.stop) || task.failedExecutionsInARow >= task.maxFailuresInARow)
this.logs.error('Task "' + task.name + '" stopped and removed from the tasks list.');
this._logs.error('Task "' + task.name + '" stopped and removed from the tasks list.');
else if (error && error.stopAll) {
this._tasks = [];
this.logs.error('All tasks have been stopped and removed from the tasks list.');
this._logs.error('All tasks have been stopped and removed from the tasks list.');
}

@@ -126,7 +126,5 @@ else

if (!this._tasks || this._tasks.length == 0)
return Promise.resolve();
return new Promise(function (resolve, reject) {
for (let task of this._tasks)
this.taskLoop(task);
}.bind(this));
return this.endTaskManager('No tasks to process.');
for (let task of this._tasks)
this.taskLoop(task);
}

@@ -139,3 +137,3 @@ taskLoop(task) {

this._tasks.splice(this._tasks.indexOf(task), 1);
this.logs.info('Task "' + task.name + '" stopped and removed from the tasks list.');
this._logs.info('Task "' + task.name + '" stopped and removed from the tasks list.');
if (!this._tasks.length)

@@ -153,8 +151,8 @@ this.endTaskManager();

this._tasks.splice(this._tasks.indexOf(task), 1);
this.logs.error('Task "' + task.name + '" stopped and removed from the tasks list.');
this._logs.error('Task "' + task.name + '" stopped and removed from the tasks list.');
if (!this._tasks.length)
this.endTaskManager(true);
this.endTaskManager('The last task has been stopped and removed from the tasks list.');
}
else if (error && error.stopAll)
this.endTaskManager(true);
this.endTaskManager('All tasks have been stopped and removed from the tasks list.');
else

@@ -168,7 +166,10 @@ this.scheduleTask(task);

task.timeout = setTimeout(this.taskLoop.bind(this, task), nextExecutionTime);
this.logs.info('Task "' + task.name + '" : ' + nextExecutionTime + ' milliseconds until the next execution...');
this._logs.info('Task "' + task.name + '" : ' + nextExecutionTime + ' milliseconds until the next execution...');
}
endTaskManager(isError) {
endTaskManager(error) {
if (!this._isEnded) {
if (error)
this._logs.error(error);
this._isEnded = true;
this._logs.info('Ending task manager...');
if (this._tasks.length) {

@@ -179,3 +180,2 @@ this._tasks.forEach((task) => {

this._tasks = [];
(isError ? this.logs.error : this.logs.info).call(this, 'All tasks have been cancelled and removed from the tasks list.');
}

@@ -182,0 +182,0 @@ if (this._end)

{
"name": "@coya/task-manager",
"version": "0.1.4",
"version": "0.1.5",
"description": "Scheduler for run tasks successively or simultaneously",

@@ -5,0 +5,0 @@ "main": "js/TaskManager.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc