Socket
Socket
Sign inDemoInstall

concurrent-tasks

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

concurrent-tasks - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

README.md

24

es/index.js

@@ -34,3 +34,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

if (_this.__working) {
log('already_running');
console.warn(log('already_running'));
return false;

@@ -40,3 +40,3 @@ }

if (_this.config.autoStart) {
log('auto_start_true');
console.warn(log('auto_start_true'));
return false;

@@ -50,9 +50,14 @@ }

this.add = function (task) {
var autoStart = _this.config.autoStart;
if (isFunction(task)) {
var autoStart = _this.config.autoStart;
_this.tasks.list.push(task);
_this.tasks.total++;
if (autoStart) {
startCheckAndRun.call(_this);
_this.tasks.list.push(task);
_this.tasks.total++;
if (autoStart) {
startCheckAndRun.call(_this);
}
return true;
}
throw new TypeError(log('add_requires_function'));
};

@@ -67,3 +72,3 @@

_this.tasks = {
list: tasks,
list: [].concat(_this.tasks.list, tasks),
total: tasks.length

@@ -74,3 +79,6 @@ };

}
return true;
}
throw new TypeError(log('add_multiple_requires_array_of_functions'));
};

@@ -77,0 +85,0 @@

var logs = {
already_running: 'Cannot start ConcurrentTasks as it is already running!',
auto_start_true: 'Cannot programmatically start ConcurrentTasks as autoStart is true!'
already_running: 'Cannot start TaskRunner instance as it is already running!',
auto_start_true: 'Cannot programmatically start TaskRunner instance as autoStart is true!',
add_requires_function: 'The "add" operation requires a function. Check if the first argument is a function!',
add_multiple_requires_array_of_functions: 'The "addMultiple" operation requires an array of functions. Check if the first argument is an array and whether all the items in the array are functions!'
};
export default (function (logKey) {
return console.warn('ConcurrentTasks: ' + logs[logKey]);
return 'TaskRunner: ' + logs[logKey];
});

@@ -44,3 +44,3 @@ 'use strict';

if (_this.__working) {
(0, _log2.default)('already_running');
console.warn((0, _log2.default)('already_running'));
return false;

@@ -50,3 +50,3 @@ }

if (_this.config.autoStart) {
(0, _log2.default)('auto_start_true');
console.warn((0, _log2.default)('auto_start_true'));
return false;

@@ -60,9 +60,14 @@ }

this.add = function (task) {
var autoStart = _this.config.autoStart;
if ((0, _util.isFunction)(task)) {
var autoStart = _this.config.autoStart;
_this.tasks.list.push(task);
_this.tasks.total++;
if (autoStart) {
_PrivateFunctions.startCheckAndRun.call(_this);
_this.tasks.list.push(task);
_this.tasks.total++;
if (autoStart) {
_PrivateFunctions.startCheckAndRun.call(_this);
}
return true;
}
throw new TypeError((0, _log2.default)('add_requires_function'));
};

@@ -77,3 +82,3 @@

_this.tasks = {
list: tasks,
list: [].concat(_this.tasks.list, tasks),
total: tasks.length

@@ -84,3 +89,6 @@ };

}
return true;
}
throw new TypeError((0, _log2.default)('add_multiple_requires_array_of_functions'));
};

@@ -87,0 +95,0 @@

@@ -5,10 +5,12 @@ 'use strict';

var logs = {
already_running: 'Cannot start ConcurrentTasks as it is already running!',
auto_start_true: 'Cannot programmatically start ConcurrentTasks as autoStart is true!'
already_running: 'Cannot start TaskRunner instance as it is already running!',
auto_start_true: 'Cannot programmatically start TaskRunner instance as autoStart is true!',
add_requires_function: 'The "add" operation requires a function. Check if the first argument is a function!',
add_multiple_requires_array_of_functions: 'The "addMultiple" operation requires an array of functions. Check if the first argument is an array and whether all the items in the array are functions!'
};
exports.default = function (logKey) {
return console.warn('ConcurrentTasks: ' + logs[logKey]);
return 'TaskRunner: ' + logs[logKey];
};
module.exports = exports['default'];
{
"name": "concurrent-tasks",
"version": "0.0.2",
"version": "0.0.3",
"description": "A simple task runner which will run tasks in parallel while maintaining limits.",

@@ -20,3 +20,3 @@ "author": "Samrith Shankar",

"test": "nwb test",
"prepublishOnly": "cp ../README.md ./README.md && npm run build && rm ./README.md"
"prepublishOnly": "npm run build"
},

