import { Iterable } from './Iterable.ts' import { collect } from './Collection.ts' /** * 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_index(i: number) { return this.items[i] } async from_range(start: number, end: number) { return collect(this.items.slice(start, end + 1)) } async count() { return this.items.length } clone() { return new ArrayIterable([...this.items]) } }