isaacscript-common 34.0.0 → 34.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.
- package/dist/index.rollup.d.ts +12 -0
- package/dist/isaacscript-common.lua +11 -4
- package/dist/src/classes/features/other/RoomHistory.d.ts.map +1 -1
- package/dist/src/classes/features/other/RoomHistory.lua +1 -1
- package/dist/src/functions/enums.d.ts +11 -0
- package/dist/src/functions/enums.d.ts.map +1 -1
- package/dist/src/functions/enums.lua +17 -2
- package/package.json +1 -1
- package/src/classes/features/other/RoomHistory.ts +1 -2
- package/src/functions/enums.ts +24 -2
package/dist/index.rollup.d.ts
CHANGED
|
@@ -5581,6 +5581,8 @@ export declare function getHighestArrayElement(array: number[]): number | undefi
|
|
|
5581
5581
|
*
|
|
5582
5582
|
* Note that this is not necessarily the enum value that is declared last in the code, since there
|
|
5583
5583
|
* is no way to infer that at run-time.
|
|
5584
|
+
*
|
|
5585
|
+
* Throws an error if the provided enum is empty.
|
|
5584
5586
|
*/
|
|
5585
5587
|
export declare function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T];
|
|
5586
5588
|
|
|
@@ -5745,6 +5747,16 @@ export declare function getLevelBossIDs(): BossID[];
|
|
|
5745
5747
|
*/
|
|
5746
5748
|
export declare function getLowestArrayElement(array: number[]): number | undefined;
|
|
5747
5749
|
|
|
5750
|
+
/**
|
|
5751
|
+
* Helper function to get the enum value with the lowest value.
|
|
5752
|
+
*
|
|
5753
|
+
* Note that this is not necessarily the enum value that is declared first in the code, since there
|
|
5754
|
+
* is no way to infer that at run-time.
|
|
5755
|
+
*
|
|
5756
|
+
* Throws an error if the provided enum is empty.
|
|
5757
|
+
*/
|
|
5758
|
+
export declare function getLowestEnumValue<T>(transpiledEnum: T): T[keyof T];
|
|
5759
|
+
|
|
5748
5760
|
/**
|
|
5749
5761
|
* Helper function to get the closest value from a map based on partial search text. For the
|
|
5750
5762
|
* purposes of this function, both search text and map keys are converted to lowercase before
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 34.
|
|
3
|
+
isaacscript-common 34.1.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -17221,6 +17221,7 @@ return ____exports
|
|
|
17221
17221
|
local ____lualib = require("lualib_bundle")
|
|
17222
17222
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
17223
17223
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
17224
|
+
local __TS__ArrayAt = ____lualib.__TS__ArrayAt
|
|
17224
17225
|
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
|
|
17225
17226
|
local __TS__New = ____lualib.__TS__New
|
|
17226
17227
|
local ____exports = {}
|
|
@@ -17287,10 +17288,16 @@ function ____exports.getEnumValues(self, transpiledEnum)
|
|
|
17287
17288
|
end
|
|
17288
17289
|
function ____exports.getHighestEnumValue(self, transpiledEnum)
|
|
17289
17290
|
local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
|
|
17290
|
-
local lastElement = enumValues
|
|
17291
|
+
local lastElement = __TS__ArrayAt(enumValues, -1)
|
|
17291
17292
|
assertDefined(nil, lastElement, "Failed to get the last value from an enum since the enum was empty.")
|
|
17292
17293
|
return lastElement
|
|
17293
17294
|
end
|
|
17295
|
+
function ____exports.getLowestEnumValue(self, transpiledEnum)
|
|
17296
|
+
local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
|
|
17297
|
+
local firstElement = enumValues[1]
|
|
17298
|
+
assertDefined(nil, firstElement, "Failed to get the first value from an enum since the enum was empty.")
|
|
17299
|
+
return firstElement
|
|
17300
|
+
end
|
|
17294
17301
|
function ____exports.getRandomEnumValue(self, transpiledEnum, seedOrRNG, exceptions)
|
|
17295
17302
|
if seedOrRNG == nil then
|
|
17296
17303
|
seedOrRNG = getRandomSeed(nil)
|
|
@@ -17316,7 +17323,7 @@ function ____exports.validateCustomEnum(self, transpiledEnumName, transpiledEnum
|
|
|
17316
17323
|
end
|
|
17317
17324
|
function ____exports.validateEnumContiguous(self, transpiledEnumName, transpiledEnum)
|
|
17318
17325
|
local values = ____exports.getEnumValues(nil, transpiledEnum)
|
|
17319
|
-
local lastValue = values
|
|
17326
|
+
local lastValue = __TS__ArrayAt(values, -1)
|
|
17320
17327
|
assertDefined(nil, lastValue, "Failed to validate that an enum was contiguous, since the last value was undefined.")
|
|
17321
17328
|
if not isNumber(nil, lastValue) then
|
|
17322
17329
|
error("Failed to validate that an enum was contiguous, since the last value was not a number.")
|
|
@@ -34680,7 +34687,7 @@ function RoomHistory.prototype.getRoomHistory(self)
|
|
|
34680
34687
|
end
|
|
34681
34688
|
__TS__DecorateLegacy({Exported}, RoomHistory.prototype, "getRoomHistory", true)
|
|
34682
34689
|
function RoomHistory.prototype.getPreviousRoomDescription(self)
|
|
34683
|
-
local previousRoomDescription = v.run.roomHistory
|
|
34690
|
+
local previousRoomDescription = __TS__ArrayAt(v.run.roomHistory, -2)
|
|
34684
34691
|
if previousRoomDescription ~= nil then
|
|
34685
34692
|
return previousRoomDescription
|
|
34686
34693
|
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoomHistory.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/RoomHistory.ts"],"names":[],"mappings":";AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAQhD,qBAAa,WAAY,SAAQ,OAAO;IActC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAgC/B;IAEF;;;;OAIG;IAEI,yBAAyB,IAAI,IAAI;IAIxC;;;;;OAKG;IAEI,kBAAkB,IAAI,GAAG;IAIhC;;;;;OAKG;IAEI,cAAc,IAAI,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAIjE;;;;;;;OAOG;IAEI,0BAA0B,IAAI,QAAQ,CAAC,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"RoomHistory.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/RoomHistory.ts"],"names":[],"mappings":";AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAQhD,qBAAa,WAAY,SAAQ,OAAO;IActC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAgC/B;IAEF;;;;OAIG;IAEI,yBAAyB,IAAI,IAAI;IAIxC;;;;;OAKG;IAEI,kBAAkB,IAAI,GAAG;IAIhC;;;;;OAKG;IAEI,cAAc,IAAI,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAIjE;;;;;;;OAOG;IAEI,0BAA0B,IAAI,QAAQ,CAAC,eAAe,CAAC;IAgB9D;;;;;;;;;;OAUG;IAEI,wBAAwB,IAAI,QAAQ,CAAC,eAAe,CAAC,GAAG,SAAS;IAIxE,gFAAgF;IAEzE,WAAW,IAAI,OAAO;IAI7B;;;;;;;;;;OAUG;IAEI,aAAa,IAAI,OAAO;CAwBhC"}
|
|
@@ -78,7 +78,7 @@ function RoomHistory.prototype.getRoomHistory(self)
|
|
|
78
78
|
end
|
|
79
79
|
__TS__DecorateLegacy({Exported}, RoomHistory.prototype, "getRoomHistory", true)
|
|
80
80
|
function RoomHistory.prototype.getPreviousRoomDescription(self)
|
|
81
|
-
local previousRoomDescription = v.run.roomHistory
|
|
81
|
+
local previousRoomDescription = __TS__ArrayAt(v.run.roomHistory, -2)
|
|
82
82
|
if previousRoomDescription ~= nil then
|
|
83
83
|
return previousRoomDescription
|
|
84
84
|
end
|
|
@@ -60,8 +60,19 @@ export declare function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]>;
|
|
|
60
60
|
*
|
|
61
61
|
* Note that this is not necessarily the enum value that is declared last in the code, since there
|
|
62
62
|
* is no way to infer that at run-time.
|
|
63
|
+
*
|
|
64
|
+
* Throws an error if the provided enum is empty.
|
|
63
65
|
*/
|
|
64
66
|
export declare function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T];
|
|
67
|
+
/**
|
|
68
|
+
* Helper function to get the enum value with the lowest value.
|
|
69
|
+
*
|
|
70
|
+
* Note that this is not necessarily the enum value that is declared first in the code, since there
|
|
71
|
+
* is no way to infer that at run-time.
|
|
72
|
+
*
|
|
73
|
+
* Throws an error if the provided enum is empty.
|
|
74
|
+
*/
|
|
75
|
+
export declare function getLowestEnumValue<T>(transpiledEnum: T): T[keyof T];
|
|
65
76
|
/**
|
|
66
77
|
* Helper function to get a random value from the provided enum.
|
|
67
78
|
*
|
|
@@ -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,MAAM,CAAC,GACvD,GAAG,CAGL;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAGrE;AAED
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/functions/enums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ACtB,cAAc,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GACvD,OAAO,CAGT;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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
3
3
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
4
|
+
local __TS__ArrayAt = ____lualib.__TS__ArrayAt
|
|
4
5
|
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
|
|
5
6
|
local __TS__New = ____lualib.__TS__New
|
|
6
7
|
local ____exports = {}
|
|
@@ -113,12 +114,26 @@ end
|
|
|
113
114
|
--
|
|
114
115
|
-- Note that this is not necessarily the enum value that is declared last in the code, since there
|
|
115
116
|
-- is no way to infer that at run-time.
|
|
117
|
+
--
|
|
118
|
+
-- Throws an error if the provided enum is empty.
|
|
116
119
|
function ____exports.getHighestEnumValue(self, transpiledEnum)
|
|
117
120
|
local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
|
|
118
|
-
local lastElement = enumValues
|
|
121
|
+
local lastElement = __TS__ArrayAt(enumValues, -1)
|
|
119
122
|
assertDefined(nil, lastElement, "Failed to get the last value from an enum since the enum was empty.")
|
|
120
123
|
return lastElement
|
|
121
124
|
end
|
|
125
|
+
--- Helper function to get the enum value with the lowest value.
|
|
126
|
+
--
|
|
127
|
+
-- Note that this is not necessarily the enum value that is declared first in the code, since there
|
|
128
|
+
-- is no way to infer that at run-time.
|
|
129
|
+
--
|
|
130
|
+
-- Throws an error if the provided enum is empty.
|
|
131
|
+
function ____exports.getLowestEnumValue(self, transpiledEnum)
|
|
132
|
+
local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
|
|
133
|
+
local firstElement = enumValues[1]
|
|
134
|
+
assertDefined(nil, firstElement, "Failed to get the first value from an enum since the enum was empty.")
|
|
135
|
+
return firstElement
|
|
136
|
+
end
|
|
122
137
|
--- Helper function to get a random value from the provided enum.
|
|
123
138
|
--
|
|
124
139
|
-- @param transpiledEnum The enum to get the value from.
|
|
@@ -167,7 +182,7 @@ end
|
|
|
167
182
|
-- This is useful to automate checking large enums for typos.
|
|
168
183
|
function ____exports.validateEnumContiguous(self, transpiledEnumName, transpiledEnum)
|
|
169
184
|
local values = ____exports.getEnumValues(nil, transpiledEnum)
|
|
170
|
-
local lastValue = values
|
|
185
|
+
local lastValue = __TS__ArrayAt(values, -1)
|
|
171
186
|
assertDefined(nil, lastValue, "Failed to validate that an enum was contiguous, since the last value was undefined.")
|
|
172
187
|
if not isNumber(nil, lastValue) then
|
|
173
188
|
error("Failed to validate that an enum was contiguous, since the last value was not a number.")
|
package/package.json
CHANGED
|
@@ -110,8 +110,7 @@ export class RoomHistory extends Feature {
|
|
|
110
110
|
*/
|
|
111
111
|
@Exported
|
|
112
112
|
public getPreviousRoomDescription(): Readonly<RoomDescription> {
|
|
113
|
-
const previousRoomDescription =
|
|
114
|
-
v.run.roomHistory[v.run.roomHistory.length - 2];
|
|
113
|
+
const previousRoomDescription = v.run.roomHistory.at(-2);
|
|
115
114
|
if (previousRoomDescription !== undefined) {
|
|
116
115
|
return previousRoomDescription;
|
|
117
116
|
}
|
package/src/functions/enums.ts
CHANGED
|
@@ -101,11 +101,13 @@ export function getEnumValues<T>(transpiledEnum: T): Array<T[keyof T]> {
|
|
|
101
101
|
*
|
|
102
102
|
* Note that this is not necessarily the enum value that is declared last in the code, since there
|
|
103
103
|
* is no way to infer that at run-time.
|
|
104
|
+
*
|
|
105
|
+
* Throws an error if the provided enum is empty.
|
|
104
106
|
*/
|
|
105
107
|
export function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T] {
|
|
106
108
|
const enumValues = getEnumValues(transpiledEnum);
|
|
107
109
|
|
|
108
|
-
const lastElement = enumValues
|
|
110
|
+
const lastElement = enumValues.at(-1);
|
|
109
111
|
assertDefined(
|
|
110
112
|
lastElement,
|
|
111
113
|
"Failed to get the last value from an enum since the enum was empty.",
|
|
@@ -114,6 +116,26 @@ export function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T] {
|
|
|
114
116
|
return lastElement;
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Helper function to get the enum value with the lowest value.
|
|
121
|
+
*
|
|
122
|
+
* Note that this is not necessarily the enum value that is declared first in the code, since there
|
|
123
|
+
* is no way to infer that at run-time.
|
|
124
|
+
*
|
|
125
|
+
* Throws an error if the provided enum is empty.
|
|
126
|
+
*/
|
|
127
|
+
export function getLowestEnumValue<T>(transpiledEnum: T): T[keyof T] {
|
|
128
|
+
const enumValues = getEnumValues(transpiledEnum);
|
|
129
|
+
|
|
130
|
+
const firstElement = enumValues[0];
|
|
131
|
+
assertDefined(
|
|
132
|
+
firstElement,
|
|
133
|
+
"Failed to get the first value from an enum since the enum was empty.",
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
return firstElement;
|
|
137
|
+
}
|
|
138
|
+
|
|
117
139
|
/**
|
|
118
140
|
* Helper function to get a random value from the provided enum.
|
|
119
141
|
*
|
|
@@ -178,7 +200,7 @@ export function validateEnumContiguous<T>(
|
|
|
178
200
|
transpiledEnum: T,
|
|
179
201
|
): void {
|
|
180
202
|
const values = getEnumValues(transpiledEnum);
|
|
181
|
-
const lastValue = values
|
|
203
|
+
const lastValue = values.at(-1);
|
|
182
204
|
assertDefined(
|
|
183
205
|
lastValue,
|
|
184
206
|
"Failed to validate that an enum was contiguous, since the last value was undefined.",
|