isaacscript-common 84.2.0 → 84.2.2

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 (109) hide show
  1. package/dist/{arrays/cachedEnumValues.d.ts → cachedEnumValues.d.ts} +4 -4
  2. package/dist/cachedEnumValues.d.ts.map +1 -0
  3. package/dist/{arrays/cachedEnumValues.js → cachedEnumValues.js} +5 -5
  4. package/dist/callbacks.js +1 -1
  5. package/dist/callbacks.lua +1 -1
  6. package/dist/classes/callbacks/PostItemDischarge.js +1 -1
  7. package/dist/classes/callbacks/PostItemDischarge.lua +1 -1
  8. package/dist/classes/callbacks/PostKeyboardChanged.js +1 -1
  9. package/dist/classes/callbacks/PostKeyboardChanged.lua +1 -1
  10. package/dist/classes/callbacks/PostPlayerChangeHealth.js +1 -1
  11. package/dist/classes/callbacks/PostPlayerChangeHealth.lua +1 -1
  12. package/dist/classes/callbacks/PostPlayerChangeStat.js +1 -1
  13. package/dist/classes/callbacks/PostPlayerChangeStat.lua +1 -1
  14. package/dist/classes/callbacks/PostTransformation.js +1 -1
  15. package/dist/classes/callbacks/PostTransformation.lua +1 -1
  16. package/dist/classes/callbacks/PreRoomEntitySpawnFilter.d.ts +1 -1
  17. package/dist/classes/features/callbackLogic/PlayerCollectibleDetection.js +1 -1
  18. package/dist/classes/features/callbackLogic/PlayerCollectibleDetection.lua +1 -1
  19. package/dist/classes/features/other/DeployJSONRoom.js +1 -1
  20. package/dist/classes/features/other/DeployJSONRoom.lua +1 -1
  21. package/dist/classes/features/other/ModdedElementSets.js +1 -1
  22. package/dist/classes/features/other/ModdedElementSets.lua +1 -1
  23. package/dist/classes/features/other/customStages/streakText.js +1 -1
  24. package/dist/classes/features/other/customStages/streakText.lua +1 -1
  25. package/dist/classes/features/other/extraConsoleCommands/commands.js +1 -1
  26. package/dist/classes/features/other/extraConsoleCommands/commands.lua +1 -1
  27. package/dist/decorators.d.ts.map +1 -1
  28. package/dist/decorators.js +9 -3
  29. package/dist/decorators.lua +9 -2
  30. package/dist/functions/cards.js +1 -1
  31. package/dist/functions/cards.lua +1 -1
  32. package/dist/functions/decorators.d.ts.map +1 -1
  33. package/dist/functions/decorators.js +10 -6
  34. package/dist/functions/decorators.lua +10 -6
  35. package/dist/functions/doors.d.ts.map +1 -1
  36. package/dist/functions/doors.js +1 -1
  37. package/dist/functions/doors.lua +1 -1
  38. package/dist/functions/enums.d.ts.map +1 -1
  39. package/dist/functions/enums.js +6 -11
  40. package/dist/functions/enums.lua +14 -7
  41. package/dist/functions/gridEntities.js +1 -1
  42. package/dist/functions/gridEntities.lua +1 -1
  43. package/dist/functions/input.js +1 -1
  44. package/dist/functions/input.lua +1 -1
  45. package/dist/functions/itemPool.js +1 -1
  46. package/dist/functions/itemPool.lua +1 -1
  47. package/dist/functions/level.js +1 -1
  48. package/dist/functions/level.lua +1 -1
  49. package/dist/functions/pills.js +1 -1
  50. package/dist/functions/pills.lua +1 -1
  51. package/dist/functions/playerCollectibles.js +1 -1
  52. package/dist/functions/playerCollectibles.lua +1 -1
  53. package/dist/functions/playerTrinkets.js +1 -1
  54. package/dist/functions/playerTrinkets.lua +1 -1
  55. package/dist/functions/pocketItems.js +1 -1
  56. package/dist/functions/pocketItems.lua +1 -1
  57. package/dist/functions/roomData.js +1 -1
  58. package/dist/functions/roomData.lua +1 -1
  59. package/dist/functions/roomShapeWalls.js +1 -1
  60. package/dist/functions/roomShapeWalls.lua +1 -1
  61. package/dist/functions/run.js +1 -1
  62. package/dist/functions/run.lua +1 -1
  63. package/dist/functions/sound.js +1 -1
  64. package/dist/functions/sound.lua +1 -1
  65. package/dist/functions/transformations.js +1 -1
  66. package/dist/functions/transformations.lua +1 -1
  67. package/dist/isaacscript-common.lua +1419 -1401
  68. package/dist/objects/itemPoolTypeToCollectibleTypesSet.js +1 -1
  69. package/dist/objects/itemPoolTypeToCollectibleTypesSet.lua +1 -1
  70. package/dist/serialization.js +1 -1
  71. package/dist/serialization.lua +1 -1
  72. package/dist/sets/bossSets.js +1 -1
  73. package/dist/sets/bossSets.lua +1 -1
  74. package/package.json +1 -1
  75. package/src/{arrays/cachedEnumValues.ts → cachedEnumValues.ts} +5 -5
  76. package/src/callbacks.ts +1 -1
  77. package/src/classes/callbacks/PostItemDischarge.ts +1 -1
  78. package/src/classes/callbacks/PostKeyboardChanged.ts +1 -1
  79. package/src/classes/callbacks/PostPlayerChangeHealth.ts +1 -1
  80. package/src/classes/callbacks/PostPlayerChangeStat.ts +1 -1
  81. package/src/classes/callbacks/PostTransformation.ts +1 -1
  82. package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +1 -1
  83. package/src/classes/features/other/DeployJSONRoom.ts +1 -1
  84. package/src/classes/features/other/ModdedElementSets.ts +1 -1
  85. package/src/classes/features/other/customStages/streakText.ts +1 -1
  86. package/src/classes/features/other/extraConsoleCommands/commands.ts +1 -1
  87. package/src/decorators.ts +18 -9
  88. package/src/functions/cards.ts +1 -1
  89. package/src/functions/decorators.ts +12 -13
  90. package/src/functions/doors.ts +1 -4
  91. package/src/functions/enums.ts +9 -11
  92. package/src/functions/gridEntities.ts +1 -1
  93. package/src/functions/input.ts +1 -1
  94. package/src/functions/itemPool.ts +1 -1
  95. package/src/functions/level.ts +1 -1
  96. package/src/functions/pills.ts +1 -1
  97. package/src/functions/playerCollectibles.ts +1 -1
  98. package/src/functions/playerTrinkets.ts +1 -1
  99. package/src/functions/pocketItems.ts +1 -1
  100. package/src/functions/roomData.ts +1 -1
  101. package/src/functions/roomShapeWalls.ts +1 -1
  102. package/src/functions/run.ts +1 -1
  103. package/src/functions/sound.ts +1 -1
  104. package/src/functions/transformations.ts +1 -1
  105. package/src/objects/itemPoolTypeToCollectibleTypesSet.ts +1 -1
  106. package/src/serialization.ts +1 -1
  107. package/src/sets/bossSets.ts +1 -1
  108. package/dist/arrays/cachedEnumValues.d.ts.map +0 -1
  109. /package/dist/{arrays/cachedEnumValues.lua → cachedEnumValues.lua} +0 -0
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET = void 0;
27
- const cachedEnumValues_1 = require("../arrays/cachedEnumValues");
27
+ const cachedEnumValues_1 = require("../cachedEnumValues");
28
28
  const itemPoolsJSON = __importStar(require("../data/itempools.json"));
29
29
  const types_1 = require("../functions/types");
30
30
  const itemPoolTypeToItemPoolName_1 = require("../maps/itemPoolTypeToItemPoolName");
@@ -4,7 +4,7 @@ local __TS__New = ____lualib.__TS__New
4
4
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
5
5
  local ____exports = {}
6
6
  local getItemPoolJSON
7
- local ____cachedEnumValues = require("arrays.cachedEnumValues")
7
+ local ____cachedEnumValues = require("cachedEnumValues")
8
8
  local ITEM_POOL_TYPE_VALUES = ____cachedEnumValues.ITEM_POOL_TYPE_VALUES
9
9
  local itemPoolsJSON = require("data.itempools")
10
10
  local ____types = require("functions.types")
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isSerializationBrand = void 0;
4
- const cachedEnumValues_1 = require("./arrays/cachedEnumValues");
4
+ const cachedEnumValues_1 = require("./cachedEnumValues");
5
5
  const types_1 = require("./functions/types");
6
6
  const ReadonlySet_1 = require("./types/ReadonlySet");
7
7
  const SERIALIZATION_BRAND_SET = new ReadonlySet_1.ReadonlySet(cachedEnumValues_1.SERIALIZATION_BRAND_VALUES);
@@ -1,7 +1,7 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__New = ____lualib.__TS__New
3
3
  local ____exports = {}
