isaacscript-common 41.1.0 → 43.0.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.
@@ -1112,14 +1112,13 @@ export declare function arrayRemoveIndex<T>(originalArray: T[] | readonly T[], .
1112
1112
 
1113
1113
  /**
1114
1114
  * Removes the elements at the specified indexes from the array. If the specified indexes are not
1115
- * found in the array, this function will do nothing. Returns true if one or more elements were
1116
- * removed.
1115
+ * found in the array, this function will do nothing.
1117
1116
  *
1118
1117
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
1119
1118
  *
1120
- * @returns Whether any array elements were removed.
1119
+ * @returns The removed elements. This will be an empty array if no elements were removed.
1121
1120
  */
1122
- export declare function arrayRemoveIndexInPlace<T>(array: T[], ...indexesToRemove: int[]): boolean;
1121
+ export declare function arrayRemoveIndexInPlace<T>(array: T[], ...indexesToRemove: int[]): T[];
1123
1122
 
1124
1123
  /**
1125
1124
  * Removes the specified element(s) from the array. If the specified element(s) are not found in the
@@ -1131,9 +1130,9 @@ export declare function arrayRemoveIndexInPlace<T>(array: T[], ...indexesToRemov
1131
1130
  * matching element. If you want to remove all of the elements, use the `arrayRemoveAllInPlace`
1132
1131
  * function instead.
1133
1132
  *
1134
- * @returns True if one or more elements were removed, false otherwise.
1133
+ * @returns The removed elements. This will be an empty array if no elements were removed.
1135
1134
  */
1136
- export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: T[]): boolean;
1135
+ export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: T[]): T[];
1137
1136
 
1138
1137
  /** Helper function to convert a set of flags to a single `BitFlags` object. */
1139
1138
  export declare function arrayToBitFlags<T extends BitFlag | BitFlag128>(array: T[] | readonly T[]): BitFlags<T>;
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 41.1.0
3
+ isaacscript-common 43.0.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -16854,6 +16854,7 @@ local ____lualib = require("lualib_bundle")
16854
16854
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
16855
16855
  local __TS__ArrayIndexOf = ____lualib.__TS__ArrayIndexOf
16856
16856
  local __TS__ArraySplice = ____lualib.__TS__ArraySplice
16857
+ local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
16857
16858
  local __TS__New = ____lualib.__TS__New
16858
16859
  local __TS__ArrayEntries = ____lualib.__TS__ArrayEntries
16859
16860
  local __TS__Iterator = ____lualib.__TS__Iterator
@@ -16903,15 +16904,15 @@ function ____exports.arrayRemoveAllInPlace(self, array, ...)
16903
16904
  end
16904
16905
  function ____exports.arrayRemoveInPlace(self, array, ...)
16905
16906
  local elementsToRemove = {...}
16906
- local removedOneOrMoreElements = false
16907
+ local removedElements = {}
16907
16908
  for ____, element in ipairs(elementsToRemove) do
16908
16909
  local index = __TS__ArrayIndexOf(array, element)
16909
16910
  if index > -1 then
16910
- removedOneOrMoreElements = true
16911
- __TS__ArraySplice(array, index, 1)
16911
+ local removedElement = __TS__ArraySplice(array, index, 1)
16912
+ __TS__ArrayPushArray(removedElements, removedElement)
16912
16913
  end
16913
16914
  end
16914
- return removedOneOrMoreElements
16915
+ return removedElements
16915
16916
  end
16916
16917
  function ____exports.copyArray(self, oldArray, numElements)
16917
16918
  if numElements == nil then
@@ -17030,16 +17031,18 @@ function ____exports.arrayRemoveIndexInPlace(self, array, ...)
17030
17031
  )
17031
17032
  __TS__ArraySort(legalIndexes)
17032
17033
  if #legalIndexes == 0 then
17033
- return false
17034
+ return {}
17034
17035
  end
17036
+ local removedElements = {}
17035
17037
  do
17036
17038
  local i = #array - 1
17037
17039
  while i >= 0 do
17038
- __TS__ArraySplice(array, i, 1)
17040
+ local removedElement = __TS__ArraySplice(array, i, 1)
17041
+ __TS__ArrayPushArray(removedElements, removedElement)
17039
17042
  i = i - 1
