Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const LIST = ['Orange', 'Lemon', 'Banana' ]
- process(LIST);
- async function eachAsync(arr, fn) { // take an array and a function
- for(const item of arr) await fn(item);
- }
- async function process(list) {
- await eachAsync(list, async (data) => {
- let result = await print(data)
- console.log(result)
- });
- console.log('Done');
- }
- function print(data) {
- return new Promise((resolve, reject) => {
- setTimeout(() => {
- console.log(data);
- resolve("Data was sent")
- }, 3000)
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement