import { Iterable } from './Iterable' import {collect, Collection} from './Collection' /** * A basic Iterable implementation that uses an array as a backend. * @extends Iterable */ export class ArrayIterable extends Iterable { constructor( /** * Items to use for this iterable. */ protected items: T[], ) { super() } async at(i: number): Promise { return this.items[i] } async range(start: number, end: number): Promise> { return collect(this.items.slice(start, end + 1)) } async count(): Promise { return this.items.length } clone(): ArrayIterable { return new ArrayIterable([...this.items]) } }