17040
17043
  end
17041
17044
  end
17042
- return true
17045
+ return removedElements
17043
17046
  end
17044
17047
  function ____exports.arrayToString(self, array)
17045
17048
  if #array == 0 then
@@ -53,9 +53,9 @@ export declare function arrayRemoveAllInPlace<T>(array: T[], ...elementsToRemove
53
53
  * matching element. If you want to remove all of the elements, use the `arrayRemoveAllInPlace`
54
54
  * function instead.
55
55
  *
56
- * @returns True if one or more elements were removed, false otherwise.
56
+ * @returns The removed elements. This will be an empty array if no elements were removed.
57
57
  */
58
- export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: T[]): boolean;
58
+ export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: T[]): T[];
59
59
  /**
60
60
  * Shallow copies and removes the elements at the specified indexes from the array. Returns the
61
61
  * copied array. If the specified indexes are not found in the array, it will simply return a
@@ -66,14 +66,13 @@ export declare function arrayRemoveInPlace<T>(array: T[], ...elementsToRemove: T
66
66
  export declare function arrayRemoveIndex<T>(originalArray: T[] | readonly T[], ...indexesToRemove: int[]): T[];
67
67
  /**
68
68
  * Removes the elements at the specified indexes from the array. If the specified indexes are not
69
- * found in the array, this function will do nothing. Returns true if one or more elements were
70
- * removed.
69
+ * found in the array, this function will do nothing.
71
70
  *
72
71
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
73
72
  *
74
- * @returns Whether any array elements were removed.
73
+ * @returns The removed elements. This will be an empty array if no elements were removed.
75
74
  */
76
- export declare function arrayRemoveIndexInPlace<T>(array: T[], ...indexesToRemove: int[]): boolean;
75
+ export declare function arrayRemoveIndexInPlace<T>(array: T[], ...indexesToRemove: int[]): T[];
77
76
  export declare function arrayToString(array: unknown[]): string;
78
77
  /**
79
78
  * Helper function to combine two or more arrays. Returns a new array that is the composition of all
@@ -1 +1 @@
1
- {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/functions/array.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAC1B,MAAM,EAAE,CAAC,EAA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,CAAC,EAAE,CAAC,GACrC,OAAO,CAET;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAIjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,CAAC,EAAE,CAKL;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,IAAI,CAWN;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAEpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3E"}
@@ -2,6 +2,7 @@ local ____lualib = require("lualib_bundle")
2
2
  local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
3
3
  local __TS__ArrayIndexOf = ____lualib.__TS__ArrayIndexOf
4
4
  local __TS__ArraySplice = ____lualib.__TS__ArraySplice
5
+ local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
5
6
  local __TS__New = ____lualib.__TS__New
6
7
  local __TS__ArrayEntries = ____lualib.__TS__ArrayEntries
7
8
  local __TS__Iterator = ____lualib.__TS__Iterator
@@ -68,18 +69,18 @@ end
68
69
  -- matching element. If you want to remove all of the elements, use the `arrayRemoveAllInPlace`
69
70
  -- function instead.
70
71
  --
71
- -- @returns True if one or more elements were removed, false otherwise.
72
+ -- @returns The removed elements. This will be an empty array if no elements were removed.
72
73
  function ____exports.arrayRemoveInPlace(self, array, ...)
73
74
  local elementsToRemove = {...}
74
- local removedOneOrMoreElements = false
75
+ local removedElements = {}
75
76
  for ____, element in ipairs(elementsToRemove) do
76
77
  local index = __TS__ArrayIndexOf(array, element)
77
78
  if index > -1 then
78
- removedOneOrMoreElements = true
79
- __TS__ArraySplice(array, index, 1)
79
+ local removedElement = __TS__ArraySplice(array, index, 1)
80
+ __TS__ArrayPushArray(removedElements, removedElement)
80
81
  end
81
82
  end
82
- return removedOneOrMoreElements
83
+ return removedElements
83
84
  end
84
85
  --- Helper function to perform a shallow copy.
85
86
  --
@@ -236,12 +237,11 @@ function ____exports.arrayRemoveIndex(self, originalArray, ...)
236
237
  return array
237
238
  end
238
239
  --- Removes the elements at the specified indexes from the array. If the specified indexes are not
239
- -- found in the array, this function will do nothing. Returns true if one or more elements were
240
- -- removed.
240
+ -- found in the array, this function will do nothing.
241
241
  --
242
242
  -- This function is variadic, meaning that you can specify N arguments to remove N elements.
243
243
  --
244
- -- @returns Whether any array elements were removed.
244
+ -- @returns The removed elements. This will be an empty array if no elements were removed.
245
245
  function ____exports.arrayRemoveIndexInPlace(self, array, ...)
246
246
  local indexesToRemove = {...}
247
247
  local legalIndexes = __TS__ArrayFilter(
@@ -250,16 +250,18 @@ function ____exports.arrayRemoveIndexInPlace(self, array, ...)
250
250
  )
251
251
  __TS__ArraySort(legalIndexes)
252
252
  if #legalIndexes == 0 then
253
- return false
253
+ return {}
254
254
  end
255
+ local removedElements = {}
255
256
  do
256
257
  local i = #array - 1
257
258
  while i >= 0 do
258
- __TS__ArraySplice(array, i, 1)
259
+ local removedElement = __TS__ArraySplice(array, i, 1)
260
+ __TS__ArrayPushArray(removedElements, removedElement)
259
261
  i = i - 1
260
262
  end
261
263
  end
262
- return true
264
+ return removedElements
263
265
  end
264
266
  function ____exports.arrayToString(self, array)
265
267
  if #array == 0 then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "41.1.0",
3
+ "version": "43.0.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -103,22 +103,23 @@ export function arrayRemoveAllInPlace<T>(
103
103
  * matching element. If you want to remove all of the elements, use the `arrayRemoveAllInPlace`
104
104
  * function instead.
105
105
  *
106
- * @returns True if one or more elements were removed, false otherwise.
106
+ * @returns The removed elements. This will be an empty array if no elements were removed.
107
107
  */
