isaacscript-common 87.6.2 → 87.8.0

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.
Files changed (68) hide show
  1. package/dist/classes/ModUpgraded.lua +4 -4
  2. package/dist/classes/callbacks/InputActionFilter.lua +2 -2
  3. package/dist/classes/callbacks/InputActionPlayer.lua +2 -2
  4. package/dist/classes/callbacks/PostCollectibleEmpty.lua +2 -2
  5. package/dist/classes/callbacks/PostCursedTeleport.lua +2 -2
  6. package/dist/classes/callbacks/PostCustomRevive.lua +2 -2
  7. package/dist/classes/callbacks/PostDiceRoomActivated.lua +2 -2
  8. package/dist/classes/callbacks/PostGridEntityCollision.lua +2 -2
  9. package/dist/classes/callbacks/PostGridEntityCustomCollision.lua +2 -2
  10. package/dist/classes/callbacks/PostGridEntityCustomRemove.lua +2 -2
  11. package/dist/classes/callbacks/PostGridEntityRemove.lua +2 -2
  12. package/dist/classes/callbacks/PostItemDischarge.lua +2 -2
  13. package/dist/classes/callbacks/PostKeyboardChanged.lua +2 -2
  14. package/dist/classes/callbacks/PostPickupSelectionFilter.lua +2 -2
  15. package/dist/classes/callbacks/PostPurchase.lua +2 -2
  16. package/dist/classes/callbacks/PostRoomClearChanged.lua +2 -2
  17. package/dist/classes/callbacks/PostTransformation.lua +2 -2
  18. package/dist/classes/callbacks/PreEntitySpawnFilter.lua +2 -2
  19. package/dist/classes/callbacks/PreRoomEntitySpawnFilter.lua +2 -2
  20. package/dist/classes/features/callbackLogic/GridEntityUpdateDetection.lua +2 -2
  21. package/dist/classes/features/other/DeployJSONRoom.lua +1 -1
  22. package/dist/classes/features/other/ExtraConsoleCommands.lua +1 -1
  23. package/dist/classes/features/other/NoSirenSteal.lua +1 -1
  24. package/dist/classes/features/other/PersistentEntities.lua +1 -1
  25. package/dist/classes/features/other/extraConsoleCommands/commands.lua +5 -5
  26. package/dist/functions/array.d.ts +3 -17
  27. package/dist/functions/array.d.ts.map +1 -1
  28. package/dist/functions/array.js +13 -31
  29. package/dist/functions/array.lua +45 -61
  30. package/dist/functions/bitSet128.lua +10 -6
  31. package/dist/functions/color.lua +10 -6
  32. package/dist/functions/debugFunctions.d.ts.map +1 -1
  33. package/dist/functions/debugFunctions.js +0 -1
  34. package/dist/functions/doors.lua +1 -1
  35. package/dist/functions/entities.lua +8 -4
  36. package/dist/functions/globals.lua +1 -1
  37. package/dist/functions/gridEntities.lua +1 -1
  38. package/dist/functions/input.lua +1 -1
  39. package/dist/functions/kColor.lua +10 -6
  40. package/dist/functions/logMisc.lua +0 -1
  41. package/dist/functions/map.d.ts +1 -1
  42. package/dist/functions/map.d.ts.map +1 -1
  43. package/dist/functions/map.js +0 -1
  44. package/dist/functions/rng.lua +10 -6
  45. package/dist/functions/roomShapeWalls.lua +5 -5
  46. package/dist/functions/set.d.ts +1 -1
  47. package/dist/functions/set.d.ts.map +1 -1
  48. package/dist/functions/set.js +0 -4
  49. package/dist/functions/sort.d.ts.map +1 -1
  50. package/dist/functions/sort.js +0 -1
  51. package/dist/functions/utils.d.ts +11 -1
  52. package/dist/functions/utils.d.ts.map +1 -1
  53. package/dist/functions/utils.js +19 -1
  54. package/dist/functions/utils.lua +17 -1
  55. package/dist/functions/vector.lua +10 -6
  56. package/dist/functions/weighted.lua +1 -1
  57. package/dist/index.rollup.d.ts +17 -21
  58. package/dist/isaacscript-common.lua +8184 -8126
  59. package/dist/maps/entityTypeVariantToBossIDMap.lua +1 -1
  60. package/dist/shouldFire.lua +56 -56
  61. package/dist/tsdoc-metadata.json +1 -1
  62. package/package.json +7 -10
  63. package/src/functions/array.ts +9 -33
  64. package/src/functions/debugFunctions.ts +0 -1
  65. package/src/functions/map.ts +1 -2
  66. package/src/functions/set.ts +6 -5
  67. package/src/functions/sort.ts +1 -1
  68. package/src/functions/utils.ts +19 -1
