isaacscript-common 6.10.0 → 6.11.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.
@@ -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,9 +450,16 @@ 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
455
+ local convertStringKeysToNumbers = serializationType == SerializationType.DESERIALIZE and __TS__ArraySome(
456
+ entries,
457
+ function(____, ____bindingPattern0)
458
+ local key
459
+ key = ____bindingPattern0[1]
460
+ return key == SerializationBrand.OBJECT_WITH_NUMBER_KEYS
461
+ end
462
+ )
439
463
  local hasNumberKeys = __TS__ArraySome(
440
464
  entries,
441
465
  function(____, ____bindingPattern0)
@@ -451,7 +475,7 @@ function getCopiedEntries(self, object, serializationType, traversalDescription,
451
475
  local value = ____value[2]
452
476
  do
453
477
  if isSerializationBrand(nil, key) then
454
- goto __continue80
478
+ goto __continue87
455
479
  end
456
480
  traversalDescription = getTraversalDescription(nil, key, traversalDescription)
457
481
  local newValue = ____exports.deepCopy(
@@ -461,10 +485,19 @@ function getCopiedEntries(self, object, serializationType, traversalDescription,
461
485
  traversalDescription,
462
486
  insideMap
463
487
  )
464
- local keyToUse = convertNumberKeysToStrings and tostring(key) or key
488
+ local keyToUse = key
489
+ if convertStringKeysToNumbers then
490
+ local numberKey = tonumber(key)
491
+ if numberKey ~= nil then
492
+ keyToUse = numberKey
493
+ end
494
+ end
495
+ if convertNumberKeysToStrings then
496
+ keyToUse = tostring(key)
497
+ end
465
498
  copiedEntries[#copiedEntries + 1] = {keyToUse, newValue}
466
499
  end
467
- ::__continue80::
500
+ ::__continue87::
468
501
  end
469
502
  return {entries = copiedEntries, convertedNumberKeysToStrings = convertNumberKeysToStrings}
470
503
  end
@@ -477,6 +510,9 @@ function checkMetatable(self, luaMap, traversalDescription)
477
510
  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
511
  end
479
512
  function deepCopyUserdata(self, value, serializationType, traversalDescription)
513
+ if SAVE_DATA_MANAGER_DEBUG then
514
+ log("deepCopy is copying userdata.")
515
+ end
480
516
  local classType = getIsaacAPIClassName(nil, value)
481
517
  if classType == nil then
482
518
  error("The deep copy function was not able to derive the Isaac API class type for: " .. traversalDescription)
@@ -1 +1 @@
1
- {"version":3,"file":"deepCopyTests.d.ts","sourceRoot":"","sources":["../../src/functions/deepCopyTests.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAqBvC"}
1
+ {"version":3,"file":"deepCopyTests.d.ts","sourceRoot":"","sources":["../../src/functions/deepCopyTests.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CA2BvC"}
@@ -4,7 +4,7 @@ local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local Set = ____lualib.Set
6
6
  local ____exports = {}
7
- local copiedObjectIsTable, copiedObjectHasKeyAndValueString, copiedTableHasKeyAndValueNumber, copiedTableDoesNotCoerceTypes, copiedObjectHasNoReferencesForPrimitivesForward, copiedObjectHasNoReferencesForPrimitivesBackward, copiedObjectHasNoReferencesForArray, copiedObjectHasChildObject, copiedMapIsMap, copiedMapHasValue, copiedSetIsSet, copiedSetHasValue, copiedMapHasChildMap, copiedDefaultMapHasChildDefaultMap, copiedDefaultMapHasBrand
7
+ local copiedObjectIsTable, copiedObjectHasKeyAndValueString, copiedTableHasKeyAndValueNumber, copiedTableDoesNotCoerceTypes, copiedObjectHasNoReferencesForPrimitivesForward, copiedObjectHasNoReferencesForPrimitivesBackward, copiedObjectHasNoReferencesForArray, copiedObjectHasChildObject, copiedMapIsMap, copiedMapHasValue, copiedSetIsSet, copiedSetHasValue, copiedMapHasChildMap, copiedDefaultMapHasChildDefaultMap, copiedDefaultMapHasBrand, copiedSerializedMapHasStringKey, copiedSerializedMapHasNumberKey, copiedSerializedDefaultMapHasStringKey, copiedSerializedDefaultMapHasNumberKey
8
8
  local ____DefaultMap = require("classes.DefaultMap")
9
9
  local DefaultMap = ____DefaultMap.DefaultMap
10
10
  local ____SerializationBrand = require("enums.private.SerializationBrand")
@@ -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,10 +290,63 @@ 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
296
299
  end
300
+ function copiedSerializedMapHasStringKey(self)
301
+ local mapKey = "123"
302
+ local mapValue = 456
303
+ local oldMap = __TS__New(Map)
304
+ oldMap:set(mapKey, mapValue)
305
+ local serializedOldMap = deepCopy(nil, oldMap, SerializationType.SERIALIZE, "copiedSerializedMapHasStringKey-serialize")
306
+ local newTable = deepCopy(nil, serializedOldMap, SerializationType.DESERIALIZE, "copiedSerializedMapHasStringKey-deserialize")
307
+ local newMap = newTable
308
+ if not newMap:has(mapKey) then
309
+ local keyType = type(mapKey)
310
+ error((("The copied Map did not have a key of: " .. mapKey) .. " with type ") .. keyType)
311
+ end
312
+ end
313
+ function copiedSerializedMapHasNumberKey(self)
314
+ local mapKey = 123
315
+ local mapValue = 456
316
+ local oldMap = __TS__New(Map)
317
+ oldMap:set(mapKey, mapValue)
318
+ local serializedOldMap = deepCopy(nil, oldMap, SerializationType.SERIALIZE, "copiedSerializedMapHasNumberKey-serialize")
319
+ local newTable = deepCopy(nil, serializedOldMap, SerializationType.DESERIALIZE, "copiedSerializedMapHasNumberKey-deserialize")
320
+ local newMap = newTable
321
+ if not newMap:has(mapKey) then
322
+ local keyType = type(mapKey)
323
+ error((("The copied Map did not have a key of: " .. tostring(mapKey)) .. " with type ") .. keyType)
324
+ end
325
+ end
326
+ function copiedSerializedDefaultMapHasStringKey(self)
327
+ local mapKey = "123"
328
+ local oldDefaultMap = __TS__New(DefaultMap, 456)
329
+ oldDefaultMap:getAndSetDefault(mapKey)
330
+ local serializedOldDefaultMap = deepCopy(nil, oldDefaultMap, SerializationType.SERIALIZE, "copiedSerializedDefaultMapHasStringKey-serialize")
331
+ local newTable = deepCopy(nil, serializedOldDefaultMap, SerializationType.DESERIALIZE, "copiedSerializedDefaultMapHasStringKey-deserialize")
332
+ local newDefaultMap = newTable
333
+ if not newDefaultMap:has(mapKey) then
334
+ local keyType = type(mapKey)
335
+ error((("The copied DefaultMap did not have a key of \"" .. mapKey) .. "\" with type: ") .. keyType)
336
+ end
337
+ end
338
+ function copiedSerializedDefaultMapHasNumberKey(self)
339
+ local mapKey = 123
340
+ local oldDefaultMap = __TS__New(DefaultMap, 456)
341
+ oldDefaultMap:getAndSetDefault(mapKey)
342
+ local serializedOldDefaultMap = deepCopy(nil, oldDefaultMap, SerializationType.SERIALIZE, "copiedSerializedDefaultMapHasNumberKey-serialize")
343
+ local newTable = deepCopy(nil, serializedOldDefaultMap, SerializationType.DESERIALIZE, "copiedSerializedDefaultMapHasNumberKey-deserialize")
344
+ local newDefaultMap = newTable
345
+ if not newDefaultMap:has(mapKey) then
346
+ local keyType = type(mapKey)
347
+ error((("The copied DefaultMap did not have a key of: " .. tostring(mapKey)) .. " with type ") .. keyType)
348
+ end
349
+ end
297
350
  --- Run the suite of tests that prove that the "deepCopy" helper function works properly.
298
351
  --
299
352
  -- This function is only useful if you are troubleshooting the "deepCopy" function.
@@ -313,6 +366,10 @@ function ____exports.runDeepCopyTests(self)
313
366
  copiedMapHasChildMap(nil)
314
367
  copiedDefaultMapHasChildDefaultMap(nil)
315
368
  copiedDefaultMapHasBrand(nil)
369
+ copiedSerializedMapHasStringKey(nil)
370
+ copiedSerializedMapHasNumberKey(nil)
371
+ copiedSerializedDefaultMapHasStringKey(nil)
372
+ copiedSerializedDefaultMapHasNumberKey(nil)
316
373
  log("All deep copy tests passed!")
317
374
  end
318
375
  return ____exports
@@ -6,6 +6,9 @@
6
6
  * fails, it will return a blank Lua table instead of throwing an error. (This allows execution to
7
7
  * continue in cases where users have no current save data or have manually removed their existing
8
8
  * save data.)
9
+ *
10
+ * Under the hood, this uses a custom JSON parser that was measured to be 11.8 times faster than the
11
+ * vanilla JSON parser.
9
12
  */
10
13
  export declare function jsonDecode(jsonString: string): LuaMap<AnyNotNil, unknown>;
11
14
  /**
@@ -14,6 +17,9 @@ export declare function jsonDecode(jsonString: string): LuaMap<AnyNotNil, unknow
14
17
  * In most cases, this function will be used for writing data to a "save#.dat" file. If encoding
15
18
  * fails, it will throw an error to prevent writing a blank string or corrupted data to a user's
16
19
  * "save#.dat" file.
20
+ *
21
+ * Under the hood, this uses a custom JSON parser that was measured to be 11.8 times faster than the
22
+ * vanilla JSON parser.
17
23
  */
18
24
  export declare function jsonEncode(luaTable: unknown): string;
19
25
  //# sourceMappingURL=jsonHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonHelpers.d.ts","sourceRoot":"","sources":["../../src/functions/jsonHelpers.ts"],"names":[],"mappings":";AAWA;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CASzE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAOpD"}
1
+ {"version":3,"file":"jsonHelpers.d.ts","sourceRoot":"","sources":["../../src/functions/jsonHelpers.ts"],"names":[],"mappings":";AAWA;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CASzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAOpD"}
@@ -1,12 +1,12 @@
1
1
  local ____exports = {}
2
- local json = require("@NoResolution:json")
2
+ local jsonLua = require("lib.jsonLua")
3
3
  local ____log = require("functions.log")
4
4
  local logError = ____log.logError
5
5
  local function tryDecode(jsonString)
6
- return json.decode(jsonString)
6
+ return jsonLua.decode(jsonString)
7
7
  end
8
8
  local function tryEncode(luaTable)
9
- return json.encode(luaTable)
9
+ return jsonLua.encode(luaTable)
10
10
  end
11
11
  --- Converts a JSON string to a Lua table.
12
12
  --
@@ -14,6 +14,9 @@ end
14
14
  -- fails, it will return a blank Lua table instead of throwing an error. (This allows execution to
15
15
  -- continue in cases where users have no current save data or have manually removed their existing
16
16
  -- save data.)
17
+ --
18
+ -- Under the hood, this uses a custom JSON parser that was measured to be 11.8 times faster than the
19
+ -- vanilla JSON parser.
17
20
  function ____exports.jsonDecode(self, jsonString)
18
21
  local ok, luaTableOrErrMsg = pcall(tryDecode, jsonString)
19
22
  if not ok then
@@ -27,6 +30,9 @@ end
27
30
  -- In most cases, this function will be used for writing data to a "save#.dat" file. If encoding
28
31
  -- fails, it will throw an error to prevent writing a blank string or corrupted data to a user's
29
32
  -- "save#.dat" file.
33
+ --
34
+ -- Under the hood, this uses a custom JSON parser that was measured to be 11.8 times faster than the
35
+ -- vanilla JSON parser.
30
36
  function ____exports.jsonEncode(self, luaTable)
31
37
  local ok, jsonStringOrErrMsg = pcall(tryEncode, luaTable)
32
38
  if not ok then
@@ -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,Q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B,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
@@ -149,7 +149,6 @@ function oldTableHasFilledDefaultMap(self)
149
149
  end
150
150
  end
151
151
  function oldTableHasVector(self)
152
- log("Starting test: oldTableHasVector")
153
152
  local key = "foo"
154
153
  local x = 50
155
154
  local y = 60
@@ -173,7 +172,6 @@ function oldTableHasVector(self)
173
172
  end
174
173
  end
175
174
  function oldTableHasVectorSerialized(self)
176
- log("Starting test: oldTableHasVectorSerialized")
177
175
  local key = "foo"
178
176
  local x = 50
179
177
  local y = 60
@@ -198,7 +196,6 @@ function oldTableHasVectorSerialized(self)
198
196
  end
199
197
  end
200
198
  function oldTableHasRNG(self)
201
- log("Starting test: oldTableHasRNG")
202
199
  local key = "foo"
203
200
  local seed = 50
204
201
  local newValue = newRNG(nil, seed)
@@ -219,7 +216,6 @@ function oldTableHasRNG(self)
219
216
  end
220
217
  end
221
218
  function oldTableHasRNGSerialized(self)
222
- log("Starting test: oldTableHasRNGSerialized")
223
219
  local key = "foo"
224
220
  local seed = 50
225
221
  local newValue = newRNG(nil, seed)