Created
January 21, 2015 19:38
-
-
Save Philmod/d09464626b5ed0c92ab0 to your computer and use it in GitHub Desktop.
Async with a null value returned
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async') | |
, _ = require('underscore'); | |
var array = [1,2,3,4,5]; | |
async.map(array, function(item, cb) { | |
if (item === 3) | |
return cb(); | |
else | |
return cb(null, item*2); | |
}, function(e, newArray) { | |
console.log('End error : ', e); | |
console.log('End array : ', newArray); | |
console.log('Compact : ', _.compact(newArray)); | |
}); | |
/* | |
End error : undefined | |
End array : [ 2, 4, undefined, 8, 10 ] | |
Compact : [ 2, 4, 8, 10 ] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment