import { as as asIterable } from './as' ; import { _initialize as _initializeFrom } from './from' ; import { UnaryFunction , OperatorFunction } from '../interfaces' ; import { bindCallback } from '../util/bindcallback' ; import { isReadableNodeStream , isWritableNodeStream } from '../util/isiterable' ; /**
 * This class serves as the base for all operations which support [Symbol.iterator].
 */ export abstract class IterableX < T > implements Iterable < T > { abstract [ Symbol . iterator ] ( ) ; forEach ( projection , thisArg ? ) { const fn = bindCallback ( projection , thisArg , 2 ) ; let i = 0 ; for ( const item of this ) { fn ( item , i ++ ) ; } } nocollapse pipe < R > ( ... operations ) ; pipe < R > ( ... operations ) ; pipe < R extends NodeJS . WritableStream > ( writable , options ? ) ; pipe < R > ( ... args ) { let i = - 1 ; const n = args . length ; let acc = this ; while ( ++ i < n ) { acc = args [ i ] ( asIterable ( acc ) ) ; } return acc ; } } ( < any > IterableX . prototype ) [ Symbol . toStringTag ] = 'IterableX' ; Object . defineProperty ( IterableX , Symbol . hasInstance , { writable : true , configurable : true , value ( inst ) { return ! ! ( inst && inst [ Symbol . toStringTag ] === 'IterableX' ) ; } , } ) ; _initializeFrom ( IterableX ) ; type WritableOrOperatorFunction < T , R > = NodeJS . WritableStream | NodeJS . ReadWriteStream | OperatorFunction < T , R > ; declare module '../iterable/iterablex' { interface IterableX < T > extends Iterable < T > { pipe ( ) : IterableX < T > ; pipe < A > ( op1 ) : IterableX < A > ; pipe < A , B > ( op1 , op2 ) : IterableX < B > ; pipe < A , B , C > ( op1 , op2 , op3 ) : IterableX < C > ; pipe < A , B , C , D > ( op1 , op2 , op3 , op4 ) : IterableX < D > ; pipe < A , B , C , D , E > ( op1 , op2 , op3 , op4 , op5 ) : IterableX < E > ; pipe < A , B , C , D , E , F > ( op1 , op2 , op3 , op4 , op5 , op6 ) : IterableX < F > ; pipe < A , B , C , D , E , F , G > ( op1 , op2 , op3 , op4 , op5 , op6 , op7 ) : IterableX < G > ; pipe < A , B , C , D , E , F , G , H > ( op1 , op2 , op3 , op4 , op5 , op6 , op7 , op8 ) : IterableX < H > ; pipe < A , B , C , D , E , F , G , H , I > ( op1 , op2 , op3 , op4 , op5 , op6 , op7 , op8 , op9 ) : IterableX < I > ; pipe < R > ( ... operations ) : IterableX < R > ; pipe < A extends NodeJS . WritableStream > ( op1 , options ? ) : A ; } } try { ( ( isBrowser ) => { if ( isBrowser ) { return ; } IterableX . prototype [ 'pipe' ] = nodePipe ; const readableOpts = ( x , opts = x . _writableState || { objectMode : true } ) => opts ; function nodePipe < T > ( this , ... args ) { let i = - 1 ; let end ; const n = args . length ; let prev = this ; let next ; while ( ++ i < n ) { next = args [ i ] ; if ( typeof next === 'function' ) { prev = next ( asIterable ( prev ) ) ; } else if ( isWritableNodeStream ( next ) ) { ( { end = true } = args [ i + 1 ] || { } ) ; return isReadableNodeStream ( prev ) ? prev . pipe ( next , { end } ) : asIterable ( prev ) . toNodeStream ( readableOpts ( next ) ) . pipe ( next , { end } ) ; } } return prev ; } } ) ( typeof window === 'object' && typeof document === 'object' && document . nodeType === 9 ) ; } catch ( e ) { }