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

async

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

40

lib/async.js

@@ -693,2 +693,25 @@ /*global setImmediate: false, setTimeout: false, console: false */

async.queue = function (worker, concurrency) {
function _insert(q, data, pos, callback) {
if(data.constructor !== Array) {
data = [data];
}
_forEach(data, function(task) {
var item = {
data: task,
callback: typeof callback === 'function' ? callback : null
};
if (pos) {
q.tasks.unshift(item);
} else {
q.tasks.push(item);
}
if (q.saturated && q.tasks.length === concurrency) {
q.saturated();
}
async.nextTick(q.process);
});
}
var workers = 0;

@@ -702,16 +725,7 @@ var q = {

push: function (data, callback) {
if(data.constructor !== Array) {
data = [data];
}
_forEach(data, function(task) {
q.tasks.push({
data: task,
callback: typeof callback === 'function' ? callback : null
});
if (q.saturated && q.tasks.length === concurrency) {
q.saturated();
}
async.nextTick(q.process);
});
_insert(q, data, false, callback);
},
unshift: function (data, callback) {
_insert(q, data, true, callback);
},
process: function () {

@@ -718,0 +732,0 @@ if (workers < q.concurrency && q.tasks.length) {

@@ -6,3 +6,3 @@ {

"author": "Caolan McMahon",
"version": "0.2.1",
"version": "0.2.2",
"repository" : {

@@ -25,3 +25,11 @@ "type" : "git",

"nodelint": ">0.0.0"
},
"jam": {
"main": "lib/async.js",
"include": [
"lib/async.js",
"README.md",
"LICENSE"
]
}
}

@@ -809,2 +809,3 @@ # Async.js

instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.
* unshift(task, [callback]) - add a new task to the front of the queue.
* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued

@@ -844,2 +845,8 @@ * empty - a callback that is called when the last item from the queue is given to a worker

});
// add some items to the front of the queue
q.unshift({name: 'bar'}, function (err) {
console.log('finished processing bar');
});
```

@@ -846,0 +853,0 @@

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