File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import asyncForEach from './forEach';
22

3-
export default async function asyncSome(arr, fn) {
3+
export default function asyncSome(arr, fn) {
44
return new Promise((resolve) => {
55
let resolved = false;
6-
// eslint-disable-next-line no-shadow
7-
asyncForEach(arr, async (cur, idx, arr) => {
8-
const result = await fn(cur, idx, arr);
9-
10-
if (!result) {
11-
resolved = true;
12-
resolve(false);
13-
}
14-
}).then(() => {
6+
asyncForEach(arr, (cur, idx, arr2) => new Promise((resolve2) => {
7+
fn(cur, idx, arr2).then((result) => {
8+
if (!result) {
9+
resolved = true;
10+
resolve(false);
11+
}
12+
resolve2();
13+
});
14+
})).then(() => {
1515
if (!resolved) {
1616
resolve(true);
1717
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import asyncForEach from './forEach';
22

3-
export default async function asyncSome(arr, fn) {
3+
export default function asyncSome(arr, fn) {
44
return new Promise((resolve) => {
55
let resolved = false;
6-
// eslint-disable-next-line no-shadow
7-
asyncForEach(arr, async (cur, idx, arr) => {
8-
const result = await fn(cur, idx, arr);
9-
10-
if (result) {
11-
resolved = true;
12-
resolve(true);
13-
}
14-
}).then(() => {
6+
asyncForEach(arr, (cur, idx, arr2) => new Promise((resolve2) => {
7+
fn(cur, idx, arr2).then((result) => {
8+
if (result) {
9+
resolved = true;
10+
resolve(true);
11+
}
12+
resolve2();
13+
});
14+
})).then(() => {
1515
if (!resolved) {
1616
resolve(false);
1717
}

0 commit comments

Comments
 (0)