@@ -17,7 +17,7 @@ ____exports.ENTITY_TYPE_VARIANT_TO_BOSS_ID_MAP = __TS__New(
17
17
  bossIDRaw = ____bindingPattern0[1]
18
18
  entityTypeVariant = ____bindingPattern0[2]
19
19
  local bossID = bossIDRaw
20
- local entityType, variant = table.unpack(entityTypeVariant)
20
+ local entityType, variant = table.unpack(entityTypeVariant, 1, 2)
21
21
  local entityTypeVariantString = (tostring(entityType) .. ".") .. tostring(variant)
22
22
  return {entityTypeVariantString, bossID}
23
23
  end
@@ -1,153 +1,153 @@
1
1
  local ____exports = {}
2
2
  function ____exports.shouldFireAmbush(self, fireArgs, optionalArgs)
3
- local ambushType = table.unpack(fireArgs)
4
- local callbackAmbushType = table.unpack(optionalArgs)
3
+ local ambushType = table.unpack(fireArgs, 1, 1)
4
+ local callbackAmbushType = table.unpack(optionalArgs, 1, 1)
5
5
  return callbackAmbushType == nil or callbackAmbushType == ambushType
6
6
  end
7
7
  function ____exports.shouldFireBomb(self, fireArgs, optionalArgs)
8
- local bomb = table.unpack(fireArgs)
9
- local callbackBombVariant, callbackSubType = table.unpack(optionalArgs)
8
+ local bomb = table.unpack(fireArgs, 1, 1)
9
+ local callbackBombVariant, callbackSubType = table.unpack(optionalArgs, 1, 2)
10
10
  return (callbackBombVariant == nil or callbackBombVariant == bomb.Variant) and (callbackSubType == nil or callbackSubType == bomb.SubType)
11
11
  end
12
12
  function ____exports.shouldFireBoolean(self, fireArgs, optionalArgs)
13
- local fireArg = table.unpack(fireArgs)
14
- local optionalArg = table.unpack(optionalArgs)
13
+ local fireArg = table.unpack(fireArgs, 1, 1)
14
+ local optionalArg = table.unpack(optionalArgs, 1, 1)
15
15
  return optionalArg == nil or optionalArg == fireArg
16
16
  end
17
17
  function ____exports.shouldFireCollectibleType(self, fireArgs, optionalArgs)
18
- local _player, collectibleType = table.unpack(fireArgs)
19
- local callbackCollectibleType = table.unpack(optionalArgs)
18
+ local _player, collectibleType = table.unpack(fireArgs, 1, 2)
19
+ local callbackCollectibleType = table.unpack(optionalArgs, 1, 1)
20
20
  return callbackCollectibleType == nil or callbackCollectibleType == collectibleType
21
21
  end
22
22
  function ____exports.shouldFireDoor(self, fireArgs, optionalArgs)
23
- local door = table.unpack(fireArgs)
24
- local callbackDoorVariant = table.unpack(optionalArgs)
23
+ local door = table.unpack(fireArgs, 1, 1)
24
+ local callbackDoorVariant = table.unpack(optionalArgs, 1, 1)
25
25
  local doorVariant = door:GetVariant()
26
26
  return callbackDoorVariant == nil or callbackDoorVariant == doorVariant
27
27
  end
28
28
  function ____exports.shouldFireEffect(self, fireArgs, optionalArgs)
29
- local effect = table.unpack(fireArgs)
30
- local callbackEffectVariant, callbackSubType = table.unpack(optionalArgs)
29
+ local effect = table.unpack(fireArgs, 1, 1)
30
+ local callbackEffectVariant, callbackSubType = table.unpack(optionalArgs, 1, 2)
31
31
  return (callbackEffectVariant == nil or callbackEffectVariant == effect.Variant) and (callbackSubType == nil or callbackSubType == effect.SubType)
32
32
  end
33
33
  function ____exports.shouldFireEntity(self, fireArgs, optionalArgs)
34
- local entity = table.unpack(fireArgs)
35
- local callbackEntityType, callbackVariant, callbackSubType = table.unpack(optionalArgs)
34
+ local entity = table.unpack(fireArgs, 1, 1)
35
+ local callbackEntityType, callbackVariant, callbackSubType = table.unpack(optionalArgs, 1, 3)
36
36
  return (callbackEntityType == nil or callbackEntityType == entity.Type) and (callbackVariant == nil or callbackVariant == entity.Variant) and (callbackSubType == nil or callbackSubType == entity.SubType)
37
37
  end
38
38
  function ____exports.shouldFireFamiliar(self, fireArgs, optionalArgs)
39
- local familiar = table.unpack(fireArgs)
40
- local callbackFamiliarVariant, callbackSubType = table.unpack(optionalArgs)
39
+ local familiar = table.unpack(fireArgs, 1, 1)
40
+ local callbackFamiliarVariant, callbackSubType = table.unpack(optionalArgs, 1, 2)
41
41
  return (callbackFamiliarVariant == nil or callbackFamiliarVariant == familiar.Variant) and (callbackSubType == nil or callbackSubType == familiar.SubType)
42
42
  end
43
43
  function ____exports.shouldFireGridEntity(self, fireArgs, optionalArgs)
44
- local gridEntity = table.unpack(fireArgs)
45
- local callbackGridEntityType, callbackVariant = table.unpack(optionalArgs)
44
+ local gridEntity = table.unpack(fireArgs, 1, 1)
45
+ local callbackGridEntityType, callbackVariant = table.unpack(optionalArgs, 1, 2)
46
46
  local gridEntityType = gridEntity:GetType()
47
47
  local variant = gridEntity:GetVariant()
48
48
  return (callbackGridEntityType == nil or callbackGridEntityType == gridEntityType) and (callbackVariant == nil or callbackVariant == variant)
49
49
  end
50
50
  function ____exports.shouldFireGridEntityCustom(self, fireArgs, optionalArgs)
51
- local _gridEntity, gridEntityTypeCustom = table.unpack(fireArgs)
52
- local callbackGridEntityTypeCustom = table.unpack(optionalArgs)
51
+ local _gridEntity, gridEntityTypeCustom = table.unpack(fireArgs, 1, 2)
52
+ local callbackGridEntityTypeCustom = table.unpack(optionalArgs, 1, 1)
53
53
  return callbackGridEntityTypeCustom == nil or callbackGridEntityTypeCustom == gridEntityTypeCustom
54
54
  end
55
55
  function ____exports.shouldFireItemPickup(self, fireArgs, optionalArgs)
56
- local _player, pickingUpItem = table.unpack(fireArgs)
57
- local callbackItemType, callbackSubtype = table.unpack(optionalArgs)
56
+ local _player, pickingUpItem = table.unpack(fireArgs, 1, 2)
57
+ local callbackItemType, callbackSubtype = table.unpack(optionalArgs, 1, 2)
58
58
  return (callbackItemType == nil or callbackItemType == pickingUpItem.itemType) and (callbackSubtype == nil or callbackSubtype == pickingUpItem.subType)
59
59
  end
60
60
  function ____exports.shouldFireKnife(self, fireArgs, optionalArgs)
61
- local knife = table.unpack(fireArgs)
62
- local callbackKnifeVariant, callbackSubType = table.unpack(optionalArgs)
61
+ local knife = table.unpack(fireArgs, 1, 1)
62
+ local callbackKnifeVariant, callbackSubType = table.unpack(optionalArgs, 1, 2)
63
63
  return (callbackKnifeVariant == nil or callbackKnifeVariant == knife.Variant) and (callbackSubType == nil or callbackSubType == knife.SubType)
64
64
  end
65
65
  function ____exports.shouldFireLaser(self, fireArgs, optionalArgs)
66
- local laser = table.unpack(fireArgs)
67
- local callbackLaserVariant, callbackSubType = table.unpack(optionalArgs)
66
+ local laser = table.unpack(fireArgs, 1, 1)
67
+ local callbackLaserVariant, callbackSubType = table.unpack(optionalArgs, 1, 2)
68
68
  return (callbackLaserVariant == nil or callbackLaserVariant == laser.Variant) and (callbackSubType == nil or callbackSubType == laser.SubType)
69
69
  end
70
70
  function ____exports.shouldFireLevel(self, fireArgs, optionalArgs)
71
- local stage, stageType = table.unpack(fireArgs)
72
- local callbackStage, callbackStageType = table.unpack(optionalArgs)
71
+ local stage, stageType = table.unpack(fireArgs, 1, 2)
72
+ local callbackStage, callbackStageType = table.unpack(optionalArgs, 1, 2)
73
73
  return (callbackStage == nil or callbackStage == stage) and (callbackStageType == nil or callbackStageType == stageType)
74
74
  end
75
75
  function ____exports.shouldFireNPC(self, fireArgs, optionalArgs)
76
- local npc = table.unpack(fireArgs)
77
- local callbackEntityType, callbackVariant, callbackSubType = table.unpack(optionalArgs)
76
+ local npc = table.unpack(fireArgs, 1, 1)
77
+ local callbackEntityType, callbackVariant, callbackSubType = table.unpack(optionalArgs, 1, 3)
78
78
  return (callbackEntityType == nil or callbackEntityType == npc.Type) and (callbackVariant == nil or callbackVariant == npc.Variant) and (callbackSubType == nil or callbackSubType == npc.SubType)
79
79
  end
80
80
  function ____exports.shouldFirePickup(self, fireArgs, optionalArgs)
81
- local pickup = table.unpack(fireArgs)
82
- local callbackPickupVariant, callbackPickupSubType = table.unpack(optionalArgs)
81
+ local pickup = table.unpack(fireArgs, 1, 1)
82
+ local callbackPickupVariant, callbackPickupSubType = table.unpack(optionalArgs, 1, 2)
83
83
  return (callbackPickupVariant == nil or callbackPickupVariant == pickup.Variant) and (callbackPickupSubType == nil or callbackPickupSubType == pickup.SubType)
84
84
  end
85
85
  function ____exports.shouldFirePit(self, fireArgs, optionalArgs)
86
- local pit = table.unpack(fireArgs)
87
- local callbackPitVariant = table.unpack(optionalArgs)
86
+ local pit = table.unpack(fireArgs, 1, 1)
87
+ local callbackPitVariant = table.unpack(optionalArgs, 1, 1)
88
88
  local pitVariant = pit:GetVariant()
89
89
  return callbackPitVariant == nil or callbackPitVariant == pitVariant
90
90
  end
91
91
  function ____exports.shouldFirePlayer(self, fireArgs, optionalArgs)
92
- local player = table.unpack(fireArgs)
93
- local callbackPlayerVariant, callbackCharacter = table.unpack(optionalArgs)
92
+ local player = table.unpack(fireArgs, 1, 1)
93
+ local callbackPlayerVariant, callbackCharacter = table.unpack(optionalArgs, 1, 2)
94
94
  local character = player:GetPlayerType()
95
95
  return (callbackPlayerVariant == nil or callbackPlayerVariant == player.Variant) and (callbackCharacter == nil or callbackCharacter == character)
96
96
  end
97
97
  function ____exports.shouldFirePoop(self, fireArgs, optionalArgs)
98
- local poop = table.unpack(fireArgs)
99
- local callbackPoopGridEntityVariant = table.unpack(optionalArgs)
98
+ local poop = table.unpack(fireArgs, 1, 1)
99
+ local callbackPoopGridEntityVariant = table.unpack(optionalArgs, 1, 1)
100
100
  local poopGridEntityVariant = poop:GetVariant()
101
101
  return callbackPoopGridEntityVariant == nil or callbackPoopGridEntityVariant == poopGridEntityVariant
102
102
  end
103
103
  function ____exports.shouldFirePressurePlate(self, fireArgs, optionalArgs)
104
- local pressurePlate = table.unpack(fireArgs)
105
- local callbackPressurePlateVariant = table.unpack(optionalArgs)
104
+ local pressurePlate = table.unpack(fireArgs, 1, 1)
105
+ local callbackPressurePlateVariant = table.unpack(optionalArgs, 1, 1)
106
106
  local pressurePlateVariant = pressurePlate:GetVariant()
107
107
  return callbackPressurePlateVariant == nil or callbackPressurePlateVariant == pressurePlateVariant
108
108
  end
109
109
  function ____exports.shouldFireProjectile(self, fireArgs, optionalArgs)
110
- local projectile = table.unpack(fireArgs)
111
- local callbackProjectileVariant, callbackSubType = table.unpack(optionalArgs)
110
+ local projectile = table.unpack(fireArgs, 1, 1)
111
+ local callbackProjectileVariant, callbackSubType = table.unpack(optionalArgs, 1, 2)
112
112
  return (callbackProjectileVariant == nil or callbackProjectileVariant == projectile.Variant) and (callbackSubType == nil or callbackSubType == projectile.SubType)
113
113
  end
114
114
  function ____exports.shouldFireRock(self, fireArgs, optionalArgs)
115
- local rock = table.unpack(fireArgs)
116
- local callbackGridEntity, callbackVariant = table.unpack(optionalArgs)
115
+ local rock = table.unpack(fireArgs, 1, 1)
116
+ local callbackGridEntity, callbackVariant = table.unpack(optionalArgs, 1, 2)
117
117
  local gridEntityType = rock:GetType()
118
118
  local variant = rock:GetVariant()
119
119
  return (callbackGridEntity == nil or callbackGridEntity == gridEntityType) and (callbackVariant == nil or callbackVariant == variant)
120
120
  end
121
121
  function ____exports.shouldFireRoom(self, fireArgs, optionalArgs)
122
- local roomType = table.unpack(fireArgs)
123
- local callbackRoomType = table.unpack(optionalArgs)
122
+ local roomType = table.unpack(fireArgs, 1, 1)
123
+ local callbackRoomType = table.unpack(optionalArgs, 1, 1)
124
124
  return callbackRoomType == nil or callbackRoomType == roomType
125
125
  end
126
126
  function ____exports.shouldFireSlot(self, fireArgs, optionalArgs)
127
- local slot = table.unpack(fireArgs)
128
- local callbackSlotVariant, callbackSubType = table.unpack(optionalArgs)
127
+ local slot = table.unpack(fireArgs, 1, 1)
128
+ local callbackSlotVariant, callbackSubType = table.unpack(optionalArgs, 1, 2)
129
129
  return (callbackSlotVariant == nil or callbackSlotVariant == slot.Variant) and (callbackSubType == nil or callbackSubType == slot.SubType)
130
130
  end
131
131
  function ____exports.shouldFireSpikes(self, fireArgs, optionalArgs)
132
- local spikes = table.unpack(fireArgs)
133
- local callbackVariant = table.unpack(optionalArgs)
132
+ local spikes = table.unpack(fireArgs, 1, 1)
133
+ local callbackVariant = table.unpack(optionalArgs, 1, 1)
134
134
  local variant = spikes:GetVariant()
135
135
  return callbackVariant == nil or callbackVariant == variant
136
136
  end
137
137
  function ____exports.shouldFireTNT(self, fireArgs, optionalArgs)
138
- local tnt = table.unpack(fireArgs)
139
- local callbackVariant = table.unpack(optionalArgs)
138
+ local tnt = table.unpack(fireArgs, 1, 1)
139
+ local callbackVariant = table.unpack(optionalArgs, 1, 1)
140
140
  local variant = tnt:GetVariant()
141
141
  return callbackVariant == nil or callbackVariant == variant
142
142
  end
143
143
  function ____exports.shouldFireTear(self, fireArgs, optionalArgs)
144
- local tear = table.unpack(fireArgs)
145
- local callbackTearVariant, callbackSubType = table.unpack(optionalArgs)
144
+ local tear = table.unpack(fireArgs, 1, 1)
145
+ local callbackTearVariant, callbackSubType = table.unpack(optionalArgs, 1, 2)
146
146
  return (callbackTearVariant == nil or callbackTearVariant == tear.Variant) and (callbackSubType == nil or callbackSubType == tear.SubType)
147
147
  end
148
148
  function ____exports.shouldFireTrinketType(self, fireArgs, optionalArgs)
149
- local _player, trinketType = table.unpack(fireArgs)
150
- local callbackTrinketType = table.unpack(optionalArgs)
149
+ local _player, trinketType = table.unpack(fireArgs, 1, 2)
150
+ local callbackTrinketType = table.unpack(optionalArgs, 1, 1)
151
151
  return callbackTrinketType == nil or callbackTrinketType == trinketType
152
152
  end
153
153
  return ____exports
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.9"
8
+ "packageVersion": "7.52.13"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "87.6.2",
3
+ "version": "87.8.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,10 +26,7 @@
26
26
  "types": "./dist/index.rollup.d.ts",
27
27
  "files": [
28
28
  "dist",
29
- "src",
30
- "LICENSE",
31
- "package.json",
32
- "README.md"
29
+ "src"
33
30
  ],
34
31
  "scripts": {
35
32
  "build": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/build.mts",
@@ -37,13 +34,13 @@
37
34
  "lint": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/lint.mts"
38
35
  },
39
36
  "dependencies": {
40
- "isaac-typescript-definitions": "42.2.1"
37
+ "isaac-typescript-definitions": "42.3.0"
41
38
  },
42
39
  "devDependencies": {
43
- "@microsoft/api-extractor": "7.52.9",
44
- "complete-node": "7.4.3",
40
+ "@microsoft/api-extractor": "7.52.13",
41
+ "complete-node": "12.0.0",
45
42
  "eslint-plugin-sort-exports": "0.9.1",
46
- "typescript-eslint": "8.38.0",
47
- "typescript-to-lua": "1.31.4"
43
+ "typescript-eslint": "8.43.0",
44
+ "typescript-to-lua": "1.32.0"
48
45
  }
49
46
  }
