isaacscript-common 1.2.77 → 1.2.78

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,5 +1,10 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
+ /**
4
+ * Helper function for determining if two arrays contain the exact same elements. Note that this
5
+ * only performs a shallow comparison.
6
+ */
7
+ export declare function arrayEquals<T>(array1: T[] | readonly T[], array2: T[] | readonly T[]): boolean;
3
8
  /**
4
9
  * Helper function to combine two or more arrays. Returns a new array that is the composition of all
5
10
  * of the specified arrays. This function is variadic, meaning that you can specify N arguments to
@@ -15,11 +20,8 @@ export declare function combineArray<T>(...arrays: Array<T[] | readonly T[]>): T
15
20
  */
16
21
  export declare function copyArray<T>(oldArray: T[] | readonly T[], numElements?: int): T[];
17
22
  export declare function emptyArray<T>(array: T[]): void;
18
- /**
19
- * Helper function for determining if two arrays contain the exact same elements. Note that this
20
- * only performs a shallow comparison.
21
- */
22
- export declare function arrayEquals<T>(array1: T[] | readonly T[], array2: T[] | readonly T[]): boolean;
23
+ /** Helper function to return the last element of an array. */
24
+ export declare function getLastElement<T>(array: T[]): T;
23
25
  /**
24
26
  * Initializes an array with all elements containing the specified default value.
25
27
  *
@@ -1,8 +1,8 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
+ local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
3
4
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
5
  local __TS__ArraySplice = ____lualib.__TS__ArraySplice
5
- local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
6
6
  local __TS__ArraySome = ____lualib.__TS__ArraySome
7
7
  local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
8
8
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
@@ -35,8 +35,19 @@ function ____exports.getRandomArrayIndex(self, array, seed)
35
35
  if #array == 0 then
36
36
  error("Failed to get a random array index since the provided array is empty.")
37
37
  end
38
- local randomIndex = getRandomInt(nil, 0, #array - 1, seed)
39
- return randomIndex
38
+ return getRandomInt(nil, 0, #array - 1, seed)
39
+ end
40
+ function ____exports.arrayEquals(self, array1, array2)
41
+ if #array1 ~= #array2 then
42
+ return false
43
+ end
44
+ return __TS__ArrayEvery(
45
+ array1,
46
+ function(____, array1Element, i)
47
+ local array2Element = array2[i + 1]
48
+ return array1Element == array2Element
49
+ end
50
+ )
40
51
  end
41
52
  function ____exports.combineArray(self, ...)
42
53
  local arrays = {...}
@@ -66,17 +77,8 @@ end
66
77
  function ____exports.emptyArray(self, array)
67
78
  __TS__ArraySplice(array, 0, #array)
68
79
  end
69
- function ____exports.arrayEquals(self, array1, array2)
70
- if #array1 ~= #array2 then
71
- return false
72
- end
73
- return __TS__ArrayEvery(
74
- array1,
75
- function(____, array1Element, i)
76
- local array2Element = array2[i + 1]
77
- return array1Element == array2Element
78
- end
79
- )
80
+ function ____exports.getLastElement(self, array)
81
+ return array[#array]
80
82
  end
81
83
  function ____exports.initArray(self, defaultValue, size)
82
84
  local array = {}
@@ -22,6 +22,7 @@ local MAX_VANILLA_CHARACTER = ____constants.MAX_VANILLA_CHARACTER
22
22
  local ____HealthType = require("types.HealthType")
23
23
  local HealthType = ____HealthType.HealthType
24
24
  local ____array = require("functions.array")
25
+ local getLastElement = ____array.getLastElement
25
26
  local sumArray = ____array.sumArray
26
27
  local ____bitwise = require("functions.bitwise")
27
28
  local getKBitOfN = ____bitwise.getKBitOfN
@@ -336,7 +337,7 @@ function ____exports.getEffectsList(self, player)
336
337
  end
337
338
  function ____exports.getFinalPlayer(self)
338
339
  local players = ____exports.getPlayers(nil)
339
- return players[#players]
340
+ return getLastElement(nil, players)
340
341
  end
341
342
  function ____exports.getLastHeart(self, player)
342
343
  local hearts = player:GetHearts()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.77",
3
+ "version": "1.2.78",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",