108
108
  export function arrayRemoveInPlace<T>(
109
109
  array: T[],
110
110
  ...elementsToRemove: T[]
111
- ): boolean {
112
- let removedOneOrMoreElements = false;
111
+ ): T[] {
112
+ const removedElements: T[] = [];
113
+
113
114
  for (const element of elementsToRemove) {
114
115
  const index = array.indexOf(element);
115
116
  if (index > -1) {
116
- removedOneOrMoreElements = true;
117
- array.splice(index, 1);
117
+ const removedElement = array.splice(index, 1);
118
+ removedElements.push(...removedElement);
118
119
  }
119
120
  }
120
121
 
121
- return removedOneOrMoreElements;
122
+ return removedElements;
122
123
  }
123
124
 
124
125
  /**
@@ -146,31 +147,33 @@ export function arrayRemoveIndex<T>(
146
147
 
147
148
  /**
148
149
  * Removes the elements at the specified indexes from the array. If the specified indexes are not
149
- * found in the array, this function will do nothing. Returns true if one or more elements were
150
- * removed.
150
+ * found in the array, this function will do nothing.
151
151
  *
152
152
  * This function is variadic, meaning that you can specify N arguments to remove N elements.
153
153
  *
154
- * @returns Whether any array elements were removed.
154
+ * @returns The removed elements. This will be an empty array if no elements were removed.
155
155
  */
156
156
  export function arrayRemoveIndexInPlace<T>(
157
157
  array: T[],
158
158
  ...indexesToRemove: int[]
159
- ): boolean {
159
+ ): T[] {
160
160
  const legalIndexes = indexesToRemove.filter(
161
161
  (i) => i >= 0 && i < array.length,
162
162
  );
163
163
  legalIndexes.sort();
164
164
 
165
165
  if (legalIndexes.length === 0) {
166
- return false;
166
+ return [];
167
167
  }
168
168
 
169
+ const removedElements: T[] = [];
170
+
169
171
  for (let i = array.length - 1; i >= 0; i--) {
170
- array.splice(i, 1);
172
+ const removedElement = array.splice(i, 1);
173
+ removedElements.push(...removedElement);
171
174
  }
172
175
 
173
- return true;
176
+ return removedElements;
174
177
  }
175
178
 
176
179
  export function arrayToString(array: unknown[]): string {