import { IIterator , iter , IterableOrArrayLike } from './iter' ; param objects returns export function chain < T > ( ... objects ) { return new ChainIterator < T > ( iter ( objects . map ( iter ) ) ) ; } /**
 * An iterator which chains together several iterators.
 */ export class ChainIterator < T > implements IIterator < T > { param source constructor ( source ) { this . _source = source ; this . _active = undefined ; } returns iter ( ) { return this ; } returns clone ( ) { let result = new ChainIterator < T > ( this . _source . clone ( ) ) ; result . _active = this . _active && this . _active . clone ( ) ; result . _cloned = true ; this . _cloned = true ; return result ; } returns next ( ) { if ( this . _active === undefined ) { let active = this . _source . next ( ) ; if ( active === undefined ) { return undefined ; } this . _active = this . _cloned ? active . clone ( ) : active ; } let value = this . _active . next ( ) ; if ( value !== undefined ) { return value ; } this . _active = undefined ; return this . next ( ) ; } private _source : IIterator < IIterator < T > > ; private _active : IIterator < T > | undefined ; private _cloned = false ; }