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

mapLimit of Generator doesn't invoke final callback #69

Closed
mattoshry opened this issue May 4, 2019 · 1 comment
Closed

mapLimit of Generator doesn't invoke final callback #69

mattoshry opened this issue May 4, 2019 · 1 comment
Assignees
Labels

Comments

@mattoshry
Copy link

const assert = require('assert'),
  async = require('neo-async');

function *makeGen(arr) {
  let idx = 0;
  let len = arr.length;
  while (idx < len) {
    yield arr[idx];
    idx += 1;
  }
}

const LIMIT = 2;
const INPUT = ['abc', 'def', 'ghi', 'jkl'];
const gen = makeGen(INPUT);

async.mapLimit(gen, LIMIT, (v, cb) => {
  setTimeout(() => {
    console.log(`processing: ${v}`);
    cb(undefined, v);
  }, Math.round(Math.random()*1000));
}, (err, results) => {
  assert(!err, err);
  console.log(`ACTUAL: ${results}`);
  assert.strict.deepEqual(results, INPUT);
});

Results with neo-async:

processing: abc
processing: def
processing: jkl
processing: ghi

Results with async:

processing: abc
processing: def
processing: jkl
processing: ghi
ACTUAL: abc,def,ghi,jkl
@suguru03
Copy link
Owner

suguru03 commented May 5, 2019

@mattoshry Thanks for the issue! I will take a look this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants