Skip to content

Instantly share code, notes, and snippets.

@nickpoorman
Created January 7, 2013 12:12
Show Gist options
  • Save nickpoorman/4474548 to your computer and use it in GitHub Desktop.
Save nickpoorman/4474548 to your computer and use it in GitHub Desktop.
Possibly a horrible way to trim elements in nested arrays?
function deepTrimAsync(array, cb) {
async.map(array, function(item, callback) {
if(!Array.isArray(item)) {
if(typeof item === 'string') {
item = sanitize(item).trim();
}
return callback(null, item);
}
trimArrayElementsAsync(item, function(err, results) {
if(err) return console.error(err);
return callback(null, results);
});
}, function done(err, results) {
if(err) return console.error(err);
return cb(null, results);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment