isaacscript-common 42.0.0 → 43.0.1
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.
package/dist/index.rollup.d.ts
CHANGED
|
@@ -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.
|
|
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
|
|
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[]):
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common
|
|
3
|
+
isaacscript-common 43.0.1
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -16859,7 +16859,6 @@ local __TS__New = ____lualib.__TS__New
|
|
|
16859
16859
|
local __TS__ArrayEntries = ____lualib.__TS__ArrayEntries
|
|
16860
16860
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
16861
16861
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
16862
|
-
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
16863
16862
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
16864
16863
|
local __TS__ArrayUnshift = ____lualib.__TS__ArrayUnshift
|
|
16865
16864
|
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
|
|
@@ -17029,18 +17028,22 @@ function ____exports.arrayRemoveIndexInPlace(self, array, ...)
|
|
|
17029
17028
|
indexesToRemove,
|
|
17030
17029
|
function(____, i) return i >= 0 and i < #array end
|
|
17031
17030
|
)
|
|
17032
|
-
__TS__ArraySort(legalIndexes)
|
|
17033
17031
|
if #legalIndexes == 0 then
|
|
17034
|
-
return
|
|
17032
|
+
return {}
|
|
17035
17033
|
end
|
|
17034
|
+
local legalIndexesSet = __TS__New(ReadonlySet, legalIndexes)
|
|
17035
|
+
local removedElements = {}
|
|
17036
17036
|
do
|
|
17037
17037
|
local i = #array - 1
|
|
17038
17038
|
while i >= 0 do
|
|
17039
|
-
|
|
17039
|
+
if legalIndexesSet:has(i) then
|
|
17040
|
+
local removedElement = __TS__ArraySplice(array, i, 1)
|
|
17041
|
+
__TS__ArrayPushArray(removedElements, removedElement)
|
|
17042
|
+
end
|
|
17040
17043
|
i = i - 1
|
|
17041
17044
|
end
|
|
17042
17045
|
end
|
|
17043
|
-
return
|
|
17046
|
+
return removedElements
|
|
17044
17047
|
end
|
|
17045
17048
|
function ____exports.arrayToString(self, array)
|
|
17046
17049
|
if #array == 0 then
|
|
@@ -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.
|
|
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
|
|
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[]):
|
|
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,EAAE,GAAG,SAAS,CAAC,EAAE,GACzB,OAAO,CAST;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,CAAC,EAAE,CAIL;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,CAAC,EAAE,CAIL;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,KAAK,EAAE,CAAC,EAAE,EACV,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,OAAO,CAcT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,CAAC,EAAE,EACV,GAAG,gBAAgB,EAAE,CAAC,EAAE,GACvB,CAAC,EAAE,CAYL;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,aAAa,EAAE,CAAC,EAAE,GAAG,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ED;;;;;;;;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"}
|
|
@@ -7,7 +7,6 @@ local __TS__New = ____lualib.__TS__New
|
|
|
7
7
|
local __TS__ArrayEntries = ____lualib.__TS__ArrayEntries
|
|
8
8
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
9
9
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
10
|
-
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
11
10
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
12
11
|
local __TS__ArrayUnshift = ____lualib.__TS__ArrayUnshift
|
|
13
12
|
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
|
|
@@ -237,30 +236,33 @@ function ____exports.arrayRemoveIndex(self, originalArray, ...)
|
|
|
237
236
|
return array
|
|
238
237
|
end
|
|
239
238
|
--- Removes the elements at the specified indexes from the array. If the specified indexes are not
|
|
240
|
-
-- found in the array, this function will do nothing.
|
|
241
|
-
-- removed.
|
|
239
|
+
-- found in the array, this function will do nothing.
|
|
242
240
|
--
|
|
243
241
|
-- This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
244
242
|
--
|
|
245
|
-
-- @returns
|
|
243
|
+
-- @returns The removed elements. This will be an empty array if no elements were removed.
|
|
246
244
|
function ____exports.arrayRemoveIndexInPlace(self, array, ...)
|
|
247
245
|
local indexesToRemove = {...}
|
|
248
246
|
local legalIndexes = __TS__ArrayFilter(
|
|
249
247
|
indexesToRemove,
|
|
250
248
|
function(____, i) return i >= 0 and i < #array end
|
|
251
249
|
)
|
|
252
|
-
__TS__ArraySort(legalIndexes)
|
|
253
250
|
if #legalIndexes == 0 then
|
|
254
|
-
return
|
|
251
|
+
return {}
|
|
255
252
|
end
|
|
253
|
+
local legalIndexesSet = __TS__New(ReadonlySet, legalIndexes)
|
|
254
|
+
local removedElements = {}
|
|
256
255
|
do
|
|
257
256
|
local i = #array - 1
|
|
258
257
|
while i >= 0 do
|
|
259
|
-
|
|
258
|
+
if legalIndexesSet:has(i) then
|
|
259
|
+
local removedElement = __TS__ArraySplice(array, i, 1)
|
|
260
|
+
__TS__ArrayPushArray(removedElements, removedElement)
|
|
261
|
+
end
|
|
260
262
|
i = i - 1
|
|
261
263
|
end
|
|
262
264
|
end
|
|
263
|
-
return
|
|
265
|
+
return removedElements
|
|
264
266
|
end
|
|
265
267
|
function ____exports.arrayToString(self, array)
|
|
266
268
|
if #array == 0 then
|
package/package.json
CHANGED
package/src/functions/array.ts
CHANGED
|
@@ -147,31 +147,35 @@ export function arrayRemoveIndex<T>(
|
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
149
|
* Removes the elements at the specified indexes from the array. If the specified indexes are not
|
|
150
|
-
* found in the array, this function will do nothing.
|
|
151
|
-
* removed.
|
|
150
|
+
* found in the array, this function will do nothing.
|
|
152
151
|
*
|
|
153
152
|
* This function is variadic, meaning that you can specify N arguments to remove N elements.
|
|
154
153
|
*
|
|
155
|
-
* @returns
|
|
154
|
+
* @returns The removed elements. This will be an empty array if no elements were removed.
|
|
156
155
|
*/
|
|
157
156
|
export function arrayRemoveIndexInPlace<T>(
|
|
158
157
|
array: T[],
|
|
159
158
|
...indexesToRemove: int[]
|
|
160
|
-
):
|
|
159
|
+
): T[] {
|
|
161
160
|
const legalIndexes = indexesToRemove.filter(
|
|
162
161
|
(i) => i >= 0 && i < array.length,
|
|
163
162
|
);
|
|
164
|
-
legalIndexes.sort();
|
|
165
163
|
|
|
166
164
|
if (legalIndexes.length === 0) {
|
|
167
|
-
return
|
|
165
|
+
return [];
|
|
168
166
|
}
|
|
169
167
|
|
|
168
|
+
const legalIndexesSet = new ReadonlySet(legalIndexes);
|
|
169
|
+
const removedElements: T[] = [];
|
|
170
|
+
|
|
170
171
|
for (let i = array.length - 1; i >= 0; i--) {
|
|
171
|
-
|
|
172
|
+
if (legalIndexesSet.has(i)) {
|
|
173
|
+
const removedElement = array.splice(i, 1);
|
|
174
|
+
removedElements.push(...removedElement);
|
|
175
|
+
}
|
|
172
176
|
}
|
|
173
177
|
|
|
174
|
-
return
|
|
178
|
+
return removedElements;
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
export function arrayToString(array: unknown[]): string {
|