@@ -29,16 +29,14 @@ export function arrayEquals<T>(
29
29
  * array. If the specified element(s) are not found in the array, it will simply return a shallow
30
30
  * copy of the array.
31
31
  *
32
- * This function is variadic, meaning that you can specify N arguments to remove N elements.
32
+ * If there is more than one matching element in the array, this function will remove all of them.
33
33
  *
34
- * If there is more than one matching element in the array, this function will only remove the first
35
- * matching element. If you want to remove all of the elements, use the `arrayRemoveAll` function
36
- * instead.
34
+ * This function is variadic, meaning that you can specify N arguments to remove N elements.
37
35
  */
38
- // eslint-disable-next-line complete/no-mutable-return
39
36
  export function arrayRemove<T>(
40
37
  originalArray: readonly T[],
41
38
  ...elementsToRemove: readonly T[]
39
+ // eslint-disable-next-line complete/no-mutable-return
42
40
  ): T[] {
43
41
  const elementsToRemoveSet = new ReadonlySet(elementsToRemove);
44
42
 
@@ -52,27 +50,6 @@ export function arrayRemove<T>(
52
50
  return array;
53
51
  }
54
52
 
55
- /**
56
- * Shallow copies and removes the specified element(s) from the array. Returns the copied array. If
57
- * the specified element(s) are not found in the array, it will simply return a shallow copy of the
58
- * array.
59
- *
60
- * This function is variadic, meaning that you can specify N arguments to remove N elements.
61
- *
62
- * If there is more than one matching element in the array, this function will remove every matching
63
- * element. If you want to only remove the first matching element, use the `arrayRemove` function
64
- * instead.
65
- */
66
- // eslint-disable-next-line complete/no-mutable-return
67
- export function arrayRemoveAll<T>(
68
- originalArray: readonly T[],
69
- ...elementsToRemove: readonly T[]
70
- ): T[] {
71
- const array = copyArray(originalArray);
72
- arrayRemoveAllInPlace(array, ...elementsToRemove);
73
- return array;
74
- }
75
-
76
53
  /**
77
54
  * Removes all of the specified element(s) from the array. If the specified element(s) are not found
78
55
  * in the array, this function will do nothing.
@@ -118,11 +95,11 @@ export function arrayRemoveAllInPlace<T>(
118
95
  *
119
96
  * @returns The removed elements. This will be an empty array if no elements were removed.
120
97
  */
121
- // eslint-disable-next-line complete/no-mutable-return
122
98
  export function arrayRemoveInPlace<T>(
123
99
  // eslint-disable-next-line complete/prefer-readonly-parameter-types
124
100
  array: T[],
125
101
  ...elementsToRemove: readonly T[]
102
+ // eslint-disable-next-line complete/no-mutable-return
126
103
  ): T[] {
127
104
  const removedElements: T[] = [];
128
105
 
@@ -144,10 +121,10 @@ export function arrayRemoveInPlace<T>(
144
121
  *
145
122
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
146
123
  */
147
- // eslint-disable-next-line complete/no-mutable-return
148
124
  export function arrayRemoveIndex<T>(
149
125
  originalArray: readonly T[],
150
126
  ...indexesToRemove: readonly int[]
127
+ // eslint-disable-next-line complete/no-mutable-return
151
128
  ): T[] {
152
129
  const indexesToRemoveSet = new ReadonlySet(indexesToRemove);
153
130
 
@@ -169,11 +146,11 @@ export function arrayRemoveIndex<T>(
169
146
  *
170
147
  * @returns The removed elements. This will be an empty array if no elements were removed.
171
148
  */
172
- // eslint-disable-next-line complete/no-mutable-return
173
149
  export function arrayRemoveIndexInPlace<T>(
174
150
  // eslint-disable-next-line complete/prefer-readonly-parameter-types
175
151
  array: T[],
176
152
  ...indexesToRemove: readonly int[]
153
+ // eslint-disable-next-line complete/no-mutable-return
177
154
  ): T[] {
178
155
  const legalIndexes = indexesToRemove.filter(
179
156
  (i) => i >= 0 && i < array.length,
@@ -266,11 +243,10 @@ export function emptyArray(array: unknown[]): void {
266
243
  * This is named `filterMap` after the Rust function:
267
244
  * https://doc.rust-lang.org/std/iter/struct.FilterMap.html
268
245
  */
269
- // eslint-disable-next-line complete/no-mutable-return
270
246
  export function filterMap<OldT, NewT>(
271
247
  array: readonly OldT[],
272
248
  func: (element: OldT) => NewT | undefined,
273
- ): NewT[] {
249
+ ): readonly NewT[] {
274
250
  const filteredArray: NewT[] = [];
275
251
 
276
252
  for (const element of array) {
@@ -375,7 +351,7 @@ export function getArrayDuplicateElements<T extends number | string>(
375
351
  }
376
352
 
377
353
  const values = [...duplicateElements];
378
- return values.sort(sortNormal);
354
+ return values.toSorted(sortNormal);
379
355
  }
380
356
 
381
357
  /**
@@ -647,10 +623,10 @@ export function setAllArrayElements<T>(array: T[], value: T): void {
647
623
  * `RNG.Next` method will be called. If `undefined` is provided, it will default to
648
624
  * a random seed.
649
625
  */
650
- // eslint-disable-next-line complete/no-mutable-return
651
626
  export function shuffleArray<T>(
652
627
  originalArray: readonly T[],
653
628
  seedOrRNG: Seed | RNG | undefined,
629
+ // eslint-disable-next-line complete/no-mutable-return
654
630
  ): T[] {
655
631
  const array = copyArray(originalArray);
656
632
  shuffleArrayInPlace(array, seedOrRNG);
@@ -42,7 +42,6 @@ export function getTime(useSocketIfAvailable = true): int | float {
42
42
  }
43
43
 
44
44
  if (isLuaDebugEnabled()) {
45
- // eslint-disable-next-line unicorn/prefer-module
46
45
  const [ok, requiredSocket] = pcall(require, "socket");
47
46
  if (ok) {
48
47
  const socket = requiredSocket as Socket;
@@ -101,10 +101,9 @@ export function mapSetHash<V>(
101
101
  *
102
102
  * Also see the `objectToReadonlyMap` function.
103
103
  */
104
- // eslint-disable-next-line complete/no-mutable-return
105
104
  export function objectToMap<K extends string | number | symbol, V>(
106
105
  object: Record<K, V>,
107
- ): Map<K, V> {
106
+ ): ReadonlyMap<K, V> {
108
107
  const map = new Map<K, V>();
109
108
 
110
109
  for (const [key, value] of Object.entries(object)) {
@@ -26,8 +26,9 @@ export function addSetsToSet<T>(
26
26
  *
27
27
  * This function is variadic, meaning that you can specify N sets.
28
28
  */
29
- // eslint-disable-next-line complete/no-mutable-return
30
- export function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>): Set<T> {
29
+ export function combineSets<T>(
30
+ ...sets: ReadonlyArray<ReadonlySet<T>>
31
+ ): ReadonlySet<T> {
31
32
  const newSet = new Set<T>();
32
33
  for (const set of sets) {
33
34
  for (const value of set) {
@@ -123,9 +124,9 @@ export function getSetCombinations<T extends number | string>(
123
124
  * Normally, set values are returned in insertion order, so use this function when the ordering of
124
125
  * the contents is important.
125
126
  */
126
- // eslint-disable-next-line complete/no-mutable-return
127
127
  export function getSortedSetValues<T extends number | string>(
128
128
  set: ReadonlySet<T>,
129
+ // eslint-disable-next-line complete/no-mutable-return
129
130
  ): T[] {
130
131
  const values = [...set];
131
132
 
@@ -167,9 +168,9 @@ export function objectKeysToReadonlySet<K extends string | number | symbol, V>(
167
168
  *
168
169
  * Also see the `objectKeysToReadonlySet` function.
169
170
  */
170
- // eslint-disable-next-line complete/no-mutable-return
171
171
  export function objectKeysToSet<K extends string | number | symbol, V>(
172
172
  object: Record<K, V>,
173
+ // eslint-disable-next-line complete/no-mutable-return
173
174
  ): Set<K> {
174
175
  const set = new Set<K>();
175
176
 
@@ -203,9 +204,9 @@ export function objectValuesToReadonlySet<
203
204
  *
204
205
  * Also see the `objectValuesToReadonlySet` function.
205
206
  */
206
- // eslint-disable-next-line complete/no-mutable-return
207
207
  export function objectValuesToSet<K extends string | number | symbol, V>(
208
208
  object: Record<K, V>,
209
+ // eslint-disable-next-line complete/no-mutable-return
209
210
  ): Set<V> {
210
211
  const set = new Set<V>();
211
212
 
@@ -149,11 +149,11 @@ export function sortTwoDimensionalArray<T>(
149
149
  *
150
150
  * Under the hood, this uses the merge sort algorithm.
151
151
  */
152
- // eslint-disable-next-line complete/no-mutable-return
153
152
  export function stableSort<T>(
154
153
  // eslint-disable-next-line complete/prefer-readonly-parameter-types
155
154
  array: T[],
156
155
  sortFunc: (a: T, b: T) => -1 | 0 | 1 = sortNormal,
156
+ // eslint-disable-next-line complete/no-mutable-return
157
157
  ): T[] {
158
158
  // Base case: an array of zero or one elements is already sorted
159
159
  if (array.length <= 1) {
@@ -1,3 +1,4 @@
1
+ import { game } from "../core/cachedClasses";
1
2
  import { ReadonlySet } from "../types/ReadonlySet";
2
3
  import { getAllPlayers } from "./playerIndex";
3
4
  import { isFunction } from "./types";
@@ -155,7 +156,7 @@ export function isMultiplayer(): boolean {
155
156
  }
156
157
 
157
158
  /**
158
- * Helper function to check if the player is using Afterbirth+ or Repentance.
159
+ * Helper function to check if the player has the Repentance DLC installed.
159
160
  *
160
161
  * This function should always be used over the `REPENTANCE` constant, since the latter is not safe.
161
162
  *
@@ -181,6 +182,23 @@ export function isRepentance(): boolean {
181
182
  return isFunction(getAnimation);
182
183
  }
183
184
 
185
+ /**
186
+ * Helper function to check if the player has the Repentance+ DLC installed.
187
+ *
188
+ * This function should always be used over the `REPENTANCE_PLUS` constant, since the latter is not
189
+ * safe.
190
+ *
191
+ * Specifically, this function checks for `Room:DamageGridWithSource` method:
192
+ * https://bindingofisaacrebirth.wiki.gg/wiki/The_Binding_of_Isaac:_Repentance%2B#Modding_Changes
193
+ */
194
+ export function isRepentancePlus(): boolean {
195
+ const room = game.GetRoom();
196
+ const metatable = getmetatable(room) as LuaMap<string, unknown> | undefined;
197
+ assertDefined(metatable, "Failed to get the metatable of the room class.");
198
+ const damageGridWithSource = metatable.get("DamageGridWithSource");
199
+ return isFunction(damageGridWithSource);
200
+ }
201
+
184
202
  /**
185
203
  * Helper function to check if the player is using REPENTOGON, an exe-hack which expands the modding
186
204
  * API.