isaacscript-common 6.10.0 → 6.10.1

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.
@@ -27,7 +27,6 @@ local ____isaacAPIClass = require("functions.isaacAPIClass")
27
27
  local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
28
28
  local ____log = require("functions.log")
29
29
  local log = ____log.log
30
- local logTable = ____log.logTable
31
30
  local ____serialization = require("functions.serialization")
32
31
  local copyIsaacAPIClass = ____serialization.copyIsaacAPIClass
33
32
  local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
@@ -198,6 +197,9 @@ function deepCopyTable(self, luaMap, serializationType, traversalDescription, in
198
197
  )
199
198
  end
200
199
  function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescription, insideMap)
200
+ if SAVE_DATA_MANAGER_DEBUG then
201
+ log("deepCopy is copying a DefaultMap.")
202
+ end
201
203
  local ____isDefaultMap_result_0
202
204
  if isDefaultMap(nil, defaultMap) then
203
205
  ____isDefaultMap_result_0 = defaultMap:getConstructorArg()
@@ -239,7 +241,7 @@ function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescri
239
241
  if isDefaultMap(nil, newDefaultMap) then
240
242
  newDefaultMap:set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "")
241
243
  else
242
- newDefaultMap:set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "")
244
+ newDefaultMap[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
243
245
  end
244
246
  end
245
247
  for ____, ____value in ipairs(entries) do
@@ -248,7 +250,7 @@ function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescri
248
250
  if isDefaultMap(nil, newDefaultMap) then
249
251
  newDefaultMap:set(key, value)
250
252
  else
251
- newDefaultMap:set(key, value)
253
+ newDefaultMap[key] = value
252
254
  end
253
255
  end
254
256
  insideMap = false
@@ -256,15 +258,15 @@ function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescri
256
258
  end
257
259
  function getNewDefaultMap(self, defaultMap, serializationType, traversalDescription, constructorArg)
258
260
  repeat
259
- local ____switch33 = serializationType
260
- local ____cond33 = ____switch33 == SerializationType.NONE
261
- if ____cond33 then
261
+ local ____switch34 = serializationType
262
+ local ____cond34 = ____switch34 == SerializationType.NONE
263
+ if ____cond34 then
262
264
  do
263
265
  return __TS__New(DefaultMap, constructorArg)
264
266
  end
265
267
  end
266
- ____cond33 = ____cond33 or ____switch33 == SerializationType.SERIALIZE
267
- if ____cond33 then
268
+ ____cond34 = ____cond34 or ____switch34 == SerializationType.SERIALIZE
269
+ if ____cond34 then
268
270
  do
269
271
  local newDefaultMap = {}
270
272
  newDefaultMap[SerializationBrand.DEFAULT_MAP] = ""
@@ -272,8 +274,8 @@ function getNewDefaultMap(self, defaultMap, serializationType, traversalDescript
272
274
  return newDefaultMap
273
275
  end
274
276
  end
275
- ____cond33 = ____cond33 or ____switch33 == SerializationType.DESERIALIZE
276
- if ____cond33 then
277
+ ____cond34 = ____cond34 or ____switch34 == SerializationType.DESERIALIZE
278
+ if ____cond34 then
277
279
  do
278
280
  if isDefaultMap(nil, defaultMap) then
279
281
  error(("The deep copy function failed to deserialize a default map of \"" .. traversalDescription) .. "\", since it was not a Lua table.")
@@ -288,6 +290,9 @@ function getNewDefaultMap(self, defaultMap, serializationType, traversalDescript
288
290
  until true
289
291
  end
290
292
  function deepCopyMap(self, map, serializationType, traversalDescription, insideMap)
293
+ if SAVE_DATA_MANAGER_DEBUG then
294
+ log("deepCopy is copying a Map.")
295
+ end
291
296
  local newMap
292
297
  if serializationType == SerializationType.SERIALIZE then
293
298
  newMap = {}
@@ -325,6 +330,9 @@ function deepCopyMap(self, map, serializationType, traversalDescription, insideM
325
330
  return newMap
326
331
  end
327
332
  function deepCopySet(self, set, serializationType, traversalDescription, insideMap)
333
+ if SAVE_DATA_MANAGER_DEBUG then
334
+ log("deepCopy is copying a Set.")
335
+ end
328
336
  local newSet
329
337
  if serializationType == SerializationType.SERIALIZE then
330
338
  newSet = {}
@@ -359,6 +367,9 @@ function deepCopySet(self, set, serializationType, traversalDescription, insideM
359
367
  return newSet
360
368
  end
361
369
  function deepCopyTSTLClass(self, tstlClass, serializationType, traversalDescription, insideMap)
370
+ if SAVE_DATA_MANAGER_DEBUG then
371
+ log("deepCopy is copying a TSTL class.")
372
+ end
362
373
  local newClass
363
374
  if serializationType == SerializationType.SERIALIZE then
364
375
  newClass = {}
@@ -385,6 +396,9 @@ function deepCopyTSTLClass(self, tstlClass, serializationType, traversalDescript
385
396
  return newClass
386
397
  end
387
398
  function deepCopyArray(self, array, serializationType, traversalDescription, insideMap)
399
+ if SAVE_DATA_MANAGER_DEBUG then
400
+ log("deepCopy is copying an array.")
401
+ end
388
402
  local newArray = {}
389
403
  for ____, value in ipairs(array) do
390
404
  local newValue = ____exports.deepCopy(
@@ -399,6 +413,9 @@ function deepCopyArray(self, array, serializationType, traversalDescription, ins
399
413
  return newArray
400
414
  end
401
415
  function deepCopyNormalLuaTable(self, luaMap, serializationType, traversalDescription, insideMap)
416
+ if SAVE_DATA_MANAGER_DEBUG then
417
+ log("deepCopy is copying a normal Lua table.")
418
+ end
402
419
  local newTable = {}
403
420
  local ____getCopiedEntries_result_5 = getCopiedEntries(
404
421
  nil,
@@ -433,7 +450,6 @@ function getCopiedEntries(self, object, serializationType, traversalDescription,
433
450
  end
434
451
  end
435
452
  if SAVE_DATA_MANAGER_DEBUG then
436
- logTable(entries)
437
453
  __TS__ArraySort(entries, twoDimensionalSort)
438
454
  end
439
455
  local hasNumberKeys = __TS__ArraySome(
@@ -451,7 +467,7 @@ function getCopiedEntries(self, object, serializationType, traversalDescription,
451
467
  local value = ____value[2]
452
468
  do
453
469
  if isSerializationBrand(nil, key) then
454
- goto __continue80
470
+ goto __continue86
455
471
  end
456
472
  traversalDescription = getTraversalDescription(nil, key, traversalDescription)
457
473
  local newValue = ____exports.deepCopy(
@@ -464,7 +480,7 @@ function getCopiedEntries(self, object, serializationType, traversalDescription,
464
480
  local keyToUse = convertNumberKeysToStrings and tostring(key) or key
465
481
  copiedEntries[#copiedEntries + 1] = {keyToUse, newValue}
466
482
  end
467
- ::__continue80::
483
+ ::__continue86::
468
484
  end
469
485
  return {entries = copiedEntries, convertedNumberKeysToStrings = convertNumberKeysToStrings}
470
486
  end
@@ -477,6 +493,9 @@ function checkMetatable(self, luaMap, traversalDescription)
477
493
  error(("The deepCopy function detected that " .. tableDescription) .. " has a metatable. Copying tables with metatables is not supported, unless they are explicitly handled by the save data manager. (e.g. TypeScriptToLua Maps, TypeScriptToLua Sets, etc.)")
478
494
  end
479
495
  function deepCopyUserdata(self, value, serializationType, traversalDescription)
496
+ if SAVE_DATA_MANAGER_DEBUG then
497
+ log("deepCopy is copying userdata.")
498
+ end
480
499
  local classType = getIsaacAPIClassName(nil, value)
481
500
  if classType == nil then
482
501
  error("The deep copy function was not able to derive the Isaac API class type for: " .. traversalDescription)
@@ -172,11 +172,8 @@ function copiedMapIsMap(self)
172
172
  oldMap:set(keyToLookFor, valueToLookFor)
173
173
  local newObject = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapIsMap")
174
174
  local newMap = newObject
175
- if not isTable(nil, newMap) then
176
- error("The copied Map had a type of: " .. __TS__TypeOf(newMap))
177
- end
178
175
  if not isTSTLMap(nil, newMap) then
179
- error("The copied Map was not a Map.")
176
+ error("The copied Map was not a Map and has a type of: " .. __TS__TypeOf(newMap))
180
177
  end
181
178
  end
182
179
  function copiedMapHasValue(self)
@@ -186,6 +183,9 @@ function copiedMapHasValue(self)
186
183
  oldMap:set(keyToLookFor, valueToLookFor)
187
184
  local newTable = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasValue")
188
185
  local newMap = newTable
186
+ if not isTSTLMap(nil, newMap) then
187
+ error("The copied Map was not a Map and has a type of: " .. __TS__TypeOf(newMap))
188
+ end
189
189
  local value = newMap:get(keyToLookFor)
190
190
  if value == nil then
191
191
  error("The copied Map did not have a key of: " .. keyToLookFor)
@@ -200,11 +200,8 @@ function copiedSetIsSet(self)
200
200
  oldSet:add(valueToLookFor)
201
201
  local newTable = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetIsSet")
202
202
  local newSet = newTable
203
- if not isTable(nil, newSet) then
204
- error("The copied Set had a type of: " .. __TS__TypeOf(newSet))
205
- end
206
203
  if not isTSTLSet(nil, newSet) then
207
- error("The copied Set was not a Map.")
204
+ error("The copied Set was not a Set and has a type of: " .. __TS__TypeOf(newSet))
208
205
  end
209
206
  end
210
207
  function copiedSetHasValue(self)
@@ -213,6 +210,9 @@ function copiedSetHasValue(self)
213
210
  oldSet:add(valueToLookFor)
214
211
  local newTable = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetHasValue")
215
212
  local newSet = newTable
213
+ if not isTSTLSet(nil, newSet) then
214
+ error("The copied Set was not a Set and has a type of: " .. __TS__TypeOf(newSet))
215
+ end
216
216
  local hasValue = newSet:has(valueToLookFor)
217
217
  if not hasValue then
218
218
  error("The copied Set did not have a value of: " .. valueToLookFor)
@@ -223,22 +223,22 @@ function copiedMapHasChildMap(self)
223
223
  local childMapValue = 456
224
224
  local oldChildMap = __TS__New(Map)
225
225
  oldChildMap:set(childMapKey, childMapValue)
226
- local keyToLookFor = "abc"
226
+ local keyToLookFor = "childMap"
227
227
  local oldMap = __TS__New(Map)
228
228
  oldMap:set(keyToLookFor, oldChildMap)
229
229
  local newTable = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasChildMap")
230
230
  local newMap = newTable
231
+ if not isTSTLMap(nil, newMap) then
232
+ error("The copied Map was not a Map and had a type of: " .. __TS__TypeOf(newMap))
233
+ end
231
234
  local newChildMap = newMap:get(keyToLookFor)
232
235
  if newChildMap == nil then
233
236
  error("The copied Map did not have a child map at key: " .. keyToLookFor)
234
237
  end
235
- if not isTable(nil, newChildMap) then
236
- error("The copied child Map had a type of: " .. __TS__TypeOf(newChildMap))
237
- end
238
238
  if not isTSTLMap(nil, newChildMap) then
239
- error("The copied child Map was not a Map.")
239
+ error("The copied child Map was not a Map and had a type of: " .. __TS__TypeOf(newChildMap))
240
240
  end
241
- local value = newChildMap[childMapKey]
241
+ local value = newChildMap:get(childMapKey)
242
242
  if value == nil then
243
243
  error("The copied child Map did not have a key of: " .. tostring(childMapKey))
244
244
  end
@@ -261,24 +261,24 @@ function copiedDefaultMapHasChildDefaultMap(self)
261
261
  oldChildMap:set(childMapKey2, childMapCustomValue)
262
262
  local newTable = deepCopy(nil, oldParentMap, SerializationType.NONE, "copiedDefaultMapHasChildDefaultMap")
263
263
  local newParentMap = newTable
264
+ if not isDefaultMap(nil, newParentMap) then
265
+ error("The copied parent DefaultMap was not a DefaultMap and had a type of: " .. __TS__TypeOf(newParentMap))
266
+ end
264
267
  local newChildMap = newParentMap:get(parentMapKey)
265
268
  if newChildMap == nil then
266
269
  error("The copied DefaultMap did not have a child map at key: " .. parentMapKey)
267
270
  end
268
- if not isTable(nil, newChildMap) then
269
- error("The copied child DefaultMap had a type of: " .. __TS__TypeOf(newChildMap))
270
- end
271
271
  if not isDefaultMap(nil, newChildMap) then
272
- error("The copied child DefaultMap was not a DefaultMap.")
272
+ error("The copied child DefaultMap was not a DefaultMap and had a type of: " .. __TS__TypeOf(newChildMap))
273
273
  end
274
- local newChildMapValue1 = newChildMap[childMapKey1]
274
+ local newChildMapValue1 = newChildMap:get(childMapKey1)
275
275
  if newChildMapValue1 == nil then
276
276
  error("The copied child DefaultMap did not have a key of: " .. tostring(childMapKey1))
277
277
  end
278
278
  if newChildMapValue1 ~= childMapDefaultValue then
279
279
  error("The copied child Map did not have a default value of: " .. tostring(childMapDefaultValue))
280
280
  end
281
- local newChildMapValue2 = newChildMap[childMapKey2]
281
+ local newChildMapValue2 = newChildMap:get(childMapKey2)
282
282
  if newChildMapValue2 == nil then
283
283
  error("The copied child DefaultMap did not have a key of: " .. tostring(childMapKey2))
284
284
  end
@@ -290,6 +290,9 @@ function copiedDefaultMapHasBrand(self)
290
290
  local oldDefaultValue = "foo"
291
291
  local oldDefaultMap = __TS__New(DefaultMap, oldDefaultValue)
292
292
  local newTable = deepCopy(nil, oldDefaultMap, SerializationType.SERIALIZE, "copiedDefaultMapHasBrand")
293
+ if not isTable(nil, newTable) then
294
+ error("The copied DefaultMap was not a table and had a type of: " .. __TS__TypeOf(newTable))
295
+ end
293
296
  if not (newTable[SerializationBrand.DEFAULT_MAP] ~= nil) then
294
297
  error("The copied DefaultMap does not have the brand: " .. SerializationBrand.DEFAULT_MAP)
295
298
  end
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/functions/log.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAEV,UAAU,EACV,UAAU,EAEV,cAAc,EAGd,cAAc,EAGd,QAAQ,EACR,OAAO,EACR,MAAM,8BAA8B,CAAC;AA+BtC;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EAKX,kBAAkB,SAAI,GACrB,MAAM,CAiBR;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAGjD;AAED,8FAA8F;AAC9F,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,wBAAwB,EAAE,OAAO,EACjC,gBAAgB,CAAC,EAAE,UAAU,GAC5B,IAAI,CAuCN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,OAAO,EACrB,oBAAoB,CAAC,EAAE,cAAc,GACpC,IAAI,CA6CN;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAGvE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAIvD;AAED,mGAAmG;AACnG,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wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EACtC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,IAAI,CA0BN;AAED,iGAAiG;AACjG,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,GACnC,IAAI,CAEN;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GACjC,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAsB/D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,IAAI,CAGzE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAkC5C"}
@@ -517,6 +517,7 @@ function ____exports.logTable(luaTable, parentTables)
517
517
  end)(nil)
518
518
  return
519
519
  end
520
+ local numElements = 0
520
521
  iterateTableInOrder(
521
522
  nil,
522
523
  luaTable,
@@ -529,12 +530,11 @@ function ____exports.logTable(luaTable, parentTables)
529
530
  ____exports.logTable(value, parentTables + 1)
530
531
  end
531
532
  end
533
+ numElements = numElements + 1
532
534
  end
533
535
  );
534
536
  (function()
535
- local ____TS__ObjectKeys_result_0 = __TS__ObjectKeys(luaTable)
536
- local length = ____TS__ObjectKeys_result_0.length
537
- ____exports.log((indentation .. "The size of the table was: ") .. tostring(length))
537
+ ____exports.log((indentation .. "The size of the table was: ") .. tostring(numElements))
538
538
  end)(nil)
539
539
  end
540
540
  --- Helper function to print out the differences between the entries of two tables. Note that this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "6.10.0",
3
+ "version": "6.10.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -8,7 +8,7 @@ import { TSTLClass } from "../types/private/TSTLClass";
8
8
  import { isArray } from "./array";
9
9
  import { getEnumValues } from "./enums";
10
10
  import { getIsaacAPIClassName } from "./isaacAPIClass";
11
- import { log, logTable } from "./log";
11
+ import { log } from "./log";
12
12
  import {
13
13
  copyIsaacAPIClass,
14
14
  deserializeIsaacAPIClass,
@@ -209,6 +209,11 @@ function deepCopyDefaultMap(
209
209
  traversalDescription: string,
210
210
  insideMap: boolean,
211
211
  ) {
212
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
213
+ if (SAVE_DATA_MANAGER_DEBUG) {
214
+ log("deepCopy is copying a DefaultMap.");
215
+ }
216
+
212
217
  const constructorArg = isDefaultMap(defaultMap)
213
218
  ? defaultMap.getConstructorArg()
214
219
  : undefined; // The undefined case is handled explicitly in the "getNewDefaultMap" function.
@@ -291,7 +296,7 @@ function getNewDefaultMap(
291
296
  serializationType: SerializationType,
292
297
  traversalDescription: string,
293
298
  constructorArg: unknown,
294
- ) {
299
+ ): DefaultMap<AnyNotNil, unknown> | LuaMap<AnyNotNil, unknown> {
295
300
  switch (serializationType) {
296
301
  case SerializationType.NONE: {
297
302
  // eslint-disable-next-line isaacscript/no-invalid-default-map
@@ -336,6 +341,11 @@ function deepCopyMap(
336
341
  traversalDescription: string,
337
342
  insideMap: boolean,
338
343
  ) {
344
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
345
+ if (SAVE_DATA_MANAGER_DEBUG) {
346
+ log("deepCopy is copying a Map.");
347
+ }
348
+
339
349
  let newMap: Map<AnyNotNil, unknown> | LuaMap<AnyNotNil, unknown>;
340
350
  if (serializationType === SerializationType.SERIALIZE) {
341
351
  // Since we are serializing, the new object will be a Lua table.
@@ -384,6 +394,11 @@ function deepCopySet(
384
394
  traversalDescription: string,
385
395
  insideMap: boolean,
386
396
  ) {
397
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
398
+ if (SAVE_DATA_MANAGER_DEBUG) {
399
+ log("deepCopy is copying a Set.");
400
+ }
401
+
387
402
  let newSet: Set<AnyNotNil> | LuaMap<AnyNotNil, string>;
388
403
  if (serializationType === SerializationType.SERIALIZE) {
389
404
  // For serialization purposes, we represent a `Set` as a table with keys that match the
@@ -405,7 +420,7 @@ function deepCopySet(
405
420
  // Differentiating between the two types looks superfluous but is necessary for TSTL to produce
406
421
  // the proper set method call.
407
422
  if (isTSTLSet(newSet)) {
408
- // We should never be serializing an object of type Set.
423
+ // We should never be serializing an object of type `Set`.
409
424
  error(
410
425
  "The deep copy function cannot convert number keys to strings for a Set.",
411
426
  );
@@ -433,6 +448,11 @@ function deepCopyTSTLClass(
433
448
  traversalDescription: string,
434
449
  insideMap: boolean,
435
450
  ) {
451
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
452
+ if (SAVE_DATA_MANAGER_DEBUG) {
453
+ log("deepCopy is copying a TSTL class.");
454
+ }
455
+
436
456
  let newClass: TSTLClass | LuaMap<AnyNotNil, unknown>;
437
457
  if (serializationType === SerializationType.SERIALIZE) {
438
458
  // Since we are serializing, the new object will be a Lua table.
@@ -467,6 +487,11 @@ function deepCopyArray(
467
487
  traversalDescription: string,
468
488
  insideMap: boolean,
469
489
  ) {
490
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
491
+ if (SAVE_DATA_MANAGER_DEBUG) {
492
+ log("deepCopy is copying an array.");
493
+ }
494
+
470
495
  const newArray: unknown[] = [];
471
496
 
472
497
  for (const value of array) {
@@ -488,6 +513,11 @@ function deepCopyNormalLuaTable(
488
513
  traversalDescription: string,
489
514
  insideMap: boolean,
490
515
  ) {
516
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
517
+ if (SAVE_DATA_MANAGER_DEBUG) {
518
+ log("deepCopy is copying a normal Lua table.");
519
+ }
520
+
491
521
  const newTable = new LuaMap<AnyNotNil, unknown>();
492
522
  const { entries, convertedNumberKeysToStrings } = getCopiedEntries(
493
523
  luaMap,
@@ -535,7 +565,6 @@ function getCopiedEntries(
535
565
 
536
566
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
537
567
  if (SAVE_DATA_MANAGER_DEBUG) {
538
- logTable(entries);
539
568
  entries.sort(twoDimensionalSort);
540
569
  }
541
570
 
@@ -600,6 +629,11 @@ function deepCopyUserdata(
600
629
  serializationType: SerializationType,
601
630
  traversalDescription: string,
602
631
  ) {
632
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
633
+ if (SAVE_DATA_MANAGER_DEBUG) {
634
+ log("deepCopy is copying userdata.");
635
+ }
636
+
603
637
  const classType = getIsaacAPIClassName(value);
604
638
  if (classType === undefined) {
605
639
  error(
@@ -268,11 +268,8 @@ function copiedMapIsMap() {
268
268
  const newObject = deepCopy(oldMap, SerializationType.NONE, "copiedMapIsMap");
269
269
  const newMap = newObject as Map<string, string>;
270
270
 
271
- if (!isTable(newMap)) {
272
- error(`The copied Map had a type of: ${typeof newMap}`);
273
- }
274
271
  if (!isTSTLMap(newMap)) {
275
- error("The copied Map was not a Map.");
272
+ error(`The copied Map was not a Map and has a type of: ${typeof newMap}`);
276
273
  }
277
274
  }
278
275
 
@@ -287,8 +284,13 @@ function copiedMapHasValue() {
287
284
  SerializationType.NONE,
288
285
  "copiedMapHasValue",
289
286
  );
287
+
290
288
  const newMap = newTable as typeof oldMap;
291
289
 
290
+ if (!isTSTLMap(newMap)) {
291
+ error(`The copied Map was not a Map and has a type of: ${typeof newMap}`);
292
+ }
293
+
292
294
  const value = newMap.get(keyToLookFor);
293
295
  if (value === undefined) {
294
296
  error(`The copied Map did not have a key of: ${keyToLookFor}`);
@@ -306,11 +308,8 @@ function copiedSetIsSet() {
306
308
  const newTable = deepCopy(oldSet, SerializationType.NONE, "copiedSetIsSet");
307
309
  const newSet = newTable as Set<string>;
308
310
 
309
- if (!isTable(newSet)) {
310
- error(`The copied Set had a type of: ${typeof newSet}`);
311
- }
312
311
  if (!isTSTLSet(newSet)) {
313
- error("The copied Set was not a Map.");
312
+ error(`The copied Set was not a Set and has a type of: ${typeof newSet}`);
314
313
  }
315
314
  }
316
315
 
@@ -326,6 +325,10 @@ function copiedSetHasValue() {
326
325
  );
327
326
  const newSet = newTable as Set<string>;
328
327
 
328
+ if (!isTSTLSet(newSet)) {
329
+ error(`The copied Set was not a Set and has a type of: ${typeof newSet}`);
330
+ }
331
+
329
332
  const hasValue = newSet.has(valueToLookFor);
330
333
  if (!hasValue) {
331
334
  error(`The copied Set did not have a value of: ${valueToLookFor}`);
@@ -338,7 +341,7 @@ function copiedMapHasChildMap() {
338
341
  const oldChildMap = new Map<number, number>();
339
342
  oldChildMap.set(childMapKey, childMapValue);
340
343
 
341
- const keyToLookFor = "abc";
344
+ const keyToLookFor = "childMap";
342
345
  const oldMap = new Map<string, Map<number, number>>();
343
346
  oldMap.set(keyToLookFor, oldChildMap);
344
347
 
@@ -349,16 +352,19 @@ function copiedMapHasChildMap() {
349
352
  );
350
353
  const newMap = newTable as typeof oldMap;
351
354
 
355
+ if (!isTSTLMap(newMap)) {
356
+ error(`The copied Map was not a Map and had a type of: ${typeof newMap}`);
357
+ }
358
+
352
359
  const newChildMap = newMap.get(keyToLookFor);
353
360
  if (newChildMap === undefined) {
354
361
  error(`The copied Map did not have a child map at key: ${keyToLookFor}`);
355
362
  }
356
363
 
357
- if (!isTable(newChildMap)) {
358
- error(`The copied child Map had a type of: ${typeof newChildMap}`);
359
- }
360
364
  if (!isTSTLMap(newChildMap)) {
361
- error("The copied child Map was not a Map.");
365
+ error(
366
+ `The copied child Map was not a Map and had a type of: ${typeof newChildMap}`,
367
+ );
362
368
  }
363
369
 
364
370
  const value = newChildMap.get(childMapKey);
@@ -390,6 +396,12 @@ function copiedDefaultMapHasChildDefaultMap() {
390
396
  );
391
397
  const newParentMap = newTable as typeof oldParentMap;
392
398
 
399
+ if (!isDefaultMap(newParentMap)) {
400
+ error(
401
+ `The copied parent DefaultMap was not a DefaultMap and had a type of: ${typeof newParentMap}`,
402
+ );
403
+ }
404
+
393
405
  const newChildMap = newParentMap.get(parentMapKey);
394
406
  if (newChildMap === undefined) {
395
407
  error(
@@ -397,11 +409,10 @@ function copiedDefaultMapHasChildDefaultMap() {
397
409
  );
398
410
  }
399
411
 
400
- if (!isTable(newChildMap)) {
401
- error(`The copied child DefaultMap had a type of: ${typeof newChildMap}`);
402
- }
403
412
  if (!isDefaultMap(newChildMap)) {
404
- error("The copied child DefaultMap was not a DefaultMap.");
413
+ error(
414
+ `The copied child DefaultMap was not a DefaultMap and had a type of: ${typeof newChildMap}`,
415
+ );
405
416
  }
406
417
 
407
418
  const newChildMapValue1 = newChildMap.get(childMapKey1);
@@ -434,6 +445,12 @@ function copiedDefaultMapHasBrand() {
434
445
  "copiedDefaultMapHasBrand",
435
446
  ) as LuaMap<AnyNotNil, unknown>;
436
447
 
448
+ if (!isTable(newTable)) {
449
+ error(
450
+ `The copied DefaultMap was not a table and had a type of: ${typeof newTable}`,
451
+ );
452
+ }
453
+
437
454
  if (!newTable.has(SerializationBrand.DEFAULT_MAP)) {
438
455
  error(
439
456
  `The copied DefaultMap does not have the brand: ${SerializationBrand.DEFAULT_MAP}`,
@@ -640,6 +640,7 @@ export function logTable(
640
640
  return;
641
641
  }
642
642
 
643
+ let numElements = 0;
643
644
  iterateTableInOrder(luaTable, (key, value) => {
644
645
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
645
646
  log(`${indentation}${key} --> ${value}`);
@@ -653,13 +654,14 @@ export function logTable(
653
654
  logTable(value, parentTables + 1);
654
655
  }
655
656
  }
657
+
658
+ numElements++;
656
659
  });
657
660
 
658
661
  // Put it in an IIFE so that the it will show as "func" instead of "logTable" and align with the
659
662
  // other text.
660
663
  (() => {
661
- const { length } = Object.keys(luaTable);
662
- log(`${indentation}The size of the table was: ${length}`);
664
+ log(`${indentation}The size of the table was: ${numElements}`);
663
665
  })();
664
666
  }
665
667