1var arr = [
2 {subarr: [1,2,3]},
3 {subarr: [4,5,6]},
4 {subarr: [7,8,9]}
5];
6function processAsync(n) {
7 return new Promise(function(resolve) {
8 setTimeout(
9 function() { resolve(n * n); },
10 Math.random() * 1e3
11 );
12 });
13}
14Promise.all(arr.map(function(entity){
15 return Promise.all(entity.subarr.map(function(item){
16 return processAsync(item);
17 }));
18})).then(function(data) {
19 console.log(data);
20});