Skip to content

Instantly share code, notes, and snippets.

@diorahman
Created March 14, 2016 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diorahman/0a4ce611d47dab85a311 to your computer and use it in GitHub Desktop.
Save diorahman/0a4ce611d47dab85a311 to your computer and use it in GitHub Desktop.
'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