File tree
Expand file treeCollapse file tree2 files changed
+20
-20
lines changed Expand file treeCollapse file tree2 files changed
+20
-20
lines changed Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | import asyncForEach from './forEach';
|
2 | 2 |
|
3 |
| -export default async function asyncSome(arr, fn) { |
| 3 | +export default function asyncSome(arr, fn) { |
4 | 4 | return new Promise((resolve) => {
|
5 | 5 | 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(() => { |
15 | 15 | if (!resolved) {
|
16 | 16 | resolve(true);
|
17 | 17 | }
|
|
Original file line number | Diff line number | Diff line change |
---|
|
1 | 1 | import asyncForEach from './forEach';
|
2 | 2 |
|
3 |
| -export default async function asyncSome(arr, fn) { |
| 3 | +export default function asyncSome(arr, fn) { |
4 | 4 | return new Promise((resolve) => {
|
5 | 5 | 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(() => { |
15 | 15 | if (!resolved) {
|
16 | 16 | resolve(false);
|
17 | 17 | }
|
|
You can’t perform that action at this time.
0 commit comments