import type { IGen } from "./api.js" ; import { __take } from "./internal/take.js" ; /**
 * Wraps given ES6 iterable to provide full  IGen implementation.
 *
 *  remarks param src param initial export const iterable = < T > ( src , initial ) => new $Iterable < T > ( src , initial ) ; export class $Iterable < T > implements IGen < T > { protected _iter : Iterator < T > | null ; protected _val : T ; constructor ( src , initial ) { this . _iter = src [ Symbol . iterator ] ( ) ; this . _val = initial ; } deref ( ) { return this . _val ; } * [ Symbol . iterator ] ( ) { while ( true ) yield this . next ( ) ; } next ( ) { if ( this . _iter ) { const res = this . _iter . next ( ) ; if ( ! res . done ) { this . _val = res . value ; } else { this . _iter = null ; } } return this . _val ; } take ( num , out = [ ] , idx = 0 ) { return __take ( this , num , out , idx ) ; } }