Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inSeries util bug #18

Open
deugene opened this issue Jun 7, 2022 · 0 comments
Open

inSeries util bug #18

deugene opened this issue Jun 7, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@deugene
Copy link

deugene commented Jun 7, 2022

export function getProcess(parallel) {
  return parallel ? inParallel : inSeries;
}

async function inParallel(locations, processingFunction) {
  await Promise.all(Object.entries(locations).map(processingFunction));
}

async function inSeries(locations, processingFunction) {
  for (const location of locations) {
    await processingFunction(location);
  }
}

If we try to iterate through locations inSeries we'll get an error (TypeError: locations is not iterable), because location is an object. We must use the same method as in inParallel function:

async function inSeries(locations, processingFunction) {
  for (const [locationName, location] of Object.entries(locations)) {
    await processingFunction([locationName, location]);
  }
}
@benpankow benpankow self-assigned this Jun 27, 2022
@benpankow benpankow added the bug Something isn't working label Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants