import { IterableX } from './iterablex' ; import { returnIterator } from '../util/returniterator' ; export class ZipIterable < TSource > extends IterableX < TSource [ ] > { private _sources : Iterable < TSource > [ ] ; constructor ( sources ) { super ( ) ; this . _sources = sources ; } * [ Symbol . iterator ] ( ) { const sourcesLength = this . _sources . length ; const its = this . _sources . map ( ( x ) => x [ Symbol . iterator ] ( ) ) ; while ( sourcesLength > 0 ) { const values = new Array ( sourcesLength ) ; for ( let index = - 1 ; ++ index < sourcesLength ; ) { const result = its [ index ] . next ( ) ; if ( result . done ) { its . forEach ( returnIterator ) ; return undefined ; } values [ index ] = result . value ; } yield values ; } } } template T template T2 param { Iterable < T > } source param { Iterable < T2 > } source2 returns { IterableX < [ T , T2 ] > } export function zip < T , T2 > ( source , source2 ) ; template T template T2 template T3 param { Iterable < T > } source param { Iterable < T2 > } source2 param { Iterable < T3 > } source3 returns { IterableX < [ T , T2 , T3 ] > } export function zip < T , T2 , T3 > ( source , source2 , source3 ) ; template T template T2 template T3 template T4 param { Iterable < T > } source param { Iterable < T2 > } source2 param { Iterable < T3 > } source3 param { Iterable < T4 > } source4 returns { IterableX < [ T , T2 , T3 , T4 ] > } export function zip < T , T2 , T3 , T4 > ( source , source2 , source3 , source4 ) ; template T template T2 template T3 template T4 template T5 param { Iterable < T > } source param { Iterable < T2 > } source2 param { Iterable < T3 > } source3 param { Iterable < T4 > } source4 param { Iterable < T5 > } source5 returns { IterableX < [ T , T2 , T3 , T4 , T5 ] > } export function zip < T , T2 , T3 , T4 , T5 > ( source , source2 , source3 , source4 , source5 ) ; template T template T2 template T3 template T4 template T5 template T6 param { Iterable < T > } source param { Iterable < T2 > } source2 param { Iterable < T3 > } source3 param { Iterable < T4 > } source4 param { Iterable < T5 > } source5 param { Iterable < T6 > } source6 returns { IterableX < [ T , T2 , T3 , T4 , T5 , T6 ] > } export function zip < T , T2 , T3 , T4 , T5 , T6 > ( source , source2 , source3 , source4 , source5 , source6 ) ; template T param { ... Iterable < T > [ ] } sources returns { IterableX < T [ ] > } export function zip < T > ( ... sources ) ; export function zip < T > ( ... sources ) { return new ZipIterable < T > ( sources ) ; }