4
- local ____cachedEnumValues = require("arrays.cachedEnumValues")
4
+ local ____cachedEnumValues = require("cachedEnumValues")
5
5
  local SERIALIZATION_BRAND_VALUES = ____cachedEnumValues.SERIALIZATION_BRAND_VALUES
6
6
  local ____types = require("functions.types")
7
7
  local isString = ____types.isString
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BOSS_ID_TO_STAGE_IDS = exports.NON_STORY_BOSSES = exports.ALL_BOSSES = exports.STAGE_TO_COMBINED_BOSS_SET_MAP = exports.STAGE_ID_TO_BOSS_IDS = void 0;
4
4
  const isaac_typescript_definitions_1 = require("isaac-typescript-definitions");
5
- const cachedEnumValues_1 = require("../arrays/cachedEnumValues");
5
+ const cachedEnumValues_1 = require("../cachedEnumValues");
6
6
  const storyBosses_1 = require("../functions/storyBosses");
7
7
  const ReadonlyMap_1 = require("../types/ReadonlyMap");
8
8
  const ReadonlySet_1 = require("../types/ReadonlySet");
@@ -12,7 +12,7 @@ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitio
12
12
  local BossID = ____isaac_2Dtypescript_2Ddefinitions.BossID
13
13
  local LevelStage = ____isaac_2Dtypescript_2Ddefinitions.LevelStage
14
14
  local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
15
- local ____cachedEnumValues = require("arrays.cachedEnumValues")
15
+ local ____cachedEnumValues = require("cachedEnumValues")
16
16
  local BOSS_ID_VALUES = ____cachedEnumValues.BOSS_ID_VALUES
17
17
  local ____storyBosses = require("functions.storyBosses")
18
18
  local isStoryBossID = ____storyBosses.isStoryBossID
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "84.2.0",
3
+ "version": "84.2.2",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -21,11 +21,11 @@ import {
21
21
  SoundEffect,
22
22
  TrinketSlot,
23
23
  } from "isaac-typescript-definitions";
24
- import { HealthType } from "../enums/HealthType";
25
- import { ModCallbackCustom } from "../enums/ModCallbackCustom";
26
- import { PlayerStat } from "../enums/PlayerStat";
27
- import { SerializationBrand } from "../enums/private/SerializationBrand";
28
- import { getEnumValues } from "../functions/enums";
24
+ import { HealthType } from "./enums/HealthType";
25
+ import { ModCallbackCustom } from "./enums/ModCallbackCustom";
26
+ import { PlayerStat } from "./enums/PlayerStat";
27
+ import { SerializationBrand } from "./enums/private/SerializationBrand";
28
+ import { getEnumValues } from "./functions/enums";
29
29
 
30
30
  export const ACTIVE_SLOT_VALUES = getEnumValues(ActiveSlot);
31
31
 
package/src/callbacks.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MOD_CALLBACK_CUSTOM_VALUES } from "./arrays/cachedEnumValues";
1
+ import { MOD_CALLBACK_CUSTOM_VALUES } from "./cachedEnumValues";
2
2
  import * as cc from "./callbackClasses";
3
3
  import { ModCallbackCustom } from "./enums/ModCallbackCustom";
4
4
  import type { AnyClass } from "./types/AnyClass";
@@ -4,7 +4,7 @@ import {
4
4
  ModCallback,
5
5
  SuckerVariant,
6
6
  } from "isaac-typescript-definitions";
7
- import { ACTIVE_SLOT_VALUES } from "../../arrays/cachedEnumValues";
7
+ import { ACTIVE_SLOT_VALUES } from "../../cachedEnumValues";
8
8
  import { game } from "../../core/cachedClasses";
9
9
  import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
10
10
  import { getTotalCharge } from "../../functions/charge";
@@ -1,6 +1,6 @@
1
1
  import type { Keyboard } from "isaac-typescript-definitions";
2
2
  import { ModCallback } from "isaac-typescript-definitions";
3
- import { KEYBOARD_VALUES } from "../../arrays/cachedEnumValues";
3
+ import { KEYBOARD_VALUES } from "../../cachedEnumValues";
4
4
  import type { ModCallbackCustom } from "../../enums/ModCallbackCustom";
5
5
  import { isKeyboardPressed } from "../../functions/input";
6
6
  import type { FireArgs, OptionalArgs } from "../private/CustomCallback";
@@ -1,4 +1,4 @@
1
- import { HEALTH_TYPE_VALUES } from "../../arrays/cachedEnumValues";
1
+ import { HEALTH_TYPE_VALUES } from "../../cachedEnumValues";
2
2
  import type { HealthType } from "../../enums/HealthType";
3
3
  import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
4
4
  import { getPlayerHealthType } from "../../functions/playerHealth";
@@ -1,4 +1,4 @@
1
- import { PLAYER_STAT_VALUES } from "../../arrays/cachedEnumValues";
1
+ import { PLAYER_STAT_VALUES } from "../../cachedEnumValues";
2
2
  import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
3
3
  import type { PlayerStat } from "../../enums/PlayerStat";
4
4
  import { isBitSet128 } from "../../functions/bitSet128";
@@ -1,5 +1,5 @@
1
1
  import type { PlayerForm } from "isaac-typescript-definitions";
2
- import { PLAYER_FORM_VALUES } from "../../arrays/cachedEnumValues";
2
+ import { PLAYER_FORM_VALUES } from "../../cachedEnumValues";
3
3
  import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
4
4
  import { defaultMapGetPlayer } from "../../functions/playerDataStructures";
5
5
  import type { PlayerIndex } from "../../types/PlayerIndex";
@@ -6,7 +6,7 @@ import {
6
6
  ModCallback,
7
7
  PlayerType,
8
8
  } from "isaac-typescript-definitions";
9
- import { ACTIVE_SLOT_VALUES } from "../../../arrays/cachedEnumValues";
9
+ import { ACTIVE_SLOT_VALUES } from "../../../cachedEnumValues";
10
10
  import { ISCFeature } from "../../../enums/ISCFeature";
11
11
  import { ModCallbackCustom } from "../../../enums/ModCallbackCustom";
12
12
  import { arrayEquals } from "../../../functions/array";
@@ -8,7 +8,7 @@ import {
8
8
  PitfallVariant,
9
9
  RoomType,
10
10
  } from "isaac-typescript-definitions";
11
- import { GRID_ENTITY_XML_TYPE_VALUES } from "../../../arrays/cachedEnumValues";
11
+ import { GRID_ENTITY_XML_TYPE_VALUES } from "../../../cachedEnumValues";
12
12
  import { game } from "../../../core/cachedClasses";
13
13
  import { Exported } from "../../../decorators";
14
14
  import { ISCFeature } from "../../../enums/ISCFeature";
@@ -12,7 +12,7 @@ import {
12
12
  CACHE_FLAG_VALUES,
13
13
  ITEM_CONFIG_CARD_TYPE_VALUES,
14
14
  ITEM_CONFIG_TAG_VALUES,
15
- } from "../../../arrays/cachedEnumValues";
15
+ } from "../../../cachedEnumValues";
16
16
  import { itemConfig } from "../../../core/cachedClasses";
