UNPKG

bit-bin

Version:

<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b

16 lines (14 loc) 546 B
"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) { // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX! return Promise.all(array.map(entry => filter(entry))).then(results => array.filter(() => results.shift())); }