isaacscript-common 6.6.3 → 6.6.4

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.
@@ -1,6 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
- local Map = ____lualib.Map
3
2
  local Set = ____lualib.Set
3
+ local Map = ____lualib.Map
4
4
  local ____exports = {}
5
5
  local mergeArray, mergeTSTLObject, mergeTable
6
6
  local ____SerializationBrand = require("enums.private.SerializationBrand")
@@ -20,6 +20,7 @@ local ____table = require("functions.table")
20
20
  local clearTable = ____table.clearTable
21
21
  local iterateTableInOrder = ____table.iterateTableInOrder
22
22
  local ____tstlClass = require("functions.tstlClass")
23
+ local isDefaultMap = ____tstlClass.isDefaultMap
23
24
  local isTSTLMap = ____tstlClass.isTSTLMap
24
25
  local isTSTLSet = ____tstlClass.isTSTLSet
25
26
  local ____types = require("functions.types")
@@ -64,7 +65,7 @@ function ____exports.merge(self, oldObject, newTable, traversalDescription)
64
65
  mergeArray(nil, oldObject, newTable)
65
66
  return
66
67
  end
67
- if isTSTLMap(nil, oldObject) or isTSTLSet(nil, oldObject) then
68
+ if isTSTLMap(nil, oldObject) or isTSTLSet(nil, oldObject) or isDefaultMap(nil, oldObject) then
68
69
  mergeTSTLObject(nil, oldObject, newTable, traversalDescription)
69
70
  else
70
71
  mergeTable(nil, oldObject, newTable, traversalDescription)
@@ -99,7 +100,7 @@ function mergeTSTLObject(self, oldObject, newTable, traversalDescription)
99
100
  end
100
101
  keyToUse = numberKey
101
102
  end
102
- if isTSTLMap(nil, oldObject) then
103
+ if isTSTLMap(nil, oldObject) or isDefaultMap(nil, oldObject) then
103
104
  local valueCopy
104
105
  if isTable(nil, value) then
105
106
  valueCopy = deepCopy(nil, value, SerializationType.DESERIALIZE, traversalDescription)
