ecclesia
Version:
Framework for political and electoral simulations
1 lines • 1.56 kB
Source Map (JSON)
{"version":3,"sources":["../src/utils.ts"],"sourcesContent":["import RNG from \"@gouvernathor/rng\";\n\nexport type RandomObjParam = {randomObj: RNG} | {randomSeed?: number|string};\n\nexport function createRandomObj(param?: RandomObjParam): RNG;\nexport function createRandomObj({ randomObj, randomSeed }:\n { randomObj?: RNG, randomSeed?: number | string } = {},\n): RNG {\n if (randomObj === undefined) {\n randomObj = new RNG(randomSeed);\n }\n return randomObj;\n}\n\n\n// https://stackoverflow.com/a/71700658\n\n/**\n * Mutable tuple of a single element type and a given length.\n *\n * Warning: due to limitations in TypeScript, when N is unknown/generic,\n * the typing system does not recognize that the type extends array.\n * Using methods such as map will require a (double) cast first to any then to T[].\n */\nexport type Tuple<\n T,\n N extends number,\n R extends T[] = [],\n> = R['length'] extends N ? R : Tuple<T, N, [T, ...R]>;\n\n/**\n * Immutable version of Tuple.\n *\n * Warning: due to limitations in TypeScript, when N is unknown/generic,\n * the typing system does not recognize that the type extends readonly array.\n * Using methods such as map will require a (double) cast first to any then to readonly T[].\n */\nexport type ReadonlyTuple<T, N extends number> = Readonly<Tuple<T, N>>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAgB;AAKT,SAAS,gBAAgB,EAAE,WAAW,WAAW,IACA,CAAC,GAClD;AACH,MAAI,cAAc,QAAW;AACzB,gBAAY,IAAI,WAAAA,QAAI,UAAU;AAAA,EAClC;AACA,SAAO;AACX;","names":["RNG"]}