Last active
June 12, 2016 15:29
-
-
Save MdaaaaO/1b26167d83276b8adc4248f0fd235a01 to your computer and use it in GitHub Desktop.
Iteration over an object and manipulating every node in a loop by adding new calculated content.
This file contains 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
getProject(filteredSAV, metricPROJECT, function (distribution, mapped) { | |
var keys = Object.keys(mapped); | |
var tasksLeft = keys.length; | |
function onComplete() { | |
saveJSON("./tmp/", "project.json", mapped); | |
} | |
keys.forEach(function (subchar) { | |
calcFrequencies(mapped[subchar], function (calculatedFrequencies) { | |
mapped[subchar].analysis.stats = calculatedFrequencies; | |
if (--tasksLeft === 0) { | |
onComplete(); | |
} | |
}); | |
}); | |
}); |
is this actually the answer:
async.forEach(Object.keys(dataObj), function (item, callback){
console.log(item); // print the key
callback(); // tell async that the iterator has completed
}, function(err) {
console.log('iterating done');
});
??
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
calcFrequencies() takes a while.
Is there a better way to write such a loop?