Start routing and pipeline rewrite
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-01-17 15:57:40 -06:00
parent 9b8333295f
commit 8cf19792a6
34 changed files with 470 additions and 1654 deletions

View File

@@ -7,7 +7,7 @@ import {
} from './Collection'
import {Iterable, StopIteration} from './Iterable'
import {applyWhere, WhereOperator} from './where'
import {AsyncPipe, Pipe} from '../support/Pipe'
import {AsyncPipe, Pipeline} from '../support/Pipe'
type AsyncCollectionComparable<T> = CollectionItem<T>[] | Collection<T> | AsyncCollection<T>
type AsyncKeyFunction<T, T2> = (item: CollectionItem<T>, index: number) => CollectionItem<T2> | Promise<CollectionItem<T2>>
type AsyncCollectionFunction<T, T2> = (items: AsyncCollection<T>) => T2
@@ -798,19 +798,16 @@ export class AsyncCollection<T> {
return this.storedItems.range(start, end)
}
/**
* Return the value of the function, passing this collection to it.
* @param {AsyncCollectionFunction} func
*/
pipeTo<T2>(func: AsyncCollectionFunction<T, T2>): any {
return func(this)
}
/**
* Return a new Pipe of this collection.
*/
pipe(): Pipe<AsyncCollection<T>> {
return Pipe.wrap(this)
pipeTo<TOut>(pipeline: Pipeline<this, TOut>): TOut {
return pipeline.apply(this)
}
/** Build and apply a pipeline. */
pipe<TOut>(builder: (pipeline: Pipeline<this, this>) => Pipeline<this, TOut>): TOut {
return builder(Pipeline.id()).apply(this)
}
/**

View File

@@ -1,4 +1,4 @@
import {AsyncPipe, Pipe} from '../support/Pipe'
import {AsyncPipe, Pipeline} from '../support/Pipe'
type CollectionItem<T> = T
type MaybeCollectionItem<T> = CollectionItem<T> | undefined
@@ -822,8 +822,13 @@ class Collection<T> {
/**
* Return a new Pipe of this collection.
*/
pipe(): Pipe<Collection<T>> {
return Pipe.wrap(this)
pipeTo<TOut>(pipeline: Pipeline<this, TOut>): TOut {
return pipeline.apply(this)
}
/** Build and apply a pipeline. */
pipe<TOut>(builder: (pipeline: Pipeline<this, this>) => Pipeline<this, TOut>): TOut {
return builder(Pipeline.id()).apply(this)
}
/**