@linzjs/step-ag-grid
Version:
[](https://github.com/semantic-release/semantic-release) > Reusable [ag-grid](https://www.ag-grid.com/) component for LINZ / Toitū te whenua.
20 lines (17 loc) • 446 B
text/typescript
export class SeededRandomForTests {
value: number;
constructor(seed: number) {
this.value = seed % 2147483647;
}
next(maxInc?: number) {
this.value = (this.value * 16807) % 2147483647;
const result = (this.value - 1) / 2147483646;
if (maxInc == null) {
return result;
}
return ((result * (maxInc + 1)) | 0) % (maxInc + 1);
}
fromArray<T>(arr: T[]): T {
return arr[this.next(arr.length - 1)];
}
}