Loop

Loop

This is module expose an helper method used to loop over an index list in
either direction.

import Loop     from 'paraviewweb/src/Common/Misc/Loop';
import { loop } from 'paraviewweb/src/Common/Misc/Loop';

loop(reverseOrder, count, fn)

fn will be called with an index that go from 0 to (count-1) if reverseOrder is false,
or from (count-1) to 0 if true.

Source

index.js
export function loop(reverseOrder, count_, fn) {
let count = count_;
if (reverseOrder) {
while (count--) {
fn(count);
}
} else {
for (let i = 0; i < count; i++) {
fn(i);
}
}
}

export default {
loop,
};