isaacscript-common 47.5.4 → 48.1.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.
@@ -5427,13 +5427,14 @@ export declare function getEntityPositions(entities?: Entity[]): Map<PtrHash, Ve
5427
5427
  export declare function getEntityVelocities(entities?: Entity[]): Map<PtrHash, Vector>;
5428
5428
 
5429
5429
  /**
5430
- * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
5431
- * when you iterate over them, you will get both the names of the enums and the values of the enums,
5432
- * in a random order. Use this helper function to get the entries of the enum with the reverse
5433
- * mappings filtered out.
5430
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
5431
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
5432
+ * enums, in a random order. Use this helper function to get the entries of the enum with the
5433
+ * reverse mappings filtered out.
5434
5434
  *
5435
5435
  * This function will return the enum values in a sorted order, which may not necessarily be the
5436
- * same order as which they were declared in.
5436
+ * same order as which they were declared in. (It is impossible to get the declaration order at
5437
+ * run-time.)
5437
5438
  *
5438
5439
  * This function will work properly for both number enums and string enums. (Reverse mappings are
5439
5440
  * not created for string enums.)
@@ -5446,12 +5447,13 @@ export declare function getEntityVelocities(entities?: Entity[]): Map<PtrHash, V
5446
5447
  export declare function getEnumEntries<T>(transpiledEnum: T): Array<[key: string, value: T[keyof T]]>;
5447
5448
 
5448
5449
  /**
5449
- * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
5450
- * when you iterate over them, you will get both the names of the enums and the values of the enums,
5451
- * in a random order. If all you need are the keys of an enum, use this helper function.
5450
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
5451
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
5452
+ * enums, in a random order. If all you need are the keys of an enum, use this helper function.
5452
5453
  *
5453
5454
  * This function will return the enum keys in a sorted order, which may not necessarily be the same
5454
- * order as which they were declared in.
5455
+ * order as which they were declared in. (It is impossible to get the declaration order at
5456
+ * run-time.)
5455
5457
  *
5456
5458
  * This function will work properly for both number enums and string enums. (Reverse mappings are
5457
5459
  * not created for string enums.)
@@ -5467,12 +5469,32 @@ export declare function getEnumKeys(transpiledEnum: Record<string | number, stri
5467
5469
  export declare function getEnumLength(transpiledEnum: Record<string | number, string | number>): int;
5468
5470
 
5469
5471
  /**
5470
- * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
5471
- * when you iterate over them, you will get both the names of the enums and the values of the enums,
5472
- * in a random order. If all you need are the values of an enum, use this helper function.
5472
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
5473
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
5474
+ * enums, in a random order. If all you need are the names of an enum from the reverse mapping, use
5475
+ * this helper function.
5476
+ *
5477
+ * This function will return the enum names in a sorted order, which may not necessarily be the same
5478
+ * order as which they were declared in. (It is impossible to get the declaration order at
5479
+ * run-time.)
5480
+ *
5481
+ * This function will work properly for both number enums and string enums. (Reverse mappings are
5482
+ * not created for string enums, so their names would be equivalent to what would be returned by the
5483
+ * `getEnumKeys` function.)
5484
+ *
5485
+ * For a more in depth explanation, see:
5486
+ * https://isaacscript.github.io/main/gotchas#iterating-over-enums
5487
+ */
5488
+ export declare function getEnumNames(transpiledEnum: Record<string | number, string | number>): string[];
5489
+
5490
+ /**
5491
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
5492
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
5493
+ * enums, in a random order. If all you need are the values of an enum, use this helper function.
5473
5494
  *
5474
5495
  * This function will return the enum values in a sorted order, which may not necessarily be the
5475
- * same order as which they were declared in.
5496
+ * same order as which they were declared in. (It is impossible to get the declaration order at
5497
+ * run-time.)
5476
5498
  *
5477
5499
  * This function will work properly for both number enums and string enums. (Reverse mappings are
5478
5500
  * not created for string enums.)
@@ -17804,7 +17826,7 @@ export declare function useCardTemp(player: EntityPlayer, cardType: CardType): v
17804
17826
  export declare function validateCustomEnum(transpiledEnumName: string, transpiledEnum: unknown): void;
17805
17827
 
17806
17828
  /**
17807
- * Helper function to validate if every value in an enum is contiguous, starting at 0.
17829
+ * Helper function to validate if every value in a number enum is contiguous, starting at 0.
17808
17830
  *
17809
17831
  * This is useful to automate checking large enums for typos.
17810
17832
  */
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 47.5.4
3
+ isaacscript-common 48.1.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -9595,8 +9595,8 @@ ____exports.BossID.CHUB = 3
9595
9595
  ____exports.BossID[____exports.BossID.CHUB] = "CHUB"
