You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
727 B
23 lines
727 B
import {AsyncCollection} from '../../../../../lib/src/collection/AsyncCollection.ts'
|
|
import {ResultIterable} from './ResultIterable.ts'
|
|
import {Collection} from '../../../../../lib/src/collection/Collection.ts'
|
|
|
|
export class ResultCollection<T> extends AsyncCollection<T> {
|
|
constructor(
|
|
executable: ResultIterable<T>,
|
|
chunk_size: number = 1000
|
|
) {
|
|
super(executable, chunk_size)
|
|
}
|
|
|
|
then(func?: (items: Collection<T>) => any) {
|
|
if ( func ) {
|
|
this.collect().then((items: Collection<T>) => func(items))
|
|
} else {
|
|
return new Promise(res => [
|
|
this.collect().then((items: Collection<T>) => res(items))
|
|
])
|
|
}
|
|
}
|
|
}
|