import { IterableX } from '../iterablex' ; import { OperatorFunction } from '../../interfaces' ; export class PairwiseIterable < TSource > extends IterableX < TSource [ ] > { private _source : Iterable < TSource > ; constructor ( source ) { super ( ) ; this . _source = source ; } * [ Symbol . iterator ] ( ) { let value ; let hasValue = false ; for ( const item of this . _source ) { if ( ! hasValue ) { hasValue = true ; } else { yield [ value ! , item ] ; } value = item ; } } } template TSource returns { OperatorFunction < TSource , TSource [ ] > } export function pairwise < TSource > ( ) { return function pairwiseOperatorFunction ( source ) : IterableX < TSource [ ] > { return new PairwiseIterable < TSource > ( source ) ; } ; }