"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = filterAsync;


/**
 * Array.filter is synchronous and therefore does not support Promises.
 * This one works with promises.
 * Taken from https://stackoverflow.com/questions/33355528/filtering-an-array-with-a-function-that-returns-a-promise
 */
function filterAsync(array, filter) {
  return Promise.all(array.map(function (entry) {
    return filter(entry);
  })).then(function (results) {
    return array.filter(function () {
      return results.shift();
    });
  });
}