@@ -23,0 +23,0 @@ "dependencies": {},

/*!
* concurrent-tasks v0.0.2 - https://samrith-s.github.io/concurrent-tasks
* concurrent-tasks v0.0.3 - https://samrith-s.github.io/concurrent-tasks
* MIT Licensed

@@ -192,8 +192,10 @@ */

var logs = {
already_running: 'Cannot start ConcurrentTasks as it is already running!',
auto_start_true: 'Cannot programmatically start ConcurrentTasks as autoStart is true!'
already_running: 'Cannot start TaskRunner instance as it is already running!',
auto_start_true: 'Cannot programmatically start TaskRunner instance as autoStart is true!',
add_requires_function: 'The "add" operation requires a function. Check if the first argument is a function!',
add_multiple_requires_array_of_functions: 'The "addMultiple" operation requires an array of functions. Check if the first argument is an array and whether all the items in the array are functions!'
};
/* harmony default export */ var log = (function (logKey) {
return console.warn('ConcurrentTasks: ' + logs[logKey]);
return 'TaskRunner: ' + logs[logKey];
});

@@ -235,3 +237,3 @@ // CONCATENATED MODULE: ./src/index.js

if (_this.__working) {
log('already_running');
console.warn(log('already_running'));
return false;

@@ -241,3 +243,3 @@ }

if (_this.config.autoStart) {
log('auto_start_true');
console.warn(log('auto_start_true'));
return false;

@@ -251,9 +253,14 @@ }

this.add = function (task) {
var autoStart = _this.config.autoStart;
if (isFunction(task)) {
var autoStart = _this.config.autoStart;
_this.tasks.list.push(task);
_this.tasks.total++;
if (autoStart) {
startCheckAndRun.call(_this);
_this.tasks.list.push(task);
_this.tasks.total++;
if (autoStart) {
startCheckAndRun.call(_this);
}
return true;
}
throw new TypeError(log('add_requires_function'));
};

@@ -268,3 +275,3 @@

_this.tasks = {
list: tasks,
list: [].concat(_this.tasks.list, tasks),
total: tasks.length

@@ -275,3 +282,6 @@ };

}
return true;
}
throw new TypeError(log('add_multiple_requires_array_of_functions'));
};

@@ -278,0 +288,0 @@

