@@ -33,16 +33,19 @@ async function findInternal (iterable, iteratee, queueOrConcurrency, ordered) {
33
33
let lastIndexHandled = - 1
34
34
const results = [ ]
35
35
36
+ let waitListIndex = 0
36
37
const waitList = new Map ( )
37
- const addToWaitList = ( identifier , fct ) => {
38
+ const addToWaitList = ( fct ) => {
39
+ const identifier = waitListIndex
40
+ waitListIndex += 1
38
41
const p = ( async ( ) => {
39
42
try {
40
43
return [ identifier , 'resolved' , await fct ( ) ]
41
44
} catch ( e ) {
42
45
return [ identifier , 'rejected' , e ]
43
46
}
44
47
} ) ( )
45
- assert ( ! waitList . has ( ' identifier' ) , 'waitList already contains identifier' )
48
+ assert ( ! waitList . has ( identifier ) , 'waitList already contains identifier' )
46
49
waitList . set ( identifier , p )
47
50
}
48
51
const raceWaitList = async ( ) => {
@@ -63,7 +66,7 @@ async function findInternal (iterable, iteratee, queueOrConcurrency, ordered) {
63
66
state : null
64
67
}
65
68
scheduledList . set ( index , task )
66
- addToWaitList ( task . index , async ( ) => {
69
+ addToWaitList ( async ( ) => {
67
70
const p = queue . exec ( async ( ) => {
68
71
if ( task . state === 'cancelled' ) {
69
72
throw new CustomCancelledError ( )
@@ -103,7 +106,7 @@ async function findInternal (iterable, iteratee, queueOrConcurrency, ordered) {
103
106
}
104
107
const fetch = ( ) => {
105
108
fetching = true
106
- addToWaitList ( 'next' , async ( ) => {
109
+ addToWaitList ( async ( ) => {
107
110
const [ state , result ] = await it . next ( ) . then ( ( r ) => [ 'resolved' , r ] , ( e ) => [ 'rejected' , e ] )
108
111
fetching = false
109
112
if ( state === 'resolved' ) {
0 commit comments