@@ -1 +1 @@
1
- {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/functions/array.ts"],"names":[],"mappings":";;;AAKA;;;GAGG;AACH,wBAAgB,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,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"}
@@ -437,7 +437,7 @@ function ____exports.isArray(self, object)
437
437
  if not hasAllNumberKeys then
438
438
  return false
439
439
  end
440
- local tableLength = #object
440
+ local tableLength = #__TS__ObjectKeys(object)
441
441
  if tableLength == 0 then
442
442
  return true
443
443
  end
@@ -1,2 +1,7 @@
1
- export declare function deepCopyTests(): void;
1
+ /**
2
+ * Run the suite of tests that prove that the "deepCopy" helper function works properly.
3
+ *
4
+ * This function is only useful if you are troubleshooting the "deepCopy" function.
5
+ */
6
+ export declare function runDeepCopyTests(): void;
2
7
  //# sourceMappingURL=deepCopyTests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deepCopyTests.d.ts","sourceRoot":"","sources":["../../src/functions/deepCopyTests.ts"],"names":[],"mappings":"AASA,wBAAgB,aAAa,IAAI,IAAI,CAqBpC"}
1
+ {"version":3,"file":"deepCopyTests.d.ts","sourceRoot":"","sources":["../../src/functions/deepCopyTests.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAqBvC"}
@@ -27,7 +27,7 @@ local isString = ____types.isString
27
27
  local isTable = ____types.isTable
28
28
  function copiedObjectIsTable(self)
29
29
  local oldObject = {abc = "def"}
30
- local newObject = deepCopy(nil, oldObject)
30
+ local newObject = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectIsTable")
31
31
  if not isTable(nil, newObject) then
32
32
  error("The copied object had a type of: " .. __TS__TypeOf(newObject))
33
33
  end
@@ -36,7 +36,7 @@ function copiedObjectHasKeyAndValueString(self)
36
36
  local keyToLookFor = "abc"
37
37
  local valueToLookFor = "def"
38
38
  local oldObject = {abc = valueToLookFor}
39
- local newTable = deepCopy(nil, oldObject)
39
+ local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasKeyAndValueString")
40
40
  local newObject = newTable
41
41
  local value = newObject[keyToLookFor]
42
42
  if value == nil then
@@ -54,7 +54,7 @@ function copiedTableHasKeyAndValueNumber(self)
54
54
  local valueToLookFor = 456
55
55
  local oldTable = {}
56
56
  oldTable[keyToLookFor] = valueToLookFor
57
- local newObject = deepCopy(nil, oldTable)
57
+ local newObject = deepCopy(nil, oldTable, SerializationType.NONE, "copiedTableHasKeyAndValueNumber")
58
58
  local newTable = newObject
59
59
  local value = newTable[keyToLookFor]
60
60
  if value == nil then
@@ -72,7 +72,7 @@ function copiedTableDoesNotCoerceTypes(self)
72
72
  local valueToLookFor = 456
73
73
  local oldTable = {}
74
74
  oldTable[keyToLookFor] = valueToLookFor
75
- local newObject = deepCopy(nil, oldTable)
75
+ local newObject = deepCopy(nil, oldTable, SerializationType.NONE, "copiedTableDoesNotCoerceTypes")
76
76
  local newTable = newObject
77
77
  local keyString = tostring(keyToLookFor)
78
78
  local valueString = tostring(valueToLookFor)
@@ -89,7 +89,7 @@ function copiedObjectHasNoReferencesForPrimitivesForward(self)
89
89
  local originalStringValue = "abcdef"
90
90
  local originalNumberValue = 123
91
91
  local oldObject = {abc = originalStringValue, def = originalNumberValue}
92
- local newTable = deepCopy(nil, oldObject)
92
+ local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForPrimitivesForward")
93
93
  local newObject = newTable
94
94
  oldObject.abc = "newValue"
95
95
  if oldObject.abc == newObject.abc then
@@ -104,7 +104,7 @@ function copiedObjectHasNoReferencesForPrimitivesBackward(self)
104
104
  local originalStringValue = "abcdef"
105
105
  local originalNumberValue = 123
106
106
  local oldObject = {abc = originalStringValue, def = originalNumberValue}
107
- local newTable = deepCopy(nil, oldObject)
107
+ local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForPrimitivesBackward")
108
108
  local newObject = newTable
109
109
  newObject.abc = "newValue"
110
110
  if newObject.abc == oldObject.abc then
@@ -117,7 +117,7 @@ function copiedObjectHasNoReferencesForPrimitivesBackward(self)
117
117
  end
118
118
  function copiedObjectHasNoReferencesForArray(self)
119
119
  local oldObject = {abc = {1, 2, 3}}
120
- local newTable = deepCopy(nil, oldObject)
120
+ local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasNoReferencesForArray")
121
121
  local newObject = newTable
122
122
  if oldObject.abc == newObject.abc then
123
123
  error("The copied object has the same point to the child array.")
@@ -145,7 +145,7 @@ function copiedObjectHasChildObject(self)
145
145
  local keyToLookFor = "def"
146
146
  local valueToLookFor = "ghi"
147
147
  local oldObject = {abc = {def = valueToLookFor}}
148
- local newTable = deepCopy(nil, oldObject)
148
+ local newTable = deepCopy(nil, oldObject, SerializationType.NONE, "copiedObjectHasChildObject")
149
149
  local newObject = newTable
150
150
  local childObject = newObject[childObjectIndex]
151
151
  if childObject == nil then
@@ -170,7 +170,7 @@ function copiedMapIsMap(self)
170
170
  local valueToLookFor = "def"
171
171
  local oldMap = __TS__New(Map)
172
172
  oldMap:set(keyToLookFor, valueToLookFor)
173
- local newObject = deepCopy(nil, oldMap)
173
+ local newObject = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapIsMap")
174
174
  local newMap = newObject
175
175
  if not isTable(nil, newMap) then
176
176
  error("The copied Map had a type of: " .. __TS__TypeOf(newMap))
@@ -184,7 +184,7 @@ function copiedMapHasValue(self)
184
184
  local valueToLookFor = "def"
185
185
  local oldMap = __TS__New(Map)
186
186
  oldMap:set(keyToLookFor, valueToLookFor)
187
- local newTable = deepCopy(nil, oldMap)
187
+ local newTable = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasValue")
188
188
  local newMap = newTable
189
189
  local value = newMap:get(keyToLookFor)
190
190
  if value == nil then
@@ -198,7 +198,7 @@ function copiedSetIsSet(self)
198
198
  local valueToLookFor = "abc"
199
199
  local oldSet = __TS__New(Set)
200
200
  oldSet:add(valueToLookFor)
201
- local newTable = deepCopy(nil, oldSet)
201
+ local newTable = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetIsSet")
202
202
  local newSet = newTable
203
203
  if not isTable(nil, newSet) then
204
204
  error("The copied Set had a type of: " .. __TS__TypeOf(newSet))
@@ -211,7 +211,7 @@ function copiedSetHasValue(self)
211
211
  local valueToLookFor = "abc"
212
212
  local oldSet = __TS__New(Set)
213
213
  oldSet:add(valueToLookFor)
214
- local newTable = deepCopy(nil, oldSet)
214
+ local newTable = deepCopy(nil, oldSet, SerializationType.NONE, "copiedSetHasValue")
215
215
  local newSet = newTable
216
216
  local hasValue = newSet:has(valueToLookFor)
217
217
  if not hasValue then
@@ -226,7 +226,7 @@ function copiedMapHasChildMap(self)
226
226
  local keyToLookFor = "abc"
227
227
  local oldMap = __TS__New(Map)
228
228
  oldMap:set(keyToLookFor, oldChildMap)
229
- local newTable = deepCopy(nil, oldMap)
229
+ local newTable = deepCopy(nil, oldMap, SerializationType.NONE, "copiedMapHasChildMap")
230
230
  local newMap = newTable
231
231
  local newChildMap = newMap:get(keyToLookFor)
232
232
  if newChildMap == nil then
@@ -259,7 +259,7 @@ function copiedDefaultMapHasChildDefaultMap(self)
259
259
  local oldChildMap = oldParentMap:getAndSetDefault(parentMapKey)
260
260
  oldChildMap:getAndSetDefault(childMapKey1)
261
261
  oldChildMap:set(childMapKey2, childMapCustomValue)
262
- local newTable = deepCopy(nil, oldParentMap)
262
+ local newTable = deepCopy(nil, oldParentMap, SerializationType.NONE, "copiedDefaultMapHasChildDefaultMap")
263
263
  local newParentMap = newTable
264
264
  local newChildMap = newParentMap:get(parentMapKey)
265
265
  if newChildMap == nil then
@@ -289,12 +289,15 @@ end
289
289
  function copiedDefaultMapHasBrand(self)
290
290
  local oldDefaultValue = "foo"
291
291
  local oldDefaultMap = __TS__New(DefaultMap, oldDefaultValue)
292
- local newTable = deepCopy(nil, oldDefaultMap, SerializationType.SERIALIZE)
292
+ local newTable = deepCopy(nil, oldDefaultMap, SerializationType.SERIALIZE, "copiedDefaultMapHasBrand")
293
293
  if not (newTable[SerializationBrand.DEFAULT_MAP] ~= nil) then
294
294
  error("The copied DefaultMap does not have the brand: " .. SerializationBrand.DEFAULT_MAP)
295
295
  end
296
296
  end
297
- function ____exports.deepCopyTests(self)
297
+ --- Run the suite of tests that prove that the "deepCopy" helper function works properly.
298
+ --
299
+ -- This function is only useful if you are troubleshooting the "deepCopy" function.
300
+ function ____exports.runDeepCopyTests(self)
298
301
  copiedObjectIsTable(nil)
299
302
  copiedObjectHasKeyAndValueString(nil)
300
303
  copiedTableHasKeyAndValueNumber(nil)
@@ -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,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,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,GACvC,IAAI,CAEN;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,IA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-478,7 +478,9 @@ function ____exports.logTable(luaTable, parentTables)
478
478
  math.floor(numSpaces)
479
479
  )
480
480
  if not isTable(nil, luaTable) then
481
- ____exports.log(((indentation .. "n/a (encountered a variable of type \"") .. __TS__TypeOf(luaTable)) .. "\" instead of a table)")
481
+ (function()
482
+ ____exports.log(((indentation .. "n/a (encountered a variable of type \"") .. __TS__TypeOf(luaTable)) .. "\" instead of a table)")
483
+ end)(nil)
482
484
  return
483
485
  end
484
486
  iterateTableInOrder(
@@ -494,8 +496,10 @@ function ____exports.logTable(luaTable, parentTables)
494
496
  end
495
497
  end
496
498
  end
497
- )
498
- ____exports.log((indentation .. "The size of the table was: ") .. tostring(#luaTable))
499
+ );
500
+ (function()
501
+ ____exports.log((indentation .. "The size of the table was: ") .. tostring(#luaTable))
502
+ end)(nil)
499
503
  end
500
504
  --- Helper function to print out the differences between the entries of two tables. Note that this
501
505
  -- will only do a shallow comparison.
@@ -1,2 +1,8 @@
1
- export declare function mergeTests(): void;
1
+ /**
2
+ * Run the suite of tests that prove that the "merge" helper function works properly. (This function
3
+ * is not exported but is used internally in the save data manager.)
4
+ *
5
+ * This function is only useful if you are troubleshooting the save data manager.
6
+ */
7
+ export declare function runMergeTests(): void;
2
8
  //# sourceMappingURL=mergeTests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTests.d.ts","sourceRoot":"","sources":["../../src/functions/mergeTests.ts"],"names":[],"mappings":"AAQA,wBAAgB,UAAU,IAAI,IAAI,CAajC"}
1
+ {"version":3,"file":"mergeTests.d.ts","sourceRoot":"","sources":["../../src/functions/mergeTests.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAgBpC"}
@@ -1,5 +1,10 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Map = ____lualib.Map
3
+ local __TS__New = ____lualib.__TS__New
1
4
  local ____exports = {}
2
- local oldTableHasUpdatedValue, newTableHasSameValue, oldTableHasUpdatedValueFromNull, oldTableHasSerializedIsaacAPIClass, oldTableHasFilledInterface, oldTableHasVector, oldTableHasVectorSerialized, oldTableHasRNG, oldTableHasRNGSerialized
5
+ local oldTableHasUpdatedValue, newTableHasSameValue, oldTableHasUpdatedValueFromNull, oldTableHasSerializedIsaacAPIClass, oldTableHasFilledChildTable, oldTableHasFilledMap, oldTableHasFilledDefaultMap, oldTableHasVector, oldTableHasVectorSerialized, oldTableHasRNG, oldTableHasRNGSerialized
6
+ local ____DefaultMap = require("classes.DefaultMap")
7
+ local DefaultMap = ____DefaultMap.DefaultMap
3
8
  local ____SerializationType = require("enums.SerializationType")
4
9
  local SerializationType = ____SerializationType.SerializationType
5
10
  local ____merge = require("features.saveDataManager.merge")
@@ -60,13 +65,13 @@ function oldTableHasSerializedIsaacAPIClass(self)
60
65
  error("The \"isSerializedIsaacAPIClass\" function says that a serialized vector is not serialized.")
61
66
  end
62
67
  end
63
- function oldTableHasFilledInterface(self)
68
+ function oldTableHasFilledChildTable(self)
64
69
  local key = "foo"
65
70
  local newValue = "baz"
66
71
  local oldTable = {foo = nil}
67
72
  local foo = {bar = newValue}
68
73
  local newTable = {foo = foo}
69
- merge(nil, oldTable, newTable, "oldTableHasFilledInterface")
74
+ merge(nil, oldTable, newTable, "oldTableHasFilledChildTable")
70
75
  local oldTableValue = oldTable[key]
71
76
  if oldTableValue == nil then
72
77
  error(("The old table's key of \"" .. key) .. "\" was not filled.")
@@ -75,6 +80,74 @@ function oldTableHasFilledInterface(self)
75
80
  error("The old table's key of \"bar\" was not filled.")
76
81
  end
77
82
  end
83
+ function oldTableHasFilledMap(self)
84
+ local v = {run = {myMap = __TS__New(Map)}}
85
+ local saveData = {run = {myMap = __TS__New(Map, {{"foo1", "bar1"}, {"foo2", "bar2"}, {"foo3", "bar3"}})}}
86
+ local serializedSaveData = deepCopy(nil, saveData, SerializationType.SERIALIZE)
87
+ merge(nil, v, serializedSaveData, "oldTableHasFilledMap")
88
+ local expectedSize = 3
89
+ if v.run.myMap.size ~= expectedSize then
90
+ error((("The size of the merged map was equal to " .. tostring(v.run.myMap.size)) .. ", but it should be equal to: ") .. tostring(expectedSize))
91
+ end
92
+ do
93
+ local key = "foo1"
94
+ local expectedValue = "bar1"
95
+ local value = v.run.myMap:get(key)
96
+ if value ~= expectedValue then
97
+ error((((("The old table's map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
98
+ end
99
+ end
100
+ do
101
+ local key = "foo2"
102
+ local expectedValue = "bar2"
103
+ local value = v.run.myMap:get(key)
104
+ if value ~= expectedValue then
105
+ error((((("The old table's map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
106
+ end
107
+ end
108
+ do
109
+ local key = "foo3"
110
+ local expectedValue = "bar3"
111
+ local value = v.run.myMap:get(key)
112
+ if value ~= expectedValue then
113
+ error((((("The old table's map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
114
+ end
115
+ end
116
+ end
117
+ function oldTableHasFilledDefaultMap(self)
118
+ local v = {run = {myDefaultMap = __TS__New(DefaultMap, "default")}}
119
+ local saveData = {run = {myDefaultMap = __TS__New(DefaultMap, "default", {{"foo1", "bar1"}, {"foo2", "bar2"}, {"foo3", "bar3"}})}}
120
+ local serializedSaveData = deepCopy(nil, saveData, SerializationType.SERIALIZE)
121
+ merge(nil, v, serializedSaveData, "oldTableHasFilledDefaultMap")
122
+ local expectedSize = 3
123
+ if v.run.myDefaultMap.size ~= expectedSize then
124
+ error((("The size of the merged default map was equal to " .. tostring(v.run.myDefaultMap.size)) .. ", but it should be equal to: ") .. tostring(expectedSize))
125
+ end
126
+ do
127
+ local key = "foo1"
128
+ local expectedValue = "bar1"
129
+ local value = v.run.myDefaultMap:get(key)
130
+ if value ~= expectedValue then
131
+ error((((("The old table's default map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
132
+ end
133
+ end
134
+ do
135
+ local key = "foo2"
136
+ local expectedValue = "bar2"
137
+ local value = v.run.myDefaultMap:get(key)
138
+ if value ~= expectedValue then
139
+ error((((("The old table's default map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
140
+ end
141
+ end
142
+ do
143
+ local key = "foo3"
144
+ local expectedValue = "bar3"
145
+ local value = v.run.myDefaultMap:get(key)
146
+ if value ~= expectedValue then
147
+ error((((("The old table's default map key of \"" .. key) .. "\" was not equal to \"") .. expectedValue) .. "\" and was instead equal to: ") .. tostring(value))
148
+ end
149
+ end
150
+ end
78
151
  function oldTableHasVector(self)
79
152
  log("Starting test: oldTableHasVector")
80
153
  local key = "foo"
@@ -108,7 +181,7 @@ function oldTableHasVectorSerialized(self)
108
181
  local oldTable = {foo = nil}
109
182
  local foo = {bar = newValue}
110
183
  local newTable = {foo = foo}
111
- local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE)
184
+ local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE, "oldTableHasVectorSerialized")
112
185
  merge(nil, oldTable, newTableSerialized, "oldTableHasVectorSerialized")
113
186
  local oldTableValue = oldTable[key]
114
187
  if oldTableValue == nil then
@@ -153,7 +226,7 @@ function oldTableHasRNGSerialized(self)
153
226
  local oldTable = {foo = nil}
154
227
  local foo = {bar = newValue}
155
228
  local newTable = {foo = foo}
156
- local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE)
229
+ local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE, "oldTableHasRNGSerialized")
157
230
  merge(nil, oldTable, newTableSerialized, "oldTableHasRNGSerialized")
158
231
  local oldTableValue = oldTable[key]
159
232
  if oldTableValue == nil then
@@ -167,12 +240,18 @@ function oldTableHasRNGSerialized(self)
167
240
  error("The old table's seed not match: " .. tostring(seed))
168
241
  end
169
242
  end
170
- function ____exports.mergeTests(self)
243
+ --- Run the suite of tests that prove that the "merge" helper function works properly. (This function
244
+ -- is not exported but is used internally in the save data manager.)
245
+ --
246
+ -- This function is only useful if you are troubleshooting the save data manager.
247
+ function ____exports.runMergeTests(self)
171
248
  oldTableHasUpdatedValue(nil)
172
249
  newTableHasSameValue(nil)
173
250
  oldTableHasUpdatedValueFromNull(nil)
174
251
  oldTableHasSerializedIsaacAPIClass(nil)
175
- oldTableHasFilledInterface(nil)
252
+ oldTableHasFilledChildTable(nil)
253
+ oldTableHasFilledMap(nil)
254
+ oldTableHasFilledDefaultMap(nil)
176
255
  oldTableHasVector(nil)
177
256
  oldTableHasVectorSerialized(nil)
178
257
  oldTableHasRNG(nil)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "6.6.3",
3
+ "version": "6.6.4",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -8,7 +8,7 @@ import {
8
8
  isSerializedIsaacAPIClass,
9
9
  } from "../../functions/serialization";
10
10
  import { clearTable, iterateTableInOrder } from "../../functions/table";
11
- import { isTSTLMap, isTSTLSet } from "../../functions/tstlClass";
11
+ import { isDefaultMap, isTSTLMap, isTSTLSet } from "../../functions/tstlClass";
12
12
  import { isTable } from "../../functions/types";
13
13
  import { getTraversalDescription } from "../../functions/utils";
14
14
  import { SAVE_DATA_MANAGER_DEBUG } from "./saveDataManagerConstants";
@@ -65,7 +65,7 @@ export function merge(
65
65
 
66
66
  // Depending on whether we are working on a Lua table or a TypeScriptToLua object, we need to
67
67
  // iterate in a specific way.
68
- if (isTSTLMap(oldObject) || isTSTLSet(oldObject)) {
68
+ if (isTSTLMap(oldObject) || isTSTLSet(oldObject) || isDefaultMap(oldObject)) {
69
69
  mergeTSTLObject(oldObject, newTable, traversalDescription);
70
70
  } else {
71
71
  mergeTable(oldObject, newTable, traversalDescription);
@@ -118,7 +118,7 @@ function mergeTSTLObject(
118
118
  keyToUse = numberKey;
119
119
  }
120
120
 
121
- if (isTSTLMap(oldObject)) {
121
+ if (isTSTLMap(oldObject) || isDefaultMap(oldObject)) {
122
122
  let valueCopy: unknown;
123
123
  if (isTable(value)) {
124
124
  valueCopy = deepCopy(
@@ -443,7 +443,10 @@ export function isArray(object: unknown): object is unknown[] {
443
443
  return false;
444
444
  }
445
445
 
446
- const tableLength = object.length();
446
+ // Third, handle the case of an "empty" table. We cannot use the "LuaTable.length" method to
447
+ // determine this, since that will not actually return the number of keys. (It will only work
448
+ // properly for tables that are being used as arrays, which is not necessarily the case here.)
449
+ const tableLength = Object.keys(object).length;
447
450
  if (tableLength === 0) {
448
451
  return true;
449
452
  }
@@ -7,7 +7,12 @@ import { log } from "./log";
7
7
  import { isDefaultMap, isTSTLMap, isTSTLSet } from "./tstlClass";
8
8
  import { isNumber, isString, isTable } from "./types";
9
9
 
10
- export function deepCopyTests(): void {
10
+ /**
11
+ * Run the suite of tests that prove that the "deepCopy" helper function works properly.
12
+ *
13
+ * This function is only useful if you are troubleshooting the "deepCopy" function.
14
+ */
15
+ export function runDeepCopyTests(): void {
11
16
  copiedObjectIsTable();
12
17
  copiedObjectHasKeyAndValueString();
13
18
  copiedTableHasKeyAndValueNumber();
@@ -34,7 +39,11 @@ function copiedObjectIsTable() {
34
39
  const oldObject = {
35
40
  abc: "def",
36
41
  };
37
- const newObject = deepCopy(oldObject as unknown as LuaTable);
42
+ const newObject = deepCopy(
43
+ oldObject as unknown as LuaTable,
44
+ SerializationType.NONE,
45
+ "copiedObjectIsTable",
46
+ );
38
47
  if (!isTable(newObject)) {
39
48
  error(`The copied object had a type of: ${typeof newObject}`);
40
49
  }
@@ -46,7 +55,11 @@ function copiedObjectHasKeyAndValueString() {
46
55
  const oldObject = {
47
56
  abc: valueToLookFor,
48
57
  };
49
- const newTable = deepCopy(oldObject as unknown as LuaTable);
58
+ const newTable = deepCopy(
59
+ oldObject as unknown as LuaTable,
60
+ SerializationType.NONE,
61
+ "copiedObjectHasKeyAndValueString",
62
+ );
50
63
  const newObject = newTable as typeof oldObject;
51
64
 
52
65
  const value = newObject[keyToLookFor];
@@ -69,7 +82,11 @@ function copiedTableHasKeyAndValueNumber() {
69
82
  const oldTable = new LuaTable<AnyNotNil, unknown>();
70
83
  oldTable.set(keyToLookFor, valueToLookFor);
71
84
 
72
- const newObject = deepCopy(oldTable);
85
+ const newObject = deepCopy(
86
+ oldTable,
87
+ SerializationType.NONE,
88
+ "copiedTableHasKeyAndValueNumber",
89
+ );
73
90
  const newTable = newObject as LuaTable<AnyNotNil, unknown>;
74
91
 
75
92
  const value = newTable.get(keyToLookFor) as number | undefined;
@@ -91,7 +108,11 @@ function copiedTableDoesNotCoerceTypes() {
91
108
  const oldTable = new LuaTable<AnyNotNil, unknown>();
92
109
  oldTable.set(keyToLookFor, valueToLookFor);
93
110
 
94
- const newObject = deepCopy(oldTable);
111
+ const newObject = deepCopy(
112
+ oldTable,
113
+ SerializationType.NONE,
114
+ "copiedTableDoesNotCoerceTypes",
115
+ );
95
116
  const newTable = newObject as LuaTable<AnyNotNil, unknown>;
96
117
 
97
118
  const keyString = tostring(keyToLookFor);
@@ -117,7 +138,11 @@ function copiedObjectHasNoReferencesForPrimitivesForward() {
117
138
  abc: originalStringValue,
118
139
  def: originalNumberValue,
119
140
  };
120
- const newTable = deepCopy(oldObject as unknown as LuaTable);
141
+ const newTable = deepCopy(
142
+ oldObject as unknown as LuaTable,
143
+ SerializationType.NONE,
144
+ "copiedObjectHasNoReferencesForPrimitivesForward",
145
+ );
121
146
  const newObject = newTable as typeof oldObject;
122
147
 
123
148
  oldObject.abc = "newValue";
@@ -138,7 +163,11 @@ function copiedObjectHasNoReferencesForPrimitivesBackward() {
138
163
  abc: originalStringValue,
139
164
  def: originalNumberValue,
140
165
  };
141
- const newTable = deepCopy(oldObject as unknown as LuaTable);
166
+ const newTable = deepCopy(
167
+ oldObject as unknown as LuaTable,
168
+ SerializationType.NONE,
169
+ "copiedObjectHasNoReferencesForPrimitivesBackward",
170
+ );
142
171
  const newObject = newTable as typeof oldObject;
143
172
 
144
173
  newObject.abc = "newValue";
@@ -156,7 +185,11 @@ function copiedObjectHasNoReferencesForArray() {
156
185
  const oldObject = {
157
186
  abc: [1, 2, 3],
158
187
  };
159
- const newTable = deepCopy(oldObject as unknown as LuaTable);
188
+ const newTable = deepCopy(
189
+ oldObject as unknown as LuaTable,
190
+ SerializationType.NONE,
191
+ "copiedObjectHasNoReferencesForArray",
192
+ );
160
193
  const newObject = newTable as typeof oldObject;
161
194
 
162
195
  if (oldObject.abc === newObject.abc) {
@@ -193,7 +226,11 @@ function copiedObjectHasChildObject() {
193
226
  def: valueToLookFor,
194
227
  },
195
228
  };
196
- const newTable = deepCopy(oldObject as unknown as LuaTable);
229
+ const newTable = deepCopy(
230
+ oldObject as unknown as LuaTable,
231
+ SerializationType.NONE,
232
+ "copiedObjectHasChildObject",
233
+ );
197
234
  const newObject = newTable as typeof oldObject;
198
235
 
199
236
  const childObject = newObject[childObjectIndex];
@@ -226,7 +263,7 @@ function copiedMapIsMap() {
226
263
  const oldMap = new Map<string, string>();
227
264
  oldMap.set(keyToLookFor, valueToLookFor);
228
265
 
229
- const newObject = deepCopy(oldMap);
266
+ const newObject = deepCopy(oldMap, SerializationType.NONE, "copiedMapIsMap");
230
267
  const newMap = newObject as Map<string, string>;
231
268
 
232
269
  if (!isTable(newMap)) {
@@ -243,7 +280,11 @@ function copiedMapHasValue() {
243
280
  const oldMap = new Map<string, string>();
244
281
  oldMap.set(keyToLookFor, valueToLookFor);
245
282
 
246
- const newTable = deepCopy(oldMap);
283
+ const newTable = deepCopy(
284
+ oldMap,
285
+ SerializationType.NONE,
286
+ "copiedMapHasValue",
287
+ );
247
288
  const newMap = newTable as typeof oldMap;
248
289
 
249
290
  const value = newMap.get(keyToLookFor);
@@ -260,7 +301,7 @@ function copiedSetIsSet() {
260
301
  const oldSet = new Set<string>();
261
302
  oldSet.add(valueToLookFor);
262
303
 
263
- const newTable = deepCopy(oldSet);
304
+ const newTable = deepCopy(oldSet, SerializationType.NONE, "copiedSetIsSet");
264
305
  const newSet = newTable as Set<string>;
265
306
 
266
307
  if (!isTable(newSet)) {
@@ -276,7 +317,11 @@ function copiedSetHasValue() {
276
317
  const oldSet = new Set<string>();
277
318
  oldSet.add(valueToLookFor);
278
319
 
279
- const newTable = deepCopy(oldSet);
320
+ const newTable = deepCopy(
321
+ oldSet,
322
+ SerializationType.NONE,
323
+ "copiedSetHasValue",
324
+ );
280
325
  const newSet = newTable as Set<string>;
281
326
 
282
327
  const hasValue = newSet.has(valueToLookFor);
@@ -295,7 +340,11 @@ function copiedMapHasChildMap() {
295
340
  const oldMap = new Map<string, Map<number, number>>();
296
341
  oldMap.set(keyToLookFor, oldChildMap);
297
342
 
298
- const newTable = deepCopy(oldMap);
343
+ const newTable = deepCopy(
344
+ oldMap,
345
+ SerializationType.NONE,
346
+ "copiedMapHasChildMap",
347
+ );
299
348
  const newMap = newTable as typeof oldMap;
300
349
 
301
350
  const newChildMap = newMap.get(keyToLookFor);
@@ -332,7 +381,11 @@ function copiedDefaultMapHasChildDefaultMap() {
332
381
  oldChildMap.getAndSetDefault(childMapKey1);
333
382
  oldChildMap.set(childMapKey2, childMapCustomValue);
334
383
 
335
- const newTable = deepCopy(oldParentMap);
384
+ const newTable = deepCopy(
385
+ oldParentMap,
386
+ SerializationType.NONE,
387
+ "copiedDefaultMapHasChildDefaultMap",
388
+ );
336
389
  const newParentMap = newTable as typeof oldParentMap;
337
390
 
338
391
  const newChildMap = newParentMap.get(parentMapKey);
@@ -376,6 +429,7 @@ function copiedDefaultMapHasBrand() {
376
429
  const newTable = deepCopy(
377
430
  oldDefaultMap,
378
431
  SerializationType.SERIALIZE,
432
+ "copiedDefaultMapHasBrand",
379
433
  ) as LuaTable<AnyNotNil, unknown>;
380
434
 
381
435
  if (!newTable.has(SerializationBrand.DEFAULT_MAP)) {
@@ -587,9 +587,14 @@ export function logTable(
587
587
  const indentation = " ".repeat(numSpaces);
588
588
 
589
589
  if (!isTable(luaTable)) {
590
- log(
591
- `${indentation}n/a (encountered a variable of type "${typeof luaTable}" instead of a table)`,
592
- );
590
+ // Put it in an IIFE so that the it will show as "func" instead of "logTable" and align with the
591
+ // other text.
592
+ (() => {
593
+ log(
594
+ `${indentation}n/a (encountered a variable of type "${typeof luaTable}" instead of a table)`,
595
+ );
596
+ })();
597
+
593
598
  return;
594
599
  }
595
600
 
@@ -608,7 +613,11 @@ export function logTable(
608
613
  }
609
614
  });
610
615
 
611
- log(`${indentation}The size of the table was: ${luaTable.length()}`);
616
+ // Put it in an IIFE so that the it will show as "func" instead of "logTable" and align with the
617
+ // other text.
618
+ (() => {
619
+ log(`${indentation}The size of the table was: ${luaTable.length()}`);
620
+ })();
612
621
  }
613
622
 
614
623
  /**
@@ -1,3 +1,4 @@
1
+ import { DefaultMap } from "../classes/DefaultMap";
1
2
  import { SerializationType } from "../enums/SerializationType";
2
3
  import { merge } from "../features/saveDataManager/merge";
3
4
  import { deepCopy } from "./deepCopy";
@@ -6,13 +7,22 @@ import { isRNG, newRNG } from "./rng";
6
7
  import { isSerializedIsaacAPIClass } from "./serialization";
7
8
  import { copyVector, isVector } from "./vector";
8
9
 
9
- export function mergeTests(): void {
10
+ /**
11
+ * Run the suite of tests that prove that the "merge" helper function works properly. (This function
12
+ * is not exported but is used internally in the save data manager.)
13
+ *
14
+ * This function is only useful if you are troubleshooting the save data manager.
15
+ */
16
+ export function runMergeTests(): void {
10
17
  oldTableHasUpdatedValue();
11
18
  newTableHasSameValue();
12
19
  oldTableHasUpdatedValueFromNull();
13
20
  oldTableHasSerializedIsaacAPIClass();
14
21
 
15
- oldTableHasFilledInterface();
22
+ oldTableHasFilledChildTable();
23
+ oldTableHasFilledMap();
24
+ oldTableHasFilledDefaultMap();
25
+
16
26
  oldTableHasVector();
17
27
  oldTableHasVectorSerialized();
18
28
  oldTableHasRNG();
@@ -90,7 +100,7 @@ function oldTableHasSerializedIsaacAPIClass() {
90
100
  }
91
101
  }
92
102
 
93
- function oldTableHasFilledInterface() {
103
+ function oldTableHasFilledChildTable() {
94
104
  interface Foo {
95
105
  bar: string;
96
106
  }
@@ -107,7 +117,7 @@ function oldTableHasFilledInterface() {
107
117
  foo,
108
118
  } as unknown as LuaTable<AnyNotNil, unknown>;
109
119
 
110
- merge(oldTable, newTable, "oldTableHasFilledInterface");
120
+ merge(oldTable, newTable, "oldTableHasFilledChildTable");
111
121
 
112
122
  const oldTableValue = oldTable.get(key) as Foo | undefined;
113
123
  if (oldTableValue === undefined) {
@@ -119,6 +129,142 @@ function oldTableHasFilledInterface() {
119
129
  }
120
130
  }
121
131
 
132
+ function oldTableHasFilledMap() {
133
+ const v = {
134
+ run: {
135
+ myMap: new Map<string, string>(),
136
+ },
137
+ };
138
+
139
+ const saveData = {
140
+ run: {
141
+ myMap: new Map<string, string>([
142
+ ["foo1", "bar1"],
143
+ ["foo2", "bar2"],
144
+ ["foo3", "bar3"],
145
+ ]),
146
+ },
147
+ };
148
+ const serializedSaveData = deepCopy(saveData, SerializationType.SERIALIZE);
149
+
150
+ merge(
151
+ v as unknown as LuaTable,
152
+ serializedSaveData as LuaTable,
153
+ "oldTableHasFilledMap",
154
+ );
155
+
156
+ const expectedSize = 3;
157
+ if (v.run.myMap.size !== expectedSize) {
158
+ error(
159
+ `The size of the merged map was equal to ${v.run.myMap.size}, but it should be equal to: ${expectedSize}`,
160
+ );
161
+ }
162
+
163
+ {
164
+ const key = "foo1";
165
+ const expectedValue = "bar1";
166
+
167
+ const value = v.run.myMap.get(key);
168
+ if (value !== expectedValue) {
169
+ error(
170
+ `The old table's map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
171
+ );
172
+ }
173
+ }
174
+
175
+ {
176
+ const key = "foo2";
177
+ const expectedValue = "bar2";
178
+
179
+ const value = v.run.myMap.get(key);
180
+ if (value !== expectedValue) {
181
+ error(
182
+ `The old table's map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
183
+ );
184
+ }
185
+ }
186
+
187
+ {
188
+ const key = "foo3";
189
+ const expectedValue = "bar3";
190
+
191
+ const value = v.run.myMap.get(key);
192
+ if (value !== expectedValue) {
193
+ error(
194
+ `The old table's map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
195
+ );
196
+ }
197
+ }
198
+ }
199
+
200
+ function oldTableHasFilledDefaultMap() {
201
+ const v = {
202
+ run: {
203
+ myDefaultMap: new DefaultMap<string, string>("default"),
204
+ },
205
+ };
206
+
207
+ const saveData = {
208
+ run: {
209
+ myDefaultMap: new DefaultMap<string, string>("default", [
210
+ ["foo1", "bar1"],
211
+ ["foo2", "bar2"],
212
+ ["foo3", "bar3"],
213
+ ]),
214
+ },
215
+ };
216
+ const serializedSaveData = deepCopy(saveData, SerializationType.SERIALIZE);
217
+
218
+ merge(
219
+ v as unknown as LuaTable,
220
+ serializedSaveData as LuaTable,
221
+ "oldTableHasFilledDefaultMap",
222
+ );
223
+
224
+ const expectedSize = 3;
225
+ if (v.run.myDefaultMap.size !== expectedSize) {
226
+ error(
227
+ `The size of the merged default map was equal to ${v.run.myDefaultMap.size}, but it should be equal to: ${expectedSize}`,
228
+ );
229
+ }
230
+
231
+ {
232
+ const key = "foo1";
233
+ const expectedValue = "bar1";
234
+
235
+ const value = v.run.myDefaultMap.get(key);
236
+ if (value !== expectedValue) {
237
+ error(
238
+ `The old table's default map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
239
+ );
240
+ }
241
+ }
242
+
243
+ {
244
+ const key = "foo2";
245
+ const expectedValue = "bar2";
246
+
247
+ const value = v.run.myDefaultMap.get(key);
248
+ if (value !== expectedValue) {
249
+ error(
250
+ `The old table's default map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
251
+ );
252
+ }
253
+ }
254
+
255
+ {
256
+ const key = "foo3";
257
+ const expectedValue = "bar3";
258
+
259
+ const value = v.run.myDefaultMap.get(key);
260
+ if (value !== expectedValue) {
261
+ error(
262
+ `The old table's default map key of "${key}" was not equal to "${expectedValue}" and was instead equal to: ${value}`,
263
+ );
264
+ }
265
+ }
266
+ }
267
+
122
268
  function oldTableHasVector() {
123
269
  log("Starting test: oldTableHasVector");
124
270
 
@@ -183,6 +329,7 @@ function oldTableHasVectorSerialized() {
183
329
  const newTableSerialized = deepCopy(
184
330
  newTable,
185
331
  SerializationType.SERIALIZE,
332
+ "oldTableHasVectorSerialized",
186
333
  ) as LuaTable<AnyNotNil, unknown>;
187
334
 
188
335
  merge(oldTable, newTableSerialized, "oldTableHasVectorSerialized");
@@ -266,6 +413,7 @@ function oldTableHasRNGSerialized() {
266
413
  const newTableSerialized = deepCopy(
267
414
  newTable,
268
415
  SerializationType.SERIALIZE,
416
+ "oldTableHasRNGSerialized",
269
417
  ) as LuaTable<AnyNotNil, unknown>;
270
418
 
271
419
  merge(oldTable, newTableSerialized, "oldTableHasRNGSerialized");