isaacscript-common 84.1.1 → 84.2.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/classes/features/callbackLogic/PlayerCollectibleDetection.d.ts.map +1 -1
- package/dist/classes/features/callbackLogic/PlayerCollectibleDetection.js +3 -2
- package/dist/classes/features/callbackLogic/PlayerCollectibleDetection.lua +4 -2
- package/dist/functions/array.d.ts +1 -1
- package/dist/functions/array.d.ts.map +1 -1
- package/dist/functions/array.js +2 -1
- package/dist/functions/array.lua +3 -1
- package/dist/functions/enums.d.ts.map +1 -1
- package/dist/functions/enums.js +7 -4
- package/dist/functions/enums.lua +9 -4
- package/dist/functions/logMisc.d.ts +2 -2
- package/dist/functions/logMisc.d.ts.map +1 -1
- package/dist/functions/logMisc.js +3 -4
- package/dist/functions/logMisc.lua +4 -3
- package/dist/functions/set.d.ts +3 -3
- package/dist/functions/set.d.ts.map +1 -1
- package/dist/functions/set.js +2 -1
- package/dist/functions/set.lua +3 -1
- package/dist/functions/sort.d.ts +2 -1
- package/dist/functions/sort.d.ts.map +1 -1
- package/dist/functions/sort.js +3 -2
- package/dist/functions/sort.lua +6 -6
- package/dist/functions/table.js +1 -1
- package/dist/functions/types.d.ts.map +1 -1
- package/dist/functions/types.js +7 -5
- package/dist/functions/types.lua +3 -1
- package/dist/index.rollup.d.ts +9 -7
- package/dist/isaacscript-common.lua +33 -19
- package/dist/lib/jsonLua.d.ts +12 -0
- package/dist/lib/jsonLua.js +701 -0
- package/package.json +1 -1
- package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +3 -2
- package/src/functions/array.ts +3 -2
- package/src/functions/enums.ts +7 -6
- package/src/functions/logMisc.ts +5 -6
- package/src/functions/set.ts +7 -4
- package/src/functions/sort.ts +2 -2
- package/src/functions/table.ts +1 -1
- package/src/functions/types.ts +7 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlayerCollectibleDetection.d.ts","sourceRoot":"","sources":["../../../../src/classes/features/callbackLogic/PlayerCollectibleDetection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,eAAe,EAKhB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"PlayerCollectibleDetection.d.ts","sourceRoot":"","sources":["../../../../src/classes/features/callbackLogic/PlayerCollectibleDetection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,eAAe,EAKhB,MAAM,8BAA8B,CAAC;AActC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAC7F,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAgB1D,qBAAa,0BAA2B,SAAQ,OAAO;IACrC,CAAC;;;;;;MAAK;IAEtB,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAA6B;IACxE,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAA+B;IAC5E,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoB;IACtD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;gBAG1C,0BAA0B,EAAE,0BAA0B,EACtD,4BAA4B,EAAE,4BAA4B,EAC1D,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,YAAY;IA6B5B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,2BAA2B;IA0CnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAqB5B;IAEF,gEAAgE;IAEhE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CA2BlC;IAEF;;;OAGG;IAEH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAe7B;IAGF,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAiBzC;IAEF;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;CA+BhC"}
|
|
@@ -9,6 +9,7 @@ const array_1 = require("../../../functions/array");
|
|
|
9
9
|
const flag_1 = require("../../../functions/flag");
|
|
10
10
|
const playerDataStructures_1 = require("../../../functions/playerDataStructures");
|
|
11
11
|
const players_1 = require("../../../functions/players");
|
|
12
|
+
const sort_1 = require("../../../functions/sort");
|
|
12
13
|
const utils_1 = require("../../../functions/utils");
|
|
13
14
|
const DefaultMap_1 = require("../../DefaultMap");
|
|
14
15
|
const Feature_1 = require("../../private/Feature");
|
|
@@ -181,8 +182,8 @@ class PlayerCollectibleDetection extends Feature_1.Feature {
|
|
|
181
182
|
// For example, it is possible for the player to switch Schoolbag items, which will cause the
|
|
182
183
|
// collectibles in the array to be the same, but in a different order. Thus, we sort both arrays
|
|
183
184
|
// before comparing them.
|
|
184
|
-
oldCollectibleTypes.sort();
|
|
185
|
-
newCollectibleTypes.sort();
|
|
185
|
+
oldCollectibleTypes.sort(sort_1.sortNormal);
|
|
186
|
+
newCollectibleTypes.sort(sort_1.sortNormal);
|
|
186
187
|
if (!(0, array_1.arrayEquals)(oldCollectibleTypes, newCollectibleTypes)) {
|
|
187
188
|
// One or more active items have changed (with the player's total collectible count remaining
|
|
188
189
|
// the same).
|
|
@@ -32,6 +32,8 @@ local defaultMapGetPlayer = ____playerDataStructures.defaultMapGetPlayer
|
|
|
32
32
|
local mapSetPlayer = ____playerDataStructures.mapSetPlayer
|
|
33
33
|
local ____players = require("functions.players")
|
|
34
34
|
local getPlayerFromPtr = ____players.getPlayerFromPtr
|
|
35
|
+
local ____sort = require("functions.sort")
|
|
36
|
+
local sortNormal = ____sort.sortNormal
|
|
35
37
|
local ____utils = require("functions.utils")
|
|
36
38
|
local ____repeat = ____utils["repeat"]
|
|
37
39
|
local ____DefaultMap = require("classes.DefaultMap")
|
|
@@ -155,8 +157,8 @@ function PlayerCollectibleDetection.prototype.checkActiveItemsChanged(self, play
|
|
|
155
157
|
oldCollectibleTypes[#oldCollectibleTypes + 1] = oldCollectibleType
|
|
156
158
|
newCollectibleTypes[#newCollectibleTypes + 1] = newCollectibleType
|
|
157
159
|
end
|
|
158
|
-
__TS__ArraySort(oldCollectibleTypes)
|
|
159
|
-
__TS__ArraySort(newCollectibleTypes)
|
|
160
|
+
__TS__ArraySort(oldCollectibleTypes, sortNormal)
|
|
161
|
+
__TS__ArraySort(newCollectibleTypes, sortNormal)
|
|
160
162
|
if not arrayEquals(nil, oldCollectibleTypes, newCollectibleTypes) then
|
|
161
163
|
self:updateCollectibleMapAndFire(player, nil)
|
|
162
164
|
end
|
|
@@ -134,7 +134,7 @@ export declare function getArrayCombinations<T>(array: readonly T[], includeEmpt
|
|
|
134
134
|
* Helper function to get the duplicate elements in an array. Only one element for each value will
|
|
135
135
|
* be returned. The elements will be sorted before they are returned.
|
|
136
136
|
*/
|
|
137
|
-
export declare function getArrayDuplicateElements<T>(array: readonly T[]): readonly T[];
|
|
137
|
+
export declare function getArrayDuplicateElements<T extends number | string>(array: readonly T[]): readonly T[];
|
|
138
138
|
/**
|
|
139
139
|
* Helper function to get an array containing the indexes of an array.
|
|
140
140
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":";;;AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":";;;AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAO1D;;;GAGG;AACH,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AE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAIjE;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,aAAa,EAAE,SAAS,CAAC,EAAE,EAC3B,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,CAAC,EAAE,CAKL;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAEnC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,IAAI,GAAG,GAAG,GAAG,SAAS,GAChC,IAAI,CAWN;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEzD;AAED;;GAEG;AAEH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3E"}
|
package/dist/functions/array.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.swapArrayElements = exports.sumArray = exports.shuffleArrayInPlace = exp
|
|
|
4
4
|
const ReadonlySet_1 = require("../types/ReadonlySet");
|
|
5
5
|
const random_1 = require("./random");
|
|
6
6
|
const rng_1 = require("./rng");
|
|
7
|
+
const sort_1 = require("./sort");
|
|
7
8
|
const types_1 = require("./types");
|
|
8
9
|
const utils_1 = require("./utils");
|
|
9
10
|
/**
|
|
@@ -314,7 +315,7 @@ function getArrayDuplicateElements(array) {
|
|
|
314
315
|
set.add(element);
|
|
315
316
|
}
|
|
316
317
|
const values = [...duplicateElements];
|
|
317
|
-
return values.sort();
|
|
318
|
+
return values.sort(sort_1.sortNormal);
|
|
318
319
|
}
|
|
319
320
|
exports.getArrayDuplicateElements = getArrayDuplicateElements;
|
|
320
321
|
/**
|
package/dist/functions/array.lua
CHANGED
|
@@ -29,6 +29,8 @@ local getRandomInt = ____random.getRandomInt
|
|
|
29
29
|
local ____rng = require("functions.rng")
|
|
30
30
|
local isRNG = ____rng.isRNG
|
|
31
31
|
local newRNG = ____rng.newRNG
|
|
32
|
+
local ____sort = require("functions.sort")
|
|
33
|
+
local sortNormal = ____sort.sortNormal
|
|
32
34
|
local ____types = require("functions.types")
|
|
33
35
|
local isNumber = ____types.isNumber
|
|
34
36
|
local isTable = ____types.isTable
|
|
@@ -387,7 +389,7 @@ function ____exports.getArrayDuplicateElements(self, array)
|
|
|
387
389
|
set:add(element)
|
|
388
390
|
end
|
|
389
391
|
local values = {__TS__Spread(duplicateElements)}
|
|
390
|
-
return __TS__ArraySort(values)
|
|
392
|
+
return __TS__ArraySort(values, sortNormal)
|
|
391
393
|
end
|
|
392
394
|
--- Helper function to get an array containing the indexes of an array.
|
|
393
395
|
--
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/functions/enums.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/functions/enums.ts"],"names":[],"mappings":";;;;;AAMA;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CACjC,MAAM,EACN,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CACvC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,cAAc,EACrD,cAAc,EAAE,CAAC,GAChB,aAAa,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAmBjD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,MAAM,EAAE,CAG7E;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,GAAG,CAGjE;AAED;;;;;;;;;;;;;;;;GAgB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;;GA0BG;AACH,wBAAgB,4BAA4B,CAE1C,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,EAC/B,IAAI,SAAS,MAAM,GAAG,MAAM,KACzB,IAAI,CAAG"}
|
package/dist/functions/enums.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.validateInterfaceMatchesEnum = exports.validateEnumContiguous = exports.validateCustomEnum = exports.isEnumValue = exports.getRandomEnumValue = exports.getLowestEnumValue = exports.getHighestEnumValue = exports.getEnumValues = exports.getEnumNames = exports.getEnumLength = exports.getEnumKeys = exports.getEnumEntries = void 0;
|
|
4
4
|
const ReadonlySet_1 = require("../types/ReadonlySet");
|
|
5
5
|
const array_1 = require("./array");
|
|
6
|
+
const sort_1 = require("./sort");
|
|
6
7
|
const types_1 = require("./types");
|
|
7
8
|
const utils_1 = require("./utils");
|
|
8
9
|
/**
|
|
@@ -128,8 +129,9 @@ exports.getEnumValues = getEnumValues;
|
|
|
128
129
|
*/
|
|
129
130
|
function getHighestEnumValue(transpiledEnum) {
|
|
130
131
|
const enumValues = getEnumValues(transpiledEnum);
|
|
131
|
-
const
|
|
132
|
-
|
|
132
|
+
const sortedValues = enumValues.toSorted(sort_1.sortNormal);
|
|
133
|
+
const lastElement = sortedValues.at(-1);
|
|
134
|
+
(0, utils_1.assertDefined)(lastElement, "Failed to get the highest value from an enum since the enum was empty.");
|
|
133
135
|
return lastElement;
|
|
134
136
|
}
|
|
135
137
|
exports.getHighestEnumValue = getHighestEnumValue;
|
|
@@ -143,8 +145,9 @@ exports.getHighestEnumValue = getHighestEnumValue;
|
|
|
143
145
|
*/
|
|
144
146
|
function getLowestEnumValue(transpiledEnum) {
|
|
145
147
|
const enumValues = getEnumValues(transpiledEnum);
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
+
const sortedValues = enumValues.toSorted(sort_1.sortNormal);
|
|
149
|
+
const firstElement = sortedValues[0];
|
|
150
|
+
(0, utils_1.assertDefined)(firstElement, "Failed to get the lowest value from an enum since the enum was empty.");
|
|
148
151
|
return firstElement;
|
|
149
152
|
}
|
|
150
153
|
exports.getLowestEnumValue = getLowestEnumValue;
|
package/dist/functions/enums.lua
CHANGED
|
@@ -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__ArrayToSorted = ____lualib.__TS__ArrayToSorted
|
|
4
5
|
local __TS__ArrayAt = ____lualib.__TS__ArrayAt
|
|
5
6
|
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
|
|
6
7
|
local __TS__New = ____lualib.__TS__New
|
|
@@ -9,6 +10,8 @@ local ____ReadonlySet = require("types.ReadonlySet")
|
|
|
9
10
|
local ReadonlySet = ____ReadonlySet.ReadonlySet
|
|
10
11
|
local ____array = require("functions.array")
|
|
11
12
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
13
|
+
local ____sort = require("functions.sort")
|
|
14
|
+
local sortNormal = ____sort.sortNormal
|
|
12
15
|
local ____types = require("functions.types")
|
|
13
16
|
local isNumber = ____types.isNumber
|
|
14
17
|
local isString = ____types.isString
|
|
@@ -144,8 +147,9 @@ end
|
|
|
144
147
|
-- Throws an error if the provided enum is empty.
|
|
145
148
|
function ____exports.getHighestEnumValue(self, transpiledEnum)
|
|
146
149
|
local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
|
|
147
|
-
local
|
|
148
|
-
|
|
150
|
+
local sortedValues = __TS__ArrayToSorted(enumValues, sortNormal)
|
|
151
|
+
local lastElement = __TS__ArrayAt(sortedValues, -1)
|
|
152
|
+
assertDefined(nil, lastElement, "Failed to get the highest value from an enum since the enum was empty.")
|
|
149
153
|
return lastElement
|
|
150
154
|
end
|
|
151
155
|
--- Helper function to get the enum value with the lowest value.
|
|
@@ -156,8 +160,9 @@ end
|
|
|
156
160
|
-- Throws an error if the provided enum is empty.
|
|
157
161
|
function ____exports.getLowestEnumValue(self, transpiledEnum)
|
|
158
162
|
local enumValues = ____exports.getEnumValues(nil, transpiledEnum)
|
|
159
|
-
local
|
|
160
|
-
|
|
163
|
+
local sortedValues = __TS__ArrayToSorted(enumValues, sortNormal)
|
|
164
|
+
local firstElement = sortedValues[1]
|
|
165
|
+
assertDefined(nil, firstElement, "Failed to get the lowest value from an enum since the enum was empty.")
|
|
161
166
|
return firstElement
|
|
162
167
|
end
|
|
163
168
|
--- Helper function to get a random value from the provided enum.
|
|
@@ -56,7 +56,7 @@ export declare function logLevelStateFlags(this: void): void;
|
|
|
56
56
|
* @param map The TSTL `Map` to log.
|
|
57
57
|
* @param name Optional. The name of the map, which will be logged before the elements.
|
|
58
58
|
*/
|
|
59
|
-
export declare function logMap(this: void, map: ReadonlyMap<
|
|
59
|
+
export declare function logMap(this: void, map: ReadonlyMap<number | string, unknown>, name?: string): void;
|
|
60
60
|
export declare function logMusic(this: void): void;
|
|
61
61
|
export declare function logPlayerEffects(this: void, player: EntityPlayer): void;
|
|
62
62
|
export declare function logPlayerHealth(this: void, player: EntityPlayer): void;
|
|
@@ -75,7 +75,7 @@ export declare function logSeedEffects(this: void): void;
|
|
|
75
75
|
* @param set The TSTL `Set` to log.
|
|
76
76
|
* @param name Optional. The name of the set, which will be logged before the elements.
|
|
77
77
|
*/
|
|
78
|
-
export declare function logSet(this: void, set: ReadonlySet<
|
|
78
|
+
export declare function logSet(this: void, set: ReadonlySet<number | string>, name?: string): void;
|
|
79
79
|
/** Helper function for logging every sound effect that is currently playing. */
|
|
80
80
|
export declare function logSounds(this: void): void;
|
|
81
81
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logMisc.d.ts","sourceRoot":"","sources":["../../src/functions/logMisc.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACb,MAAM,8BAA8B,CAAC;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E,IAAI,EACV,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,GACvC,IAAI,CAEN;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GACpC,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAoB/D;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,UAAQ,GACZ,IAAI,CAON"}
|
|
@@ -18,6 +18,7 @@ const playerHealth_1 = require("./playerHealth");
|
|
|
18
18
|
const players_1 = require("./players");
|
|
19
19
|
const roomData_1 = require("./roomData");
|
|
20
20
|
const set_1 = require("./set");
|
|
21
|
+
const sort_1 = require("./sort");
|
|
21
22
|
const table_1 = require("./table");
|
|
22
23
|
const trinkets_1 = require("./trinkets");
|
|
23
24
|
const tstlClass_1 = require("./tstlClass");
|
|
@@ -197,10 +198,9 @@ function logMap(map, name) {
|
|
|
197
198
|
const suffix = name === undefined ? "" : ` "${name}"`;
|
|
198
199
|
(0, log_1.log)(`Logging a TSTL map${suffix}:`);
|
|
199
200
|
const mapKeys = [...map.keys()];
|
|
200
|
-
mapKeys.sort();
|
|
201
|
+
mapKeys.sort(sort_1.sortNormal);
|
|
201
202
|
for (const key of mapKeys) {
|
|
202
203
|
const value = map.get(key);
|
|
203
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
204
204
|
(0, log_1.log)(` ${key} --> ${value}`);
|
|
205
205
|
}
|
|
206
206
|
(0, log_1.log)(` The size of the map was: ${map.size}`);
|
|
@@ -327,7 +327,6 @@ function logSet(set, name) {
|
|
|
327
327
|
(0, log_1.log)(`Logging a TSTL set${suffix}:`);
|
|
328
328
|
const setValues = (0, set_1.getSortedSetValues)(set);
|
|
329
329
|
for (const value of setValues) {
|
|
330
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
331
330
|
(0, log_1.log)(` Value: ${value}`);
|
|
332
331
|
}
|
|
333
332
|
(0, log_1.log)(` The size of the set was: ${set.size}`);
|
|
@@ -395,7 +394,7 @@ function logTableDifferences(table1, table2) {
|
|
|
395
394
|
const table2KeysSet = new ReadonlySet_1.ReadonlySet(table2Keys);
|
|
396
395
|
const keysSet = (0, set_1.combineSets)(table1KeysSet, table2KeysSet);
|
|
397
396
|
const keys = [...keysSet.values()];
|
|
398
|
-
keys.sort();
|
|
397
|
+
keys.sort(); // eslint-disable-line @typescript-eslint/require-array-sort-compare
|
|
399
398
|
for (const key of keys) {
|
|
400
399
|
const value1 = table1.get(key);
|
|
401
400
|
const value2 = table2.get(key);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Map = ____lualib.Map
|
|
3
2
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
4
3
|
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
5
4
|
local __TS__ArrayEntries = ____lualib.__TS__ArrayEntries
|
|
6
5
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
7
|
-
local Set = ____lualib.Set
|
|
8
6
|
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
9
7
|
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
10
8
|
local __TS__New = ____lualib.__TS__New
|
|
9
|
+
local Set = ____lualib.Set
|
|
11
10
|
local ____exports = {}
|
|
12
11
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
13
12
|
local BossID = ____isaac_2Dtypescript_2Ddefinitions.BossID
|
|
@@ -64,6 +63,8 @@ local getRoomListIndex = ____roomData.getRoomListIndex
|
|
|
64
63
|
local ____set = require("functions.set")
|
|
65
64
|
local combineSets = ____set.combineSets
|
|
66
65
|
local getSortedSetValues = ____set.getSortedSetValues
|
|
66
|
+
local ____sort = require("functions.sort")
|
|
67
|
+
local sortNormal = ____sort.sortNormal
|
|
67
68
|
local ____table = require("functions.table")
|
|
68
69
|
local iterateTableInOrder = ____table.iterateTableInOrder
|
|
69
70
|
local ____trinkets = require("functions.trinkets")
|
|
@@ -232,7 +233,7 @@ function ____exports.logMap(map, name)
|
|
|
232
233
|
local suffix = name == nil and "" or (" \"" .. name) .. "\""
|
|
233
234
|
log(("Logging a TSTL map" .. suffix) .. ":")
|
|
234
235
|
local mapKeys = {__TS__Spread(map:keys())}
|
|
235
|
-
__TS__ArraySort(mapKeys)
|
|
236
|
+
__TS__ArraySort(mapKeys, sortNormal)
|
|
236
237
|
for ____, key in ipairs(mapKeys) do
|
|
237
238
|
local value = map:get(key)
|
|
238
239
|
log(((" " .. tostring(key)) .. " --> ") .. tostring(value))
|
package/dist/functions/set.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare function deleteSetsFromSet<T>(mainSet: Set<T>, ...setsToRemove: R
|
|
|
34
34
|
* a random seed.
|
|
35
35
|
* @param exceptions Optional. An array of elements to skip over if selected.
|
|
36
36
|
*/
|
|
37
|
-
export declare function getRandomSetElement<T>(set: ReadonlySet<T>, seedOrRNG: Seed | RNG | undefined, exceptions?: readonly T[]): T;
|
|
37
|
+
export declare function getRandomSetElement<T extends number | string>(set: ReadonlySet<T>, seedOrRNG: Seed | RNG | undefined, exceptions?: readonly T[]): T;
|
|
38
38
|
/**
|
|
39
39
|
* Helper function to get all possible combinations of the given set. This includes the combination
|
|
40
40
|
* of an empty set.
|
|
@@ -54,14 +54,14 @@ export declare function getRandomSetElement<T>(set: ReadonlySet<T>, seedOrRNG: S
|
|
|
54
54
|
* @param set The set to get the combinations of.
|
|
55
55
|
* @param includeEmptyArray Whether to include an empty array in the combinations.
|
|
56
56
|
*/
|
|
57
|
-
export declare function getSetCombinations<T>(set: ReadonlySet<T>, includeEmptyArray: boolean): ReadonlyArray<ReadonlySet<T>>;
|
|
57
|
+
export declare function getSetCombinations<T extends number | string>(set: ReadonlySet<T>, includeEmptyArray: boolean): ReadonlyArray<ReadonlySet<T>>;
|
|
58
58
|
/**
|
|
59
59
|
* Helper function to get a sorted array based on the contents of a set.
|
|
60
60
|
*
|
|
61
61
|
* Normally, set values are returned in insertion order, so use this function when the ordering of
|
|
62
62
|
* the contents is important.
|
|
63
63
|
*/
|
|
64
|
-
export declare function getSortedSetValues<T>(set: ReadonlySet<T>): T[];
|
|
64
|
+
export declare function getSortedSetValues<T extends number | string>(set: ReadonlySet<T>): T[];
|
|
65
65
|
/**
|
|
66
66
|
* Helper function to convert the keys of an object to a read-only set.
|
|
67
67
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/functions/set.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/functions/set.ts"],"names":[],"mappings":";;AAKA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAE5B,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC1C,IAAI,CAMN;AAED;;;;GAIG;AAEH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAS7E;AAED,mGAAmG;AAEnG,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAOzD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAEjC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,CAA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CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACrE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,GAAG,CAAC,CAAC,CAAC,CAQR;AAED;;;;;GAKG;AAEH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAItE;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EACnB,GAAG,QAAQ,EAAE,SAAS,CAAC,EAAE,GACxB,OAAO,CAET;AAED,4DAA4D;AAC5D,wBAAgB,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAGvD"}
|
package/dist/functions/set.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.sumSet = exports.setHas = exports.setAdd = exports.objectValuesToSet = exports.objectValuesToReadonlySet = exports.objectKeysToSet = exports.objectKeysToReadonlySet = exports.getSortedSetValues = exports.getSetCombinations = exports.getRandomSetElement = exports.deleteSetsFromSet = exports.copySet = exports.combineSets = exports.addSetsToSet = void 0;
|
|
4
4
|
const ReadonlySet_1 = require("../types/ReadonlySet");
|
|
5
5
|
const array_1 = require("./array");
|
|
6
|
+
const sort_1 = require("./sort");
|
|
6
7
|
const types_1 = require("./types");
|
|
7
8
|
/**
|
|
8
9
|
* Helper function to add all of the values in one set to another set. The first set passed will be
|
|
@@ -121,7 +122,7 @@ function getSortedSetValues(set) {
|
|
|
121
122
|
error(`Failed to get the sorted set values because the provided set was of type "${arrayType}". Having sets with non-primitive types doesn't make much sense in general, so you might need to rethink what you are doing.`);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
values.sort();
|
|
125
|
+
values.sort(sort_1.sortNormal);
|
|
125
126
|
return values;
|
|
126
127
|
}
|
|
127
128
|
exports.getSortedSetValues = getSortedSetValues;
|
package/dist/functions/set.lua
CHANGED
|
@@ -15,6 +15,8 @@ local ____array = require("functions.array")
|
|
|
15
15
|
local getArrayCombinations = ____array.getArrayCombinations
|
|
16
16
|
local getRandomArrayElement = ____array.getRandomArrayElement
|
|
17
17
|
local sumArray = ____array.sumArray
|
|
18
|
+
local ____sort = require("functions.sort")
|
|
19
|
+
local sortNormal = ____sort.sortNormal
|
|
18
20
|
local ____types = require("functions.types")
|
|
19
21
|
local isPrimitive = ____types.isPrimitive
|
|
20
22
|
--- Helper function to get a sorted array based on the contents of a set.
|
|
@@ -30,7 +32,7 @@ function ____exports.getSortedSetValues(self, set)
|
|
|
30
32
|
error(("Failed to get the sorted set values because the provided set was of type \"" .. tostring(arrayType)) .. "\". Having sets with non-primitive types doesn't make much sense in general, so you might need to rethink what you are doing.")
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
|
-
__TS__ArraySort(values)
|
|
35
|
+
__TS__ArraySort(values, sortNormal)
|
|
34
36
|
return values
|
|
35
37
|
end
|
|
36
38
|
--- Helper function to convert the keys of an object to a set.
|
package/dist/functions/sort.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function sortNormal(a: unknown, b: unknown): -1 | 0 | 1;
|
|
1
2
|
/**
|
|
2
3
|
* Helper function to sort an array of objects by one of the object keys.
|
|
3
4
|
*
|
|
@@ -25,7 +26,7 @@ export declare function sortObjectArrayByKey(key: string): (a: unknown, b: unkno
|
|
|
25
26
|
*
|
|
26
27
|
* ```ts
|
|
27
28
|
* const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
28
|
-
* myArray.sort(
|
|
29
|
+
* myArray.sort(sortTwoDimensionalArray);
|
|
29
30
|
* ```
|
|
30
31
|
*
|
|
31
32
|
* This function also properly handles when the array elements are strings or numbers (instead of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/functions/sort.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/functions/sort.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CA0B7D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,OACnC,OAAO,KAAK,OAAO,KAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAsB5C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,CAAC,EAAE,SAAS,CAAC,EAAE,EACf,CAAC,EAAE,SAAS,CAAC,EAAE,GACd,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAiDZ;AAED;;;;;;GAMG;AAEH,wBAAgB,UAAU,CAAC,CAAC,EAE1B,KAAK,EAAE,CAAC,EAAE,EACV,QAAQ,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAc,GAChD,CAAC,EAAE,CAuDL"}
|
package/dist/functions/sort.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stableSort = exports.sortTwoDimensionalArray = exports.sortObjectArrayByKey = void 0;
|
|
3
|
+
exports.stableSort = exports.sortTwoDimensionalArray = exports.sortObjectArrayByKey = exports.sortNormal = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
function sortNormal(a, b) {
|
|
6
6
|
if (!(0, types_1.isNumber)(a) && !(0, types_1.isString)(a)) {
|
|
@@ -17,6 +17,7 @@ function sortNormal(a, b) {
|
|
|
17
17
|
}
|
|
18
18
|
return 0;
|
|
19
19
|
}
|
|
20
|
+
exports.sortNormal = sortNormal;
|
|
20
21
|
/**
|
|
21
22
|
* Helper function to sort an array of objects by one of the object keys.
|
|
22
23
|
*
|
|
@@ -57,7 +58,7 @@ exports.sortObjectArrayByKey = sortObjectArrayByKey;
|
|
|
57
58
|
*
|
|
58
59
|
* ```ts
|
|
59
60
|
* const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
60
|
-
* myArray.sort(
|
|
61
|
+
* myArray.sort(sortTwoDimensionalArray);
|
|
61
62
|
* ```
|
|
62
63
|
*
|
|
63
64
|
* This function also properly handles when the array elements are strings or numbers (instead of
|
package/dist/functions/sort.lua
CHANGED
|
@@ -5,7 +5,7 @@ local ____types = require("functions.types")
|
|
|
5
5
|
local isNumber = ____types.isNumber
|
|
6
6
|
local isString = ____types.isString
|
|
7
7
|
local isTable = ____types.isTable
|
|
8
|
-
|
|
8
|
+
function ____exports.sortNormal(self, a, b)
|
|
9
9
|
if not isNumber(nil, a) and not isString(nil, a) then
|
|
10
10
|
error("Failed to normal sort since the first value was not a number or string and was instead: " .. type(a))
|
|
11
11
|
end
|
|
@@ -47,7 +47,7 @@ function ____exports.sortObjectArrayByKey(self, key)
|
|
|
47
47
|
end
|
|
48
48
|
local aValue = a[key]
|
|
49
49
|
local bValue = b[key]
|
|
50
|
-
return sortNormal(nil, aValue, bValue)
|
|
50
|
+
return ____exports.sortNormal(nil, aValue, bValue)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
--- Helper function to sort a two-dimensional array by the first element.
|
|
@@ -56,7 +56,7 @@ end
|
|
|
56
56
|
--
|
|
57
57
|
-- ```ts
|
|
58
58
|
-- const myArray = [[1, 2], [2, 3], [3, 4]];
|
|
59
|
-
-- myArray.sort(
|
|
59
|
+
-- myArray.sort(sortTwoDimensionalArray);
|
|
60
60
|
-- ```
|
|
61
61
|
--
|
|
62
62
|
-- This function also properly handles when the array elements are strings or numbers (instead of
|
|
@@ -71,7 +71,7 @@ function ____exports.sortTwoDimensionalArray(self, a, b)
|
|
|
71
71
|
error(((((((("Failed to two-dimensional sort since the two elements were disparate types: " .. tostring(a)) .. " & ") .. tostring(b)) .. " (") .. aType) .. " & ") .. bType) .. ")")
|
|
72
72
|
end
|
|
73
73
|
if aType == "string" or aType == "number" then
|
|
74
|
-
return sortNormal(nil, a, b)
|
|
74
|
+
return ____exports.sortNormal(nil, a, b)
|
|
75
75
|
end
|
|
76
76
|
if aType ~= "table" then
|
|
77
77
|
error("Failed to two-dimensional sort since the first element was not a string, number, or table.")
|
|
@@ -92,7 +92,7 @@ function ____exports.sortTwoDimensionalArray(self, a, b)
|
|
|
92
92
|
if elementType1 ~= elementType2 then
|
|
93
93
|
error(((((((("Failed to two-dimensional sort since the first element of each array were disparate types: " .. tostring(firstElement1)) .. " & ") .. tostring(firstElement2)) .. " (") .. elementType1) .. " & ") .. elementType2) .. ")")
|
|
94
94
|
end
|
|
95
|
-
return sortNormal(nil, firstElement1, firstElement2)
|
|
95
|
+
return ____exports.sortNormal(nil, firstElement1, firstElement2)
|
|
96
96
|
end
|
|
97
97
|
--- Helper function to sort an array in a stable way.
|
|
98
98
|
--
|
|
@@ -101,7 +101,7 @@ end
|
|
|
101
101
|
-- Under the hood, this uses the merge sort algorithm.
|
|
102
102
|
function ____exports.stableSort(self, array, sortFunc)
|
|
103
103
|
if sortFunc == nil then
|
|
104
|
-
sortFunc = sortNormal
|
|
104
|
+
sortFunc = ____exports.sortNormal
|
|
105
105
|
end
|
|
106
106
|
if #array <= 1 then
|
|
107
107
|
return array
|
package/dist/functions/table.js
CHANGED
|
@@ -140,7 +140,7 @@ function iterateTableInOrder(luaMap, func, inOrder = true) {
|
|
|
140
140
|
}
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
keys.sort();
|
|
143
|
+
keys.sort(); // eslint-disable-line @typescript-eslint/require-array-sort-compare
|
|
144
144
|
for (const key of keys) {
|
|
145
145
|
const keyIndex = key;
|
|
146
146
|
const value = luaM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,EAAE,OAAO,GAAG,QAAQ,IAAI,MAAM,CAE9D;AAED,wBAAgB,OAAO,CACrB,QAAQ,EAAE,OAAO,GAChB,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAGxC;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,WAAW,CAGrE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAe5D"}
|
package/dist/functions/types.js
CHANGED
|
@@ -161,12 +161,12 @@ function asTrinketType(num) {
|
|
|
161
161
|
}
|
|
162
162
|
exports.asTrinketType = asTrinketType;
|
|
163
163
|
function isBoolean(variable) {
|
|
164
|
-
return
|
|
164
|
+
return typeof variable === "boolean";
|
|
165
165
|
}
|
|
166
166
|
exports.isBoolean = isBoolean;
|
|
167
167
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
168
168
|
function isFunction(variable) {
|
|
169
|
-
return
|
|
169
|
+
return typeof variable === "function";
|
|
170
170
|
}
|
|
171
171
|
exports.isFunction = isFunction;
|
|
172
172
|
function isInteger(variable) {
|
|
@@ -177,26 +177,28 @@ function isInteger(variable) {
|
|
|
177
177
|
}
|
|
178
178
|
exports.isInteger = isInteger;
|
|
179
179
|
function isNumber(variable) {
|
|
180
|
-
return
|
|
180
|
+
return typeof variable === "number";
|
|
181
181
|
}
|
|
182
182
|
exports.isNumber = isNumber;
|
|
183
183
|
/** Helper function to detect if a variable is a boolean, number, or string. */
|
|
184
184
|
function isPrimitive(variable) {
|
|
185
|
-
const variableType =
|
|
185
|
+
const variableType = typeof variable;
|
|
186
186
|
return (variableType === "boolean" ||
|
|
187
187
|
variableType === "number" ||
|
|
188
188
|
variableType === "string");
|
|
189
189
|
}
|
|
190
190
|
exports.isPrimitive = isPrimitive;
|
|
191
191
|
function isString(variable) {
|
|
192
|
-
return
|
|
192
|
+
return typeof variable === "string";
|
|
193
193
|
}
|
|
194
194
|
exports.isString = isString;
|
|
195
195
|
function isTable(variable) {
|
|
196
|
+
// We cannot use `typeof` here since "table" is not a JavaScript type.
|
|
196
197
|
return type(variable) === "table";
|
|
197
198
|
}
|
|
198
199
|
exports.isTable = isTable;
|
|
199
200
|
function isUserdata(variable) {
|
|
201
|
+
// We cannot use `typeof` here since "userdata" is not a JavaScript type.
|
|
200
202
|
return type(variable) === "userdata";
|
|
201
203
|
}
|
|
202
204
|
exports.isUserdata = isUserdata;
|
package/dist/functions/types.lua
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__TypeOf = ____lualib.__TS__TypeOf
|
|
1
3
|
local ____exports = {}
|
|
2
4
|
function ____exports.isNumber(self, variable)
|
|
3
5
|
return type(variable) == "number"
|
|
@@ -107,7 +109,7 @@ function ____exports.isInteger(self, variable)
|
|
|
107
109
|
end
|
|
108
110
|
--- Helper function to detect if a variable is a boolean, number, or string.
|
|
109
111
|
function ____exports.isPrimitive(self, variable)
|
|
110
|
-
local variableType =
|
|
112
|
+
local variableType = __TS__TypeOf(variable)
|
|
111
113
|
return variableType == "boolean" or variableType == "number" or variableType == "string"
|
|
112
114
|
end
|
|
113
115
|
function ____exports.isString(self, variable)
|