isaacscript-common 33.8.0 → 33.9.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 +13 -1
- package/dist/isaacscript-common.lua +27 -3
- package/dist/src/classes/features/other/SaveDataManager.d.ts +1 -1
- package/dist/src/functions/array.d.ts +10 -0
- package/dist/src/functions/array.d.ts.map +1 -1
- package/dist/src/functions/array.lua +28 -0
- package/dist/src/functions/logMisc.lua +2 -2
- package/package.json +1 -1
- package/src/classes/features/other/SaveDataManager.ts +1 -1
- package/src/functions/array.ts +40 -0
- package/src/functions/logMisc.ts +2 -2
package/dist/index.rollup.d.ts
CHANGED
|
@@ -5533,6 +5533,12 @@ export declare function getHearts(heartSubType?: HeartSubType | -1): EntityPicku
|
|
|
5533
5533
|
*/
|
|
5534
5534
|
export declare function getHeartsUIWidth(): int;
|
|
5535
5535
|
|
|
5536
|
+
/**
|
|
5537
|
+
* Helper function to get the highest value in an array. Returns undefined if there were no elements
|
|
5538
|
+
* in the array.
|
|
5539
|
+
*/
|
|
5540
|
+
export declare function getHighestArrayElement(array: number[]): number | undefined;
|
|
5541
|
+
|
|
5536
5542
|
/**
|
|
5537
5543
|
* Helper function to get the enum value with the highest value.
|
|
5538
5544
|
*
|
|
@@ -5697,6 +5703,12 @@ export declare function getLastElement<T>(array: T[]): T | undefined;
|
|
|
5697
5703
|
*/
|
|
5698
5704
|
export declare function getLastFrameOfAnimation(sprite: Sprite, animation?: string): int;
|
|
5699
5705
|
|
|
5706
|
+
/**
|
|
5707
|
+
* Helper function to get the lowest value in an array. Returns undefined if there were no elements
|
|
5708
|
+
* in the array.
|
|
5709
|
+
*/
|
|
5710
|
+
export declare function getLowestArrayElement(array: number[]): number | undefined;
|
|
5711
|
+
|
|
5700
5712
|
/**
|
|
5701
5713
|
* Helper function to get the closest value from a map based on partial search text. For the
|
|
5702
5714
|
* purposes of this function, both search text and map keys are converted to lowercase before
|
|
@@ -15667,7 +15679,7 @@ declare class SaveDataManager extends Feature {
|
|
|
15667
15679
|
* use-case, then add a key of `__ignoreGlowingHourGlass: true` to your "run" or "level" object.
|
|
15668
15680
|
*
|
|
15669
15681
|
* If you want the automatic variable restoring with Glowing Hour Glass functionality to apply to
|
|
15670
|
-
* a "persistent" object, you can add a key of `
|
|
15682
|
+
* a "persistent" object, you can add a key of `__rewindWithGlowingHourGlass: true` to the object.
|
|
15671
15683
|
*
|
|
15672
15684
|
* @param key The name of the file or feature that is submitting data to be managed by the save
|
|
15673
15685
|
* data manager. The save data manager will throw an error if the key is already
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 33.
|
|
3
|
+
isaacscript-common 33.9.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -17063,9 +17063,33 @@ end
|
|
|
17063
17063
|
function ____exports.getArrayIndexes(self, array)
|
|
17064
17064
|
return eRange(nil, #array)
|
|
17065
17065
|
end
|
|
17066
|
+
function ____exports.getHighestArrayElement(self, array)
|
|
17067
|
+
if #array == 0 then
|
|
17068
|
+
return nil
|
|
17069
|
+
end
|
|
17070
|
+
local highestValue
|
|
17071
|
+
for ____, element in ipairs(array) do
|
|
17072
|
+
if highestValue == nil or element > highestValue then
|
|
17073
|
+
highestValue = element
|
|
17074
|
+
end
|
|
17075
|
+
end
|
|
17076
|
+
return highestValue
|
|
17077
|
+
end
|
|
17066
17078
|
function ____exports.getLastElement(self, array)
|
|
17067
17079
|
return array[#array]
|
|
17068
17080
|
end
|
|
17081
|
+
function ____exports.getLowestArrayElement(self, array)
|
|
17082
|
+
if #array == 0 then
|
|
17083
|
+
return nil
|
|
17084
|
+
end
|
|
17085
|
+
local lowestValue
|
|
17086
|
+
for ____, element in ipairs(array) do
|
|
17087
|
+
if lowestValue == nil or element < lowestValue then
|
|
17088
|
+
lowestValue = element
|
|
17089
|
+
end
|
|
17090
|
+
end
|
|
17091
|
+
return lowestValue
|
|
17092
|
+
end
|
|
17069
17093
|
function ____exports.getRandomArrayElement(self, array, seedOrRNG, exceptions)
|
|
17070
17094
|
if seedOrRNG == nil then
|
|
17071
17095
|
seedOrRNG = getRandomSeed(nil)
|
|
@@ -29733,7 +29757,7 @@ function ____exports.logMap(map, name)
|
|
|
29733
29757
|
log("Tried to log a TSTL map, but the given object was not a TSTL map.")
|
|
29734
29758
|
return
|
|
29735
29759
|
end
|
|
29736
|
-
local suffix = name == nil and (" \"" ..
|
|
29760
|
+
local suffix = name == nil and "" or (" \"" .. name) .. "\""
|
|
29737
29761
|
log(("Logging a TSTL map" .. suffix) .. ":")
|
|
29738
29762
|
local mapKeys = {__TS__Spread(map:keys())}
|
|
29739
29763
|
__TS__ArraySort(mapKeys)
|
|
@@ -29836,7 +29860,7 @@ function ____exports.logSet(set, name)
|
|
|
29836
29860
|
log("Tried to log a TSTL set, but the given object was not a TSTL set.")
|
|
29837
29861
|
return
|
|
29838
29862
|
end
|
|
29839
|
-
local suffix = name == nil and (" \"" ..
|
|
29863
|
+
local suffix = name == nil and "" or (" \"" .. name) .. "\""
|
|
29840
29864
|
log(("Logging a TSTL set" .. suffix) .. ":")
|
|
29841
29865
|
local setValues = getSortedSetValues(nil, set)
|
|
29842
29866
|
for ____, value in ipairs(setValues) do
|
|
@@ -127,7 +127,7 @@ export declare class SaveDataManager extends Feature {
|
|
|
127
127
|
* use-case, then add a key of `__ignoreGlowingHourGlass: true` to your "run" or "level" object.
|
|
128
128
|
*
|
|
129
129
|
* If you want the automatic variable restoring with Glowing Hour Glass functionality to apply to
|
|
130
|
-
* a "persistent" object, you can add a key of `
|
|
130
|
+
* a "persistent" object, you can add a key of `__rewindWithGlowingHourGlass: true` to the object.
|
|
131
131
|
*
|
|
132
132
|
* @param key The name of the file or feature that is submitting data to be managed by the save
|
|
133
133
|
* data manager. The save data manager will throw an error if the key is already
|
|
@@ -136,6 +136,11 @@ export declare function getArrayCombinations<T>(array: T[] | readonly T[], inclu
|
|
|
136
136
|
* For example, an array of `["Apple", "Banana"]` would return an array of `[0, 1]`.
|
|
137
137
|
*/
|
|
138
138
|
export declare function getArrayIndexes<T>(array: T[] | readonly T[]): int[];
|
|
139
|
+
/**
|
|
140
|
+
* Helper function to get the highest value in an array. Returns undefined if there were no elements
|
|
141
|
+
* in the array.
|
|
142
|
+
*/
|
|
143
|
+
export declare function getHighestArrayElement(array: number[]): number | undefined;
|
|
139
144
|
/**
|
|
140
145
|
* Helper function to return the last element of an array.
|
|
141
146
|
*
|
|
@@ -145,6 +150,11 @@ export declare function getArrayIndexes<T>(array: T[] | readonly T[]): int[];
|
|
|
145
150
|
* unnecessary.)
|
|
146
151
|
*/
|
|
147
152
|
export declare function getLastElement<T>(array: T[]): T | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Helper function to get the lowest value in an array. Returns undefined if there were no elements
|
|
155
|
+
* in the array.
|
|
156
|
+
*/
|
|
157
|
+
export declare function getLowestArrayElement(array: number[]): number | undefined;
|
|
148
158
|
/**
|
|
149
159
|
* Helper function to get a random element from the provided array.
|
|
150
160
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/functions/array.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAC1B,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GACzB,OAAO,CAST;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,CAAC,EAAE,CAIL;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,aAAa,EAAE,CAAC,EA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AE,IAAI,GAAG,GAAqB,GACtC,CAAC,EAAE,CAKL;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,IAAI,CAWN;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAEpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3E"}
|
|
@@ -367,6 +367,20 @@ end
|
|
|
367
367
|
function ____exports.getArrayIndexes(self, array)
|
|
368
368
|
return eRange(nil, #array)
|
|
369
369
|
end
|
|
370
|
+
--- Helper function to get the highest value in an array. Returns undefined if there were no elements
|
|
371
|
+
-- in the array.
|
|
372
|
+
function ____exports.getHighestArrayElement(self, array)
|
|
373
|
+
if #array == 0 then
|
|
374
|
+
return nil
|
|
375
|
+
end
|
|
376
|
+
local highestValue
|
|
377
|
+
for ____, element in ipairs(array) do
|
|
378
|
+
if highestValue == nil or element > highestValue then
|
|
379
|
+
highestValue = element
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
return highestValue
|
|
383
|
+
end
|
|
370
384
|
--- Helper function to return the last element of an array.
|
|
371
385
|
--
|
|
372
386
|
-- If the array is empty, this will return undefined.
|
|
@@ -376,6 +390,20 @@ end
|
|
|
376
390
|
function ____exports.getLastElement(self, array)
|
|
377
391
|
return array[#array]
|
|
378
392
|
end
|
|
393
|
+
--- Helper function to get the lowest value in an array. Returns undefined if there were no elements
|
|
394
|
+
-- in the array.
|
|
395
|
+
function ____exports.getLowestArrayElement(self, array)
|
|
396
|
+
if #array == 0 then
|
|
397
|
+
return nil
|
|
398
|
+
end
|
|
399
|
+
local lowestValue
|
|
400
|
+
for ____, element in ipairs(array) do
|
|
401
|
+
if lowestValue == nil or element < lowestValue then
|
|
402
|
+
lowestValue = element
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
return lowestValue
|
|
406
|
+
end
|
|
379
407
|
--- Helper function to get a random element from the provided array.
|
|
380
408
|
--
|
|
381
409
|
-- @param array The array to get an element from.
|
|
@@ -213,7 +213,7 @@ function ____exports.logMap(map, name)
|
|
|
213
213
|
log("Tried to log a TSTL map, but the given object was not a TSTL map.")
|
|
214
214
|
return
|
|
215
215
|
end
|
|
216
|
-
local suffix = name == nil and (" \"" ..
|
|
216
|
+
local suffix = name == nil and "" or (" \"" .. name) .. "\""
|
|
217
217
|
log(("Logging a TSTL map" .. suffix) .. ":")
|
|
218
218
|
local mapKeys = {__TS__Spread(map:keys())}
|
|
219
219
|
__TS__ArraySort(mapKeys)
|
|
@@ -324,7 +324,7 @@ function ____exports.logSet(set, name)
|
|
|
324
324
|
log("Tried to log a TSTL set, but the given object was not a TSTL set.")
|
|
325
325
|
return
|
|
326
326
|
end
|
|
327
|
-
local suffix = name == nil and (" \"" ..
|
|
327
|
+
local suffix = name == nil and "" or (" \"" .. name) .. "\""
|
|
328
328
|
log(("Logging a TSTL set" .. suffix) .. ":")
|
|
329
329
|
local setValues = getSortedSetValues(nil, set)
|
|
330
330
|
for ____, value in ipairs(setValues) do
|
package/package.json
CHANGED
|
@@ -298,7 +298,7 @@ export class SaveDataManager extends Feature {
|
|
|
298
298
|
* use-case, then add a key of `__ignoreGlowingHourGlass: true` to your "run" or "level" object.
|
|
299
299
|
*
|
|
300
300
|
* If you want the automatic variable restoring with Glowing Hour Glass functionality to apply to
|
|
301
|
-
* a "persistent" object, you can add a key of `
|
|
301
|
+
* a "persistent" object, you can add a key of `__rewindWithGlowingHourGlass: true` to the object.
|
|
302
302
|
*
|
|
303
303
|
* @param key The name of the file or feature that is submitting data to be managed by the save
|
|
304
304
|
* data manager. The save data manager will throw an error if the key is already
|
package/src/functions/array.ts
CHANGED
|
@@ -340,6 +340,26 @@ export function getArrayIndexes<T>(array: T[] | readonly T[]): int[] {
|
|
|
340
340
|
return eRange(array.length);
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
/**
|
|
344
|
+
* Helper function to get the highest value in an array. Returns undefined if there were no elements
|
|
345
|
+
* in the array.
|
|
346
|
+
*/
|
|
347
|
+
export function getHighestArrayElement(array: number[]): number | undefined {
|
|
348
|
+
if (array.length === 0) {
|
|
349
|
+
return undefined;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
let highestValue: number | undefined;
|
|
353
|
+
|
|
354
|
+
for (const element of array) {
|
|
355
|
+
if (highestValue === undefined || element > highestValue) {
|
|
356
|
+
highestValue = element;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return highestValue;
|
|
361
|
+
}
|
|
362
|
+
|
|
343
363
|
/**
|
|
344
364
|
* Helper function to return the last element of an array.
|
|
345
365
|
*
|
|
@@ -352,6 +372,26 @@ export function getLastElement<T>(array: T[]): T | undefined {
|
|
|
352
372
|
return array[array.length - 1];
|
|
353
373
|
}
|
|
354
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Helper function to get the lowest value in an array. Returns undefined if there were no elements
|
|
377
|
+
* in the array.
|
|
378
|
+
*/
|
|
379
|
+
export function getLowestArrayElement(array: number[]): number | undefined {
|
|
380
|
+
if (array.length === 0) {
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
let lowestValue: number | undefined;
|
|
385
|
+
|
|
386
|
+
for (const element of array) {
|
|
387
|
+
if (lowestValue === undefined || element < lowestValue) {
|
|
388
|
+
lowestValue = element;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return lowestValue;
|
|
393
|
+
}
|
|
394
|
+
|
|
355
395
|
/**
|
|
356
396
|
* Helper function to get a random element from the provided array.
|
|
357
397
|
*
|
package/src/functions/logMisc.ts
CHANGED
|
@@ -239,7 +239,7 @@ export function logMap(
|
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
const suffix = name === undefined ? ` "${name}"
|
|
242
|
+
const suffix = name === undefined ? "" : ` "${name}"`;
|
|
243
243
|
log(`Logging a TSTL map${suffix}:`);
|
|
244
244
|
|
|
245
245
|
const mapKeys = [...map.keys()];
|
|
@@ -384,7 +384,7 @@ export function logSet(
|
|
|
384
384
|
return;
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
-
const suffix = name === undefined ? ` "${name}"
|
|
387
|
+
const suffix = name === undefined ? "" : ` "${name}"`;
|
|
388
388
|
log(`Logging a TSTL set${suffix}:`);
|
|
389
389
|
|
|
390
390
|
const setValues = getSortedSetValues(set);
|