isaacscript-common 81.0.4 → 81.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/ModFeature.d.ts +1 -1
- package/dist/classes/ModFeature.d.ts.map +1 -1
- package/dist/classes/features/other/CustomItemPools.d.ts +1 -1
- package/dist/classes/features/other/CustomItemPools.d.ts.map +1 -1
- package/dist/classes/features/other/CustomItemPools.lua +4 -2
- package/dist/classes/features/other/DisableInputs.d.ts +1 -1
- package/dist/classes/features/other/DisableInputs.d.ts.map +1 -1
- package/dist/classes/features/other/ModdedElementSets.d.ts +4 -4
- package/dist/classes/features/other/ModdedElementSets.d.ts.map +1 -1
- package/dist/classes/features/other/ModdedElementSets.lua +7 -2
- package/dist/classes/features/other/SaveDataManager.d.ts +1 -1
- package/dist/classes/features/other/SaveDataManager.d.ts.map +1 -1
- package/dist/functions/array.d.ts +5 -5
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/arrayLua.d.ts +14 -14
- package/dist/functions/arrayLua.d.ts.map +1 -1
- package/dist/functions/arrayLua.lua +7 -7
- package/dist/functions/benchmark.d.ts +1 -1
- package/dist/functions/benchmark.d.ts.map +1 -1
- package/dist/functions/bitwise.d.ts +1 -1
- package/dist/functions/bitwise.d.ts.map +1 -1
- package/dist/functions/cards.d.ts +1 -1
- package/dist/functions/cards.d.ts.map +1 -1
- package/dist/functions/challenges.d.ts +1 -1
- package/dist/functions/challenges.d.ts.map +1 -1
- package/dist/functions/curses.d.ts +1 -1
- package/dist/functions/curses.d.ts.map +1 -1
- package/dist/functions/doors.d.ts +5 -5
- package/dist/functions/doors.d.ts.map +1 -1
- package/dist/functions/external.d.ts +1 -1
- package/dist/functions/external.d.ts.map +1 -1
- package/dist/functions/flag.d.ts +5 -4
- package/dist/functions/flag.d.ts.map +1 -1
- package/dist/functions/gridEntities.d.ts +5 -5
- package/dist/functions/gridEntities.d.ts.map +1 -1
- package/dist/functions/input.d.ts +5 -5
- package/dist/functions/input.d.ts.map +1 -1
- package/dist/functions/itemPool.d.ts +2 -2
- package/dist/functions/itemPool.d.ts.map +1 -1
- package/dist/functions/jsonRoom.d.ts +1 -1
- package/dist/functions/jsonRoom.d.ts.map +1 -1
- package/dist/functions/level.d.ts +2 -2
- package/dist/functions/level.d.ts.map +1 -1
- package/dist/functions/levelGrid.d.ts +2 -2
- package/dist/functions/levelGrid.d.ts.map +1 -1
- package/dist/functions/logEntities.d.ts +3 -3
- package/dist/functions/logEntities.d.ts.map +1 -1
- package/dist/functions/logMisc.d.ts +2 -1
- package/dist/functions/logMisc.d.ts.map +1 -1
- package/dist/functions/map.d.ts.map +1 -1
- package/dist/functions/merge.d.ts +1 -1
- package/dist/functions/merge.d.ts.map +1 -1
- package/dist/functions/npcDataStructures.d.ts +3 -3
- package/dist/functions/npcDataStructures.d.ts.map +1 -1
- package/dist/functions/playerCollectibles.d.ts +7 -7
- package/dist/functions/playerCollectibles.d.ts.map +1 -1
- package/dist/functions/playerDataStructures.d.ts +3 -3
- package/dist/functions/playerDataStructures.d.ts.map +1 -1
- package/dist/functions/playerTrinkets.d.ts +2 -2
- package/dist/functions/playerTrinkets.d.ts.map +1 -1
- package/dist/functions/players.d.ts +4 -4
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/rng.d.ts +3 -2
- package/dist/functions/rng.d.ts.map +1 -1
- package/dist/functions/rooms.d.ts +4 -4
- package/dist/functions/rooms.d.ts.map +1 -1
- package/dist/functions/run.d.ts +2 -2
- package/dist/functions/run.d.ts.map +1 -1
- package/dist/functions/set.d.ts.map +1 -1
- package/dist/functions/sort.d.ts +1 -1
- package/dist/functions/sort.d.ts.map +1 -1
- package/dist/functions/stage.d.ts +3 -3
- package/dist/functions/stage.d.ts.map +1 -1
- package/dist/functions/string.d.ts +3 -2
- package/dist/functions/string.d.ts.map +1 -1
- package/dist/functions/table.d.ts +4 -4
- package/dist/functions/table.d.ts.map +1 -1
- package/dist/functions/trinketGive.d.ts +1 -1
- package/dist/functions/trinketGive.d.ts.map +1 -1
- package/dist/functions/utils.d.ts +1 -1
- package/dist/functions/utils.d.ts.map +1 -1
- package/dist/functions/vector.d.ts +1 -1
- package/dist/functions/vector.d.ts.map +1 -1
- package/dist/functions/weighted.d.ts +2 -2
- package/dist/functions/weighted.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.rollup.d.ts +109 -107
- package/dist/indexLua.d.ts +1 -0
- package/dist/indexLua.d.ts.map +1 -1
- package/dist/isaacscript-common.lua +23 -12
- package/dist/types/AnyFunction.d.ts +1 -1
- package/dist/types/AnyFunction.d.ts.map +1 -1
- package/dist/types/ReadonlyRecord.d.ts +2 -0
- package/dist/types/ReadonlyRecord.d.ts.map +1 -0
- package/dist/types/ReadonlyRecord.lua +2 -0
- package/package.json +1 -1
- package/src/classes/ModFeature.ts +4 -4
- package/src/classes/ModUpgraded.ts +1 -1
- package/src/classes/features/callbackLogic/PlayerReorderedCallbacks.ts +1 -0
- package/src/classes/features/other/CustomItemPools.ts +10 -3
- package/src/classes/features/other/DisableInputs.ts +4 -1
- package/src/classes/features/other/ItemPoolDetection.ts +2 -2
- package/src/classes/features/other/ModdedElementSets.ts +6 -6
- package/src/classes/features/other/PickupIndexCreation.ts +1 -1
- package/src/classes/features/other/RunInNFrames.ts +2 -0
- package/src/classes/features/other/SaveDataManager.ts +3 -1
- package/src/core/upgradeMod.ts +4 -1
- package/src/functions/array.ts +18 -5
- package/src/functions/arrayLua.ts +20 -20
- package/src/functions/benchmark.ts +1 -1
- package/src/functions/bitwise.ts +1 -1
- package/src/functions/cards.ts +1 -1
- package/src/functions/challenges.ts +1 -1
- package/src/functions/curses.ts +1 -1
- package/src/functions/deepCopy.ts +6 -6
- package/src/functions/doors.ts +7 -5
- package/src/functions/external.ts +1 -1
- package/src/functions/flag.ts +5 -4
- package/src/functions/gridEntities.ts +5 -5
- package/src/functions/input.ts +5 -5
- package/src/functions/itemPool.ts +4 -2
- package/src/functions/jsonRoom.ts +1 -1
- package/src/functions/level.ts +2 -2
- package/src/functions/levelGrid.ts +2 -2
- package/src/functions/logEntities.ts +6 -3
- package/src/functions/logMisc.ts +2 -1
- package/src/functions/map.ts +2 -0
- package/src/functions/merge.ts +4 -3
- package/src/functions/npcDataStructures.ts +11 -3
- package/src/functions/playerCollectibles.ts +7 -7
- package/src/functions/playerDataStructures.ts +8 -3
- package/src/functions/playerTrinkets.ts +2 -2
- package/src/functions/players.ts +6 -4
- package/src/functions/rng.ts +8 -2
- package/src/functions/rooms.ts +4 -4
- package/src/functions/run.ts +6 -2
- package/src/functions/set.ts +3 -0
- package/src/functions/sort.ts +5 -1
- package/src/functions/stage.ts +5 -3
- package/src/functions/string.ts +3 -2
- package/src/functions/table.ts +4 -4
- package/src/functions/trinketGive.ts +1 -1
- package/src/functions/utils.ts +1 -1
- package/src/functions/vector.ts +1 -1
- package/src/functions/weighted.ts +2 -2
- package/src/index.ts +1 -0
- package/src/types/AnyFunction.ts +1 -1
- package/src/types/ReadonlyRecord.ts +3 -0
package/src/functions/rng.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
|
|
2
2
|
import { game } from "../core/cachedClasses";
|
|
3
3
|
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
4
|
+
import type { ReadonlyRecord } from "../types/ReadonlyRecord";
|
|
4
5
|
import { traceback } from "./debugFunctions";
|
|
5
6
|
import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
|
|
6
7
|
import { logError } from "./log";
|
|
@@ -121,7 +122,10 @@ export function serializeRNG(rng: RNG): SerializedRNG {
|
|
|
121
122
|
* Helper function to iterate over the provided object and set the seed for all of the values that
|
|
122
123
|
* are RNG objects equal to a particular seed.
|
|
123
124
|
*/
|
|
124
|
-
export function setAllRNGToSeed(
|
|
125
|
+
export function setAllRNGToSeed(
|
|
126
|
+
object: ReadonlyRecord<string, RNG>,
|
|
127
|
+
seed: Seed,
|
|
128
|
+
): void {
|
|
125
129
|
if (!isTable(object)) {
|
|
126
130
|
error(
|
|
127
131
|
`Failed to iterate over the object containing RNG objects since the type of the provided object was: ${typeof object}`,
|
|
@@ -147,7 +151,9 @@ export function setAllRNGToSeed(object: unknown, seed: Seed): void {
|
|
|
147
151
|
* Helper function to iterate over the provided object and set the seed for all of the values that
|
|
148
152
|
* are RNG objects equal to the start seed for the current run.
|
|
149
153
|
*/
|
|
150
|
-
export function setAllRNGToStartSeed(
|
|
154
|
+
export function setAllRNGToStartSeed(
|
|
155
|
+
object: ReadonlyRecord<string, RNG>,
|
|
156
|
+
): void {
|
|
151
157
|
const seeds = game.GetSeeds();
|
|
152
158
|
const startSeed = seeds.GetStartSeed();
|
|
153
159
|
|
package/src/functions/rooms.ts
CHANGED
|
@@ -472,7 +472,7 @@ export function inMirrorRoom(): boolean {
|
|
|
472
472
|
*
|
|
473
473
|
* This function is variadic, which means you can pass as many room shapes as you want to match for.
|
|
474
474
|
*/
|
|
475
|
-
export function inRoomShape(...roomShapes: RoomShape[]): boolean {
|
|
475
|
+
export function inRoomShape(...roomShapes: readonly RoomShape[]): boolean {
|
|
476
476
|
const roomData = getRoomData();
|
|
477
477
|
return isRoomShape(roomData, ...roomShapes);
|
|
478
478
|
}
|
|
@@ -482,7 +482,7 @@ export function inRoomShape(...roomShapes: RoomShape[]): boolean {
|
|
|
482
482
|
*
|
|
483
483
|
* This function is variadic, which means you can pass as many room types as you want to match for.
|
|
484
484
|
*/
|
|
485
|
-
export function inRoomType(...roomTypes: RoomType[]): boolean {
|
|
485
|
+
export function inRoomType(...roomTypes: readonly RoomType[]): boolean {
|
|
486
486
|
const roomData = getRoomData();
|
|
487
487
|
return isRoomType(roomData, ...roomTypes);
|
|
488
488
|
}
|
|
@@ -806,7 +806,7 @@ export function isMirrorRoom(roomData: RoomConfig): boolean {
|
|
|
806
806
|
*/
|
|
807
807
|
export function isRoomShape(
|
|
808
808
|
roomData: RoomConfig,
|
|
809
|
-
...roomShapes: RoomShape[]
|
|
809
|
+
...roomShapes: readonly RoomShape[]
|
|
810
810
|
): boolean {
|
|
811
811
|
return roomShapes.includes(roomData.Shape);
|
|
812
812
|
}
|
|
@@ -818,7 +818,7 @@ export function isRoomShape(
|
|
|
818
818
|
*/
|
|
819
819
|
export function isRoomType(
|
|
820
820
|
roomData: RoomConfig,
|
|
821
|
-
...roomTypes: RoomType[]
|
|
821
|
+
...roomTypes: readonly RoomType[]
|
|
822
822
|
): boolean {
|
|
823
823
|
return roomTypes.includes(roomData.Type);
|
|
824
824
|
}
|
package/src/functions/run.ts
CHANGED
|
@@ -10,7 +10,9 @@ import { log } from "./log";
|
|
|
10
10
|
import { isString } from "./types";
|
|
11
11
|
|
|
12
12
|
/** Alias for the `anySeedEffectEnabled` function. */
|
|
13
|
-
export function anyEasterEggEnabled(
|
|
13
|
+
export function anyEasterEggEnabled(
|
|
14
|
+
exceptions?: readonly SeedEffect[],
|
|
15
|
+
): boolean {
|
|
14
16
|
return anySeedEffectEnabled(exceptions);
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -19,7 +21,9 @@ export function anyEasterEggEnabled(exceptions?: SeedEffect[]): boolean {
|
|
|
19
21
|
*
|
|
20
22
|
* @param exceptions Optional. An array of seed effects to ignore.
|
|
21
23
|
*/
|
|
22
|
-
export function anySeedEffectEnabled(
|
|
24
|
+
export function anySeedEffectEnabled(
|
|
25
|
+
exceptions?: readonly SeedEffect[],
|
|
26
|
+
): boolean {
|
|
23
27
|
const seeds = game.GetSeeds();
|
|
24
28
|
|
|
25
29
|
if (exceptions === undefined) {
|
package/src/functions/set.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { isPrimitive } from "./types";
|
|
|
9
9
|
* This function is variadic, meaning that you can specify N sets to add to the first set.
|
|
10
10
|
*/
|
|
11
11
|
export function addSetsToSet<T>(
|
|
12
|
+
// eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
|
|
12
13
|
mainSet: Set<T>,
|
|
13
14
|
...setsToAdd: ReadonlyArray<ReadonlySet<T>>
|
|
14
15
|
): void {
|
|
@@ -54,6 +55,7 @@ export function copySet<T>(oldSet: ReadonlySet<T>): Set<T> {
|
|
|
54
55
|
* This function is variadic, meaning that you can specify N sets to remove from the first set.
|
|
55
56
|
*/
|
|
56
57
|
export function deleteSetsFromSet<T>(
|
|
58
|
+
// eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
|
|
57
59
|
mainSet: Set<T>,
|
|
58
60
|
...setsToRemove: ReadonlyArray<ReadonlySet<T>>
|
|
59
61
|
): void {
|
|
@@ -217,6 +219,7 @@ export function objectValuesToSet<K extends string | number | symbol, V>(
|
|
|
217
219
|
*
|
|
218
220
|
* This function is variadic, meaning that you can pass as many things as you want to add.
|
|
219
221
|
*/
|
|
222
|
+
// eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
|
|
220
223
|
export function setAdd<T>(set: Set<T>, ...elements: readonly T[]): void {
|
|
221
224
|
for (const element of elements) {
|
|
222
225
|
set.add(element);
|
package/src/functions/sort.ts
CHANGED
|
@@ -88,7 +88,10 @@ export function sortObjectArrayByKey(key: string) {
|
|
|
88
88
|
* From:
|
|
89
89
|
* https://stackoverflow.com/questions/16096872/how-to-sort-2-dimensional-array-by-column-value
|
|
90
90
|
*/
|
|
91
|
-
export function sortTwoDimensionalArray<T>(
|
|
91
|
+
export function sortTwoDimensionalArray<T>(
|
|
92
|
+
a: readonly T[],
|
|
93
|
+
b: readonly T[],
|
|
94
|
+
): -1 | 0 | 1 {
|
|
92
95
|
const aType = type(a);
|
|
93
96
|
const bType = type(b);
|
|
94
97
|
if (aType !== bType) {
|
|
@@ -148,6 +151,7 @@ export function sortTwoDimensionalArray<T>(a: T[], b: T[]): -1 | 0 | 1 {
|
|
|
148
151
|
*/
|
|
149
152
|
// eslint-disable-next-line isaacscript/no-mutable-return
|
|
150
153
|
export function stableSort<T>(
|
|
154
|
+
// eslint-disable-next-line isaacscript/prefer-readonly-parameter-types
|
|
151
155
|
array: T[],
|
|
152
156
|
sortFunc: (a: T, b: T) => -1 | 0 | 1 = sortNormal,
|
|
153
157
|
): T[] {
|
package/src/functions/stage.ts
CHANGED
|
@@ -362,7 +362,9 @@ export function onDarkRoom(): boolean {
|
|
|
362
362
|
*
|
|
363
363
|
* This function is variadic, which means you can pass as many stages as you want to match for.
|
|
364
364
|
*/
|
|
365
|
-
export function onEffectiveStage(
|
|
365
|
+
export function onEffectiveStage(
|
|
366
|
+
...effectiveStages: readonly LevelStage[]
|
|
367
|
+
): boolean {
|
|
366
368
|
const thisEffectiveStage = getEffectiveStage();
|
|
367
369
|
return effectiveStages.includes(thisEffectiveStage);
|
|
368
370
|
}
|
|
@@ -422,7 +424,7 @@ export function onSheol(): boolean {
|
|
|
422
424
|
*
|
|
423
425
|
* This function is variadic, which means you can pass as many stages as you want to match for.
|
|
424
426
|
*/
|
|
425
|
-
export function onStage(...stages: LevelStage[]): boolean {
|
|
427
|
+
export function onStage(...stages: readonly LevelStage[]): boolean {
|
|
426
428
|
const level = game.GetLevel();
|
|
427
429
|
const thisStage = level.GetStage();
|
|
428
430
|
return stages.includes(thisStage);
|
|
@@ -447,7 +449,7 @@ export function onStageOrLower(stage: LevelStage): boolean {
|
|
|
447
449
|
*
|
|
448
450
|
* This function is variadic, which means you can pass as many room types as you want to match for.
|
|
449
451
|
*/
|
|
450
|
-
export function onStageType(...stageTypes: StageType[]): boolean {
|
|
452
|
+
export function onStageType(...stageTypes: readonly StageType[]): boolean {
|
|
451
453
|
const level = game.GetLevel();
|
|
452
454
|
const thisStageType = level.GetStageType();
|
|
453
455
|
return stageTypes.includes(thisStageType);
|
package/src/functions/string.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReadonlyRecord } from "../types/ReadonlyRecord";
|
|
1
2
|
import { parseIntSafe } from "./types";
|
|
2
3
|
import { assertDefined } from "./utils";
|
|
3
4
|
|
|
@@ -81,7 +82,7 @@ export function getMapPartialMatch<T>(
|
|
|
81
82
|
*/
|
|
82
83
|
export function getObjectPartialMatch<T>(
|
|
83
84
|
searchText: string,
|
|
84
|
-
object:
|
|
85
|
+
object: ReadonlyRecord<string, T>,
|
|
85
86
|
): [string, T] | undefined {
|
|
86
87
|
const keys = Object.keys(object);
|
|
87
88
|
|
|
@@ -204,7 +205,7 @@ export function removeNonAlphanumericCharacters(str: string): string {
|
|
|
204
205
|
*/
|
|
205
206
|
export function removeSubstring(
|
|
206
207
|
string: string,
|
|
207
|
-
...substrings: string[]
|
|
208
|
+
...substrings: readonly string[]
|
|
208
209
|
): string {
|
|
209
210
|
for (const substring of substrings) {
|
|
210
211
|
string = string.replaceAll(substring, "");
|
package/src/functions/table.ts
CHANGED
|
@@ -43,7 +43,7 @@ export function copyUserdataValuesToTable(
|
|
|
43
43
|
export function getBooleansFromTable(
|
|
44
44
|
luaMap: LuaMap<string, unknown>,
|
|
45
45
|
objectName: string,
|
|
46
|
-
...keys: string[]
|
|
46
|
+
...keys: readonly string[]
|
|
47
47
|
): readonly boolean[] {
|
|
48
48
|
const booleans: boolean[] = [];
|
|
49
49
|
for (const key of keys) {
|
|
@@ -75,7 +75,7 @@ export function getBooleansFromTable(
|
|
|
75
75
|
export function getNumbersFromTable(
|
|
76
76
|
luaMap: LuaMap<string, unknown>,
|
|
77
77
|
objectName: string,
|
|
78
|
-
...keys: string[]
|
|
78
|
+
...keys: readonly string[]
|
|
79
79
|
): readonly number[] {
|
|
80
80
|
const numbers: number[] = [];
|
|
81
81
|
for (const key of keys) {
|
|
@@ -114,7 +114,7 @@ export function getNumbersFromTable(
|
|
|
114
114
|
export function getStringsFromTable(
|
|
115
115
|
luaMap: LuaMap<string, unknown>,
|
|
116
116
|
objectName: string,
|
|
117
|
-
...keys: string[]
|
|
117
|
+
...keys: readonly string[]
|
|
118
118
|
): readonly string[] {
|
|
119
119
|
const strings: string[] = [];
|
|
120
120
|
for (const key of keys) {
|
|
@@ -204,7 +204,7 @@ export function iterateTableInOrder<K extends AnyNotNil, V>(
|
|
|
204
204
|
*/
|
|
205
205
|
export function tableHasKeys(
|
|
206
206
|
luaMap: LuaMap<AnyNotNil, unknown>,
|
|
207
|
-
...keys: string[]
|
|
207
|
+
...keys: readonly string[]
|
|
208
208
|
): boolean {
|
|
209
209
|
return keys.every((key) => luaMap.has(key));
|
|
210
210
|
}
|
|
@@ -88,7 +88,7 @@ export function smeltTrinket(
|
|
|
88
88
|
*/
|
|
89
89
|
export function smeltTrinkets(
|
|
90
90
|
player: EntityPlayer,
|
|
91
|
-
...trinketTypes: TrinketType[]
|
|
91
|
+
...trinketTypes: readonly TrinketType[]
|
|
92
92
|
): void {
|
|
93
93
|
for (const trinketType of trinketTypes) {
|
|
94
94
|
smeltTrinket(player, trinketType);
|
package/src/functions/utils.ts
CHANGED
|
@@ -228,4 +228,4 @@ export function repeat(num: int, func: (i: int) => void): void {
|
|
|
228
228
|
* @allowEmptyVariadic
|
|
229
229
|
*/
|
|
230
230
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
|
|
231
|
-
export function todo(...args: unknown[]): void {}
|
|
231
|
+
export function todo(...args: readonly unknown[]): void {}
|
package/src/functions/vector.ts
CHANGED
|
@@ -86,7 +86,7 @@ export function doesVectorHaveLength(
|
|
|
86
86
|
*/
|
|
87
87
|
export function getClosestVectorTo(
|
|
88
88
|
referenceVector: Vector,
|
|
89
|
-
vectors: Vector[],
|
|
89
|
+
vectors: readonly Vector[],
|
|
90
90
|
): Vector | undefined {
|
|
91
91
|
let closestVector: Vector | undefined;
|
|
92
92
|
let closestDistance = math.huge;
|
|
@@ -17,7 +17,7 @@ import { assertDefined } from "./utils";
|
|
|
17
17
|
* a random seed.
|
|
18
18
|
*/
|
|
19
19
|
export function getRandomFromWeightedArray<T>(
|
|
20
|
-
weightedArray: WeightedArray<T
|
|
20
|
+
weightedArray: Readonly<WeightedArray<T>>,
|
|
21
21
|
seedOrRNG: Seed | RNG | undefined,
|
|
22
22
|
): T {
|
|
23
23
|
const randomIndex = getRandomIndexFromWeightedArray(weightedArray, seedOrRNG);
|
|
@@ -45,7 +45,7 @@ export function getRandomFromWeightedArray<T>(
|
|
|
45
45
|
* a random seed.
|
|
46
46
|
*/
|
|
47
47
|
export function getRandomIndexFromWeightedArray<T>(
|
|
48
|
-
weightedArray: WeightedArray<T
|
|
48
|
+
weightedArray: Readonly<WeightedArray<T>>,
|
|
49
49
|
seedOrRNG: Seed | RNG | undefined,
|
|
50
50
|
): int {
|
|
51
51
|
if (weightedArray.length === 0) {
|
package/src/index.ts
CHANGED
|
@@ -185,6 +185,7 @@ export * from "./types/PlayerIndex";
|
|
|
185
185
|
export * from "./types/PossibleStatType";
|
|
186
186
|
export * from "./types/PublicInterface";
|
|
187
187
|
export * from "./types/ReadonlyMap";
|
|
188
|
+
export * from "./types/ReadonlyRecord";
|
|
188
189
|
export * from "./types/ReadonlySet";
|
|
189
190
|
export * from "./types/StartsWithLowercase";
|
|
190
191
|
export * from "./types/StartsWithUppercase";
|
package/src/types/AnyFunction.ts
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Helper type to represent any function. This is safer than using the built-in `Function` type, as
|
|
3
3
|
* it does not completely turn off all type safety.
|
|
4
4
|
*/
|
|
5
|
-
export type AnyFunction = (...args: unknown[]) => unknown;
|
|
5
|
+
export type AnyFunction = (...args: readonly unknown[]) => unknown;
|