@@ -57,11 +57,6 @@ export function mergeInternals<T, R>(
5757 // against our concurrency limit later.
5858 active ++ ;
5959
60- // A flag used to show that the inner observable completed.
61- // This is checked during finalization to see if we should
62- // move to the next item in the buffer, if there is on.
63- let innerComplete = false ;
64-
6560 // Start our inner subscription.
6661 from ( project ( value , index ++ ) ) . subscribe (
6762 operate ( {
@@ -81,36 +76,26 @@ export function mergeInternals<T, R>(
8176 }
8277 } ,
8378 complete : ( ) => {
84- // Flag that we have completed, so we know to check the buffer
85- // during finalization.
86- innerComplete = true ;
87- } ,
88- finalize : ( ) => {
89- // During finalization, if the inner completed (it wasn't errored or
90- // cancelled), then we want to try the next item in the buffer if
91- // there is one.
92- if ( innerComplete ) {
93- // We have to wrap this in a try/catch because it happens during
94- // finalization, possibly asynchronously, and we want to pass
95- // any errors that happen (like in a projection function) to
96- // the outer Subscriber.
97- try {
98- // INNER SOURCE COMPLETE
99- // Decrement the active count to ensure that the next time
100- // we try to call `doInnerSub`, the number is accurate.
101- active -- ;
102- // If we have more values in the buffer, try to process those
103- // Note that this call will increment `active` ahead of the
104- // next conditional, if there were any more inner subscriptions
105- // to start.
106- while ( buffer . length && active < concurrent ) {
107- doInnerSub ( buffer . shift ( ) ! ) ;
108- }
109- // Check to see if we can complete, and complete if so.
110- checkComplete ( ) ;
111- } catch ( err ) {
112- destination . error ( err ) ;
79+ // We have to wrap this in a try/catch because it happens during
80+ // finalization, possibly asynchronously, and we want to pass
81+ // any errors that happen (like in a projection function) to
82+ // the outer Subscriber.
83+ try {
84+ // INNER SOURCE COMPLETE
85+ // Decrement the active count to ensure that the next time
86+ // we try to call `doInnerSub`, the number is accurate.
87+ active -- ;
88+ // If we have more values in the buffer, try to process those
89+ // Note that this call will increment `active` ahead of the
90+ // next conditional, if there were any more inner subscriptions
91+ // to start.
92+ while ( buffer . length && active < concurrent ) {
93+ doInnerSub ( buffer . shift ( ) ! ) ;
11394 }
95+ // Check to see if we can complete, and complete if so.
96+ checkComplete ( ) ;
97+ } catch ( err ) {
98+ destination . error ( err ) ;
11499 }
115100 } ,
116101 } )
0 commit comments