/*!
* concurrent-tasks v0.0.2 - https://samrith-s.github.io/concurrent-tasks
* concurrent-tasks v0.0.3 - https://samrith-s.github.io/concurrent-tasks
* MIT Licensed
*/
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.TaskRunner=n():t.TaskRunner=n()}(window,function(){return function(t){var n={};function r(o){if(n[o])return n[o].exports;var e=n[o]={i:o,l:!1,exports:{}};return t[o].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=t,r.c=n,r.d=function(t,n,o){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var e in t)r.d(o,e,function(n){return t[n]}.bind(null,e));return o},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=0)}([function(t,n,r){t.exports=r(1)},function(t,n,r){"use strict";r.r(n);var o=function(t){return"function"==typeof t},e=function(t){if(o(t))return t};function i(){if(this.tasks.list.length)this.tasks.running<this.concurrency&&(this.tasks.list.shift()(function(){this.tasks.completed++,this.tasks.running--,this.duration.total=Date.now()-this.duration.start,o(this.onDone)&&this.onDone(this.tasks);i.call(this)}.bind(this)),this.tasks.running++);else if(this.tasks.completed===this.tasks.total&&(this.duration.end=Date.now(),this.duration.total=this.duration.end-this.duration.start,o(this.onEnd))){var t=this.tasks.completed,n=this.duration;this.onEnd({completed:t,duration:n})}}function s(){(function(){this.__working||(this.duration.start=Date.now(),this.__working=!0,o(this.on)&&this.onStart())}).call(this),i.call(this)}var a={already_running:"Cannot start ConcurrentTasks as it is already running!",auto_start_true:"Cannot programmatically start ConcurrentTasks as autoStart is true!"},u=function(t){return console.warn("ConcurrentTasks: "+a[t])};r.d(n,"default",function(){return l});var c=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t};var l=function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.__working=!1,this.tasks={list:[],total:0,completed:0,running:0},this.duration={start:0,end:0,total:0},this.start=function(){return n.__working?(u("already_running"),!1):n.config.autoStart?(u("auto_start_true"),!1):(s.call(n),!0)},this.add=function(t){var r=n.config.autoStart;n.tasks.list.push(t),n.tasks.total++,r&&s.call(n)},this.addMultiple=function(t){if(function(t){return t.constructor===Array}(t)&&t.every(function(t){return o(t)})){var r=n.config.autoStart;n.tasks={list:t,total:t.length},r&&s.call(n)}},this.remove=function(t){n.tasks.list.splice(t,1),n.tasks.total=n.tasks.list.length},this.removeAll=function(){n.tasks.list=[],n.tasks.total=0};var i=r.concurrency,a=r.onStart,l=r.onDone,f=r.onEnd,d=function(t,n){var r={};for(var o in t)n.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o]);return r}(r,["concurrency","onStart","onDone","onEnd"]);this.config=c({autoStart:!0},d),this.concurrency=function(t,n){return function(t){return"number"==typeof t}(t)?0===t?1/0:t:n}(i,3),this.onStart=e(a),this.onDone=e(l),this.onEnd=e(f)}}]).default});
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.TaskRunner=n():t.TaskRunner=n()}(window,function(){return function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=0)}([function(t,n,r){t.exports=r(1)},function(t,n,r){"use strict";r.r(n);var e=function(t){return"function"==typeof t},o=function(t){if(e(t))return t};function i(){if(this.tasks.list.length)this.tasks.running<this.concurrency&&(this.tasks.list.shift()(function(){this.tasks.completed++,this.tasks.running--,this.duration.total=Date.now()-this.duration.start,e(this.onDone)&&this.onDone(this.tasks);i.call(this)}.bind(this)),this.tasks.running++);else if(this.tasks.completed===this.tasks.total&&(this.duration.end=Date.now(),this.duration.total=this.duration.end-this.duration.start,e(this.onEnd))){var t=this.tasks.completed,n=this.duration;this.onEnd({completed:t,duration:n})}}function a(){(function(){this.__working||(this.duration.start=Date.now(),this.__working=!0,e(this.on)&&this.onStart())}).call(this),i.call(this)}var s={already_running:"Cannot start TaskRunner instance as it is already running!",auto_start_true:"Cannot programmatically start TaskRunner instance as autoStart is true!",add_requires_function:'The "add" operation requires a function. Check if the first argument is a function!',add_multiple_requires_array_of_functions:'The "addMultiple" operation requires an array of functions. Check if the first argument is an array and whether all the items in the array are functions!'},u=function(t){return"TaskRunner: "+s[t]};r.d(n,"default",function(){return l});var c=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t};var l=function t(){var n=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.__working=!1,this.tasks={list:[],total:0,completed:0,running:0},this.duration={start:0,end:0,total:0},this.start=function(){return n.__working?(console.warn(u("already_running")),!1):n.config.autoStart?(console.warn(u("auto_start_true")),!1):(a.call(n),!0)},this.add=function(t){if(e(t)){var r=n.config.autoStart;return n.tasks.list.push(t),n.tasks.total++,r&&a.call(n),!0}throw new TypeError(u("add_requires_function"))},this.addMultiple=function(t){if(function(t){return t.constructor===Array}(t)&&t.every(function(t){return e(t)})){var r=n.config.autoStart;return n.tasks={list:[].concat(n.tasks.list,t),total:t.length},r&&a.call(n),!0}throw new TypeError(u("add_multiple_requires_array_of_functions"))},this.remove=function(t){n.tasks.list.splice(t,1),n.tasks.total=n.tasks.list.length},this.removeAll=function(){n.tasks.list=[],n.tasks.total=0};var i=r.concurrency,s=r.onStart,l=r.onDone,f=r.onEnd,d=function(t,n){var r={};for(var e in t)n.indexOf(e)>=0||Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}(r,["concurrency","onStart","onDone","onEnd"]);this.config=c({autoStart:!0},d),this.concurrency=function(t,n){return function(t){return"number"==typeof t}(t)?0===t?1/0:t:n}(i,3),this.onStart=o(s),this.onDone=o(l),this.onEnd=o(f)}}]).default});
//# sourceMappingURL=concurrent-tasks.min.js.map

Sorry, the diff of this file is not supported yet

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