ecclesia
Version:
Framework for political and electoral simulations
27 lines (24 loc) • 1.03 kB
text/typescript
import RNG from '@gouvernathor/rng';
type RandomObjParam = {
randomObj: RNG;
} | {
randomSeed?: number | string;
};
declare function createRandomObj(param?: RandomObjParam): RNG;
/**
* Mutable tuple of a single element type and a given length.
*
* Warning: due to limitations in TypeScript, when N is unknown/generic,
* the typing system does not recognize that the type extends array.
* Using methods such as map will require a (double) cast first to any then to T[].
*/
type Tuple<T, N extends number, R extends T[] = []> = R['length'] extends N ? R : Tuple<T, N, [T, ...R]>;
/**
* Immutable version of Tuple.
*
* Warning: due to limitations in TypeScript, when N is unknown/generic,
* the typing system does not recognize that the type extends readonly array.
* Using methods such as map will require a (double) cast first to any then to readonly T[].
*/
type ReadonlyTuple<T, N extends number> = Readonly<Tuple<T, N>>;
export { type RandomObjParam, type ReadonlyTuple, type Tuple, createRandomObj };