isaacscript-common 1.0.519 → 1.0.520

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.
@@ -82,6 +82,9 @@ function ____exports.arraySum(self, array)
82
82
  return sum
83
83
  end
84
84
  function ____exports.arrayToString(self, array)
85
+ if #array == 0 then
86
+ return "[]"
87
+ end
85
88
  local strings = {}
86
89
  for ____, value in ipairs(array) do
87
90
  __TS__ArrayPush(
@@ -1,7 +1,7 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
- local errorWithTraceback, slimTracebackOutput, vanillaError
4
+ local errorWithTraceback, slimTracebackOutput, removeAnyLineThatContains, LINE_SEPARATOR, USELESS_TRACEBACK_MESSAGES, vanillaError
5
5
  local ____debug = require("functions.debug")
6
6
  local getTraceback = ____debug.getTraceback
7
7
  local ____util = require("functions.util")
@@ -19,17 +19,27 @@ function errorWithTraceback(message, level)
19
19
  return vanillaError(message, level + 1)
20
20
  end
21
21
  function slimTracebackOutput(self, tracebackOutput)
22
- local lineSeparator = "\n"
23
- local lines = __TS__StringSplit(tracebackOutput, lineSeparator)
24
- if __TS__StringIncludes(lines[2], "in upvalue 'getTraceback'") or __TS__StringIncludes(lines[2], "in function 'sandboxGetTraceback'") then
25
- __TS__ArraySplice(lines, 1, 1)
22
+ for ____, msg in ipairs(USELESS_TRACEBACK_MESSAGES) do
23
+ tracebackOutput = removeAnyLineThatContains(nil, tracebackOutput, msg)
26
24
  end
27
- if __TS__StringIncludes(lines[2], "in function 'error'") then
28
- __TS__ArraySplice(lines, 1, 1)
25
+ return tracebackOutput
26
+ end
27
+ function removeAnyLineThatContains(self, msg, containsMsg)
28
+ local lines = __TS__StringSplit(msg, LINE_SEPARATOR)
29
+ do
30
+ local i = 0
31
+ while i < #lines do
32
+ local line = lines[i + 1]
33
+ if __TS__StringIncludes(line, containsMsg) then
34
+ __TS__ArraySplice(lines, i, 1)
35
+ end
36
+ i = i + 1
37
+ end
29
38
  end
30
- local slimmedTracebackOutput = table.concat(lines, lineSeparator or ",")
31
- return slimmedTracebackOutput
39
+ return table.concat(lines, LINE_SEPARATOR or ",")
32
40
  end
41
+ LINE_SEPARATOR = "\n"
42
+ USELESS_TRACEBACK_MESSAGES = {"in upvalue 'getTraceback'", "in function 'sandboxGetTraceback'", "in function 'error'"}
33
43
  function ____exports.patchErrorFunction(self)
34
44
  if not isLuaDebugEnabled(nil) then
35
45
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.519",
3
+ "version": "1.0.520",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",