Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Promise.all(resourcePromises).then(function(values)
- {
- console.log(values);
- });
- Promise.all(promises.map(Promise.all)).then(function(values) {
- console.log(values);
- });
- function deepAll(array) {
- if (array instanceof Promise)
- // Just in case...
- return array;
- else if (array.length == 0)
- // The 'real' function will fail with an empty array and it's the same in both cases anyhow.
- return [];
- else if (Array.isArray(array[0]))
- // There's another array level, so turn it into an array of promises.
- return array.map(deepAll);
- else
- // This is an array of promises, and we already have a function for that case.
- return Promise.all(array);
- }
- deepAll(promises).then(function(values) {
- console.log(values);
- });
- function *deepWalk(arr) {
- for (var item of arr) {
- if (Array.isArray(item))
- yield* deepWalk(item)
- else
- yield item;
- }
- }
- Promise.all(deepWalk(resourcePromises)).then(...
- const balancePromises = [...];
- const symbolPromises = [...];
- const [balances, symbols] = await Promise.all([
- Promise.all(balancePromises),
- Promise.all(symbolPromises)
- ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement