1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00
unleash.unleash/frontend/src/utils/cyclicIterator.ts
Christopher Kolstad 23094b016e
feat: first draft of chart for instance traffic in frontend (#2670)
## What
We've already added the backend for this. This is the initial work for
drawing a chart for instance traffic in the frontend. It requires the environment variable `PROMETHEUS_API` set to a valid prometheus-query-language (promql) supported backend, such as Prometheus itself or Victoria Metrics. Besides, at the moment we're hiding this functionality behind the flag `UNLEASH_EXPERIMENTAL_NETWORK_VIEW` which has to be set to true

Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
Co-authored-by: Gastón Fournier <gaston@getunleash.ai>
2022-12-15 08:47:07 +00:00

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;
}
}