isaacscript-common 85.1.0 → 86.0.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.
package/dist/features.js CHANGED
@@ -61,7 +61,7 @@ const UnlockAchievementsDetection_1 = require("./classes/features/other/UnlockAc
61
61
  const ISCFeature_1 = require("./enums/ISCFeature");
62
62
  const ModCallbackCustom_1 = require("./enums/ModCallbackCustom");
63
63
  const enums_1 = require("./functions/enums");
64
- (0, enums_1.validateInterfaceMatchesEnum)();
64
+ (0, enums_1.interfaceSatisfiesEnum)();
65
65
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
66
66
  function getFeatures(mod, callbacks) {
67
67
  // Some features rely on other features; we must initialize those first.
package/dist/features.lua CHANGED
@@ -120,8 +120,8 @@ local ISCFeature = ____ISCFeature.ISCFeature
120
120
  local ____ModCallbackCustom = require("enums.ModCallbackCustom")
121
121
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
122
122
  local ____enums = require("functions.enums")
123
- local validateInterfaceMatchesEnum = ____enums.validateInterfaceMatchesEnum
124
- validateInterfaceMatchesEnum(nil)
123
+ local interfaceSatisfiesEnum = ____enums.interfaceSatisfiesEnum
124
+ interfaceSatisfiesEnum(nil)
125
125
  function ____exports.getFeatures(self, mod, callbacks)
126
126
  local gameReorderedCallbacks = __TS__New(
127
127
  GameReorderedCallbacks,
@@ -113,30 +113,6 @@ export declare function getLowestEnumValue<T extends TranspiledEnum>(transpiledE
113
113
  * @param exceptions Optional. An array of elements to skip over if selected.
114
114
  */
115
115
  export declare function getRandomEnumValue<T extends TranspiledEnum>(transpiledEnum: T, seedOrRNG: Seed | RNG | undefined, exceptions?: ReadonlyArray<T[keyof T]>): T[keyof T];
116
- /** Helper function to validate that a particular value exists inside of an enum. */
117
- export declare function isEnumValue<T extends TranspiledEnum>(value: number | string | BitFlag | BitFlag128, transpiledEnum: T): value is T[keyof T];
118
- /**
119
- * Helper function to check every value of a custom enum for -1. Will throw an run-time error if any
120
- * -1 values are found. This is helpful because many methods of the Isaac class return -1 if they
121
- * fail.
122
- *
123
- * For example:
124
- *
125
- * ```ts
126
- * enum EntityTypeCustom {
127
- * FOO = Isaac.GetEntityTypeByName("Foo"),
128
- * }
129
- *
130
- * validateCustomEnum("EntityTypeCustom", EntityTypeCustom);
131
- * ```
132
- */
133
- export declare function validateCustomEnum(transpiledEnumName: string, transpiledEnum: TranspiledEnum): void;
134
- /**
135
- * Helper function to validate if every value in a number enum is contiguous, starting at 0.
136
- *
137
- * This is useful to automate checking large enums for typos.
138
- */
139
- export declare function validateEnumContiguous<T extends TranspiledEnum>(transpiledEnumName: string, transpiledEnum: T): void;
140
116
  /**
141
117
  * Helper function to validate that an interface contains all of the keys of an enum. You must
142
118
  * specify both generic parameters in order for this to work properly (i.e. the interface and then
@@ -157,12 +133,36 @@ export declare function validateEnumContiguous<T extends TranspiledEnum>(transpi
157
133
  * [MyEnum.Value3]: string;
158
134
  * }
159
135
  *
160
- * validateInterfaceMatchesEnum<MyEnumToType, MyEnum>();
136
+ * interfaceSatisfiesEnum<MyEnumToType, MyEnum>();
161
137
  * ```
162
138
  *
163
139
  * This function is only meant to be used with interfaces (i.e. types that will not exist at
164
140
  * run-time). If you are generating an object that will contain all of the keys of an enum, use the
165
141
  * `satisfies` operator with the `Record` type instead.
166
142
  */
167
- export declare function validateInterfaceMatchesEnum<T extends Record<Enum, unknown>, Enum extends string | number>(): void;
143
+ export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>, Enum extends string | number>(): void;
144
+ /** Helper function to validate that a particular value exists inside of an enum. */
145
+ export declare function isEnumValue<T extends TranspiledEnum>(value: number | string | BitFlag | BitFlag128, transpiledEnum: T): value is T[keyof T];
146
+ /**
147
+ * Helper function to check every value of a custom enum for -1. Will throw an run-time error if any
148
+ * -1 values are found. This is helpful because many methods of the Isaac class return -1 if they
149
+ * fail.
150
+ *
151
+ * For example:
152
+ *
153
+ * ```ts
154
+ * enum EntityTypeCustom {
155
+ * FOO = Isaac.GetEntityTypeByName("Foo"),
156
+ * }
157
+ *
158
+ * validateCustomEnum("EntityTypeCustom", EntityTypeCustom);
159
+ * ```
160
+ */
161
+ export declare function validateCustomEnum(transpiledEnumName: string, transpiledEnum: TranspiledEnum): void;
162
+ /**
163
+ * Helper function to validate if every value in a number enum is contiguous, starting at 0.
164
+ *
165
+ * This is useful to automate checking large enums for typos.
166
+ */
167
+ export declare function validateEnumContiguous<T extends TranspiledEnum>(transpiledEnumName: string, transpiledEnum: T): void;
168
168
  //# sourceMappingURL=enums.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/functions/enums.ts"],"names":[],"mappings":";;;;;AAMA;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CACjC,MAAM,EACN,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CACvC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,cAAc,EACrD,cAAc,EAAE,CAAC,GAChB,aAAa,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAiBjD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,MAAM,EAAE,CAG7E;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,GAAG,CAGjE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAC1B,cAAc,EAAE,cAAc,GAC7B,SAAS,MAAM,EAAE,CAanB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,cAAc,EACpD,cAAc,EAAE,CAAC,GAChB,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAG3B;AAED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,CAAC,CAAC,MAAM,CAAC,CAAC,CAGZ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CAEpC,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,EAC/B,IAAI,SAAS,MAAM,GAAG,MAAM,KACzB,IAAI,CAAG;AAEZ,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,CAAC,SAAS,cAAc,EAClD,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,EAC7C,cAAc,EAAE,CAAC,GAChB,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAGrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,cAAc,GAC7B,IAAI,CAQN;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,cAAc,EAC7D,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,CAAC,GAChB,IAAI,CAsBN"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateInterfaceMatchesEnum = exports.validateEnumContiguous = exports.validateCustomEnum = exports.isEnumValue = exports.getRandomEnumValue = exports.getLowestEnumValue = exports.getHighestEnumValue = exports.getEnumValues = exports.getEnumNames = exports.getEnumLength = exports.getEnumKeys = exports.getEnumEntries = void 0;
3
+ exports.validateEnumContiguous = exports.validateCustomEnum = exports.isEnumValue = exports.interfaceSatisfiesEnum = exports.getRandomEnumValue = exports.getLowestEnumValue = exports.getHighestEnumValue = exports.getEnumValues = exports.getEnumNames = exports.getEnumLength = exports.getEnumKeys = exports.getEnumEntries = void 0;
4
4
  const ReadonlySet_1 = require("../types/ReadonlySet");
5
5
  const array_1 = require("./array");
6
6
  const sort_1 = require("./sort");
@@ -162,6 +162,35 @@ function getRandomEnumValue(transpiledEnum, seedOrRNG, exceptions = []) {
162
162
  return (0, array_1.getRandomArrayElement)(enumValues, seedOrRNG, exceptions);
163
163
  }
164
164
  exports.getRandomEnumValue = getRandomEnumValue;
165
+ /**
166
+ * Helper function to validate that an interface contains all of the keys of an enum. You must
167
+ * specify both generic parameters in order for this to work properly (i.e. the interface and then
168
+ * the enum).
169
+ *
170
+ * For example:
171
+ *
172
+ * ```ts
173
+ * enum MyEnum {
174
+ * Value1,
175
+ * Value2,
176
+ * Value3,
177
+ * }
178
+ *
179
+ * interface MyEnumToType {
180
+ * [MyEnum.Value1]: boolean;
181
+ * [MyEnum.Value2]: number;
182
+ * [MyEnum.Value3]: string;
183
+ * }
184
+ *
185
+ * interfaceSatisfiesEnum<MyEnumToType, MyEnum>();
186
+ * ```
187
+ *
188
+ * This function is only meant to be used with interfaces (i.e. types that will not exist at
189
+ * run-time). If you are generating an object that will contain all of the keys of an enum, use the
190
+ * `satisfies` operator with the `Record` type instead.
191
+ */
192
+ function interfaceSatisfiesEnum() { } // eslint-disable-line @typescript-eslint/no-empty-function
193
+ exports.interfaceSatisfiesEnum = interfaceSatisfiesEnum;
165
194
  /** Helper function to validate that a particular value exists inside of an enum. */
166
195
  function isEnumValue(value, transpiledEnum) {
167
196
  const enumValues = getEnumValues(transpiledEnum);
@@ -211,32 +240,3 @@ function validateEnumContiguous(transpiledEnumName, transpiledEnum) {
211
240
  }
212
241
  }
213
242
  exports.validateEnumContiguous = validateEnumContiguous;
214
- /**
215
- * Helper function to validate that an interface contains all of the keys of an enum. You must
216
- * specify both generic parameters in order for this to work properly (i.e. the interface and then
217
- * the enum).
218
- *
219
- * For example:
220
- *
221
- * ```ts
222
- * enum MyEnum {
223
- * Value1,
224
- * Value2,
225
- * Value3,
226
- * }
227
- *
228
- * interface MyEnumToType {
229
- * [MyEnum.Value1]: boolean;
230
- * [MyEnum.Value2]: number;
231
- * [MyEnum.Value3]: string;
232
- * }
233
- *
234
- * validateInterfaceMatchesEnum<MyEnumToType, MyEnum>();
235
- * ```
236
- *
237
- * This function is only meant to be used with interfaces (i.e. types that will not exist at
238
- * run-time). If you are generating an object that will contain all of the keys of an enum, use the
239
- * `satisfies` operator with the `Record` type instead.
240
- */
241
- function validateInterfaceMatchesEnum() { } // eslint-disable-line @typescript-eslint/no-empty-function
242
- exports.validateInterfaceMatchesEnum = validateInterfaceMatchesEnum;
@@ -188,6 +188,33 @@ function ____exports.getRandomEnumValue(self, transpiledEnum, seedOrRNG, excepti
188
188
  local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
189
189
  return getRandomArrayElement(nil, enumValues, seedOrRNG, exceptions)
190
190
  end
191
+ --- Helper function to validate that an interface contains all of the keys of an enum. You must
192
+ -- specify both generic parameters in order for this to work properly (i.e. the interface and then
193
+ -- the enum).
194
+ --
195
+ -- For example:
196
+ --
197
+ -- ```ts
198
+ -- enum MyEnum {
199
+ -- Value1,
200
+ -- Value2,
201
+ -- Value3,
202
+ -- }
203
+ --
204
+ -- interface MyEnumToType {
205
+ -- [MyEnum.Value1]: boolean;
206
+ -- [MyEnum.Value2]: number;
207
+ -- [MyEnum.Value3]: string;
208
+ -- }
209
+ --
210
+ -- interfaceSatisfiesEnum<MyEnumToType, MyEnum>();
211
+ -- ```
212
+ --
213
+ -- This function is only meant to be used with interfaces (i.e. types that will not exist at
214
+ -- run-time). If you are generating an object that will contain all of the keys of an enum, use the
215
+ -- `satisfies` operator with the `Record` type instead.
216
+ function ____exports.interfaceSatisfiesEnum(self)
217
+ end
191
218
  --- Helper function to validate that a particular value exists inside of an enum.
192
219
  function ____exports.isEnumValue(self, value, transpiledEnum)
193
220
  local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
@@ -232,31 +259,4 @@ function ____exports.validateEnumContiguous(self, transpiledEnumName, transpiled
232
259
  end
233
260
  end
234
261
  end
235
- --- Helper function to validate that an interface contains all of the keys of an enum. You must
236
- -- specify both generic parameters in order for this to work properly (i.e. the interface and then
237
- -- the enum).
238
- --
239
- -- For example:
240
- --
241
- -- ```ts
242
- -- enum MyEnum {
243
- -- Value1,
244
- -- Value2,
245
- -- Value3,
246
- -- }
247
- --
248
- -- interface MyEnumToType {
249
- -- [MyEnum.Value1]: boolean;
250
- -- [MyEnum.Value2]: number;
251
- -- [MyEnum.Value3]: string;
252
- -- }
253
- --
254
- -- validateInterfaceMatchesEnum<MyEnumToType, MyEnum>();
255
- -- ```
256
- --
257
- -- This function is only meant to be used with interfaces (i.e. types that will not exist at
258
- -- run-time). If you are generating an object that will contain all of the keys of an enum, use the
259
- -- `satisfies` operator with the `Record` type instead.
260
- function ____exports.validateInterfaceMatchesEnum(self)
261
- end
262
262
  return ____exports
@@ -8870,6 +8870,35 @@ export declare function inSecretShop(): boolean;
8870
8870
  */
8871
8871
  export declare function inStartingRoom(): boolean;
8872
8872
 
8873
+ /**
8874
+ * Helper function to validate that an interface contains all of the keys of an enum. You must
8875
+ * specify both generic parameters in order for this to work properly (i.e. the interface and then
8876
+ * the enum).
8877
+ *
8878
+ * For example:
8879
+ *
8880
+ * ```ts
8881
+ * enum MyEnum {
8882
+ * Value1,
8883
+ * Value2,
8884
+ * Value3,
8885
+ * }
8886
+ *
8887
+ * interface MyEnumToType {
8888
+ * [MyEnum.Value1]: boolean;
8889
+ * [MyEnum.Value2]: number;
8890
+ * [MyEnum.Value3]: string;
8891
+ * }
8892
+ *
8893
+ * interfaceSatisfiesEnum<MyEnumToType, MyEnum>();
8894
+ * ```
8895
+ *
8896
+ * This function is only meant to be used with interfaces (i.e. types that will not exist at
8897
+ * run-time). If you are generating an object that will contain all of the keys of an enum, use the
8898
+ * `satisfies` operator with the `Record` type instead.
8899
+ */
8900
+ export declare function interfaceSatisfiesEnum<T extends Record<Enum, unknown>, Enum extends string | number>(): void;
8901
+
8873
8902
  /**
8874
8903
  * Helper type to get a range of integers. It is inclusive on both ends. (The "I" in the type name
8875
8904
  * stands for inclusive.)
@@ -19226,35 +19255,6 @@ export declare function validateCustomEnum(transpiledEnumName: string, transpile
19226
19255
  */
19227
19256
  export declare function validateEnumContiguous<T extends TranspiledEnum>(transpiledEnumName: string, transpiledEnum: T): void;
19228
19257
 
19229
- /**
19230
- * Helper function to validate that an interface contains all of the keys of an enum. You must
19231
- * specify both generic parameters in order for this to work properly (i.e. the interface and then
19232
- * the enum).
19233
- *
19234
- * For example:
19235
- *
19236
- * ```ts
19237
- * enum MyEnum {
19238
- * Value1,
19239
- * Value2,
19240
- * Value3,
19241
- * }
19242
- *
19243
- * interface MyEnumToType {
19244
- * [MyEnum.Value1]: boolean;
19245
- * [MyEnum.Value2]: number;
19246
- * [MyEnum.Value3]: string;
19247
- * }
19248
- *
19249
- * validateInterfaceMatchesEnum<MyEnumToType, MyEnum>();
19250
- * ```
19251
- *
19252
- * This function is only meant to be used with interfaces (i.e. types that will not exist at
19253
- * run-time). If you are generating an object that will contain all of the keys of an enum, use the
19254
- * `satisfies` operator with the `Record` type instead.
19255
- */
19256
- export declare function validateInterfaceMatchesEnum<T extends Record<Enum, unknown>, Enum extends string | number>(): void;
19257
-
19258
19258
  /**
19259
19259
  * An array that represents the range from the first vanilla card type to the last vanilla card
19260
19260
  * type.
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const enums_1 = require("../functions/enums");
4
- (0, enums_1.validateInterfaceMatchesEnum)();
4
+ (0, enums_1.interfaceSatisfiesEnum)();
@@ -1,5 +1,5 @@
1
1
  local ____exports = {}
2
2
  local ____enums = require("functions.enums")
3
- local validateInterfaceMatchesEnum = ____enums.validateInterfaceMatchesEnum
4
- validateInterfaceMatchesEnum(nil)
3
+ local interfaceSatisfiesEnum = ____enums.interfaceSatisfiesEnum
4
+ interfaceSatisfiesEnum(nil)
5
5
  return ____exports
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const enums_1 = require("../../functions/enums");
4
- (0, enums_1.validateInterfaceMatchesEnum)();
4
+ (0, enums_1.interfaceSatisfiesEnum)();
@@ -1,5 +1,5 @@
1
1
  local ____exports = {}
2
2
  local ____enums = require("functions.enums")
3
- local validateInterfaceMatchesEnum = ____enums.validateInterfaceMatchesEnum
4
- validateInterfaceMatchesEnum(nil)
3
+ local interfaceSatisfiesEnum = ____enums.interfaceSatisfiesEnum
4
+ interfaceSatisfiesEnum(nil)
5
5
  return ____exports
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 85.0.2
3
+ isaacscript-common 85.1.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -19251,6 +19251,33 @@ function ____exports.getRandomEnumValue(self, transpiledEnum, seedOrRNG, excepti
19251
19251
  local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
19252
19252
  return getRandomArrayElement(nil, enumValues, seedOrRNG, exceptions)
19253
19253
  end
19254
+ --- Helper function to validate that an interface contains all of the keys of an enum. You must
19255
+ -- specify both generic parameters in order for this to work properly (i.e. the interface and then
19256
+ -- the enum).
19257
+ --
19258
+ -- For example:
19259
+ --
19260
+ -- ```ts
19261
+ -- enum MyEnum {
19262
+ -- Value1,
19263
+ -- Value2,
19264
+ -- Value3,
19265
+ -- }
19266
+ --
19267
+ -- interface MyEnumToType {
19268
+ -- [MyEnum.Value1]: boolean;
19269
+ -- [MyEnum.Value2]: number;
19270
+ -- [MyEnum.Value3]: string;
19271
+ -- }
19272
+ --
19273
+ -- interfaceSatisfiesEnum<MyEnumToType, MyEnum>();
19274
+ -- ```
19275
+ --
19276
+ -- This function is only meant to be used with interfaces (i.e. types that will not exist at
19277
+ -- run-time). If you are generating an object that will contain all of the keys of an enum, use the
19278
+ -- `satisfies` operator with the `Record` type instead.
19279
+ function ____exports.interfaceSatisfiesEnum(self)
19280
+ end
19254
19281
  --- Helper function to validate that a particular value exists inside of an enum.
19255
19282
  function ____exports.isEnumValue(self, value, transpiledEnum)
19256
19283
  local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
@@ -19295,33 +19322,6 @@ function ____exports.validateEnumContiguous(self, transpiledEnumName, transpiled
19295
19322
  end
19296
19323
  end
19297
19324
  end
19298
- --- Helper function to validate that an interface contains all of the keys of an enum. You must
19299
- -- specify both generic parameters in order for this to work properly (i.e. the interface and then
19300
- -- the enum).
19301
- --
19302
- -- For example:
19303
- --
19304
- -- ```ts
19305
- -- enum MyEnum {
19306
- -- Value1,
19307
- -- Value2,
19308
- -- Value3,
19309
- -- }
19310
- --
19311
- -- interface MyEnumToType {
19312
- -- [MyEnum.Value1]: boolean;
19313
- -- [MyEnum.Value2]: number;
19314
- -- [MyEnum.Value3]: string;
19315
- -- }
19316
- --
19317
- -- validateInterfaceMatchesEnum<MyEnumToType, MyEnum>();
19318
- -- ```
19319
- --
19320
- -- This function is only meant to be used with interfaces (i.e. types that will not exist at
19321
- -- run-time). If you are generating an object that will contain all of the keys of an enum, use the
19322
- -- `satisfies` operator with the `Record` type instead.
19323
- function ____exports.validateInterfaceMatchesEnum(self)
19324
- end
19325
19325
  return ____exports
19326
19326
  end,
19327
19327
  ["cachedEnumValues"] = function(...)
@@ -19596,15 +19596,15 @@ return ____exports
19596
19596
  ["interfaces.PlayerStats"] = function(...)
19597
19597
  local ____exports = {}
19598
19598
  local ____enums = require("functions.enums")
19599
- local validateInterfaceMatchesEnum = ____enums.validateInterfaceMatchesEnum
19600
- validateInterfaceMatchesEnum(nil)
19599
+ local interfaceSatisfiesEnum = ____enums.interfaceSatisfiesEnum
19600
+ interfaceSatisfiesEnum(nil)
19601
19601
  return ____exports
19602
19602
  end,
19603
19603
  ["interfaces.private.AddCallbackParametersCustom"] = function(...)
19604
19604
  local ____exports = {}
19605
19605
  local ____enums = require("functions.enums")
19606
- local validateInterfaceMatchesEnum = ____enums.validateInterfaceMatchesEnum
19607
- validateInterfaceMatchesEnum(nil)
19606
+ local interfaceSatisfiesEnum = ____enums.interfaceSatisfiesEnum
19607
+ interfaceSatisfiesEnum(nil)
19608
19608
  return ____exports
19609
19609
  end,
19610
19610
  ["types.AllButFirst"] = function(...)
@@ -63616,8 +63616,8 @@ local ISCFeature = ____ISCFeature.ISCFeature
63616
63616
  local ____ModCallbackCustom = require("enums.ModCallbackCustom")
63617
63617
  local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
63618
63618
  local ____enums = require("functions.enums")
63619
- local validateInterfaceMatchesEnum = ____enums.validateInterfaceMatchesEnum
63620
- validateInterfaceMatchesEnum(nil)
63619
+ local interfaceSatisfiesEnum = ____enums.interfaceSatisfiesEnum
63620
+ interfaceSatisfiesEnum(nil)
63621
63621
  function ____exports.getFeatures(self, mod, callbacks)
63622
63622
  local gameReorderedCallbacks = __TS__New(
63623
63623
  GameReorderedCallbacks,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "85.1.0",
3
+ "version": "86.0.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
package/src/features.ts CHANGED
@@ -59,7 +59,7 @@ import { UnlockAchievementsDetection } from "./classes/features/other/UnlockAchi
59
59
  import type { Feature } from "./classes/private/Feature";
60
60
  import { ISCFeature } from "./enums/ISCFeature";
61
61
  import { ModCallbackCustom } from "./enums/ModCallbackCustom";
62
- import { validateInterfaceMatchesEnum } from "./functions/enums";
62
+ import { interfaceSatisfiesEnum } from "./functions/enums";
63
63
  import type { ModUpgradedInterface } from "./interfaces/private/ModUpgradedInterface";
64
64
 
65
65
  export interface ISCFeatureToClass {
@@ -125,7 +125,7 @@ export interface ISCFeatureToClass {
125
125
  [ISCFeature.UNLOCK_ACHIEVEMENTS_DETECTION]: UnlockAchievementsDetection;
126
126
  }
127
127
 
128
- validateInterfaceMatchesEnum<ISCFeatureToClass, ISCFeature>();
128
+ interfaceSatisfiesEnum<ISCFeatureToClass, ISCFeature>();
129
129
 
130
130
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
131
131
  export function getFeatures(
@@ -202,6 +202,39 @@ export function getRandomEnumValue<T extends TranspiledEnum>(
202
202
  return getRandomArrayElement(enumValues, seedOrRNG, exceptions);
203
203
  }
204
204
 
205
+ /**
206
+ * Helper function to validate that an interface contains all of the keys of an enum. You must
207
+ * specify both generic parameters in order for this to work properly (i.e. the interface and then
208
+ * the enum).
209
+ *
210
+ * For example:
211
+ *
212
+ * ```ts
213
+ * enum MyEnum {
214
+ * Value1,
215
+ * Value2,
216
+ * Value3,
217
+ * }
218
+ *
219
+ * interface MyEnumToType {
220
+ * [MyEnum.Value1]: boolean;
221
+ * [MyEnum.Value2]: number;
222
+ * [MyEnum.Value3]: string;
223
+ * }
224
+ *
225
+ * interfaceSatisfiesEnum<MyEnumToType, MyEnum>();
226
+ * ```
227
+ *
228
+ * This function is only meant to be used with interfaces (i.e. types that will not exist at
229
+ * run-time). If you are generating an object that will contain all of the keys of an enum, use the
230
+ * `satisfies` operator with the `Record` type instead.
231
+ */
232
+ export function interfaceSatisfiesEnum<
233
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
234
+ T extends Record<Enum, unknown>,
235
+ Enum extends string | number,
236
+ >(): void {} // eslint-disable-line @typescript-eslint/no-empty-function
237
+
205
238
  /** Helper function to validate that a particular value exists inside of an enum. */
206
239
  export function isEnumValue<T extends TranspiledEnum>(
207
240
  value: number | string | BitFlag | BitFlag128,
@@ -270,36 +303,3 @@ export function validateEnumContiguous<T extends TranspiledEnum>(
270
303
  }
271
304
  }
272
305
  }
273
-
274
- /**
275
- * Helper function to validate that an interface contains all of the keys of an enum. You must
276
- * specify both generic parameters in order for this to work properly (i.e. the interface and then
277
- * the enum).
278
- *
279
- * For example:
280
- *
281
- * ```ts
282
- * enum MyEnum {
283
- * Value1,
284
- * Value2,
285
- * Value3,
286
- * }
287
- *
288
- * interface MyEnumToType {
289
- * [MyEnum.Value1]: boolean;
290
- * [MyEnum.Value2]: number;
291
- * [MyEnum.Value3]: string;
292
- * }
293
- *
294
- * validateInterfaceMatchesEnum<MyEnumToType, MyEnum>();
295
- * ```
296
- *
297
- * This function is only meant to be used with interfaces (i.e. types that will not exist at
298
- * run-time). If you are generating an object that will contain all of the keys of an enum, use the
299
- * `satisfies` operator with the `Record` type instead.
300
- */
301
- export function validateInterfaceMatchesEnum<
302
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
303
- T extends Record<Enum, unknown>,
304
- Enum extends string | number,
305
- >(): void {} // eslint-disable-line @typescript-eslint/no-empty-function
@@ -1,6 +1,6 @@
1
1
  import type { TearFlag } from "isaac-typescript-definitions";
2
2
  import type { PlayerStat } from "../enums/PlayerStat";
3
- import { validateInterfaceMatchesEnum } from "../functions/enums";
3
+ import { interfaceSatisfiesEnum } from "../functions/enums";
4
4
 
5
5
  /**
6
6
  * Contains every player stat along with its corresponding data type. For example, `StatType.DAMAGE`
@@ -22,4 +22,4 @@ export interface PlayerStats {
22
22
  [PlayerStat.SIZE]: Vector;
23
23
  }
24
24
 
25
- validateInterfaceMatchesEnum<PlayerStats, PlayerStat>();
25
+ interfaceSatisfiesEnum<PlayerStats, PlayerStat>();
@@ -39,7 +39,7 @@ import type { HealthType } from "../../enums/HealthType";
39
39
  import type { ModCallbackCustom } from "../../enums/ModCallbackCustom";
40
40
  import type { PlayerStat } from "../../enums/PlayerStat";
41
41
  import type { SlotDestructionType } from "../../enums/SlotDestructionType";
42
- import { validateInterfaceMatchesEnum } from "../../functions/enums";
42
+ import { interfaceSatisfiesEnum } from "../../functions/enums";
43
43
  import type {
44
44
  PickingUpItem,
45
45
  PickingUpItemCollectible,
@@ -1059,4 +1059,4 @@ export interface AddCallbackParametersCustom {
1059
1059
  ];
1060
1060
  }
1061
1061
 
1062
- validateInterfaceMatchesEnum<AddCallbackParametersCustom, ModCallbackCustom>();
1062
+ interfaceSatisfiesEnum<AddCallbackParametersCustom, ModCallbackCustom>();