import { IIterator , iter , IterableOrArrayLike } from './iter' ; param object param fn returns export function map < T , U > ( object , fn ) { return new MapIterator < T , U > ( iter ( object ) , fn ) ; } /**
 * An iterator which transforms values using a mapping function.
 */ export class MapIterator < T , U > implements IIterator < U > { param source param fn constructor ( source , fn ) { this . _source = source ; this . _fn = fn ; } returns iter ( ) { return this ; } returns clone ( ) { let result = new MapIterator < T , U > ( this . _source . clone ( ) , this . _fn ) ; result . _index = this . _index ; return result ; } returns next ( ) { let value = this . _source . next ( ) ; if ( value === undefined ) { return undefined ; } return this . _fn . call ( undefined , value , this . _index ++ ) ; } private _index = 0 ; private _source : IIterator < T > ; private _fn : ( value : T , index : number ) => U ; }