Socket
Socket
Sign inDemoInstall

asynk

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.8 to 0.0.9

117

asynk.js

@@ -54,3 +54,3 @@ var utils = require('./lib/utils');

Task.prototype.fail = function (err) {
Task.prototype.reject = function (err) {
this.status = FAIL;

@@ -316,3 +316,3 @@ this.fct.apply(null, [err, null]);

args = utils.toArray(arguments);
_Context.currentTasks.forEach(function (currentTask) {
_Context.currentTasks.forEach(function(currentTask) {
_Context.tasks[currentTask].args = utils.toArray(args);

@@ -324,3 +324,3 @@ });

Asynk.require = function (dependency) {
_Context.currentTasks.forEach(function (currentTask) {
_Context.currentTasks.forEach(function(currentTask) {
var current = _Context.tasks[currentTask];

@@ -347,3 +347,3 @@ current.dependencies.push(dependency);

Asynk.serie = function (endcallArgs) {
Asynk.serie = function(endcallArgs) {
_Context.exec = {

@@ -359,15 +359,14 @@ fct: Asynk.serie,

var cb = function (err, data) {
if (!err) {
_Context.tasks[currentId].status = DONE;
_Context.results.push(data);
currentId++;
next();
}
else {
if (err) {
_Context.tasks[currentId].status = FAIL;
defer.fail(err);
endTask.fail(err);
defer.reject(err);
endTask.reject(err);
return;
}
_Context.tasks[currentId].status = DONE;
_Context.results.push(data);
currentId++;
next();
};
var next = function () {
var next = function() {
var current = _Context.tasks[currentId];

@@ -389,3 +388,3 @@ if (current) {

Asynk.parallel = function (endcallArgs) {
Asynk.parallel = function(endcallArgs) {
_Context.exec = {

@@ -403,19 +402,18 @@ fct: Asynk.parallel,

task.status = DONE;
if (!err) {
_Context.results[task.id] = data;
count++;
if (count >= todo) {
endTask.execute();
}
else {
_Context.tasks.forEach(function (task) {
if (task.status === WAITING_FOR_DEPENDENCY) {
task.execute();
}
});
}
if (err) {
defer.reject(err);
endTask.reject(err);
return;
}
_Context.results[task.id] = data;
count++;
if (count >= todo) {
endTask.execute();
}
else {
defer.fail(err);
endTask.fail(err);
_Context.tasks.forEach(function(task) {
if (task.status === WAITING_FOR_DEPENDENCY) {
task.execute();
}
});
}

@@ -429,3 +427,3 @@ };

_Context.tasks.forEach(function (task) {
_Context.tasks.forEach(function(task) {
task.setCallback(function (err, data) {

@@ -436,3 +434,3 @@ cb(task, err, data);

_Context.tasks.forEach(function (task) {
_Context.tasks.forEach(function(task) {
task.execute();

@@ -444,3 +442,3 @@ });

Asynk.parallelLimited = function (limit, endcallArgs) {
Asynk.parallelLimited = function(limit, endcallArgs) {
_Context.exec = {

@@ -458,23 +456,22 @@ fct: Asynk.parallelLimited,

task.status = DONE;
if (!err) {
_Context.results[task.id] = data;
count++;
if (count >= todo) {
endTask.execute();
}
else {
_Context.tasks.forEach(function (task) {
var stats = utils.countBy(_Context.tasks, function (task) {
return task.status;
});
var running = stats[RUNNING] || 0;
if ((running < limit) && (task.status < RUNNING)) {
task.execute();
}
});
}
if (err) {
defer.reject(err);
endTask.reject(err);
return;
}
_Context.results[task.id] = data;
count++;
if (count >= todo) {
endTask.execute();
}
else {
defer.fail(err);
endTask.fail(err);
_Context.tasks.forEach(function(task) {
var stats = utils.countBy(_Context.tasks, function(task) {
return task.status;
});
var running = stats[RUNNING] || 0;
if ((running < limit) && (task.status < RUNNING)) {
task.execute();
}
});
}

@@ -488,3 +485,3 @@ };

_Context.tasks.forEach(function (task) {
_Context.tasks.forEach(function(task) {
task.setCallback(function (err, data) {

@@ -495,4 +492,4 @@ cb(task, err, data);

_Context.tasks.forEach(function (task) {
var stats = utils.countBy(_Context.tasks, function (task) {
_Context.tasks.forEach(function(task) {
var stats = utils.countBy(_Context.tasks, function(task) {
return task.status;

@@ -513,10 +510,10 @@ });

module.exports = {
add: function (fct) {
add: function(fct) {
return Asynk().add(fct);
},
each: function (datas, fct) {
each: function(datas, fct) {
return Asynk().each(datas, fct);
},
callback: new DefArg('callback'),
data: function (val) {
data: function(val) {
if (utils.isString(val)) {

@@ -533,6 +530,6 @@ return new DefArg('alias', val);

},
progressive: function (start, step) {
progressive: function(start, step) {
return new Progressive(start, step);
},
deferred: function () {
deferred: function() {
return new Deferred();

@@ -539,0 +536,0 @@ },

{
"name": "asynk",
"version": "0.0.8",
"version": "0.0.9",
"description": "Asynk is a feature-rich JavaScript library designed to simplify common asynchronous JavaScript programming tasks.",

@@ -5,0 +5,0 @@ "main": "asynk.js",

@@ -114,2 +114,13 @@ var assert = require('assert');

});
it('should fail on error', function(done) {
asynk.add(function(cb){
cb('error','data');
}).parallelLimited(5).done(function(data){
done('should not resolve on error');
}).fail(function(err){
assert(err === 'error');
done();
});
});
});

@@ -104,2 +104,13 @@ var assert = require('assert');

});
it('should fail on error', function(done) {
asynk.add(function(cb){
cb('error','data');
}).parallel().done(function(data){
done('should not resolve on error');
}).fail(function(err){
assert(err === 'error');
done();
});
});
});

@@ -130,2 +130,13 @@ var assert = require('assert');

});
it('should fail on error', function(done) {
asynk.add(function(cb){
cb('error','data');
}).serie().done(function(data){
done('should not resolve on error');
}).fail(function(err){
assert(err === 'error');
done();
});
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc