import { IterableActivity , isSource , Source } from "./activity" ; function firstGen < T = any > ( n ) { return function * ( source ) { let i = 0 ; for ( const item of source ) { yield item ; if ( ++ i >= n ) { break ; } } } ; } export function first < T = any > ( n ) ; export function first < T > ( source , n ) ; export function first < T = any > ( s_or_n , n ? ) { if ( ! isSource ( s_or_n ) ) return firstGen < T > ( s_or_n ) ; return firstGen < T > ( n ! ) ( s_or_n ) ; }