mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
13 lines
306 B
TypeScript
13 lines
306 B
TypeScript
|
export class CyclicIterator<T> {
|
||
|
private current = 0;
|
||
|
readonly all: T[];
|
||
|
constructor(defaultList: T[]) {
|
||
|
this.all = defaultList;
|
||
|
}
|
||
|
next(): T {
|
||
|
const item = this.all[this.current];
|
||
|
this.current = (this.current + 1) % this.all.length;
|
||
|
return item;
|
||
|
}
|
||
|
}
|