3 module.exports = asyncForEach;
6 * Simultaneously processes all items in the given array.
8 * @param {array} array - The array to iterate over
9 * @param {function} iterator - The function to call for each item in the array
10 * @param {function} done - The function to call when all iterators have completed
12 function asyncForEach (array, iterator, done) {
13 if (array.length === 0) {
14 // NOTE: Normally a bad idea to mix sync and async, but it's safe here because
15 // of the way that this method is currently used by DirectoryReader.
20 // Simultaneously process all items in the array.
21 let pending = array.length;
22 array.forEach(item => {
23 iterator(item, () => {
24 if (--pending === 0) {