9596
9596
  ____exports.BossID.GURDY = 4
9597
9597
  ____exports.BossID[____exports.BossID.GURDY] = "GURDY"
9598
- ____exports.BossID.MONSTRO_II = 5
9599
- ____exports.BossID[____exports.BossID.MONSTRO_II] = "MONSTRO_II"
9598
+ ____exports.BossID.MONSTRO_2 = 5
9599
+ ____exports.BossID[____exports.BossID.MONSTRO_2] = "MONSTRO_2"
9600
9600
  ____exports.BossID.MOM = 6
9601
9601
  ____exports.BossID[____exports.BossID.MOM] = "MOM"
9602
9602
  ____exports.BossID.SCOLEX = 7
@@ -17307,6 +17307,16 @@ function ____exports.getEnumLength(self, transpiledEnum)
17307
17307
  local enumEntries = ____exports.getEnumEntries(nil, transpiledEnum)
17308
17308
  return #enumEntries
17309
17309
  end
17310
+ function ____exports.getEnumNames(self, transpiledEnum)
17311
+ local enumNames = {}
17312
+ for key, _value in pairs(transpiledEnum) do
17313
+ if isString(nil, key) then
17314
+ enumNames[#enumNames + 1] = key
17315
+ end
17316
+ end
17317
+ __TS__ArraySort(enumNames)
17318
+ return enumNames
17319
+ end
17310
17320
  function ____exports.getEnumValues(self, transpiledEnum)
17311
17321
  local enumEntries = ____exports.getEnumEntries(nil, transpiledEnum)
17312
17322
  return __TS__ArrayMap(
@@ -44571,7 +44581,7 @@ ____exports.BOSS_NAME_PNG_FILE_NAMES = {
44571
44581
  [BossID.LARRY_JR] = "bossname_19.0_larryjr.png",
44572
44582
  [BossID.CHUB] = "bossname_28.0_chub.png",
44573
44583
  [BossID.GURDY] = "bossname_36.0_gurdy.png",
44574
- [BossID.MONSTRO_II] = "bossname_43.0_monstro2.png",
44584
+ [BossID.MONSTRO_2] = "bossname_43.0_monstro2.png",
44575
44585
  [BossID.MOM] = "bossname_45.0_mom.png",
44576
44586
  [BossID.SCOLEX] = "bossname_62.1_scolex.png",
44577
44587
  [BossID.MOMS_HEART] = "bossname_78.0_momsheart.png",
@@ -44680,7 +44690,7 @@ ____exports.BOSS_PORTRAIT_PNG_FILE_NAMES = {
44680
44690
  [BossID.LARRY_JR] = "portrait_19.0_larryjr.png",
44681
44691
  [BossID.CHUB] = "portrait_28.0_chub.png",
44682
44692
  [BossID.GURDY] = "portrait_36.0_gurdy.png",
44683
- [BossID.MONSTRO_II] = "portrait_43.0_monstro2.png",
44693
+ [BossID.MONSTRO_2] = "portrait_43.0_monstro2.png",
44684
44694
  [BossID.MOM] = "portrait_45.0_mom.png",
44685
44695
  [BossID.SCOLEX] = "portrait_62.1_scolex.png",
44686
44696
  [BossID.MOMS_HEART] = "portrait_78.0_momsheart.png",
@@ -2,13 +2,14 @@
2
2
  /// <reference types="isaac-typescript-definitions" />
3
3
  /// <reference types="isaac-typescript-definitions" />
4
4
  /**
5
- * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
6
- * when you iterate over them, you will get both the names of the enums and the values of the enums,
7
- * in a random order. Use this helper function to get the entries of the enum with the reverse
8
- * mappings filtered out.
5
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
6
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
7
+ * enums, in a random order. Use this helper function to get the entries of the enum with the
8
+ * reverse mappings filtered out.
9
9
  *
10
10
  * This function will return the enum values in a sorted order, which may not necessarily be the
11
- * same order as which they were declared in.
11
+ * same order as which they were declared in. (It is impossible to get the declaration order at
12
+ * run-time.)
12
13
  *
13
14
  * This function will work properly for both number enums and string enums. (Reverse mappings are
14
15
  * not created for string enums.)
@@ -20,12 +21,13 @@
20
21
  */
21
22
  export declare function getEnumEntries<T>(transpiledEnum: T): Array<[key: string, value: T[keyof T]]>;
22
23
  /**
23
- * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
24
- * when you iterate over them, you will get both the names of the enums and the values of the enums,
25
- * in a random order. If all you need are the keys of an enum, use this helper function.
24
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
25
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
26
+ * enums, in a random order. If all you need are the keys of an enum, use this helper function.
26
27
  *
27
28
  * This function will return the enum keys in a sorted order, which may not necessarily be the same
28
- * order as which they were declared in.
29
+ * order as which they were declared in. (It is impossible to get the declaration order at
30
+ * run-time.)
29
31
  *
30
32
  * This function will work properly for both number enums and string enums. (Reverse mappings are
31
33
  * not created for string enums.)
@@ -39,12 +41,31 @@ export declare function getEnumKeys(transpiledEnum: Record<string | number, stri
39
41
  /** Helper function to get the amount of entries inside of an enum. */
40
42
  export declare function getEnumLength(transpiledEnum: Record<string | number, string | number>): int;
41
43
  /**
42
- * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
43
- * when you iterate over them, you will get both the names of the enums and the values of the enums,
44
- * in a random order. If all you need are the values of an enum, use this helper function.
44
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
45
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
46
+ * enums, in a random order. If all you need are the names of an enum from the reverse mapping, use
47
+ * this helper function.
48
+ *
49
+ * This function will return the enum names in a sorted order, which may not necessarily be the same
50
+ * order as which they were declared in. (It is impossible to get the declaration order at
51
+ * run-time.)
52
+ *
53
+ * This function will work properly for both number enums and string enums. (Reverse mappings are
54
+ * not created for string enums, so their names would be equivalent to what would be returned by the
55
+ * `getEnumKeys` function.)
56
+ *
57
+ * For a more in depth explanation, see:
58
+ * https://isaacscript.github.io/main/gotchas#iterating-over-enums
59
+ */
60
+ export declare function getEnumNames(transpiledEnum: Record<string | number, string | number>): string[];
61
+ /**
62
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
63
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
64
+ * enums, in a random order. If all you need are the values of an enum, use this helper function.
45
65
  *
46
66
  * This function will return the enum values in a sorted order, which may not necessarily be the
47
- * same order as which they were declared in.
67
+ * same order as which they were declared in. (It is impossible to get the declaration order at
68
+ * run-time.)
48
69
  *
49
70
  * This function will work properly for both number enums and string enums. (Reverse mappings are
50
71
  * not created for string enums.)
@@ -101,7 +122,7 @@ export declare function isEnumValue<T extends Record<string, number | string>>(v
101
122
  */
102
123
  export declare function validateCustomEnum(transpiledEnumName: string, transpiledEnum: unknown): void;
103
124
  /**
104
- * Helper function to validate if every value in an enum is contiguous, starting at 0.
125
+ * Helper function to validate if every value in a number enum is contiguous, starting at 0.
105
126
  *
106
127
  * This is useful to automate checking large enums for typos.
107
128
  */
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/functions/enums.ts"],"names":[],"mappings":";;;AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,cAAc,EAAE,CAAC,GAChB,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAmBzC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,cAAc,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACvD,MAAM,EAAE,CAGV;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAC3B,cAAc,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,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AC,EAClC,cAAc,EAAE,CAAC,EACjB,SAAS,GAAE,IAAI,GAAG,GAAqB,EACvC,UAAU,GAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAM,GAC7D,CAAC,CAAC,MAAM,CAAC,CAAC,CAGZ;AAED,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EACnE,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,cAAc,EAAE,CAAC,GAChB,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAGrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,OAAO,GACtB,IAAI,CAQN;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,CAAC,GAChB,IAAI,CAsBN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAE1C,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,EAC/B,IAAI,SAAS,MAAM,GAAG,MAAM,KACzB,IAAI,CAAG"}
@@ -17,13 +17,14 @@ local isString = ____types.isString
17
17
  local ____utils = require("src.functions.utils")
18
18
  local assertDefined = ____utils.assertDefined
19
19
  local iRange = ____utils.iRange
20
- --- TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
21
- -- when you iterate over them, you will get both the names of the enums and the values of the enums,
22
- -- in a random order. Use this helper function to get the entries of the enum with the reverse
23
- -- mappings filtered out.
20
+ --- TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
21
+ -- Thus, when you iterate over them, you will get both the names of the enums and the values of the
22
+ -- enums, in a random order. Use this helper function to get the entries of the enum with the
23
+ -- reverse mappings filtered out.
24
24
  --
25
25
  -- This function will return the enum values in a sorted order, which may not necessarily be the
26
- -- same order as which they were declared in.
26
+ -- same order as which they were declared in. (It is impossible to get the declaration order at
27
+ -- run-time.)
27
28
  --
28
29
  -- This function will work properly for both number enums and string enums. (Reverse mappings are
29
30
  -- not created for string enums.)
@@ -53,12 +54,13 @@ function ____exports.getEnumEntries(self, transpiledEnum)
53
54
  )
54
55
  return enumEntries
55
56
  end
56
- --- TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
57
- -- when you iterate over them, you will get both the names of the enums and the values of the enums,
58
- -- in a random order. If all you need are the keys of an enum, use this helper function.
57
+ --- TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
58
+ -- Thus, when you iterate over them, you will get both the names of the enums and the values of the
59
+ -- enums, in a random order. If all you need are the keys of an enum, use this helper function.
59
60
  --
60
61
  -- This function will return the enum keys in a sorted order, which may not necessarily be the same
61
- -- order as which they were declared in.
62
+ -- order as which they were declared in. (It is impossible to get the declaration order at
63
+ -- run-time.)
62
64
  --
63
65
  -- This function will work properly for both number enums and string enums. (Reverse mappings are
64
66
  -- not created for string enums.)
@@ -84,12 +86,38 @@ function ____exports.getEnumLength(self, transpiledEnum)
84
86
  local enumEntries = ____exports.getEnumEntries(nil, transpiledEnum)
85
87
  return #enumEntries
86
88
  end
87
- --- TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
88
- -- when you iterate over them, you will get both the names of the enums and the values of the enums,
89
- -- in a random order. If all you need are the values of an enum, use this helper function.
89
+ --- TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
90
+ -- Thus, when you iterate over them, you will get both the names of the enums and the values of the
91
+ -- enums, in a random order. If all you need are the names of an enum from the reverse mapping, use
92
+ -- this helper function.
93
+ --
94
+ -- This function will return the enum names in a sorted order, which may not necessarily be the same
95
+ -- order as which they were declared in. (It is impossible to get the declaration order at
96
+ -- run-time.)
97
+ --
98
+ -- This function will work properly for both number enums and string enums. (Reverse mappings are
99
+ -- not created for string enums, so their names would be equivalent to what would be returned by the
100
+ -- `getEnumKeys` function.)
101
+ --
102
+ -- For a more in depth explanation, see:
103
+ -- https://isaacscript.github.io/main/gotchas#iterating-over-enums
104
+ function ____exports.getEnumNames(self, transpiledEnum)
105
+ local enumNames = {}
106
+ for key, _value in pairs(transpiledEnum) do
107
+ if isString(nil, key) then
108
+ enumNames[#enumNames + 1] = key
109
+ end
110
+ end
111
+ __TS__ArraySort(enumNames)
112
+ return enumNames
113
+ end
114
+ --- TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
115
+ -- Thus, when you iterate over them, you will get both the names of the enums and the values of the
116
+ -- enums, in a random order. If all you need are the values of an enum, use this helper function.
90
117
  --
91
118
  -- This function will return the enum values in a sorted order, which may not necessarily be the
92
- -- same order as which they were declared in.
119
+ -- same order as which they were declared in. (It is impossible to get the declaration order at
120
+ -- run-time.)
93
121
  --
94
122
  -- This function will work properly for both number enums and string enums. (Reverse mappings are
95
123
  -- not created for string enums.)
@@ -177,7 +205,7 @@ function ____exports.validateCustomEnum(self, transpiledEnumName, transpiledEnum
177
205
  end
178
206
  end
179
207
  end
180
- --- Helper function to validate if every value in an enum is contiguous, starting at 0.
208
+ --- Helper function to validate if every value in a number enum is contiguous, starting at 0.
181
209
  --
182
210
  -- This is useful to automate checking large enums for typos.
183
211
  function ____exports.validateEnumContiguous(self, transpiledEnumName, transpiledEnum)
@@ -7,7 +7,7 @@ ____exports.BOSS_NAME_PNG_FILE_NAMES = {
7
7
  [BossID.LARRY_JR] = "bossname_19.0_larryjr.png",
8
8
  [BossID.CHUB] = "bossname_28.0_chub.png",
9
9
  [BossID.GURDY] = "bossname_36.0_gurdy.png",
10
- [BossID.MONSTRO_II] = "bossname_43.0_monstro2.png",
10
+ [BossID.MONSTRO_2] = "bossname_43.0_monstro2.png",
11
11
  [BossID.MOM] = "bossname_45.0_mom.png",
12
12
  [BossID.SCOLEX] = "bossname_62.1_scolex.png",
13
13
  [BossID.MOMS_HEART] = "bossname_78.0_momsheart.png",
@@ -7,7 +7,7 @@ ____exports.BOSS_PORTRAIT_PNG_FILE_NAMES = {
7
7
  [BossID.LARRY_JR] = "portrait_19.0_larryjr.png",
8
8
  [BossID.CHUB] = "portrait_28.0_chub.png",
9
9
  [BossID.GURDY] = "portrait_36.0_gurdy.png",
10
- [BossID.MONSTRO_II] = "portrait_43.0_monstro2.png",
10
+ [BossID.MONSTRO_2] = "portrait_43.0_monstro2.png",
11
11
  [BossID.MOM] = "portrait_45.0_mom.png",
12
12
  [BossID.SCOLEX] = "portrait_62.1_scolex.png",
13
13
  [BossID.MOMS_HEART] = "portrait_78.0_momsheart.png",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "47.5.4",
3
+ "version": "48.1.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,6 +25,6 @@
25
25
  "main": "dist/src/index",
26
26
  "types": "dist/index.rollup.d.ts",
27
27
  "dependencies": {
28
- "isaac-typescript-definitions": "^17.0.5"
28
+ "isaac-typescript-definitions": "^18.0.0"
29
29
  }
30
30
  }
@@ -5,13 +5,14 @@ import { isNumber, isString } from "./types";
5
5
  import { assertDefined, iRange } from "./utils";
6
6
 
7
7
  /**
8
- * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
9
- * when you iterate over them, you will get both the names of the enums and the values of the enums,
10
- * in a random order. Use this helper function to get the entries of the enum with the reverse
11
- * mappings filtered out.
8
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
9
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
10
+ * enums, in a random order. Use this helper function to get the entries of the enum with the
11
+ * reverse mappings filtered out.
12
12
  *
13
13
  * This function will return the enum values in a sorted order, which may not necessarily be the
14
- * same order as which they were declared in.
14
+ * same order as which they were declared in. (It is impossible to get the declaration order at
15
+ * run-time.)
15
16
  *
16
17
  * This function will work properly for both number enums and string enums. (Reverse mappings are
17
18
  * not created for string enums.)
@@ -45,12 +46,13 @@ export function getEnumEntries<T>(
45
46
  }
46
47
 
47
48
  /**
48
- * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
49
- * when you iterate over them, you will get both the names of the enums and the values of the enums,
50
- * in a random order. If all you need are the keys of an enum, use this helper function.
49
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
50
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
51
+ * enums, in a random order. If all you need are the keys of an enum, use this helper function.
51
52
  *
52
53
  * This function will return the enum keys in a sorted order, which may not necessarily be the same
53
- * order as which they were declared in.
54
+ * order as which they were declared in. (It is impossible to get the declaration order at
55
+ * run-time.)
54
56
  *
55
57
  * This function will work properly for both number enums and string enums. (Reverse mappings are
56
58
  * not created for string enums.)
@@ -76,12 +78,47 @@ export function getEnumLength(
76
78
  }
77
79
 
78
80
  /**
79
- * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
80
- * when you iterate over them, you will get both the names of the enums and the values of the enums,
81
- * in a random order. If all you need are the values of an enum, use this helper function.
81
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
82
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
83
+ * enums, in a random order. If all you need are the names of an enum from the reverse mapping, use
84
+ * this helper function.
85
+ *
86
+ * This function will return the enum names in a sorted order, which may not necessarily be the same
87
+ * order as which they were declared in. (It is impossible to get the declaration order at
88
+ * run-time.)
89
+ *
90
+ * This function will work properly for both number enums and string enums. (Reverse mappings are
91
+ * not created for string enums, so their names would be equivalent to what would be returned by the
92
+ * `getEnumKeys` function.)
93
+ *
94
+ * For a more in depth explanation, see:
95
+ * https://isaacscript.github.io/main/gotchas#iterating-over-enums
96
+ */
97
+ export function getEnumNames(
98
+ transpiledEnum: Record<string | number, string | number>,
99
+ ): string[] {
100
+ const enumNames: string[] = [];
101
+
102
+ for (const [key, _value] of pairs(transpiledEnum)) {
103
+ if (isString(key)) {
104
+ enumNames.push(key);
105
+ }
106
+ }
107
+
108
+ // The enum names will be in a random order (because of "pairs"), so sort them.
109
+ enumNames.sort();
110
+
111
+ return enumNames;
112
+ }
113
+
114
+ /**
115
+ * TypeScriptToLua will transpile TypeScript number enums to Lua tables that have a double mapping.
116
+ * Thus, when you iterate over them, you will get both the names of the enums and the values of the
117
+ * enums, in a random order. If all you need are the values of an enum, use this helper function.
82
118
  *
83
119
  * This function will return the enum values in a sorted order, which may not necessarily be the
84
- * same order as which they were declared in.
120
+ * same order as which they were declared in. (It is impossible to get the declaration order at
121
+ * run-time.)
85
122
  *
86
123
  * This function will work properly for both number enums and string enums. (Reverse mappings are
87
124
  * not created for string enums.)
@@ -191,7 +228,7 @@ export function validateCustomEnum(
191
228
  }
192
229
 
193
230
  /**
194
- * Helper function to validate if every value in an enum is contiguous, starting at 0.
231
+ * Helper function to validate if every value in a number enum is contiguous, starting at 0.
195
232
  *
196
233
  * This is useful to automate checking large enums for typos.
197
234
  */
@@ -8,7 +8,7 @@ export const BOSS_NAME_PNG_FILE_NAMES = {
8
8
  [BossID.LARRY_JR]: "bossname_19.0_larryjr.png", // 2
9
9
  [BossID.CHUB]: "bossname_28.0_chub.png", // 3
10
10
  [BossID.GURDY]: "bossname_36.0_gurdy.png", // 4
11
- [BossID.MONSTRO_II]: "bossname_43.0_monstro2.png", // 5
11
+ [BossID.MONSTRO_2]: "bossname_43.0_monstro2.png", // 5
12
12
  [BossID.MOM]: "bossname_45.0_mom.png", // 6
13
13
  [BossID.SCOLEX]: "bossname_62.1_scolex.png", // 7
14
14
  [BossID.MOMS_HEART]: "bossname_78.0_momsheart.png", // 8
@@ -8,7 +8,7 @@ export const BOSS_PORTRAIT_PNG_FILE_NAMES = {
8
8
  [BossID.LARRY_JR]: "portrait_19.0_larryjr.png", // 2
9
9
  [BossID.CHUB]: "portrait_28.0_chub.png", // 3
10
10
  [BossID.GURDY]: "portrait_36.0_gurdy.png", // 4
11
- [BossID.MONSTRO_II]: "portrait_43.0_monstro2.png", // 5
11
+ [BossID.MONSTRO_2]: "portrait_43.0_monstro2.png", // 5
12
12
  [BossID.MOM]: "portrait_45.0_mom.png", // 6
13
13
  [BossID.SCOLEX]: "portrait_62.1_scolex.png", // 7
14
14
  [BossID.MOMS_HEART]: "portrait_78.0_momsheart.png", // 8