question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

async.map, but with an index like async.eachOf

See original GitHub issue

Hey all

Looking through the docs, I am looking for async.map, but with the index of the iteratee passed to the callback. With async.each, the analogue is async.eachOf. But I don’t see async.mapOf or what not.

Is there such a thing? Let me know if you need more info, thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jpalalacommented, Jan 23, 2017

We’re ok 👍 Anyway here’s what i tried to get the data back:

var async = require('async');

async.forEachOf(['a', 'b', 'c'], function () {

  console.log(arguments[1]);
});
1reaction
aearlycommented, Jan 24, 2017

~forEachOf and family don’t pass the results to the callback. If you want the key, you could do something like:~

async.forEach(_.entries(obj), ( [key, value], next ) => {
  // do whatever
}, done);

~Keep in mind, this will return an array, and the order will not be guaranteed. You’d have to build a result object manually.~

EDIT: use mapValues

Read more comments on GitHub >

github_iconTop Results From Across the Web

async - Documentation - GitHub Pages
An async function to apply to each item in coll . The array index is not passed to the iteratee. If you need...
Read more >
Building async and concurrent versions of forEach and map
Let's take a look at how we can utilize Swift's built-in concurrency system when performing data transformations using functions like ...
Read more >
async.js each get index in iterator - javascript - Stack Overflow
You can use async.forEachOf - it calls its iterator callback with the index as its second argument. > async.forEachOf(['a', 'b', 'c'], ...
Read more >
How to Use Async/await With .map in JavaScript
In this short guide, you will see what the most common errors are and how to solve them. For this we will have...
Read more >
How to use async functions with Array.map in Javascript
floor(i / n) where i is the index of the element will do. As an example, a group of size 3 will map...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found