isaacscript-common 1.2.172 → 1.2.173

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.
@@ -106,13 +106,12 @@ function mergeTable(self, oldTable, newTable, traversalDescription)
106
106
  if valueType == "table" then
107
107
  local oldValue = oldTable[key]
108
108
  local oldValueType = type(oldValue)
109
- if oldValueType == "nil" then
110
- local valueDeepCopy = deepCopy(nil, value)
111
- oldTable[key] = valueDeepCopy
112
- elseif oldValueType == "table" then
113
- traversalDescription = addTraversalDescription(nil, key, traversalDescription)
114
- ____exports.merge(nil, oldValue, value, traversalDescription)
109
+ if oldValueType ~= "table" then
110
+ oldValue = {}
111
+ oldTable[key] = oldValue
115
112
  end
113
+ traversalDescription = addTraversalDescription(nil, key, traversalDescription)
114
+ ____exports.merge(nil, oldValue, value, traversalDescription)
116
115
  else
117
116
  if SAVE_DATA_MANAGER_DEBUG then
118
117
  log((("Merging key \"" .. tostring(key)) .. "\" with value: ") .. tostring(value))
@@ -1,10 +1,16 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- local oldTableHasUpdatedValue, newTableHasSameValue, oldTableHasUpdatedValueFromNull, oldTableHasFilledInterface
3
+ local oldTableHasUpdatedValue, newTableHasSameValue, oldTableHasUpdatedValueFromNull, oldTableHasFilledInterface, oldTableHasVector, oldTableHasVectorSerialized
4
+ local ____SerializationType = require("enums.SerializationType")
5
+ local SerializationType = ____SerializationType.SerializationType
4
6
  local ____merge = require("features.saveDataManager.merge")
5
7
  local merge = ____merge.merge
8
+ local ____deepCopy = require("functions.deepCopy")
9
+ local deepCopy = ____deepCopy.deepCopy
6
10
  local ____log = require("functions.log")
7
11
  local log = ____log.log
12
+ local ____vector = require("functions.vector")
13
+ local isVector = ____vector.isVector
8
14
  function oldTableHasUpdatedValue(self)
9
15
  local key = "foo"
10
16
  local oldValue = "bar"
@@ -55,11 +61,60 @@ function oldTableHasFilledInterface(self)
55
61
  error("The old table's key of \"bar\" was not filled.")
56
62
  end
57
63
  end
64
+ function oldTableHasVector(self)
65
+ local key = "foo"
66
+ local x = 50
67
+ local y = 60
68
+ local newValue = Vector(x, y)
69
+ local oldTable = {foo = nil}
70
+ local foo = {bar = newValue}
71
+ local newTable = {foo = foo}
72
+ merge(nil, oldTable, newTable, "oldTableHasVector")
73
+ local oldTableValue = oldTable[key]
74
+ if oldTableValue == nil then
75
+ error(("The old table's key of \"" .. key) .. "\" was not filled.")
76
+ end
77
+ if oldTableValue.bar.X ~= x then
78
+ error("The old table's value for \"x\" does not match: " .. tostring(x))
79
+ end
80
+ if oldTableValue.bar.Y ~= y then
81
+ error("The old table's value for \"y\" does not match: " .. tostring(y))
82
+ end
83
+ if not isVector(nil, oldTableValue.bar) then
84
+ error("The old table's value is not a Vector object.")
85
+ end
86
+ end
87
+ function oldTableHasVectorSerialized(self)
88
+ local key = "foo"
89
+ local x = 50
90
+ local y = 60
91
+ local newValue = Vector(x, y)
92
+ local oldTable = {foo = nil}
93
+ local foo = {bar = newValue}
94
+ local newTable = {foo = foo}
95
+ local newTableSerialized = deepCopy(nil, newTable, SerializationType.SERIALIZE)
96
+ merge(nil, oldTable, newTableSerialized, "oldTableHasVectorSerialized")
97
+ local oldTableValue = oldTable[key]
98
+ if oldTableValue == nil then
99
+ error(("The old table's key of \"" .. key) .. "\" was not filled.")
100
+ end
101
+ if oldTableValue.bar.X ~= x then
102
+ error("The old table's value for \"x\" does not match: " .. tostring(x))
103
+ end
104
+ if oldTableValue.bar.Y ~= y then
105
+ error("The old table's value for \"y\" does not match: " .. tostring(y))
106
+ end
107
+ if not isVector(nil, oldTableValue.bar) then
108
+ error("The old table's value is not a Vector object.")
109
+ end
110
+ end
58
111
  function ____exports.mergeTests(self)
59
112
  oldTableHasUpdatedValue(nil)
60
113
  newTableHasSameValue(nil)
61
114
  oldTableHasUpdatedValueFromNull(nil)
62
115
  oldTableHasFilledInterface(nil)
116
+ oldTableHasVector(nil)
117
+ oldTableHasVectorSerialized(nil)
63
118
  log("All merge tests passed!")
64
119
  end
65
120
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.172",
3
+ "version": "1.2.173",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",