import { IIterator , iter , IterableOrArrayLike } from './iter' ; param object param count returns export function take < T > ( object , count ) { return new TakeIterator < T > ( iter ( object ) , count ) ; } /**
 * An iterator which takes a fixed number of items from a source.
 */ export class TakeIterator < T > implements IIterator < T > { param source param count constructor ( source , count ) { this . _source = source ; this . _count = count ; } returns iter ( ) { return this ; } returns clone ( ) { return new TakeIterator < T > ( this . _source . clone ( ) , this . _count ) ; } returns next ( ) { if ( this . _count <= 0 ) { return undefined ; } let value = this . _source . next ( ) ; if ( value === undefined ) { return undefined ; } this . _count -- ; return value ; } private _count : number ; private _source : IIterator < T > ; }