isaacscript-common 87.2.2 → 87.4.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.
@@ -181,6 +181,35 @@ export function isRepentance(): boolean {
181
181
  return isFunction(getAnimation);
182
182
  }
183
183
 
184
+ /**
185
+ * Helper function to check if the player is using REPENTOGON, an exe-hack which expands the modding
186
+ * API.
187
+ *
188
+ * Although REPENTOGON has a `REPENTOGON` global to check if it's present, it is not safe to use as
189
+ * it can be overwritten by other mods.
190
+ *
191
+ * Specifically, this function checks for the `Sprite.Continue` method:
192
+ * https://repentogon.com/Sprite.html#continue
193
+ */
194
+ export function isRepentogon(): boolean {
195
+ const metatable = getmetatable(Sprite) as LuaMap<string, unknown> | undefined;
196
+ assertDefined(
197
+ metatable,
198
+ "Failed to get the metatable of the Sprite global table.",
199
+ );
200
+
201
+ const classTable = metatable.get("__class") as
202
+ | LuaMap<string, unknown>
203
+ | undefined;
204
+ assertDefined(
205
+ classTable,
206
+ 'Failed to get the "__class" key of the Sprite metatable.',
207
+ );
208
+
209
+ const getAnimation = classTable.get("Continue");
210
+ return isFunction(getAnimation);
211
+ }
212
+
184
213
  /**
185
214
  * Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
186
215
  *
package/src/index.ts CHANGED
@@ -179,6 +179,7 @@ export * from "./types/Increment";
179
179
  export * from "./types/LowercaseKeys";
180
180
  export * from "./types/NaturalNumbersLessThan";
181
181
  export * from "./types/NaturalNumbersLessThanOrEqualTo";
182
+ export * from "./types/ObjectValues";
182
183
  export * from "./types/PickingUpItem";
183
184
  export * from "./types/PickupIndex";
184
185
  export * from "./types/PlayerIndex";
@@ -0,0 +1 @@
1
+ export type ObjectValues<T> = T[keyof T];
@@ -1,6 +1,4 @@
1
- export type TupleToIntersection<T extends unknown[]> = T extends [
2
- infer F,
3
- ...infer R,
4
- ]
5
- ? F & TupleToIntersection<R>
6
- : unknown;
1
+ export type TupleToIntersection<T extends readonly unknown[]> =
2
+ T extends readonly [infer F, ...infer R]
3
+ ? F & TupleToIntersection<R>
4
+ : unknown;