import { IterableX } from '../iterablex' ; import { MonoTypeOperatorFunction } from '../../interfaces' ; export class FinallyIterable < TSource > extends IterableX < TSource > { private _source : Iterable < TSource > ; private _action : ( ) => void ; constructor ( source , action ) { super ( ) ; this . _source = source ; this . _action = action ; } * [ Symbol . iterator ] ( ) { try { yield * this . _source ; } finally { this . _action ( ) ; } } } template TSource param { ( ( ) => void ) } action returns { MonoTypeOperatorFunction < TSource > } export function finalize < TSource > ( action ) { return function finallyOperatorFunction ( source ) : IterableX < TSource > { return new FinallyIterable < TSource > ( source , action ) ; } ; }