import { as as asAsyncIterable } from './as' ; import { _initialize as _initializeFrom } from './from' ; import { OperatorAsyncFunction , UnaryFunction } from '../interfaces' ; import { Observable } from '../observer' ; import { isReadableNodeStream , isWritableNodeStream } from '../util/isiterable' ; class WithAbortAsyncIterable < TSource > implements AsyncIterable < TSource > { private _source : AsyncIterable < TSource > ; private _signal : AbortSignal ; constructor ( source , signal ) { this . _source = source ; this . _signal = signal ; } [ Symbol . asyncIterator ] ( ) { return this . _source [ Symbol . asyncIterator ] ( this . _signal ) ; } } /**
 * This class serves as the base for all operations which support [Symbol.asyncIterator].
 */ export abstract class AsyncIterableX < T > implements AsyncIterable < T > { abstract [ Symbol . asyncIterator ] ( signal ? ) ; async forEach ( projection , thisArg ? , signal ? ) { const source = signal ? new WithAbortAsyncIterable ( this , signal ) : this ; let i = 0 ; for await ( const item of source ) { await projection . call ( thisArg , item , i ++ , signal ) ; } } 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 ] ( asAsyncIterable ( acc ) ) ; } return acc ; } } ( < any > AsyncIterableX . prototype ) [ Symbol . toStringTag ] = 'AsyncIterableX' ; Object . defineProperty ( AsyncIterableX , Symbol . hasInstance , { writable : true , configurable : true , value ( inst ) { return ! ! ( inst && inst [ Symbol . toStringTag ] === 'AsyncIterableX' ) ; } , } ) ; _initializeFrom ( AsyncIterableX ) ; export type AsyncIterableInput < TSource > = AsyncIterable < TSource > | AsyncIterator < TSource > | Iterable < TSource | PromiseLike < TSource > > | ArrayLike < TSource > | PromiseLike < TSource > | Observable < TSource > ; type WritableOrOperatorAsyncFunction < T , R > = NodeJS . WritableStream | NodeJS . ReadWriteStream | OperatorAsyncFunction < T , R > ; declare module '../asynciterable/asynciterablex' { interface AsyncIterableX < T > { pipe ( ) : AsyncIterableX < T > ; pipe < A > ( op1 ) : AsyncIterableX < A > ; pipe < A , B > ( op1 , op2 ) : AsyncIterableX < B > ; pipe < A , B , C > ( op1 , op2 , op3 ) : AsyncIterableX < C > ; pipe < A , B , C , D > ( op1 , op2 , op3 , op4 ) : AsyncIterableX < D > ; pipe < A , B , C , D , E > ( op1 , op2 , op3 , op4 , op5 ) : AsyncIterableX < E > ; pipe < A , B , C , D , E , F > ( op1 , op2 , op3 , op4 , op5 , op6 ) : AsyncIterableX < F > ; pipe < A , B , C , D , E , F , G > ( op1 , op2 , op3 , op4 , op5 , op6 , op7 ) : AsyncIterableX < G > ; pipe < A , B , C , D , E , F , G , H > ( op1 , op2 , op3 , op4 , op5 , op6 , op7 , op8 ) : AsyncIterableX < H > ; pipe < A , B , C , D , E , F , G , H , I > ( op1 , op2 , op3 , op4 , op5 , op6 , op7 , op8 , op9 ) : AsyncIterableX < I > ; pipe ( ... operations ) : AsyncIterableX < any > ; pipe < A extends NodeJS . WritableStream > ( op1 , options ? ) : A ; } } try { ( ( isBrowser ) => { if ( isBrowser ) { return ; } AsyncIterableX . 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 ( asAsyncIterable ( prev ) ) ; } else if ( isWritableNodeStream ( next ) ) { ( { end = true } = args [ i + 1 ] || { } ) ; return isReadableNodeStream ( prev ) ? prev . pipe ( next , { end } ) : asAsyncIterable ( prev ) . toNodeStream ( readableOpts ( next ) ) . pipe ( next , { end } ) ; } } return prev ; } } ) ( typeof window === 'object' && typeof document === 'object' && document . nodeType === 9 ) ; } catch ( e ) { }