toniov/p-iteration

Safari Support

sstubbs opened this issue · 3 comments

Hi,

Thank you for this great library. I have been testing whether to use it or not and it seems to work very well on chrome, Firefox, edge and opera but on safari I get an error. I am using function like your second example

async function getRawResponses (userIds) {
  const responses = await map(userIds, userId => fetch(`/api/users/${userId}`));
  // ... do some stuff
  return responses;
}

The error I am getting is in this section

exports.everySeries = async (array, callback, thisArg) => {
  for (let i = 0; i < array.length; i++) {
    if (i in array && !await callback.call(thisArg || this, await array[i], i, array)) {
      return false;
    }
  }
  return true;
};

at the if statement and error is:

Unexpected identifier 'callback'. Expected ')' to end an if

Have you experienced this issue and if so can it be fixed? Otherwise I need to go with less clean Promise.all option available but I would prefer to use this if possible.

Hi!

This library uses async functions internally, so I guess you are using a Safari version not yet compatible. According to mozilla docs from version 10.1 onwards it should be ok.

Anyway if you want full compatibility with browsers you may need to transpile your code to ES5.

OK I have transpired it and it works ok now.

I'm glad you could solve it.

I'm closing the issue, if you have any more questions please feel free to ask again :)