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.7.0 to 0.8.0

31

lib/async.js

@@ -0,1 +1,8 @@

/*!
* async
* https://github.com/caolan/async
*
* Copyright 2010-2014 Caolan McMahon
* Released under the MIT license
*/
/*jshint onevar: false, indent:4 */

@@ -230,14 +237,22 @@ /*global setImmediate: false, setTimeout: false, console: false */

var _asyncMap = function (eachfn, arr, iterator, callback) {
var results = [];
arr = _map(arr, function (x, i) {
return {index: i, value: x};
});
eachfn(arr, function (x, callback) {
iterator(x.value, function (err, v) {
results[x.index] = v;
callback(err);
if (!callback) {
eachfn(arr, function (x, callback) {
iterator(x.value, function (err) {
callback(err);
});
});
}, function (err) {
callback(err, results);
});
} else {
var results = [];
eachfn(arr, function (x, callback) {
iterator(x.value, function (err, v) {
results[x.index] = v;
callback(err);
});
}, function (err) {
callback(err, results);
});
}
};

@@ -244,0 +259,0 @@ async.map = doParallel(_asyncMap);

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

"author": "Caolan McMahon",
"version": "0.7.0",
"version": "0.8.0",
"repository" : {

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

# Async.js
[![Build Status via Travis CI](https://travis-ci.org/caolan/async.png?branch=master)](https://travis-ci.org/caolan/async)
[![Build Status via Travis CI](https://travis-ci.org/caolan/async.svg?branch=master)](https://travis-ci.org/caolan/async)

@@ -133,3 +133,3 @@

* [`series`](#series)
* [`series`](#seriestasks-callback)
* [`parallel`](#parallel)

@@ -203,4 +203,3 @@ * [`parallelLimit`](#parallellimittasks-limit-callback)

```js
// assuming openFiles is an array of file names and saveFile is a function
// to save the modified contents of that file:
// assuming openFiles is an array of file names

@@ -211,15 +210,13 @@ async.each(openFiles, function( file, callback) {

console.log('Processing file ' + file);
callback();
if( file.length > 32 ) {
console.log('This file name is too long');
callback('File name too long');
return;
} else {
console.log('File saved');
// Do work to process file here
console.log('File processed');
callback();
}
}, function(err){
// if any of the saves produced an error, err would equal that error
// if any of the file processing produced an error, err would equal that error
if( err ) {

@@ -541,17 +538,18 @@ // One of the iterations produced an error.

//ascending order
async.sortBy([1,9,3,5], function(x, callback){
callback(err, x);
}, function(err,result){
//result callback
} );
```js
//ascending order
async.sortBy([1,9,3,5], function(x, callback){
callback(err, x);
}, function(err,result){
//result callback
} );
//descending order
async.sortBy([1,9,3,5], function(x, callback){
callback(err, x*-1); //<- x*-1 instead of x, turns the order around
}, function(err,result){
//result callback
} );
//descending order
async.sortBy([1,9,3,5], function(x, callback){
callback(err, x*-1); //<- x*-1 instead of x, turns the order around
}, function(err,result){
//result callback
} );
```
---------------------------------------

@@ -558,0 +556,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