isaacscript-common 1.2.255 → 1.2.258

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.
Files changed (87) hide show
  1. package/dist/callbacks/postPlayerReordered.lua +9 -6
  2. package/dist/callbacks/subscriptions/postBombInitLate.lua +2 -3
  3. package/dist/callbacks/subscriptions/postBoneSwing.lua +2 -3
  4. package/dist/callbacks/subscriptions/postCollectibleInitFirst.lua +2 -3
  5. package/dist/callbacks/subscriptions/postCursedTeleport.lua +2 -3
  6. package/dist/callbacks/subscriptions/postCustomDoorEnter.lua +2 -3
  7. package/dist/callbacks/subscriptions/postCustomRevive.lua +2 -3
  8. package/dist/callbacks/subscriptions/postEffectInitLate.lua +2 -3
  9. package/dist/callbacks/subscriptions/postEsauJr.lua +2 -3
  10. package/dist/callbacks/subscriptions/postFamiliarInitLate.lua +2 -3
  11. package/dist/callbacks/subscriptions/postFirstEsauJr.lua +2 -3
  12. package/dist/callbacks/subscriptions/postFirstFlip.lua +2 -3
  13. package/dist/callbacks/subscriptions/postFlip.lua +2 -3
  14. package/dist/callbacks/subscriptions/postGameStartedReordered.lua +2 -3
  15. package/dist/callbacks/subscriptions/postGridEntityBroken.lua +2 -3
  16. package/dist/callbacks/subscriptions/postGridEntityCollision.lua +2 -3
  17. package/dist/callbacks/subscriptions/postGridEntityInit.lua +2 -3
  18. package/dist/callbacks/subscriptions/postGridEntityRemove.lua +2 -3
  19. package/dist/callbacks/subscriptions/postGridEntityStateChange.lua +2 -3
  20. package/dist/callbacks/subscriptions/postGridEntityUpdate.lua +2 -3
  21. package/dist/callbacks/subscriptions/postItemPickup.lua +2 -3
  22. package/dist/callbacks/subscriptions/postKnifeInitLate.lua +2 -3
  23. package/dist/callbacks/subscriptions/postLaserInitLate.lua +2 -3
  24. package/dist/callbacks/subscriptions/postNPCInitLate.lua +2 -3
  25. package/dist/callbacks/subscriptions/postNewLevelReordered.lua +2 -3
  26. package/dist/callbacks/subscriptions/postNewRoomEarly.lua +2 -3
  27. package/dist/callbacks/subscriptions/postNewRoomReordered.lua +2 -3
  28. package/dist/callbacks/subscriptions/postPEffectUpdateReordered.lua +2 -3
  29. package/dist/callbacks/subscriptions/postPickupCollect.lua +2 -3
  30. package/dist/callbacks/subscriptions/postPickupInitLate.lua +2 -3
  31. package/dist/callbacks/subscriptions/postPlayerChangeHealth.lua +2 -3
  32. package/dist/callbacks/subscriptions/postPlayerChangeType.lua +2 -3
  33. package/dist/callbacks/subscriptions/postPlayerFatalDamage.lua +2 -3
  34. package/dist/callbacks/subscriptions/postPlayerInitLate.lua +2 -3
  35. package/dist/callbacks/subscriptions/postPlayerInitReordered.lua +2 -3
  36. package/dist/callbacks/subscriptions/postPlayerRenderReordered.lua +2 -3
  37. package/dist/callbacks/subscriptions/postPlayerUpdateReordered.lua +2 -3
  38. package/dist/callbacks/subscriptions/postProjectileInitLate.lua +2 -3
  39. package/dist/callbacks/subscriptions/postPurchase.lua +2 -3
  40. package/dist/callbacks/subscriptions/postSacrifice.lua +2 -3
  41. package/dist/callbacks/subscriptions/postSlotAnimationChanged.lua +2 -3
  42. package/dist/callbacks/subscriptions/postSlotDestroyed.lua +2 -3
  43. package/dist/callbacks/subscriptions/postSlotInit.lua +2 -3
  44. package/dist/callbacks/subscriptions/postSlotRender.lua +2 -3
  45. package/dist/callbacks/subscriptions/postSlotUpdate.lua +2 -3
  46. package/dist/callbacks/subscriptions/postTearInitLate.lua +2 -3
  47. package/dist/callbacks/subscriptions/postTearInitVeryLate.lua +2 -3
  48. package/dist/callbacks/subscriptions/postTransformation.lua +2 -3
  49. package/dist/callbacks/subscriptions/postTrinketBreak.lua +2 -3
  50. package/dist/callbacks/subscriptions/preBerserkDeath.lua +2 -3
  51. package/dist/callbacks/subscriptions/preCustomRevive.lua +2 -3
  52. package/dist/callbacks/subscriptions/preItemPickup.lua +2 -3
  53. package/dist/callbacks/subscriptions/preNewLevel.lua +2 -3
  54. package/dist/callbacks/subscriptions/roomClearChange.lua +2 -3
  55. package/dist/constants.d.ts +8 -0
  56. package/dist/features/deployJSONRoom.lua +2 -3
  57. package/dist/features/playerInventory.lua +3 -4
  58. package/dist/features/runInNFrames.lua +6 -5
  59. package/dist/features/sirenHelpers.lua +2 -2
  60. package/dist/features/taintedLazarusPlayers.lua +6 -6
  61. package/dist/functions/array.lua +5 -6
  62. package/dist/functions/benchmark.lua +1 -2
  63. package/dist/functions/collectibleCacheFlag.lua +1 -2
  64. package/dist/functions/color.d.ts +1 -0
  65. package/dist/functions/deepCopy.lua +4 -5
  66. package/dist/functions/doors.lua +1 -2
  67. package/dist/functions/entity.d.ts +2 -2
  68. package/dist/functions/entity.lua +4 -8
  69. package/dist/functions/entitySpecific.lua +10 -11
  70. package/dist/functions/globals.lua +1 -2
  71. package/dist/functions/gridEntity.lua +2 -3
  72. package/dist/functions/kColor.d.ts +1 -0
  73. package/dist/functions/log.lua +1 -1
  74. package/dist/functions/math.lua +3 -4
  75. package/dist/functions/pickups.d.ts +5 -0
  76. package/dist/functions/pickups.lua +7 -0
  77. package/dist/functions/player.lua +1 -2
  78. package/dist/functions/playerHealth.lua +3 -4
  79. package/dist/functions/playerIndex.lua +1 -2
  80. package/dist/functions/pocketItems.lua +6 -7
  81. package/dist/functions/rooms.lua +2 -3
  82. package/dist/functions/table.lua +5 -6
  83. package/dist/functions/utils.lua +2 -3
  84. package/dist/lualib_bundle.lua +358 -388
  85. package/dist/objects/coinSubTypeToValue.d.ts +5 -0
  86. package/dist/objects/coinSubTypeToValue.lua +13 -0
  87. package/package.json +4 -4
