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.
- package/dist/functions/decorators.d.ts.map +1 -1
- package/dist/functions/math.d.ts +1 -1
- package/dist/functions/math.js +1 -1
- package/dist/functions/math.lua +1 -1
- package/dist/functions/stats.js +1 -1
- package/dist/functions/stats.lua +1 -1
- package/dist/functions/string.d.ts +1 -1
- package/dist/functions/string.js +1 -1
- package/dist/functions/string.lua +1 -1
- package/dist/functions/utils.d.ts +11 -0
- package/dist/functions/utils.d.ts.map +1 -1
- package/dist/functions/utils.js +20 -1
- package/dist/functions/utils.lua +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.rollup.d.ts +17 -6
- package/dist/indexLua.d.ts +1 -0
- package/dist/indexLua.d.ts.map +1 -1
- package/dist/indexLua.js +1 -0
- package/dist/isaacscript-common.lua +406 -254
- package/dist/lualib_bundle.lua +215 -181
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types/ObjectValues.d.ts +2 -0
- package/dist/types/ObjectValues.d.ts.map +1 -0
- package/dist/types/ObjectValues.js +2 -0
- package/dist/types/ObjectValues.lua +2 -0
- package/dist/types/TupleToIntersection.d.ts +1 -4
- package/dist/types/TupleToIntersection.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/functions/math.ts +1 -1
- package/src/functions/stats.ts +1 -1
- package/src/functions/string.ts +1 -1
- package/src/functions/utils.ts +29 -0
- package/src/index.ts +1 -0
- package/src/types/ObjectValues.ts +1 -0
- package/src/types/TupleToIntersection.ts +4 -6
package/src/functions/utils.ts
CHANGED
|
@@ -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[]> =
|
|
2
|
-
infer F,
|
|
3
|
-
|
|
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;
|