Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/wojtekmaj/async-array-utils. A collection of array-related async utilities.
array array-methods async promise utils
Something went wrong. Try again.
432 B · 16 lines
JavaScript
1234567891011121314151617import asyncForEachStrict from './forEach_strict';
export default function asyncFilterStrict(arr, fn) { const result = [];
// eslint-disable-next-line no-shadow return asyncForEachStrict(arr, (cur, idx, arr) => new Promise((resolve) => { fn(cur, idx, arr).then((cond) => { if (cond) { result[idx] = cur; } resolve(); }); })) .then(() => result.filter((cur, idx) => idx in result));}