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.
466 B · 20 lines
JavaScript
123456789101112131415161718192021import asyncForEach from './forEach';
export default function asyncSome(arr, fn) { return new Promise((resolve) => { let resolved = false; asyncForEach(arr, (cur, idx, arr2) => new Promise((resolve2) => { fn(cur, idx, arr2).then((result) => { if (result) { resolved = true; resolve(true); } resolve2(); }); })).then(() => { if (!resolved) { resolve(false); } }); });}