@@ -132,34 +132,32 @@ export function bufferTime<T>(bufferTimeSpan: number, ...otherArgs: any[]): Oper
132132
133133 startBuffer ( ) ;
134134
135- const bufferTimeSubscriber = operate ( {
136- destination,
137- next : ( value : T ) => {
138- // Copy the records, so if we need to remove one we
139- // don't mutate the array. It's hard, but not impossible to
140- // set up a buffer time that could mutate the array and
141- // cause issues here.
142- const recordsCopy = bufferRecords ! . slice ( ) ;
143- for ( const record of recordsCopy ) {
144- // Loop over all buffers and
145- const { buffer } = record ;
146- buffer . push ( value ) ;
147- // If the buffer is over the max size, we need to emit it.
148- maxBufferSize <= buffer . length && emit ( record ) ;
149- }
150- } ,
151- complete : ( ) => {
152- // The source completed, emit all of the active
153- // buffers we have before we complete.
154- while ( bufferRecords ?. length ) {
155- destination . next ( bufferRecords . shift ( ) ! . buffer ) ;
156- }
157- bufferTimeSubscriber ?. unsubscribe ( ) ;
158- destination . complete ( ) ;
159- destination . unsubscribe ( ) ;
160- } ,
161- } ) ;
162-
163- source . subscribe ( bufferTimeSubscriber ) ;
135+ source . subscribe (
136+ operate ( {
137+ destination,
138+ next : ( value : T ) => {
139+ // Copy the records, so if we need to remove one we
140+ // don't mutate the array. It's hard, but not impossible to
141+ // set up a buffer time that could mutate the array and
142+ // cause issues here.
143+ const recordsCopy = bufferRecords ! . slice ( ) ;
144+ for ( const record of recordsCopy ) {
145+ // Loop over all buffers and
146+ const { buffer } = record ;
147+ buffer . push ( value ) ;
148+ // If the buffer is over the max size, we need to emit it.
149+ maxBufferSize <= buffer . length && emit ( record ) ;
150+ }
151+ } ,
152+ complete : ( ) => {
153+ // The source completed, emit all of the active
154+ // buffers we have before we complete.
155+ while ( bufferRecords ?. length ) {
156+ destination . next ( bufferRecords . shift ( ) ! . buffer ) ;
157+ }
158+ destination . complete ( ) ;
159+ } ,
160+ } )
161+ ) ;
164162 } ) ;
165163}
0 commit comments