sindresorhus / p-map

Map over promises concurrently
MIT License
1.27k stars 58 forks source link

Coverage gap #57

Closed Gabisampaio closed 2 years ago

Gabisampaio commented 2 years ago

I used Istanbul to measure coverage of the test suite and I believe that I found a minor coverage gap.

It looks like the condition of the following if statement never holds.

if (typeof mapper !== 'function') {
  throw new TypeError('Mapper function is required');
}

It is a corner case and probably unlikely to happen, but it may be worth including a test just to make sure this property will hold in future. I include a suggestion of test below, which passes when I run locally.

test('invalid mapper', async t => {
  await t.throwsAsync(pMap([], "invalid mapper", {concurrency: 2}), TypeError);
});