import { IEnumerable } from "../../types" ; import { BasicEnumerable } from "../BasicEnumerable" ; param source param amount returns export const take = < TSource > ( source , amount ) : IEnumerable < TSource > => { function * iterator ( ) { let amountLeft = amount > 0 ? amount : 0 ; for ( const item of source ) { if ( amountLeft -- === 0 ) { break ; } else { yield item ; } } } return new BasicEnumerable < TSource > ( iterator ) ; } ;