Socket
Socket
Sign inDemoInstall

async

Package Overview
Dependencies
0
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.4 to 0.2.5

lib/.swp

53

lib/async.js

@@ -30,3 +30,3 @@ /*global setImmediate: false, setTimeout: false, console: false */

var _forEach = function (arr, iterator) {
var _each = function (arr, iterator) {
if (arr.forEach) {

@@ -45,3 +45,3 @@ return arr.forEach(iterator);

var results = [];
_forEach(arr, function (x, i, a) {
_each(arr, function (x, i, a) {
results.push(iterator(x, i, a));

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

}
_forEach(arr, function (x, i, a) {
_each(arr, function (x, i, a) {
memo = iterator(memo, x, i, a);

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

async.forEach = function (arr, iterator, callback) {
async.each = function (arr, iterator, callback) {
callback = callback || function () {};

@@ -102,3 +102,3 @@ if (!arr.length) {

var completed = 0;
_forEach(arr, function (x) {
_each(arr, function (x) {
iterator(x, only_once(function (err) {

@@ -118,4 +118,5 @@ if (err) {

};
async.forEach = async.each;
async.forEachSeries = function (arr, iterator, callback) {
async.eachSeries = function (arr, iterator, callback) {
callback = callback || function () {};

@@ -152,9 +153,11 @@ if (!arr.length) {

};
async.forEachSeries = async.eachSeries;
async.forEachLimit = function (arr, limit, iterator, callback) {
var fn = _forEachLimit(limit);
async.eachLimit = function (arr, limit, iterator, callback) {
var fn = _eachLimit(limit);
fn.apply(null, [arr, iterator, callback]);
};
async.forEachLimit = async.eachLimit;
var _forEachLimit = function (limit) {
var _eachLimit = function (limit) {

@@ -203,3 +206,3 @@ return function (arr, iterator, callback) {

var args = Array.prototype.slice.call(arguments);
return fn.apply(null, [async.forEach].concat(args));
return fn.apply(null, [async.each].concat(args));
};

@@ -210,3 +213,3 @@ };

var args = Array.prototype.slice.call(arguments);
return fn.apply(null, [_forEachLimit(limit)].concat(args));
return fn.apply(null, [_eachLimit(limit)].concat(args));
};

@@ -217,3 +220,3 @@ };

var args = Array.prototype.slice.call(arguments);
return fn.apply(null, [async.forEachSeries].concat(args));
return fn.apply(null, [async.eachSeries].concat(args));
};

@@ -250,3 +253,3 @@ };

async.reduce = function (arr, memo, iterator, callback) {
async.forEachSeries(arr, function (x, callback) {
async.eachSeries(arr, function (x, callback) {
iterator(memo, x, function (err, v) {

@@ -342,3 +345,3 @@ memo = v;

async.some = function (arr, iterator, main_callback) {
async.forEach(arr, function (x, callback) {
async.each(arr, function (x, callback) {
iterator(x, function (v) {

@@ -359,3 +362,3 @@ if (v) {

async.every = function (arr, iterator, main_callback) {
async.forEach(arr, function (x, callback) {
async.each(arr, function (x, callback) {
iterator(x, function (v) {

@@ -423,3 +426,3 @@ if (!v) {

var taskComplete = function () {
_forEach(listeners.slice(0), function (fn) {
_each(listeners.slice(0), function (fn) {
fn();

@@ -436,3 +439,3 @@ });

_forEach(keys, function (k) {
_each(keys, function (k) {
var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k];

@@ -521,3 +524,3 @@ var taskCallback = function (err) {

var results = {};
eachfn.forEach(_keys(tasks), function (k, callback) {
eachfn.each(_keys(tasks), function (k, callback) {
tasks[k](function (err) {

@@ -538,7 +541,7 @@ var args = Array.prototype.slice.call(arguments, 1);

async.parallel = function (tasks, callback) {
_parallel({ map: async.map, forEach: async.forEach }, tasks, callback);
_parallel({ map: async.map, each: async.each }, tasks, callback);
};
async.parallelLimit = function(tasks, limit, callback) {
_parallel({ map: _mapLimit(limit), forEach: _forEachLimit(limit) }, tasks, callback);
_parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback);
};

@@ -563,3 +566,3 @@

var results = {};
async.forEachSeries(_keys(tasks), function (k, callback) {
async.eachSeries(_keys(tasks), function (k, callback) {
tasks[k](function (err) {

@@ -715,3 +718,3 @@ var args = Array.prototype.slice.call(arguments, 1);

}
_forEach(data, function(task) {
_each(data, function(task) {
var item = {

@@ -805,3 +808,3 @@ data: task,

}
_forEach(data, function(task) {
_each(data, function(task) {
tasks.push({

@@ -838,3 +841,3 @@ data: task,

var args = arguments;
_forEach(ts, function (data) {
_each(ts, function (data) {
if (data.callback) {

@@ -870,3 +873,3 @@ data.callback.apply(null, args);

else if (console[name]) {
_forEach(args, function (x) {
_each(args, function (x) {
console[name](x);

@@ -873,0 +876,0 @@ });

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

"author": "Caolan McMahon",
"version": "0.2.4",
"version": "0.2.5",
"repository" : {

@@ -9,0 +9,0 @@ "type" : "git",

@@ -9,3 +9,3 @@ # Async.js

Async provides around 20 functions that include the usual 'functional'
suspects (map, reduce, filter, forEach…) as well as some common patterns
suspects (map, reduce, filter, each…) as well as some common patterns
for asynchronous control flow (parallel, series, waterfall…). All these

@@ -76,3 +76,3 @@ functions assume you follow the node.js convention of providing a single

* [forEach](#forEach)
* [each](#each)
* [map](#map)

@@ -119,3 +119,4 @@ * [filter](#filter)

<a name="forEach" />
### forEach(arr, iterator, callback)
<a name="each" />
### each(arr, iterator, callback)

@@ -125,3 +126,3 @@ Applies an iterator function to each item in an array, in parallel.

has finished. If the iterator passes an error to this callback, the main
callback for the forEach function is immediately called with the error.
callback for the each function is immediately called with the error.

@@ -147,3 +148,3 @@ Note, that since this function applies the iterator to each item in parallel

async.forEach(openFiles, saveFile, function(err){
async.each(openFiles, saveFile, function(err){
// if any of the saves produced an error, err would equal that error

@@ -156,5 +157,6 @@ });

<a name="forEachSeries" />
### forEachSeries(arr, iterator, callback)
<a name="eachSeries" />
### eachSeries(arr, iterator, callback)
The same as forEach only the iterator is applied to each item in the array in
The same as each only the iterator is applied to each item in the array in
series. The next iterator is only called once the current one has completed

@@ -167,5 +169,6 @@ processing. This means the iterator functions will complete in order.

<a name="forEachLimit" />
### forEachLimit(arr, limit, iterator, callback)
<a name="eachLimit" />
### eachLimit(arr, limit, iterator, callback)
The same as forEach only no more than "limit" iterators will be simultaneously
The same as each only no more than "limit" iterators will be simultaneously
running at any time.

@@ -194,3 +197,3 @@

async.forEachLimit(documents, 20, requestApi, function(err){
async.eachLimit(documents, 20, requestApi, function(err){
// if any of the saves produced an error, err would equal that error

@@ -197,0 +200,0 @@ });

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc