isaacscript-common 30.5.0 → 30.5.2
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/isaacscript-common.lua +12 -13
- package/dist/src/functions/array.d.ts.map +1 -1
- package/dist/src/functions/array.lua +11 -12
- package/dist/src/indexLua.d.ts +186 -0
- package/dist/src/indexLua.d.ts.map +1 -0
- package/dist/src/indexLua.lua +1114 -0
- package/package.json +1 -1
- package/src/functions/array.ts +8 -8
package/package.json
CHANGED
package/src/functions/array.ts
CHANGED
|
@@ -213,15 +213,13 @@ export function copyArray<T>(
|
|
|
213
213
|
numElements?: int,
|
|
214
214
|
): T[] {
|
|
215
215
|
if (numElements === undefined) {
|
|
216
|
-
|
|
216
|
+
return [...oldArray];
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
const newArray: T[] = [];
|
|
220
220
|
for (let i = 0; i < numElements; i++) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
newArray.push(oldElement);
|
|
224
|
-
}
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
222
|
+
newArray.push(oldArray[i]!);
|
|
225
223
|
}
|
|
226
224
|
|
|
227
225
|
return newArray;
|
|
@@ -342,9 +340,11 @@ export function getRandomArrayElement<T>(
|
|
|
342
340
|
);
|
|
343
341
|
}
|
|
344
342
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
343
|
+
if (exceptions.length > 0) {
|
|
344
|
+
array = arrayRemove(array, ...exceptions);
|
|
345
|
+
}
|
|
346
|
+
const randomIndex = getRandomArrayIndex(array, seedOrRNG);
|
|
347
|
+
const randomElement = array[randomIndex];
|
|
348
348
|
if (randomElement === undefined) {
|
|
349
349
|
error(
|
|
350
350
|
`Failed to get a random array element since the random index of ${randomIndex} was not valid.`,
|