@@ -1,24 +1,28 @@
1
1
  local function __TS__ArrayIsArray(value)
2
- return type(value) == "table" and (value[1] ~= nil or next(value, nil) == nil)
2
+ return type(value) == "table" and (value[1] ~= nil or next(value) == nil)
3
3
  end
4
4
 
5
- local function __TS__ArrayConcat(arr1, ...)
6
- local args = {...}
7
- local out = {}
8
- for ____, val in ipairs(arr1) do
9
- out[#out + 1] = val
10
- end
11
- for ____, arg in ipairs(args) do
12
- if __TS__ArrayIsArray(arg) then
13
- local argAsArray = arg
14
- for ____, val in ipairs(argAsArray) do
15
- out[#out + 1] = val
5
+ local function __TS__ArrayConcat(self, ...)
6
+ local items = {...}
7
+ local result = {}
8
+ local len = 0
9
+ for i = 1, #self do
10
+ len = len + 1
11
+ result[len] = self[i]
12
+ end
13
+ for i = 1, #items do
14
+ local item = items[i]
15
+ if __TS__ArrayIsArray(item) then
16
+ for j = 1, #item do
17
+ len = len + 1
18
+ result[len] = item[j]
16
19
  end
17
20
  else
18
- out[#out + 1] = arg
21
+ len = len + 1
22
+ result[len] = item
19
23
  end
20
24
  end
21
- return out
25
+ return result
22
26
  end
23
27
 
24
28
  local __TS__Symbol, Symbol
@@ -51,78 +55,52 @@ local function __TS__ArrayEntries(array)
51
55
  }
52
56
  end
53
57
 
54
- local function __TS__ArrayEvery(arr, callbackfn)
55
- do
56
- local i = 0
57
- while i < #arr do
58
- if not callbackfn(nil, arr[i + 1], i, arr) then
59
- return false
60
- end
61
- i = i + 1
58
+ local function __TS__ArrayEvery(self, callbackfn, thisArg)
59
+ for i = 1, #self do
60
+ if not callbackfn(thisArg, self[i], i - 1, self) then
61
+ return false
62
62
  end
63
63
  end
64
64
  return true
65
65
  end
66
66
 
67
- local function __TS__ArrayFilter(arr, callbackfn)
67
+ local function __TS__ArrayFilter(self, callbackfn, thisArg)
68
68
  local result = {}
69
- do
70
- local i = 0
71
- while i < #arr do
72
- if callbackfn(nil, arr[i + 1], i, arr) then
73
- result[#result + 1] = arr[i + 1]
74
- end
75
- i = i + 1
69
+ local len = 0
70
+ for i = 1, #self do
71
+ if callbackfn(thisArg, self[i], i - 1, self) then
72
+ len = len + 1
73
+ result[len] = self[i]
76
74
  end
77
75
  end
78
76
  return result
79
77
  end
80
78
 
81
- local function __TS__ArrayForEach(arr, callbackFn)
82
- do
83
- local i = 0
84
- while i < #arr do
85
- callbackFn(nil, arr[i + 1], i, arr)
86
- i = i + 1
87
- end
79
+ local function __TS__ArrayForEach(self, callbackFn, thisArg)
80
+ for i = 1, #self do
81
+ callbackFn(thisArg, self[i], i - 1, self)
88
82
  end
89
83
  end
90
84
 
91
- local function __TS__ArrayFind(arr, predicate)
92
- local len = #arr
93
- local k = 0
94
- while k < len do
95
- local elem = arr[k + 1]
96
- if predicate(nil, elem, k, arr) then
85
+ local function __TS__ArrayFind(self, predicate, thisArg)
86
+ for i = 1, #self do
87
+ local elem = self[i]
88
+ if predicate(thisArg, elem, i - 1, self) then
97
89
  return elem
98
90
  end
99
- k = k + 1
100
91
  end
101
92
  return nil
102
93
  end
103
94
 
104
- local function __TS__ArrayFindIndex(arr, callbackFn)
105
- do
106
- local i = 0
107
- local len = #arr
108
- while i < len do
109
- if callbackFn(nil, arr[i + 1], i, arr) then
110
- return i
111
- end
112
- i = i + 1
95
+ local function __TS__ArrayFindIndex(self, callbackFn, thisArg)
96
+ for i = 1, #self do
97
+ if callbackFn(thisArg, self[i], i - 1, self) then
98
+ return i - 1
113
99
  end
114
100
  end
115
101
  return -1
116
102
  end
117
103
 
118
- local function __TS__ArrayPush(arr, ...)
119
- local items = {...}
120
- for ____, item in ipairs(items) do
121
- arr[#arr + 1] = item
122
- end
123
- return #arr
124
- end
125
-
126
104
  local __TS__Iterator
127
105
  do
128
106
  local function iteratorGeneratorStep(self)
@@ -183,14 +161,11 @@ do
183
161
  local result = {}
184
162
  if mapFn == nil then
185
163
  for ____, v in arrayLikeIterator(arrayLike) do
186
- __TS__ArrayPush(result, v)
164
+ result[#result + 1] = v
187
165
  end
188
166
  else
189
167
  for i, v in arrayLikeIterator(arrayLike) do
190
- __TS__ArrayPush(
191
- result,
192
- mapFn(thisArg, v, i - 1)
193
- )
168
+ result[#result + 1] = mapFn(thisArg, v, i - 1)
194
169
  end
195
170
  end
196
171
  return result
@@ -209,42 +184,34 @@ local function __TS__ArrayIncludes(self, searchElement, fromIndex)
209
184
  if k < 0 then
210
185
  k = 0
211
186
  end
212
- for i = k, len do
213
- if self[i + 1] == searchElement then
187
+ for i = k + 1, len do
188
+ if self[i] == searchElement then
214
189
  return true
215
190
  end
216
191
  end
217
192
  return false
218
193
  end
219
194
 
220
- local function __TS__ArrayIndexOf(arr, searchElement, fromIndex)
221
- local len = #arr
195
+ local function __TS__ArrayIndexOf(self, searchElement, fromIndex)
196
+ if fromIndex == nil then
197
+ fromIndex = 0
198
+ end
199
+ local len = #self
222
200
  if len == 0 then
223
201
  return -1
224
202
  end
225
- local n = 0
226
- if fromIndex then
227
- n = fromIndex
228
- end
229
- if n >= len then
203
+ if fromIndex >= len then
230
204
  return -1
231
205
  end
232
- local k
233
- if n >= 0 then
234
- k = n
235
- else
236
- k = len + n
237
- if k < 0 then
238
- k = 0
206
+ if fromIndex < 0 then
207
+ fromIndex = len + fromIndex
208
+ if fromIndex < 0 then
209
+ fromIndex = 0
239
210
  end
240
211
  end
241
- do
242
- local i = k
243
- while i < len do
244
- if arr[i + 1] == searchElement then
245
- return i
246
- end
247
- i = i + 1
212
+ for i = fromIndex + 1, len do
213
+ if self[i] == searchElement then
214
+ return i - 1
248
215
  end
249
216
  end
250
217
  return -1
@@ -254,304 +221,310 @@ local function __TS__ArrayJoin(self, separator)
254
221
  if separator == nil then
255
222
  separator = ","
256
223
  end
257
- local result = ""
258
- for index, value in ipairs(self) do
259
- if index > 1 then
260
- result = result .. separator
261
- end
262
- result = result .. tostring(value)
224
+ local parts = {}
225
+ for i = 1, #self do
226
+ parts[i] = tostring(self[i])
227
+ end
228
+ return table.concat(parts, separator)
229
+ end
230
+
231
+ local function __TS__ArrayMap(self, callbackfn, thisArg)
232
+ local result = {}
233
+ for i = 1, #self do
234
+ result[i] = callbackfn(thisArg, self[i], i - 1, self)
263
235
  end
264
236
  return result
265
237
  end
266
238
 
267
- local function __TS__ArrayMap(arr, callbackfn)
268
- local newArray = {}
269
- do
270
- local i = 0
271
- while i < #arr do
272
- newArray[i + 1] = callbackfn(nil, arr[i + 1], i, arr)
273
- i = i + 1
274
- end
239
+ local function __TS__ArrayPush(self, ...)
240
+ local items = {...}
241
+ local len = #self
242
+ for i = 1, #items do
243
+ len = len + 1
244
+ self[len] = items[i]
275
245
  end
276
- return newArray
246
+ return len
277
247
  end
278
248
 
279
- local function __TS__ArrayReduce(arr, callbackFn, ...)
280
- local len = #arr
249
+ local function __TS__ArrayPushArray(self, items)
250
+ local len = #self
251
+ for i = 1, #items do
252
+ len = len + 1
253
+ self[len] = items[i]
254
+ end
255
+ return len
256
+ end
257
+
258
+ local function __TS__ArrayReduce(self, callbackFn, ...)
259
+ local len = #self
281
260
  local k = 0
282
261
  local accumulator = nil
283
262
  if select("#", ...) ~= 0 then
284
- accumulator = select(1, ...)
263
+ accumulator = ...
285
264
  elseif len > 0 then
286
- accumulator = arr[1]
265
+ accumulator = self[1]
287
266
  k = 1
288
267
  else
289
268
  error("Reduce of empty array with no initial value", 0)
290
269
  end
291
- for i = k, len - 1 do
270
+ for i = k + 1, len do
292
271
  accumulator = callbackFn(
293
272
  nil,
294
273
  accumulator,
295
- arr[i + 1],
296
- i,
297
- arr
274
+ self[i],
275
+ i - 1,
276
+ self
298
277
  )
299
278
  end
300
279
  return accumulator
301
280
  end
302
281
 
303
- local function __TS__ArrayReduceRight(arr, callbackFn, ...)
304
- local len = #arr
282
+ local function __TS__ArrayReduceRight(self, callbackFn, ...)
283
+ local len = #self
305
284
  local k = len - 1
306
285
  local accumulator = nil
307
286
  if select("#", ...) ~= 0 then
308
- accumulator = select(1, ...)
287
+ accumulator = ...
309
288
  elseif len > 0 then
310
- accumulator = arr[k + 1]
289
+ accumulator = self[k + 1]
311
290
  k = k - 1
312
291
  else
313
292
  error("Reduce of empty array with no initial value", 0)
314
293
  end
315
- for i = k, 0, -1 do
294
+ for i = k + 1, 1, -1 do
316
295
  accumulator = callbackFn(
317
296
  nil,
318
297
  accumulator,
319
- arr[i + 1],
320
- i,
321
- arr
298
+ self[i],
299
+ i - 1,
300
+ self
322
301
  )
323
302
  end
324
303
  return accumulator
325
304
  end
326
305
 
327
- local function __TS__ArrayReverse(arr)
328
- local i = 0
329
- local j = #arr - 1
306
+ local function __TS__ArrayReverse(self)
307
+ local i = 1
308
+ local j = #self
330
309
  while i < j do
331
- local temp = arr[j + 1]
332
- arr[j + 1] = arr[i + 1]
333
- arr[i + 1] = temp
310
+ local temp = self[j]
311
+ self[j] = self[i]
312
+ self[i] = temp
334
313
  i = i + 1
335
314
  j = j - 1
336
315
  end
337
- return arr
316
+ return self
338
317
  end
339
318
 
340
- local function __TS__ArrayShift(arr)
341
- return table.remove(arr, 1)
342
- end
343
-
344
- local function __TS__ArrayUnshift(arr, ...)
319
+ local function __TS__ArrayUnshift(self, ...)
345
320
  local items = {...}
346
- do
347
- local i = #items - 1
348
- while i >= 0 do
349
- table.insert(arr, 1, items[i + 1])
350
- i = i - 1
351
- end
321
+ local numItemsToInsert = #items
322
+ if numItemsToInsert == 0 then
323
+ return #self
324
+ end
325
+ for i = #self, 1, -1 do
326
+ self[i + numItemsToInsert] = self[i]
327
+ end
328
+ for i = 1, numItemsToInsert do
329
+ self[i] = items[i]
352
330
  end
353
- return #arr
331
+ return #self
354
332
  end
355
333
 
356
- local function __TS__ArraySort(arr, compareFn)
334
+ local function __TS__ArraySort(self, compareFn)
357
335
  if compareFn ~= nil then
358
336
  table.sort(
359
- arr,
337
+ self,
360
338
  function(a, b) return compareFn(nil, a, b) < 0 end
361
339
  )
362
340
  else
363
- table.sort(arr)
341
+ table.sort(self)
364
342
  end
365
- return arr
343
+ return self
366
344
  end
367
345
 
368
- local function __TS__ArraySlice(list, first, last)
369
- local len = #list
370
- local relativeStart = first or 0
371
- local k
372
- if relativeStart < 0 then
373
- k = math.max(len + relativeStart, 0)
346
+ local function __TS__ArraySlice(self, first, last)
347
+ local len = #self
348
+ first = first or 0
349
+ if first < 0 then
350
+ first = len + first
351
+ if first < 0 then
352
+ first = 0
353
+ end
374
354
  else
375
- k = math.min(relativeStart, len)
376
- end
377
- local relativeEnd = last
378
- if last == nil then
379
- relativeEnd = len
355
+ if first > len then
356
+ first = len
357
+ end
380
358
  end
381
- local final
382
- if relativeEnd < 0 then
383
- final = math.max(len + relativeEnd, 0)
359
+ last = last or len
360
+ if last < 0 then
361
+ last = len + last
362
+ if last < 0 then
363
+ last = 0
364
+ end
384
365
  else
385
- final = math.min(relativeEnd, len)
366
+ if last > len then
367
+ last = len
368
+ end
386
369
  end
387
370
  local out = {}
388
- local n = 0
389
- while k < final do
390
- out[n + 1] = list[k + 1]
391
- k = k + 1
371
+ first = first + 1
372
+ last = last + 1
373
+ local n = 1
374
+ while first < last do
375
+ out[n] = self[first]
376
+ first = first + 1
392
377
  n = n + 1
393
378
  end
394
379
  return out
395
380
  end
396
381
 
397
- local function __TS__ArraySome(arr, callbackfn)
398
- do
399
- local i = 0
400
- while i < #arr do
401
- if callbackfn(nil, arr[i + 1], i, arr) then
402
- return true
403
- end
404
- i = i + 1
382
+ local function __TS__ArraySome(self, callbackfn, thisArg)
383
+ for i = 1, #self do
384
+ if callbackfn(thisArg, self[i], i - 1, self) then
385
+ return true
405
386
  end
406
387
  end
407
388
  return false
408
389
  end
409
390
 
410
- local function __TS__ArraySplice(list, ...)
411
- local len = #list
391
+ local function __TS__ArraySplice(self, ...)
392
+ local args = {...}
393
+ local len = #self
412
394
  local actualArgumentCount = select("#", ...)
413
- local start = select(1, ...)
414
- local deleteCount = select(2, ...)
415
- local actualStart
395
+ local start = args[1]
396
+ local deleteCount = args[2]
416
397
  if start < 0 then
417
- actualStart = math.max(len + start, 0)
418
- else
419
- actualStart = math.min(start, len)
398
+ start = len + start
399
+ if start < 0 then
400
+ start = 0
401
+ end
402
+ elseif start > len then
403
+ start = len
404
+ end
405
+ local itemCount = actualArgumentCount - 2
406
+ if itemCount < 0 then
407
+ itemCount = 0
420
408
  end
421
- local itemCount = math.max(actualArgumentCount - 2, 0)
422
409
  local actualDeleteCount
423
410
  if actualArgumentCount == 0 then
424
411
  actualDeleteCount = 0
425
412
  elseif actualArgumentCount == 1 then
426
- actualDeleteCount = len - actualStart
413
+ actualDeleteCount = len - start
427
414
  else
428
- actualDeleteCount = math.min(
429
- math.max(deleteCount or 0, 0),
430
- len - actualStart
431
- )
415
+ actualDeleteCount = deleteCount or 0
416
+ if actualDeleteCount < 0 then
417
+ actualDeleteCount = 0
418
+ end
419
+ if actualDeleteCount > len - start then
420
+ actualDeleteCount = len - start
421
+ end
432
422
  end
433
423
  local out = {}
434
- do
435
- local k = 0
436
- while k < actualDeleteCount do
437
- local from = actualStart + k
438
- if list[from + 1] then
439
- out[k + 1] = list[from + 1]
440
- end
441
- k = k + 1
424
+ for k = 1, actualDeleteCount do
425
+ local from = start + k
426
+ if self[from] ~= nil then
427
+ out[k] = self[from]
442
428
  end
443
429
  end
444
430
  if itemCount < actualDeleteCount then
445
- do
446
- local k = actualStart
447
- while k < len - actualDeleteCount do
448
- local from = k + actualDeleteCount
449
- local to = k + itemCount
450
- if list[from + 1] then
451
- list[to + 1] = list[from + 1]
452
- else
453
- list[to + 1] = nil
454
- end
455
- k = k + 1
431
+ for k = start + 1, len - actualDeleteCount do
432
+ local from = k + actualDeleteCount
433
+ local to = k + itemCount
434
+ if self[from] then
435
+ self[to] = self[from]
436
+ else
437
+ self[to] = nil
456
438
  end
457
439
  end
458
- do
459
- local k = len
460
- while k > len - actualDeleteCount + itemCount do
461
- list[k] = nil
462
- k = k - 1
463
- end
440
+ for k = len - actualDeleteCount + itemCount + 1, len do
441
+ self[k] = nil
464
442
  end
465
443
  elseif itemCount > actualDeleteCount then
466
- do
467
- local k = len - actualDeleteCount
468
- while k > actualStart do
469
- local from = k + actualDeleteCount - 1
470
- local to = k + itemCount - 1
471
- if list[from + 1] then
472
- list[to + 1] = list[from + 1]
473
- else
474
- list[to + 1] = nil
475
- end
476
- k = k - 1
444
+ for k = len - actualDeleteCount, start + 1, -1 do
445
+ local from = k + actualDeleteCount
446
+ local to = k + itemCount
447
+ if self[from] then
448
+ self[to] = self[from]
449
+ else
450
+ self[to] = nil
477
451
  end
478
452
  end
479
453
  end
480
- local j = actualStart
454
+ local j = start + 1
481
455
  for i = 3, actualArgumentCount do
482
- list[j + 1] = select(i, ...)
456
+ self[j] = args[i]
483
457
  j = j + 1
484
458
  end
485
- do
486
- local k = #list - 1
487
- while k >= len - actualDeleteCount + itemCount do
488
- list[k + 1] = nil
489
- k = k - 1
490
- end
459
+ for k = #self, len - actualDeleteCount + itemCount + 1, -1 do
460
+ self[k] = nil
491
461
  end
492
462
  return out
493
463
  end
494
464
 
495
- local function __TS__ArrayToObject(array)
465
+ local function __TS__ArrayToObject(self)
496
466
  local object = {}
497
- do
498
- local i = 0
499
- while i < #array do
500
- object[i] = array[i + 1]
501
- i = i + 1
502
- end
467
+ for i = 1, #self do
468
+ object[i - 1] = self[i]
503
469
  end
504
470
  return object
505
471
  end
506
472
 
507
- local function __TS__ArrayFlat(array, depth)
473
+ local function __TS__ArrayFlat(self, depth)
508
474
  if depth == nil then
509
475
  depth = 1
510
476
  end
511
477
  local result = {}
512
- for ____, value in ipairs(array) do
478
+ local len = 0
479
+ for i = 1, #self do
480
+ local value = self[i]
513
481
  if depth > 0 and __TS__ArrayIsArray(value) then
514
- result = __TS__ArrayConcat(
515
- result,
516
- __TS__ArrayFlat(value, depth - 1)
517
- )
482
+ local toAdd
483
+ if depth == 1 then
484
+ toAdd = value
485
+ else
486
+ toAdd = __TS__ArrayFlat(value, depth - 1)
487
+ end
488
+ for j = 1, #toAdd do
489
+ local val = toAdd[j]
490
+ len = len + 1
491
+ result[len] = val
492
+ end
518
493
  else
519
- result[#result + 1] = value
494
+ len = len + 1
495
+ result[len] = value
520
496
  end
521
497
  end
522
498
  return result
523
499
  end
524
500
 
525
- local function __TS__ArrayFlatMap(array, callback)
501
+ local function __TS__ArrayFlatMap(self, callback, thisArg)
526
502
  local result = {}
527
- do
528
- local i = 0
529
- while i < #array do
530
- local value = callback(nil, array[i + 1], i, array)
531
- if type(value) == "table" and __TS__ArrayIsArray(value) then
532
- result = __TS__ArrayConcat(result, value)
533
- else
534
- result[#result + 1] = value
503
+ local len = 0
504
+ for i = 1, #self do
505
+ local value = callback(thisArg, self[i], i - 1, self)
506
+ if __TS__ArrayIsArray(value) then
507
+ for j = 1, #value do
508
+ len = len + 1
509
+ result[len] = value[j]
535
510
  end
536
- i = i + 1
511
+ else
512
+ len = len + 1
513
+ result[len] = value
537
514
  end
538
515
  end
539
516
  return result
540
517
  end
541
518
 
542
- local function __TS__ArraySetLength(arr, length)
519
+ local function __TS__ArraySetLength(self, length)
543
520
  if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then
544
521
  error(
545
522
  "invalid array length: " .. tostring(length),
546
523
  0
547
524
  )
548
525
  end
549
- do
550
- local i = #arr - 1
551
- while i >= length do
552
- arr[i + 1] = nil
553
- i = i - 1
554
- end
526
+ for i = length + 1, #self do
527
+ self[i] = nil
555
528
  end
556
529
  return length
557
530
  end
@@ -590,21 +563,15 @@ end
590
563
 
591
564
  local __TS__Unpack = table.unpack or unpack
592
565
 
593
- local function __TS__FunctionBind(fn, thisArg, ...)
566
+ local function __TS__FunctionBind(fn, ...)
594
567
  local boundArgs = {...}
595
568
  return function(____, ...)
596
569
  local args = {...}
597
- do
598
- local i = 0
599
- while i < #boundArgs do
600
- table.insert(args, i + 1, boundArgs[i + 1])
601
- i = i + 1
602
- end
603
- end
604
- return fn(
605
- thisArg,
606
- __TS__Unpack(args)
570
+ __TS__ArrayUnshift(
571
+ args,
572
+ __TS__Unpack(boundArgs)
607
573
  )
574
+ return fn(__TS__Unpack(args))
608
575
  end
609
576
  end
610
577
 
@@ -677,19 +644,19 @@ do
677
644
  local isRejected = self.state == 2
678
645
  if onFulfilled then
679
646
  local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
680
- __TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
647
+ local ____self_fulfilledCallbacks_1 = self.fulfilledCallbacks
648
+ ____self_fulfilledCallbacks_1[#____self_fulfilledCallbacks_1 + 1] = internalCallback
681
649
  if isFulfilled then
682
650
  internalCallback(nil, self.value)
683
651
  end
684
652
  else
685
- __TS__ArrayPush(
686
- self.fulfilledCallbacks,
687
- function() return resolve(nil, nil) end
688
- )
653
+ local ____self_fulfilledCallbacks_2 = self.fulfilledCallbacks
654
+ ____self_fulfilledCallbacks_2[#____self_fulfilledCallbacks_2 + 1] = function() return resolve(nil, nil) end
689
655
  end
690
656
  if onRejected then
691
657
  local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
692
- __TS__ArrayPush(self.rejectedCallbacks, internalCallback)
658
+ local ____self_rejectedCallbacks_3 = self.rejectedCallbacks
659
+ ____self_rejectedCallbacks_3[#____self_rejectedCallbacks_3 + 1] = internalCallback
693
660
  if isRejected then
694
661
  internalCallback(nil, self.rejectionReason)
695
662
  end
@@ -707,7 +674,8 @@ do
707
674
  end
708
675
  function __TS__Promise.prototype.finally(self, onFinally)
709
676
  if onFinally then
710
- __TS__ArrayPush(self.finallyCallbacks, onFinally)
677
+ local ____self_finallyCallbacks_4 = self.finallyCallbacks
678
+ ____self_finallyCallbacks_4[#____self_finallyCallbacks_4 + 1] = onFinally
711
679
  if self.state ~= 0 then
712
680
  onFinally(nil)
713
681
  end
@@ -903,17 +871,15 @@ local function __TS__CloneDescriptor(____bindingPattern0)
903
871
  return descriptor
904
872
  end
905
873
 
906
- local function __TS__ObjectAssign(to, ...)
874
+ local function __TS__ObjectAssign(target, ...)
907
875
  local sources = {...}
908
- if to == nil then
909
- return to
910
- end
911
- for ____, source in ipairs(sources) do
876
+ for i = 1, #sources do
877
+ local source = sources[i]
912
878
  for key in pairs(source) do
913
- to[key] = source[key]
879
+ target[key] = source[key]
914
880
  end
915
881
  end
916
- return to
882
+ return target
917
883
  end
918
884
 
919
885
  local function __TS__ObjectGetOwnPropertyDescriptor(object, key)
@@ -1528,8 +1494,10 @@ end
1528
1494
 
1529
1495
  local function __TS__ObjectEntries(obj)
1530
1496
  local result = {}
1497
+ local len = 0
1531
1498
  for key in pairs(obj) do
1532
- result[#result + 1] = {key, obj[key]}
1499
+ len = len + 1
1500
+ result[len] = {key, obj[key]}
1533
1501
  end
1534
1502
  return result
1535
1503
  end
@@ -1557,8 +1525,10 @@ end
1557
1525
 
1558
1526
  local function __TS__ObjectKeys(obj)
1559
1527
  local result = {}
1528
+ local len = 0
1560
1529
  for key in pairs(obj) do
1561
- result[#result + 1] = key
1530
+ len = len + 1
1531
+ result[len] = key
1562
1532
  end
1563
1533
  return result
1564
1534
  end
@@ -1575,8 +1545,10 @@ end
1575
1545
 
1576
1546
  local function __TS__ObjectValues(obj)
1577
1547
  local result = {}
1548
+ local len = 0
1578
1549
  for key in pairs(obj) do
1579
- result[#result + 1] = obj[key]
1550
+ len = len + 1
1551
+ result[len] = obj[key]
1580
1552
  end
1581
1553
  return result
1582
1554
  end
@@ -1776,9 +1748,9 @@ local function __TS__PromiseAny(iterable)
1776
1748
  if item.state == 1 then
1777
1749
  return __TS__Promise.resolve(item.value)
1778
1750
  elseif item.state == 2 then
1779
- __TS__ArrayPush(rejections, item.rejectionReason)
1751
+ rejections[#rejections + 1] = item.rejectionReason
1780
1752
  else
1781
- __TS__ArrayPush(pending, item)
1753
+ pending[#pending + 1] = item
1782
1754
  end
1783
1755
  else
1784
1756
  return __TS__Promise.resolve(item)
@@ -1798,7 +1770,7 @@ local function __TS__PromiseAny(iterable)
1798
1770
  resolve(nil, data)
1799
1771
  end,
1800
1772
  function(____, reason)
1801
- __TS__ArrayPush(rejections, reason)
1773
+ rejections[#rejections + 1] = reason
1802
1774
  numResolved = numResolved + 1
1803
1775
  if numResolved == #pending then
1804
1776
  reject(nil, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
@@ -1819,7 +1791,7 @@ local function __TS__PromiseRace(iterable)
1819
1791
  elseif item.state == 2 then
1820
1792
  return __TS__Promise.reject(item.rejectionReason)
1821
1793
  else
1822
- __TS__ArrayPush(pending, item)
1794
+ pending[#pending + 1] = item
1823
1795
  end
1824
1796
  else
1825
1797
  return __TS__Promise.resolve(item)
@@ -2124,16 +2096,14 @@ end
2124
2096
  local function __TS__Spread(iterable)
2125
2097
  local arr = {}
2126
2098
  if type(iterable) == "string" then
2127
- do
2128
- local i = 0
2129
- while i < #iterable do
2130
- arr[#arr + 1] = __TS__StringAccess(iterable, i)
2131
- i = i + 1
2132
- end
2099
+ for i = 0, #iterable - 1 do
2100
+ arr[i + 1] = __TS__StringAccess(iterable, i)
2133
2101
  end
2134
2102
  else
2103
+ local len = 0
2135
2104
  for ____, item in __TS__Iterator(iterable) do
2136
- arr[#arr + 1] = item
2105
+ len = len + 1
2106
+ arr[len] = item
2137
2107
  end
2138
2108
  end
2139
2109
  return __TS__Unpack(arr)
@@ -2159,15 +2129,6 @@ local function __TS__StringCharCodeAt(self, index)
2159
2129
  return string.byte(self, index + 1) or 0 / 0
2160
2130
  end
2161
2131
 
2162
- local function __TS__StringConcat(str1, ...)
2163
- local args = {...}
2164
- local out = str1
2165
- for ____, arg in ipairs(args) do
2166
- out = out .. arg
2167
- end
2168
- return out
2169
- end
2170
-
2171
2132
  local function __TS__StringEndsWith(self, searchString, endPosition)
2172
2133
  if endPosition == nil or endPosition > #self then
2173
2134
  endPosition = #self
@@ -2239,58 +2200,105 @@ local function __TS__StringPadStart(self, maxLength, fillString)
2239
2200
  ) .. self
2240
2201
  end
2241
2202
 
2242
- local function __TS__StringReplace(source, searchValue, replaceValue)
2243
- local startPos, endPos = string.find(source, searchValue, nil, true)
2244
- if not startPos then
2245
- return source
2246
- end
2203
+ local __TS__StringReplace
2204
+ do
2247
2205
  local sub = string.sub
2248
- local before = sub(source, 1, startPos - 1)
2249
- local ____temp_0
2250
- if type(replaceValue) == "string" then
2251
- ____temp_0 = replaceValue
2252
- else
2253
- ____temp_0 = replaceValue(nil, searchValue, startPos - 1, source)
2206
+ function __TS__StringReplace(source, searchValue, replaceValue)
2207
+ local startPos, endPos = string.find(source, searchValue, nil, true)
2208
+ if not startPos then
2209
+ return source
2210
+ end
2211
+ local before = sub(source, 1, startPos - 1)
2212
+ local ____temp_0
2213
+ if type(replaceValue) == "string" then
2214
+ ____temp_0 = replaceValue
2215
+ else
2216
+ ____temp_0 = replaceValue(nil, searchValue, startPos - 1, source)
2217
+ end
2218
+ local replacement = ____temp_0
2219
+ local after = sub(source, endPos + 1)
2220
+ return (before .. replacement) .. after
2254
2221
  end
2255
- local replacement = ____temp_0
2256
- local after = sub(source, endPos + 1)
2257
- return (before .. replacement) .. after
2258
2222
  end
2259
2223
 
2260
- local function __TS__StringReplaceAll(source, searchValue, replaceValue)
2261
- local replacer
2262
- if type(replaceValue) == "string" then
2263
- replacer = function() return replaceValue end
2264
- else
2265
- replacer = replaceValue
2224
+ local __TS__StringSplit
2225
+ do
2226
+ local sub = string.sub
2227
+ local find = string.find
2228
+ function __TS__StringSplit(source, separator, limit)
2229
+ if limit == nil then
2230
+ limit = 4294967295
2231
+ end
2232
+ if limit == 0 then
2233
+ return {}
2234
+ end
2235
+ local result = {}
2236
+ local resultIndex = 1
2237
+ if separator == nil or separator == "" then
2238
+ for i = 1, #source do
2239
+ result[resultIndex] = sub(source, i, i)
2240
+ resultIndex = resultIndex + 1
2241
+ end
2242
+ else
2243
+ local currentPos = 1
2244
+ while resultIndex <= limit do
2245
+ local startPos, endPos = find(source, separator, currentPos, true)
2246
+ if not startPos then
2247
+ break
2248
+ end
2249
+ result[resultIndex] = sub(source, currentPos, startPos - 1)
2250
+ resultIndex = resultIndex + 1
2251
+ currentPos = endPos + 1
2252
+ end
2253
+ if resultIndex <= limit then
2254
+ result[resultIndex] = sub(source, currentPos)
2255
+ end
2256
+ end
2257
+ return result
2266
2258
  end
2267
- local parts = {}
2268
- local partsIndex = 1
2259
+ end
2260
+
2261
+ local __TS__StringReplaceAll
2262
+ do
2269
2263
  local sub = string.sub
2270
- if #searchValue == 0 then
2271
- parts[1] = replacer(nil, "", 0, source)
2272
- partsIndex = 2
2273
- for i = 1, #source do
2274
- parts[partsIndex] = sub(source, i, i)
2275
- parts[partsIndex + 1] = replacer(nil, "", i, source)
2276
- partsIndex = partsIndex + 2
2264
+ local find = string.find
2265
+ function __TS__StringReplaceAll(source, searchValue, replaceValue)
2266
+ if type(replaceValue) == "string" then
2267
+ local concat = table.concat(
2268
+ __TS__StringSplit(source, searchValue),
2269
+ replaceValue
2270
+ )
2271
+ if #searchValue == 0 then
2272
+ return (replaceValue .. concat) .. replaceValue
2273
+ end
2274
+ return concat
2277
2275
  end
2278
- else
2279
- local find = string.find
2280
- local currentPos = 1
2281
- while true do
2282
- local startPos, endPos = find(source, searchValue, currentPos, true)
2283
- if not startPos then
2284
- break
2276
+ local parts = {}
2277
+ local partsIndex = 1
2278
+ if #searchValue == 0 then
2279
+ parts[1] = replaceValue(nil, "", 0, source)
2280
+ partsIndex = 2
2281
+ for i = 1, #source do
2282
+ parts[partsIndex] = sub(source, i, i)
2283
+ parts[partsIndex + 1] = replaceValue(nil, "", i, source)
2284
+ partsIndex = partsIndex + 2
2285
+ end
2286
+ else
2287
+ local currentPos = 1
2288
+ while true do
2289
+ local startPos, endPos = find(source, searchValue, currentPos, true)
2290
+ if not startPos then
2291
+ break
2292
+ end
2293
+ parts[partsIndex] = sub(source, currentPos, startPos - 1)
2294
+ parts[partsIndex + 1] = replaceValue(nil, searchValue, startPos - 1, source)
2295
+ partsIndex = partsIndex + 2
2296
+ currentPos = endPos + 1
2285
2297
  end
2286
- parts[partsIndex] = sub(source, currentPos, startPos - 1)
2287
- parts[partsIndex + 1] = replacer(nil, searchValue, startPos - 1, source)
2288
- partsIndex = partsIndex + 2
2289
- currentPos = endPos + 1
2298
+ parts[partsIndex] = sub(source, currentPos)
2290
2299
  end
2291
- parts[partsIndex] = sub(source, currentPos)
2300
+ return table.concat(parts)
2292
2301
  end
2293
- return table.concat(parts)
2294
2302
  end
2295
2303
 
2296
2304
  local function __TS__StringSlice(self, start, ____end)
@@ -2309,43 +2317,6 @@ local function __TS__StringSlice(self, start, ____end)
2309
2317
  return string.sub(self, start, ____end)
2310
2318
  end
2311
2319
 
2312
- local function __TS__StringSplit(source, separator, limit)
2313
- if limit == nil then
2314
- limit = 4294967295
2315
- end
2316
- if limit == 0 then
2317
- return {}
2318
- end
2319
- local out = {}
2320
- local index = 0
2321
- local count = 0
2322
- if separator == nil or separator == "" then
2323
- while index < #source - 1 and count < limit do
2324
- out[count + 1] = __TS__StringAccess(source, index)
2325
- count = count + 1
2326
- index = index + 1
2327
- end
2328
- else
2329
- local separatorLength = #separator
2330
- local nextIndex = (string.find(source, separator, nil, true) or 0) - 1
2331
- while nextIndex >= 0 and count < limit do
2332
- out[count + 1] = __TS__StringSubstring(source, index, nextIndex)
2333
- count = count + 1
2334
- index = nextIndex + separatorLength
2335
- nextIndex = (string.find(
2336
- source,
2337
- separator,
2338
- math.max(index + 1, 1),
2339
- true
2340
- ) or 0) - 1
2341
- end
2342
- end
2343
- if count < limit then
2344
- out[count + 1] = __TS__StringSubstring(source, index)
2345
- end
2346
- return out
2347
- end
2348
-
2349
2320
  local function __TS__StringStartsWith(self, searchString, position)
2350
2321
  if position == nil or position < 0 then
2351
2322
  position = 0
@@ -2412,10 +2383,10 @@ return {
2412
2383
  __TS__ArrayJoin = __TS__ArrayJoin,
2413
2384
  __TS__ArrayMap = __TS__ArrayMap,
2414
2385
  __TS__ArrayPush = __TS__ArrayPush,
2386
+ __TS__ArrayPushArray = __TS__ArrayPushArray,
2415
2387
  __TS__ArrayReduce = __TS__ArrayReduce,
2416
2388
  __TS__ArrayReduceRight = __TS__ArrayReduceRight,
2417
2389
  __TS__ArrayReverse = __TS__ArrayReverse,
2418
- __TS__ArrayShift = __TS__ArrayShift,
2419
2390
  __TS__ArrayUnshift = __TS__ArrayUnshift,
2420
2391
  __TS__ArraySort = __TS__ArraySort,
2421
2392
  __TS__ArraySlice = __TS__ArraySlice,
@@ -2481,7 +2452,6 @@ return {
2481
2452
  __TS__StringAccess = __TS__StringAccess,
2482
2453
  __TS__StringCharAt = __TS__StringCharAt,
2483
2454
  __TS__StringCharCodeAt = __TS__StringCharCodeAt,
2484
- __TS__StringConcat = __TS__StringConcat,
2485
2455
  __TS__StringEndsWith = __TS__StringEndsWith,
2486
2456
  __TS__StringIncludes = __TS__StringIncludes,
2487
2457
  __TS__StringPadEnd = __TS__StringPadEnd,