Created
March 14, 2016 04:24
-
-
Save diorahman/0a4ce611d47dab85a311 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
const rowProducer = (num) => { | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
let rows = []; | |
for (let i = 0; i < num; i++) { | |
rows.push([['a' + i, 'b' + i], ['c' + i, 'd' + i]]); | |
} | |
return resolve(rows); | |
}, 100); | |
}); | |
}; | |
const results = []; | |
rowProducer(10) | |
.then((rows) => { | |
rows.forEach((row, i) => { | |
row.forEach((col) => { | |
col.push(`processed at row ${i}`); | |
results.push(col); | |
}); | |
}); | |
console.log(results); | |
}) | |
.catch((err) => { | |
console.log(err); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment