isaacscript-common 1.0.604 → 1.0.605

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,11 +1,19 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
+ local twoDimensionalSort
4
5
  local ____log = require("functions.log")
5
6
  local log = ____log.log
6
7
  local ____util = require("functions.util")
7
- local combineSets = ____util.combineSets
8
+ local addSetsToSet = ____util.addSetsToSet
9
+ local copySet = ____util.copySet
8
10
  local isLuaDebugEnabled = ____util.isLuaDebugEnabled
11
+ function twoDimensionalSort(self, a, b)
12
+ if a[1] == b[1] then
13
+ return 0
14
+ end
15
+ return a[1] < b[1] and -1 or 1
16
+ end
9
17
  local DEFAULT_GLOBALS = __TS__New(Set, {
10
18
  "ActionTriggers",
11
19
  "ActiveSlot",
@@ -173,8 +181,14 @@ local DEFAULT_GLOBALS = __TS__New(Set, {
173
181
  "xpcall"
174
182
  })
175
183
  local LUA_DEBUG_ADDED_GLOBALS = __TS__New(Set, {"debug", "io", "os", "package"})
184
+ local RACING_PLUS_SANDBOX_ADDED_GLOBALS = __TS__New(Set, {"sandboxTraceback", "sandboxGetTraceback", "getParentFunctionDescription"})
176
185
  function ____exports.getDefaultGlobals(self)
177
- return isLuaDebugEnabled(nil) and combineSets(nil, DEFAULT_GLOBALS, LUA_DEBUG_ADDED_GLOBALS) or DEFAULT_GLOBALS
186
+ local defaultGlobals = copySet(nil, DEFAULT_GLOBALS)
187
+ if isLuaDebugEnabled(nil) then
188
+ addSetsToSet(nil, defaultGlobals, LUA_DEBUG_ADDED_GLOBALS)
189
+ end
190
+ addSetsToSet(nil, defaultGlobals, RACING_PLUS_SANDBOX_ADDED_GLOBALS)
191
+ return defaultGlobals
178
192
  end
179
193
  function ____exports.getNewGlobals(self)
180
194
  local defaultGlobals = ____exports.getDefaultGlobals(nil)
@@ -185,6 +199,7 @@ function ____exports.getNewGlobals(self)
185
199
  __TS__ArrayPush(newGlobals, keyValueTuple)
186
200
  end
187
201
  end
202
+ __TS__ArraySort(newGlobals, twoDimensionalSort)
188
203
  return newGlobals
189
204
  end
190
205
  function ____exports.logNewGlobals(self)
@@ -1,5 +1,12 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
+ /**
4
+ * Helper function to add all of the contents of one set to another set. The first set passed will
5
+ * be modified in place.
6
+ *
7
+ * This function is variadic, meaning that you can specify N sets to add to the first set.
8
+ */
9
+ export declare function addSetsToSet<T>(mainSet: Set<T>, ...setsToAdd: Array<Set<T>>): void;
3
10
  /**
4
11
  * Using a Map constructor to copy a Map does not seem to work properly, so use this helper function
5
12
  * instead.
@@ -10,6 +17,11 @@ export declare function copyMap<K, V>(oldMap: Map<K, V>): Map<K, V>;
10
17
  * instead.
11
18
  */
12
19
  export declare function copySet<T>(oldSet: Set<T>): Set<T>;
20
+ /**
21
+ * Helper function to create a new set that is the composition of two or more sets.
22
+ *
23
+ * This function is variadic, meaning that you can specify N sets.
24
+ */
13
25
  export declare function combineSets<T>(...sets: Array<Set<T>>): Set<T>;
14
26
  /**
15
27
  * Helper function to get type safety on a switch statement.
@@ -2,6 +2,14 @@
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
4
  local HEX_STRING_LENGTH = 6
5
+ function ____exports.addSetsToSet(self, mainSet, ...)
6
+ local setsToAdd = {...}
7
+ for ____, set in ipairs(setsToAdd) do
8
+ for ____, value in __TS__Iterator(set:values()) do
9
+ mainSet:add(value)
10
+ end
11
+ end
12
+ end
5
13
  function ____exports.copyMap(self, oldMap)
6
14
  local newMap = __TS__New(Map)
7
15
  for ____, ____value in __TS__Iterator(oldMap:entries()) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.604",
3
+ "version": "1.0.605",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",