17
17
  import {
18
18
  FIRST_GLITCHED_COLLECTIBLE_TYPE,
@@ -1,5 +1,5 @@
1
1
  import { ButtonAction } from "isaac-typescript-definitions";
2
- import { CONTROLLER_INDEX_VALUES } from "../../../../arrays/cachedEnumValues";
2
+ import { CONTROLLER_INDEX_VALUES } from "../../../../cachedEnumValues";
3
3
  import { fonts, game } from "../../../../core/cachedClasses";
4
4
  import { KColorDefault, VectorOne } from "../../../../core/constants";
5
5
  import { UIStreakAnimation } from "../../../../enums/private/UIStreakAnimation";
@@ -60,7 +60,7 @@ import {
60
60
  SoundEffect,
61
61
  StageType,
62
62
  } from "isaac-typescript-definitions";
63
- import { GRID_ENTITY_TYPE_VALUES } from "../../../../arrays/cachedEnumValues";
63
+ import { GRID_ENTITY_TYPE_VALUES } from "../../../../cachedEnumValues";
64
64
  import { game, sfxManager } from "../../../../core/cachedClasses";
65
65
  import {
66
66
  DOGMA_ROOM_GRID_INDEX,
package/src/decorators.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Feature } from "./classes/private/Feature";
2
+ import { getTSTLClassName } from "./functions/tstlClass";
2
3
 
3
4
  export const EXPORTED_METHOD_NAMES_KEY = "__exportedMethodNames";
4
5
 
@@ -14,16 +15,24 @@ export function Exported<Class extends Feature>(
14
15
  ): void {
15
16
  // Since the decorator runs prior to instantiation, we only have access to get and set static
16
17
  // properties, which are located on the "constructor" table.
17
- const constructor = target.constructor as unknown as LuaMap<
18
- AnyNotNil,
19
- unknown
20
- >;
21
- if (!constructor.has(EXPORTED_METHOD_NAMES_KEY)) {
22
- constructor.set(EXPORTED_METHOD_NAMES_KEY, []);
18
+ const constructor = target.constructor as unknown as
19
+ | Record<string, unknown>
20
+ | undefined;
21
+
22
+ if (constructor === undefined) {
23
+ const tstlClassName = getTSTLClassName(target) ?? "Unknown";
24
+ error(
25
+ `Failed to get the constructor for class "${tstlClassName}". Did you decorate a static method? You can only decorate non-static class methods.`,
26
+ );
27
+ }
28
+
29
+ let exportedMethodNames = constructor[EXPORTED_METHOD_NAMES_KEY] as
30
+ | unknown[]
31
+ | undefined;
32
+ if (exportedMethodNames === undefined) {
33
+ exportedMethodNames = [];
34
+ constructor[EXPORTED_METHOD_NAMES_KEY] = exportedMethodNames;
23
35
  }
24
36
 
25
- const exportedMethodNames = constructor.get(
26
- EXPORTED_METHOD_NAMES_KEY,
27
- ) as string[];
28
37
  exportedMethodNames.push(propertyKey as string);
29
38
  }
@@ -1,6 +1,6 @@
1
1
  import type { CardType } from "isaac-typescript-definitions";
2
2
  import { ItemConfigCardType, UseFlag } from "isaac-typescript-definitions";
3
- import { POCKET_ITEM_SLOT_VALUES } from "../arrays/cachedEnumValues";
3
+ import { POCKET_ITEM_SLOT_VALUES } from "../cachedEnumValues";
4
4
  import { itemConfig } from "../core/cachedClasses";
5
5
  import { LAST_VANILLA_CARD_TYPE } from "../core/constantsFirstLast";
6
6
  import {
@@ -99,7 +99,7 @@ export function PriorityCallback<T extends ModCallback>(
99
99
  // properties, which are located on the "constructor" table. Thus, we store the callback
100
100
  // arguments for later.
101
101
  const constructor = target.constructor as unknown as
102
- | LuaMap<AnyNotNil, unknown>
102
+ | Record<string, unknown>
103
103
  | undefined;
104
104
 
105
105
  if (constructor === undefined) {
@@ -109,13 +109,13 @@ export function PriorityCallback<T extends ModCallback>(
109
109
  );
110
110
  }
111
111
 
112
- if (!constructor.has(MOD_FEATURE_CALLBACKS_KEY)) {
113
- constructor.set(MOD_FEATURE_CALLBACKS_KEY, []);
112
+ const key = MOD_FEATURE_CALLBACKS_KEY;
113
+ let callbackTuples = constructor[key] as unknown[] | undefined;
114
+ if (callbackTuples === undefined) {
115
+ callbackTuples = [];
116
+ constructor[key] = callbackTuples;
114
117
  }
115
118
 
116
- const callbackTuples = constructor.get(
117
- MOD_FEATURE_CALLBACKS_KEY,
118
- ) as unknown[];
119
119
  callbackTuples.push(callbackTuple);
120
120
  };
121
121
  }
@@ -150,7 +150,7 @@ export function PriorityCallbackCustom<T extends ModCallbackCustom>(
150
150
  // properties, which are located on the "constructor" table. Thus, we store the callback
151
151
  // arguments for later.
152
152
  const constructor = target.constructor as unknown as
153
- | LuaMap<AnyNotNil, unknown>
153
+ | Record<string, unknown>
154
154
  | undefined;
155
155
 
156
156
  if (constructor === undefined) {
@@ -160,13 +160,12 @@ export function PriorityCallbackCustom<T extends ModCallbackCustom>(
160
160
  );
161
161
  }
162
162
 
163
- if (!constructor.has(MOD_FEATURE_CUSTOM_CALLBACKS_KEY)) {
164
- constructor.set(MOD_FEATURE_CUSTOM_CALLBACKS_KEY, []);
163
+ const key = MOD_FEATURE_CUSTOM_CALLBACKS_KEY;
164
+ let callbackTuples = constructor[key] as unknown[] | undefined;
165
+ if (callbackTuples === undefined) {
166
+ callbackTuples = [];
167
+ constructor[key] = callbackTuples;
165
168
  }
166
-
167
- const callbackTuples = constructor.get(
168
- MOD_FEATURE_CUSTOM_CALLBACKS_KEY,
169
- ) as unknown[];
170
169
  callbackTuples.push(callbackTuple);
171
170
  };
172
171
  }
@@ -11,10 +11,7 @@ import {
11
11
  GridRoom,
12
12
  RoomType,
13
13
  } from "isaac-typescript-definitions";
14
- import {
15
- DOOR_SLOT_FLAG_VALUES,
16
- DOOR_SLOT_VALUES,
17
- } from "../arrays/cachedEnumValues";
14
+ import { DOOR_SLOT_FLAG_VALUES, DOOR_SLOT_VALUES } from "../cachedEnumValues";
18
15
  import { game } from "../core/cachedClasses";
19
16
  import { DISTANCE_OF_GRID_TILE } from "../core/constants";
20
17
  import {
@@ -34,24 +34,22 @@ export type TranspiledEnum = Record<
34
34
  export function getEnumEntries<T extends TranspiledEnum>(
35
35
  transpiledEnum: T,
36
36
  ): ReadonlyArray<[key: string, value: T[keyof T]]> {
37
- // The values cannot simply be type `T` due to the special construction of bit flag enums.
38
- const enumEntries: Array<[key: string, value: T[keyof T]]> = [];
39
- for (const [key, value] of pairs(transpiledEnum)) {
40
- // Ignore the reverse mappings created by TypeScriptToLua. Note that reverse mappings are not
41
- // created for string enums.
42
- if (isString(key)) {
43
- enumEntries.push([key, value]);
44
- }
45
- }
37
+ const entries = Object.entries(transpiledEnum);
38
+ const numberEntries = entries.filter(
39
+ ([_key, value]) => typeof value === "number",
40
+ );
41
+
42
+ // If there are no number values, then this must be a string enum, and no filtration is required.
43
+ const valuesToReturn = numberEntries.length > 0 ? numberEntries : entries;
46
44
 
47
45
  // The enums will be in a random order (because of "pairs"), so sort them based on the values.
48
46
  // https://stackoverflow.com/questions/5199901/how-to-sort-an-associative-array-by-its-values-in-javascript
49
- enumEntries.sort(
47
+ valuesToReturn.sort(
50
48
  ([_key1, value1], [_key2, value2]) =>
51
49
  value1 < value2 ? -1 : value1 > value2 ? 1 : 0, // eslint-disable-line no-nested-ternary
52
50
  );
53
51
 
54
- return enumEntries;
52
+ return valuesToReturn as never;
55
53
  }
56
54
 
57
55
  /**
@@ -8,7 +8,7 @@ import {
8
8
  StatueVariant,
9
9
  TrapdoorVariant,
10
10
  } from "isaac-typescript-definitions";
11
- import { GRID_ENTITY_XML_TYPE_VALUES } from "../arrays/cachedEnumValues";
11
+ import { GRID_ENTITY_XML_TYPE_VALUES } from "../cachedEnumValues";
12
12
  import { game } from "../core/cachedClasses";
13
13
  import { DISTANCE_OF_GRID_TILE, VectorOne } from "../core/constants";
14
14
  import { GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP } from "../maps/gridEntityTypeToBrokenStateMap";
@@ -4,7 +4,7 @@ import {
4
4
  ControllerIndex,
5
5
  Keyboard,
6
6
  } from "isaac-typescript-definitions";
7
- import { CONTROLLER_INDEX_VALUES } from "../arrays/cachedEnumValues";
7
+ import { CONTROLLER_INDEX_VALUES } from "../cachedEnumValues";
8
8
  import { KEYBOARD_TO_STRING_MAP } from "../maps/keyboardToStringMap";
9
9
  import { ReadonlySet } from "../types/ReadonlySet";
10
10
  import { trimPrefix } from "./string";
@@ -3,7 +3,7 @@ import type {
3
3
  TrinketType,
4
4
  } from "isaac-typescript-definitions";
5
5
  import { ItemPoolType } from "isaac-typescript-definitions";
6
- import { ITEM_POOL_TYPE_VALUES } from "../arrays/cachedEnumValues";
6
+ import { ITEM_POOL_TYPE_VALUES } from "../cachedEnumValues";
7
7
  import { game } from "../core/cachedClasses";
8
8
  import { ITEM_POOL_TYPE_TO_ITEM_POOL_NAME } from "../maps/itemPoolTypeToItemPoolName";
9
9
  import { ITEM_POOL_TYPE_TO_COLLECTIBLE_TYPES_SET } from "../objects/itemPoolTypeToCollectibleTypesSet";
@@ -1,6 +1,6 @@
1
1
  import type { BossID } from "isaac-typescript-definitions";
2
2
  import { RoomType, StageID } from "isaac-typescript-definitions";
3
- import { DOOR_SLOT_VALUES } from "../arrays/cachedEnumValues";
3
+ import { DOOR_SLOT_VALUES } from "../cachedEnumValues";
4
4
  import { game } from "../core/cachedClasses";
5
5
  import { filterMap } from "./array";
6
6
  import {
@@ -4,7 +4,7 @@ import type {
4
4
  PillEffect,
5
5
  } from "isaac-typescript-definitions";
6
6
  import { PillColor } from "isaac-typescript-definitions";
7
- import { PILL_COLOR_VALUES } from "../arrays/cachedEnumValues";
7
+ import { PILL_COLOR_VALUES } from "../cachedEnumValues";
8
8
  import { game, itemConfig } from "../core/cachedClasses";
9
9
  import {
10
10
  FIRST_HORSE_PILL_COLOR,
@@ -3,7 +3,7 @@ import {
3
3
  CollectibleType,
4
4
  PlayerType,
5
5
  } from "isaac-typescript-definitions";
6
- import { ACTIVE_SLOT_VALUES } from "../arrays/cachedEnumValues";
6
+ import { ACTIVE_SLOT_VALUES } from "../cachedEnumValues";
7
7
  import { game, itemConfig } from "../core/cachedClasses";
8
8
  import { ReadonlySet } from "../types/ReadonlySet";
9
9
  import { sumArray } from "./array";
@@ -3,7 +3,7 @@ import {
3
3
  TrinketSlot,
4
4
  TrinketType,
5
5
  } from "isaac-typescript-definitions";
6
- import { TRINKET_SLOT_VALUES } from "../arrays/cachedEnumValues";
6
+ import { TRINKET_SLOT_VALUES } from "../cachedEnumValues";
7
7
  import { itemConfig } from "../core/cachedClasses";
8
8
  import { getAllPlayers, getPlayers } from "./playerIndex";
9
9
  import { isCharacter } from "./players";
@@ -6,7 +6,7 @@ import {
6
6
  PillColor,
7
7
  PlayerType,
8
8
  } from "isaac-typescript-definitions";
9
- import { POCKET_ITEM_SLOT_VALUES } from "../arrays/cachedEnumValues";
9
+ import { POCKET_ITEM_SLOT_VALUES } from "../cachedEnumValues";
10
10
  import { PocketItemType } from "../enums/PocketItemType";
11
11
  import type { PocketItemDescription } from "../interfaces/PocketItemDescription";
12
12
  import { isCharacter } from "./players";
@@ -4,7 +4,7 @@ import type {
4
4
  RoomType,
5
5
  StageID,
6
6
  } from "isaac-typescript-definitions";
7
- import { DOOR_SLOT_FLAG_VALUES } from "../arrays/cachedEnumValues";
7
+ import { DOOR_SLOT_FLAG_VALUES } from "../cachedEnumValues";
8
8
  import { game } from "../core/cachedClasses";
9
9
  import { doorSlotFlagToDoorSlot } from "./doors";
10
10
  import { hasFlag } from "./flag";
@@ -1,5 +1,5 @@
1
1
  import { BossID, RoomShape } from "isaac-typescript-definitions";
2
- import { ROOM_SHAPE_VALUES } from "../arrays/cachedEnumValues";
2
+ import { ROOM_SHAPE_VALUES } from "../cachedEnumValues";
3
3
  import { game } from "../core/cachedClasses";
4
4
  import { CornerType } from "../enums/CornerType";
5
5
  import type { Corner } from "../interfaces/Corner";
@@ -3,7 +3,7 @@ import {
3
3
  PlayerType,
4
4
  SeedEffect,
5
5
  } from "isaac-typescript-definitions";
6
- import { SEED_EFFECTS } from "../arrays/cachedEnumValues";
6
+ import { SEED_EFFECTS } from "../cachedEnumValues";
7
7
  import { game } from "../core/cachedClasses";
8
8
  import { getCharacterName } from "./characters";
9
9
  import { log } from "./log";
@@ -4,7 +4,7 @@ import type {
4
4
  SoundEffect,
5
5
  StageType,
6
6
  } from "isaac-typescript-definitions";
7
- import { SOUND_EFFECT_VALUES } from "../arrays/cachedEnumValues";
7
+ import { SOUND_EFFECT_VALUES } from "../cachedEnumValues";
8
8
  import { game, sfxManager } from "../core/cachedClasses";
9
9
  import { STAGE_TO_MUSIC } from "../objects/stageToMusic";
10
10
  import type { TranspiledEnum } from "./enums";
@@ -1,6 +1,6 @@
1
1
  import type { CollectibleType } from "isaac-typescript-definitions";
2
2
  import { ItemConfigTag, PlayerForm } from "isaac-typescript-definitions";
3
- import { PLAYER_FORM_VALUES } from "../arrays/cachedEnumValues";
3
+ import { PLAYER_FORM_VALUES } from "../cachedEnumValues";
4
4
  import { TRANSFORMATION_NAMES } from "../objects/transformationNames";
5
5
  import { ReadonlyMap } from "../types/ReadonlyMap";
6
6
  import { ReadonlySet } from "../types/ReadonlySet";
@@ -2,7 +2,7 @@ import type {
2
2
  CollectibleType,
3
3
  ItemPoolType,
4
4
  } from "isaac-typescript-definitions";
5
- import { ITEM_POOL_TYPE_VALUES } from "../arrays/cachedEnumValues";
5
+ import { ITEM_POOL_TYPE_VALUES } from "../cachedEnumValues";
6
6
  import * as itemPoolsJSON from "../data/itempools.json";
7
7
  import { asCollectibleType, parseIntSafe } from "../functions/types";
8
8
  import { ITEM_POOL_TYPE_TO_ITEM_POOL_NAME } from "../maps/itemPoolTypeToItemPoolName";
@@ -1,4 +1,4 @@
1
- import { SERIALIZATION_BRAND_VALUES } from "./arrays/cachedEnumValues";
1
+ import { SERIALIZATION_BRAND_VALUES } from "./cachedEnumValues";
2
2
  import { isString } from "./functions/types";
3
3
  import { ReadonlySet } from "./types/ReadonlySet";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { BossID, LevelStage, StageID } from "isaac-typescript-definitions";
2
- import { BOSS_ID_VALUES } from "../arrays/cachedEnumValues";
2
+ import { BOSS_ID_VALUES } from "../cachedEnumValues";
3
3
  import { isStoryBossID } from "../functions/storyBosses";
4
4
  import { ReadonlyMap } from "../types/ReadonlyMap";
5
5
  import { ReadonlySet } from "../types/ReadonlySet";
@@ -1 +0,0 @@
1
- {"version":3,"file":"cachedEnumValues.d.ts","sourceRoot":"","sources":["../../src/arrays/cachedEnumValues.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,MAAM,EAEN,eAAe,EACf,QAAQ,EAER,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAElB,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGzE,eAAO,MAAM,kBAAkB,uBAA4B,CAAC;AAE5D,eAAO,MAAM,cAAc,mBAAwB,CAAC;AAEpD,eAAO,MAAM,iBAAiB;;;;IAA2B,CAAC;AAE1D,eAAO,MAAM,uBAAuB,4BAAiC,CAAC;AAEtE,eAAO,MAAM,qBAAqB;;;;IAA8B,CAAC;AAEjE,eAAO,MAAM,gBAAgB,qBAA0B,CAAC;AAExD,eAAO,MAAM,uBAAuB,2BAAgC,CAAC;AAErE,eAAO,MAAM,2BAA2B,8BAAmC,CAAC;AAE5E,eAAO,MAAM,0BAA0B,8BAAmC,CAAC;AAE3E,eAAO,MAAM,sBAAsB;;;;IAA+B,CAAC;AAEnE,eAAO,MAAM,4BAA4B,+BAAoC,CAAC;AAE9E,eAAO,MAAM,qBAAqB,yBAA8B,CAAC;AAEjE,eAAO,MAAM,eAAe,qBAA0B,CAAC;AAEvD,eAAO,MAAM,kBAAkB,uBAA4B,CAAC;AAE5D,eAAO,MAAM,iBAAiB,sBAA2B,CAAC;AAE1D,eAAO,MAAM,kBAAkB,uBAA4B,CAAC;AAE5D,eAAO,MAAM,uBAAuB,2BAAgC,CAAC;AAErE,eAAO,MAAM,iBAAiB,sBAA2B,CAAC;AAE1D,eAAO,MAAM,YAAY,uBAA4B,CAAC;AAEtD,eAAO,MAAM,0BAA0B,+BAAoC,CAAC;AAE5E,eAAO,MAAM,mBAAmB,wBAA6B,CAAC;AAE9D,eAAO,MAAM,kBAAkB,uBAA4B,CAAC;AAE5D,eAAO,MAAM,mBAAmB,wBAA6B,CAAC"}