Created
January 7, 2013 12:12
-
-
Save nickpoorman/4474548 to your computer and use it in GitHub Desktop.
Possibly a horrible way to trim elements in nested arrays?
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
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