import { IterableX } from '../iterablex' ; import { PartialObserver } from '../../observer' ; import { MonoTypeOperatorFunction } from '../../interfaces' ; import { toObserver } from '../../util/toobserver' ; export class TapIterable < TSource > extends IterableX < TSource > { private _source : Iterable < TSource > ; private _observer : PartialObserver < TSource > ; constructor ( source , observer ) { super ( ) ; this . _source = source ; this . _observer = observer ; } * [ Symbol . iterator ] ( ) { const it = this . _source [ Symbol . iterator ] ( ) ; while ( 1 ) { let next ; try { next = it . next ( ) ; if ( next . done ) { break ; } } catch ( e ) { if ( this . _observer . error ) { this . _observer . error ( e ) ; } throw e ; } if ( this . _observer . next ) { this . _observer . next ( next . value ) ; } yield next . value ; } if ( this . _observer . complete ) { this . _observer . complete ( ) ; } } } template TSource param { PartialObserver < TSource > } observer returns { MonoTypeOperatorFunction < TSource > } export function tap < TSource > ( observer ) ; template TSource param { ( ( ( value : TSource ) => any ) | null ) } next param { ( ( ( err : any ) => any ) | null ) } error param { ( ( ( ) => any ) | null ) } complete returns { MonoTypeOperatorFunction < TSource > } export function tap < TSource > ( next ? , error ? , complete ? ) ; template TSource param { ( PartialObserver < TSource > | ( ( value : TSource ) => any ) | null ) } observerOrNext param { ( ( ( err : any ) => any ) | null ) } error param { ( ( ( ) => any ) | null ) } complete returns { MonoTypeOperatorFunction < TSource > } export function tap < TSource > ( observerOrNext ? , error ? , complete ? ) { return function tapOperatorFunction ( source ) : IterableX < TSource > { return new TapIterable < TSource > ( source , toObserver ( observerOrNext , error , complete ) ) ; } ; }