import * as assert from "@esfx/internal-assert" ; import { OrderedIterable } from "@esfx/iter-ordered" ; import { AsyncOrderedIterable } from "@esfx/async-iter-ordered" ; import { Comparison } from '@esfx/equatable' ; class AsyncFromSyncOrderedIterable < T , TSource extends OrderedIterable < T > > implements AsyncOrderedIterable < T > { private _source : TSource ; constructor ( source ) { assert . mustBeType ( OrderedIterable . hasInstance , "source" ) ; this . _source = source ; } async * [ Symbol . asyncIterator ] ( ) { yield * this . _source ; } [ AsyncOrderedIterable . thenByAsync ] < K > ( keySelector , comparison , descending ) { const thenBy = this . _source [ OrderedIterable . thenBy ] ; if ( typeof thenBy === "function" ) { return new AsyncFromSyncOrderedIterable ( thenBy . call ( this . _source , keySelector , comparison as Comparison < unknown > , descending ) ) ; } throw new TypeError ( ) ; } } export function toAsyncOrderedIterable < T > ( iterable ) { return AsyncOrderedIterable . hasInstance ( iterable ) ? iterable : new AsyncFromSyncOrderedIterable ( iterable ) ; }