isaacscript-common 1.0.607 → 1.0.608-dev.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.
Files changed (122) hide show
  1. package/dist/callbacks/itemPickup.lua +3 -1
  2. package/dist/callbacks/postBombInitLate.lua +3 -1
  3. package/dist/callbacks/postCursedTeleport.lua +6 -4
  4. package/dist/callbacks/postEffectInitLate.lua +3 -1
  5. package/dist/callbacks/postFamiliarInitLate.lua +3 -1
  6. package/dist/callbacks/postGridEntity.lua +4 -1
  7. package/dist/callbacks/postKnifeInitLate.lua +3 -1
  8. package/dist/callbacks/postLaserInitLate.lua +3 -1
  9. package/dist/callbacks/postNPCInitLate.lua +3 -1
  10. package/dist/callbacks/postPickupCollect.lua +3 -1
  11. package/dist/callbacks/postPickupInitLate.lua +3 -1
  12. package/dist/callbacks/postPlayerChangeHealth.lua +3 -1
  13. package/dist/callbacks/postPlayerChangeType.lua +3 -1
  14. package/dist/callbacks/postPlayerFatalDamage.lua +3 -1
  15. package/dist/callbacks/postPlayerInitLate.lua +3 -1
  16. package/dist/callbacks/postPlayerReordered.lua +2 -1
  17. package/dist/callbacks/postProjectileInitLate.lua +3 -1
  18. package/dist/callbacks/postPurchase.lua +4 -1
  19. package/dist/callbacks/postSlotInitUpdate.lua +3 -1
  20. package/dist/callbacks/postSlotRenderBroken.lua +3 -1
  21. package/dist/callbacks/postTearInitLate.lua +3 -1
  22. package/dist/callbacks/postTearInitVeryLate.lua +3 -1
  23. package/dist/callbacks/postTransformation.lua +3 -1
  24. package/dist/callbacks/postTrinketBreak.lua +3 -1
  25. package/dist/callbacks/preBerserkDeath.lua +3 -3
  26. package/dist/callbacks/preNewLevel.lua +3 -1
  27. package/dist/callbacks/subscriptions/postBombInitLate.lua +2 -1
  28. package/dist/callbacks/subscriptions/postCursedTeleport.lua +2 -1
  29. package/dist/callbacks/subscriptions/postCustomRevive.lua +2 -1
  30. package/dist/callbacks/subscriptions/postEffectInitLate.lua +2 -1
  31. package/dist/callbacks/subscriptions/postEsauJr.lua +2 -1
  32. package/dist/callbacks/subscriptions/postFamiliarInitLate.lua +2 -1
  33. package/dist/callbacks/subscriptions/postFirstEsauJr.lua +2 -1
  34. package/dist/callbacks/subscriptions/postFirstFlip.lua +2 -1
  35. package/dist/callbacks/subscriptions/postFlip.lua +2 -1
  36. package/dist/callbacks/subscriptions/postGameStartedReordered.lua +2 -1
  37. package/dist/callbacks/subscriptions/postGridEntityInit.lua +2 -1
  38. package/dist/callbacks/subscriptions/postGridEntityRemove.lua +2 -1
  39. package/dist/callbacks/subscriptions/postGridEntityUpdate.lua +2 -1
  40. package/dist/callbacks/subscriptions/postItemPickup.lua +2 -1
  41. package/dist/callbacks/subscriptions/postKnifeInitLate.lua +2 -1
  42. package/dist/callbacks/subscriptions/postLaserInitLate.lua +2 -1
  43. package/dist/callbacks/subscriptions/postNPCInitLate.lua +2 -1
  44. package/dist/callbacks/subscriptions/postNewLevelReordered.lua +2 -1
  45. package/dist/callbacks/subscriptions/postNewRoomEarly.lua +2 -1
  46. package/dist/callbacks/subscriptions/postNewRoomReordered.lua +2 -1
  47. package/dist/callbacks/subscriptions/postPEffectUpdateReordered.lua +2 -1
  48. package/dist/callbacks/subscriptions/postPickupCollect.lua +2 -1
  49. package/dist/callbacks/subscriptions/postPickupInitLate.lua +2 -1
  50. package/dist/callbacks/subscriptions/postPlayerChangeHealth.lua +2 -1
  51. package/dist/callbacks/subscriptions/postPlayerChangeType.lua +2 -1
  52. package/dist/callbacks/subscriptions/postPlayerFatalDamage.lua +2 -1
  53. package/dist/callbacks/subscriptions/postPlayerInitLate.lua +2 -1
  54. package/dist/callbacks/subscriptions/postPlayerInitReordered.lua +2 -1
  55. package/dist/callbacks/subscriptions/postPlayerRenderReordered.lua +2 -1
  56. package/dist/callbacks/subscriptions/postPlayerUpdateReordered.lua +2 -1
  57. package/dist/callbacks/subscriptions/postProjectileInitLate.lua +2 -1
  58. package/dist/callbacks/subscriptions/postPurchase.lua +2 -1
  59. package/dist/callbacks/subscriptions/postSacrifice.lua +2 -1
  60. package/dist/callbacks/subscriptions/postSlotDestroyed.lua +2 -1
  61. package/dist/callbacks/subscriptions/postSlotInit.lua +2 -1
  62. package/dist/callbacks/subscriptions/postSlotRender.lua +2 -1
  63. package/dist/callbacks/subscriptions/postSlotUpdate.lua +2 -1
  64. package/dist/callbacks/subscriptions/postTearInitLate.lua +2 -1
  65. package/dist/callbacks/subscriptions/postTearInitVeryLate.lua +2 -1
  66. package/dist/callbacks/subscriptions/postTransformation.lua +2 -1
  67. package/dist/callbacks/subscriptions/postTrinketBreak.lua +2 -1
  68. package/dist/callbacks/subscriptions/preBerserkDeath.lua +2 -1
  69. package/dist/callbacks/subscriptions/preCustomRevive.lua +2 -1
  70. package/dist/callbacks/subscriptions/preItemPickup.lua +2 -1
  71. package/dist/callbacks/subscriptions/preNewLevel.lua +2 -1
  72. package/dist/constants.lua +3 -1
  73. package/dist/features/deployJSONRoom.lua +6 -1
  74. package/dist/features/getCollectibleItemPoolType.lua +3 -1
  75. package/dist/features/preventCollectibleRotate.lua +3 -1
  76. package/dist/features/runInNFrames.lua +3 -1
  77. package/dist/features/saveDataManager/exports.lua +2 -1
  78. package/dist/features/saveDataManager/load.lua +2 -1
  79. package/dist/features/saveDataManager/maps.lua +3 -1
  80. package/dist/features/saveDataManager/merge.lua +2 -1
  81. package/dist/features/sirenHelpers.lua +2 -1
  82. package/dist/functions/array.lua +8 -1
  83. package/dist/functions/cards.lua +2 -1
  84. package/dist/functions/collectibleSet.lua +3 -1
  85. package/dist/functions/deepCopy.lua +6 -1
  86. package/dist/functions/deepCopyTests.lua +5 -1
  87. package/dist/functions/doors.lua +4 -1
  88. package/dist/functions/entity.lua +7 -1
  89. package/dist/functions/globals.lua +5 -1
  90. package/dist/functions/gridEntity.lua +5 -1
  91. package/dist/functions/input.lua +5 -1
  92. package/dist/functions/jsonRoom.lua +3 -1
  93. package/dist/functions/log.lua +2 -1
  94. package/dist/functions/math.lua +2 -1
  95. package/dist/functions/npc.lua +5 -1
  96. package/dist/functions/pickups.lua +3 -1
  97. package/dist/functions/player.d.ts +8 -3
  98. package/dist/functions/player.lua +11 -3
  99. package/dist/functions/playerHealth.lua +2 -1
  100. package/dist/functions/pocketItems.lua +3 -1
  101. package/dist/functions/rooms.lua +7 -1
  102. package/dist/functions/sprite.lua +2 -1
  103. package/dist/functions/trinketSet.lua +3 -1
  104. package/dist/functions/util.lua +9 -1
  105. package/dist/lualib_bundle.lua +1158 -1027
  106. package/dist/maps/cardDescriptionMap.lua +3 -1
  107. package/dist/maps/cardNameMap.lua +3 -1
  108. package/dist/maps/challengeNameMap.lua +3 -1
  109. package/dist/maps/collectibleDescriptionMap.lua +3 -1
  110. package/dist/maps/collectibleNameMap.lua +3 -1
  111. package/dist/maps/gridEntityXMLMap.lua +3 -1
  112. package/dist/maps/pillEffectNameMap.lua +3 -1
  113. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.lua +3 -1
  114. package/dist/maps/transformationMaps.lua +6 -1
  115. package/dist/maps/transformationNameMap.lua +3 -1
  116. package/dist/maps/trinketDescriptionMap.lua +3 -1
  117. package/dist/maps/trinketNameMap.lua +3 -1
  118. package/dist/patchErrorFunctions.lua +4 -1
  119. package/dist/sets/cards.lua +3 -1
  120. package/dist/types/ModUpgraded.lua +4 -1
  121. package/dist/upgradeMod.lua +2 -1
  122. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- function __TS__ArrayIsArray(value)
1
+ local function __TS__ArrayIsArray(value)
2
2
  return type(value) == "table" and (value[1] ~= nil or next(value, nil) == nil)
3
3
  end
4
4
 
5
- function __TS__ArrayConcat(arr1, ...)
5
+ local function __TS__ArrayConcat(arr1, ...)
6
6
  local args = {...}
7
7
  local out = {}
8
8
  for ____, val in ipairs(arr1) do
@@ -21,7 +21,23 @@ function __TS__ArrayConcat(arr1, ...)
21
21
  return out
22
22
  end
23
23
 
24
- function __TS__ArrayEntries(array)
24
+ local __TS__Symbol, Symbol
25
+ do
26
+ local symbolMetatable = {__tostring = function(self)
27
+ return ("Symbol(" .. (self.description or "")) .. ")"
28
+ end}
29
+ function __TS__Symbol(description)
30
+ return setmetatable({description = description}, symbolMetatable)
31
+ end
32
+ Symbol = {
33
+ iterator = __TS__Symbol("Symbol.iterator"),
34
+ hasInstance = __TS__Symbol("Symbol.hasInstance"),
35
+ species = __TS__Symbol("Symbol.species"),
36
+ toStringTag = __TS__Symbol("Symbol.toStringTag")
37
+ }
38
+ end
39
+
40
+ local function __TS__ArrayEntries(array)
25
41
  local key = 0
26
42
  return {
27
43
  [Symbol.iterator] = function(self)
@@ -35,11 +51,11 @@ function __TS__ArrayEntries(array)
35
51
  }
36
52
  end
37
53
 
38
- function __TS__ArrayEvery(arr, callbackfn)
54
+ local function __TS__ArrayEvery(arr, callbackfn)
39
55
  do
40
56
  local i = 0
41
57
  while i < #arr do
42
- if not callbackfn(_G, arr[i + 1], i, arr) then
58
+ if not callbackfn(nil, arr[i + 1], i, arr) then
43
59
  return false
44
60
  end
45
61
  i = i + 1
@@ -48,12 +64,12 @@ function __TS__ArrayEvery(arr, callbackfn)
48
64
  return true
49
65
  end
50
66
 
51
- function __TS__ArrayFilter(arr, callbackfn)
67
+ local function __TS__ArrayFilter(arr, callbackfn)
52
68
  local result = {}
53
69
  do
54
70
  local i = 0
55
71
  while i < #arr do
56
- if callbackfn(_G, arr[i + 1], i, arr) then
72
+ if callbackfn(nil, arr[i + 1], i, arr) then
57
73
  result[#result + 1] = arr[i + 1]
58
74
  end
59
75
  i = i + 1
@@ -62,22 +78,12 @@ function __TS__ArrayFilter(arr, callbackfn)
62
78
  return result
63
79
  end
64
80
 
65
- function __TS__ArrayForEach(arr, callbackFn)
66
- do
67
- local i = 0
68
- while i < #arr do
69
- callbackFn(_G, arr[i + 1], i, arr)
70
- i = i + 1
71
- end
72
- end
73
- end
74
-
75
- function __TS__ArrayFind(arr, predicate)
81
+ local function __TS__ArrayFind(arr, predicate)
76
82
  local len = #arr
77
83
  local k = 0
78
84
  while k < len do
79
85
  local elem = arr[k + 1]
80
- if predicate(_G, elem, k, arr) then
86
+ if predicate(nil, elem, k, arr) then
81
87
  return elem
82
88
  end
83
89
  k = k + 1
@@ -85,12 +91,12 @@ function __TS__ArrayFind(arr, predicate)
85
91
  return nil
86
92
  end
87
93
 
88
- function __TS__ArrayFindIndex(arr, callbackFn)
94
+ local function __TS__ArrayFindIndex(arr, callbackFn)
89
95
  do
90
96
  local i = 0
91
97
  local len = #arr
92
98
  while i < len do
93
- if callbackFn(_G, arr[i + 1], i, arr) then
99
+ if callbackFn(nil, arr[i + 1], i, arr) then
94
100
  return i
95
101
  end
96
102
  i = i + 1
@@ -99,7 +105,52 @@ function __TS__ArrayFindIndex(arr, callbackFn)
99
105
  return -1
100
106
  end
101
107
 
102
- function __TS__ArrayIncludes(self, searchElement, fromIndex)
108
+ local function __TS__ArrayFlat(array, depth)
109
+ if depth == nil then
110
+ depth = 1
111
+ end
112
+ local result = {}
113
+ for ____, value in ipairs(array) do
114
+ if depth > 0 and __TS__ArrayIsArray(value) then
115
+ result = __TS__ArrayConcat(
116
+ result,
117
+ __TS__ArrayFlat(value, depth - 1)
118
+ )
119
+ else
120
+ result[#result + 1] = value
121
+ end
122
+ end
123
+ return result
124
+ end
125
+
126
+ local function __TS__ArrayFlatMap(array, callback)
127
+ local result = {}
128
+ do
129
+ local i = 0
130
+ while i < #array do
131
+ local value = callback(nil, array[i + 1], i, array)
132
+ if type(value) == "table" and __TS__ArrayIsArray(value) then
133
+ result = __TS__ArrayConcat(result, value)
134
+ else
135
+ result[#result + 1] = value
136
+ end
137
+ i = i + 1
138
+ end
139
+ end
140
+ return result
141
+ end
142
+
143
+ local function __TS__ArrayForEach(arr, callbackFn)
144
+ do
145
+ local i = 0
146
+ while i < #arr do
147
+ callbackFn(nil, arr[i + 1], i, arr)
148
+ i = i + 1
149
+ end
150
+ end
151
+ end
152
+
153
+ local function __TS__ArrayIncludes(self, searchElement, fromIndex)
103
154
  if fromIndex == nil then
104
155
  fromIndex = 0
105
156
  end
@@ -119,7 +170,7 @@ function __TS__ArrayIncludes(self, searchElement, fromIndex)
119
170
  return false
120
171
  end
121
172
 
122
- function __TS__ArrayIndexOf(arr, searchElement, fromIndex)
173
+ local function __TS__ArrayIndexOf(arr, searchElement, fromIndex)
123
174
  local len = #arr
124
175
  if len == 0 then
125
176
  return -1
@@ -152,7 +203,7 @@ function __TS__ArrayIndexOf(arr, searchElement, fromIndex)
152
203
  return -1
153
204
  end
154
205
 
155
- function __TS__ArrayJoin(self, separator)
206
+ local function __TS__ArrayJoin(self, separator)
156
207
  if separator == nil then
157
208
  separator = ","
158
209
  end
@@ -166,19 +217,19 @@ function __TS__ArrayJoin(self, separator)
166
217
  return result
167
218
  end
168
219
 
169
- function __TS__ArrayMap(arr, callbackfn)
220
+ local function __TS__ArrayMap(arr, callbackfn)
170
221
  local newArray = {}
171
222
  do
172
223
  local i = 0
173
224
  while i < #arr do
174
- newArray[i + 1] = callbackfn(_G, arr[i + 1], i, arr)
225
+ newArray[i + 1] = callbackfn(nil, arr[i + 1], i, arr)
175
226
  i = i + 1
176
227
  end
177
228
  end
178
229
  return newArray
179
230
  end
180
231
 
181
- function __TS__ArrayPush(arr, ...)
232
+ local function __TS__ArrayPush(arr, ...)
182
233
  local items = {...}
183
234
  for ____, item in ipairs(items) do
184
235
  arr[#arr + 1] = item
@@ -186,7 +237,7 @@ function __TS__ArrayPush(arr, ...)
186
237
  return #arr
187
238
  end
188
239
 
189
- function __TS__ArrayReduce(arr, callbackFn, ...)
240
+ local function __TS__ArrayReduce(arr, callbackFn, ...)
190
241
  local len = #arr
191
242
  local k = 0
192
243
  local accumulator = nil
@@ -200,7 +251,7 @@ function __TS__ArrayReduce(arr, callbackFn, ...)
200
251
  end
201
252
  for i = k, len - 1 do
202
253
  accumulator = callbackFn(
203
- _G,
254
+ nil,
204
255
  accumulator,
205
256
  arr[i + 1],
206
257
  i,
@@ -210,7 +261,7 @@ function __TS__ArrayReduce(arr, callbackFn, ...)
210
261
  return accumulator
211
262
  end
212
263
 
213
- function __TS__ArrayReduceRight(arr, callbackFn, ...)
264
+ local function __TS__ArrayReduceRight(arr, callbackFn, ...)
214
265
  local len = #arr
215
266
  local k = len - 1
216
267
  local accumulator = nil
@@ -224,7 +275,7 @@ function __TS__ArrayReduceRight(arr, callbackFn, ...)
224
275
  end
225
276
  for i = k, 0, -1 do
226
277
  accumulator = callbackFn(
227
- _G,
278
+ nil,
228
279
  accumulator,
229
280
  arr[i + 1],
230
281
  i,
@@ -234,7 +285,7 @@ function __TS__ArrayReduceRight(arr, callbackFn, ...)
234
285
  return accumulator
235
286
  end
236
287
 
237
- function __TS__ArrayReverse(arr)
288
+ local function __TS__ArrayReverse(arr)
238
289
  local i = 0
239
290
  local j = #arr - 1
240
291
  while i < j do
@@ -247,35 +298,28 @@ function __TS__ArrayReverse(arr)
247
298
  return arr
248
299
  end
249
300
 
250
- function __TS__ArrayShift(arr)
251
- return table.remove(arr, 1)
252
- end
253
-
254
- function __TS__ArrayUnshift(arr, ...)
255
- local items = {...}
301
+ local function __TS__ArraySetLength(arr, length)
302
+ if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then
303
+ error(
304
+ "invalid array length: " .. tostring(length),
305
+ 0
306
+ )
307
+ end
256
308
  do
257
- local i = #items - 1
258
- while i >= 0 do
259
- table.insert(arr, 1, items[i + 1])
309
+ local i = #arr - 1
310
+ while i >= length do
311
+ arr[i + 1] = nil
260
312
  i = i - 1
261
313
  end
262
314
  end
263
- return #arr
315
+ return length
264
316
  end
265
317
 
266
- function __TS__ArraySort(arr, compareFn)
267
- if compareFn ~= nil then
268
- table.sort(
269
- arr,
270
- function(a, b) return compareFn(_G, a, b) < 0 end
271
- )
272
- else
273
- table.sort(arr)
274
- end
275
- return arr
318
+ local function __TS__ArrayShift(arr)
319
+ return table.remove(arr, 1)
276
320
  end
277
321
 
278
- function __TS__ArraySlice(list, first, last)
322
+ local function __TS__ArraySlice(list, first, last)
279
323
  local len = #list
280
324
  local relativeStart = first or 0
281
325
  local k
@@ -304,11 +348,11 @@ function __TS__ArraySlice(list, first, last)
304
348
  return out
305
349
  end
306
350
 
307
- function __TS__ArraySome(arr, callbackfn)
351
+ local function __TS__ArraySome(arr, callbackfn)
308
352
  do
309
353
  local i = 0
310
354
  while i < #arr do
311
- if callbackfn(_G, arr[i + 1], i, arr) then
355
+ if callbackfn(nil, arr[i + 1], i, arr) then
312
356
  return true
313
357
  end
314
358
  i = i + 1
@@ -317,7 +361,19 @@ function __TS__ArraySome(arr, callbackfn)
317
361
  return false
318
362
  end
319
363
 
320
- function __TS__ArraySplice(list, ...)
364
+ local function __TS__ArraySort(arr, compareFn)
365
+ if compareFn ~= nil then
366
+ table.sort(
367
+ arr,
368
+ function(a, b) return compareFn(nil, a, b) < 0 end
369
+ )
370
+ else
371
+ table.sort(arr)
372
+ end
373
+ return arr
374
+ end
375
+
376
+ local function __TS__ArraySplice(list, ...)
321
377
  local len = #list
322
378
  local actualArgumentCount = select("#", ...)
323
379
  local start = select(1, ...)
@@ -402,7 +458,7 @@ function __TS__ArraySplice(list, ...)
402
458
  return out
403
459
  end
404
460
 
405
- function __TS__ArrayToObject(array)
461
+ local function __TS__ArrayToObject(array)
406
462
  local object = {}
407
463
  do
408
464
  local i = 0
@@ -414,72 +470,25 @@ function __TS__ArrayToObject(array)
414
470
  return object
415
471
  end
416
472
 
417
- function __TS__ArrayFlat(array, depth)
418
- if depth == nil then
419
- depth = 1
420
- end
421
- local result = {}
422
- for ____, value in ipairs(array) do
423
- if depth > 0 and __TS__ArrayIsArray(value) then
424
- result = __TS__ArrayConcat(
425
- result,
426
- __TS__ArrayFlat(value, depth - 1)
427
- )
428
- else
429
- result[#result + 1] = value
430
- end
431
- end
432
- return result
433
- end
434
-
435
- function __TS__ArrayFlatMap(array, callback)
436
- local result = {}
437
- do
438
- local i = 0
439
- while i < #array do
440
- local value = callback(_G, array[i + 1], i, array)
441
- if type(value) == "table" and __TS__ArrayIsArray(value) then
442
- result = __TS__ArrayConcat(result, value)
443
- else
444
- result[#result + 1] = value
445
- end
446
- i = i + 1
447
- end
448
- end
449
- return result
450
- end
451
-
452
- function __TS__ArraySetLength(arr, length)
453
- if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then
454
- error(
455
- "invalid array length: " .. tostring(length),
456
- 0
457
- )
458
- end
473
+ local function __TS__ArrayUnshift(arr, ...)
474
+ local items = {...}
459
475
  do
460
- local i = #arr - 1
461
- while i >= length do
462
- arr[i + 1] = nil
476
+ local i = #items - 1
477
+ while i >= 0 do
478
+ table.insert(arr, 1, items[i + 1])
463
479
  i = i - 1
464
480
  end
465
481
  end
466
- return length
482
+ return #arr
467
483
  end
468
484
 
469
- ____symbolMetatable = {__tostring = function(self)
470
- return ("Symbol(" .. (self.description or "")) .. ")"
471
- end}
472
- function __TS__Symbol(description)
473
- return setmetatable({description = description}, ____symbolMetatable)
485
+ local function __TS__New(target, ...)
486
+ local instance = setmetatable({}, target.prototype)
487
+ instance:____constructor(...)
488
+ return instance
474
489
  end
475
- Symbol = {
476
- iterator = __TS__Symbol("Symbol.iterator"),
477
- hasInstance = __TS__Symbol("Symbol.hasInstance"),
478
- species = __TS__Symbol("Symbol.species"),
479
- toStringTag = __TS__Symbol("Symbol.toStringTag")
480
- }
481
490
 
482
- function __TS__InstanceOf(obj, classTbl)
491
+ local function __TS__InstanceOf(obj, classTbl)
483
492
  if type(classTbl) ~= "table" then
484
493
  error("Right-hand side of 'instanceof' is not an object", 0)
485
494
  end
@@ -498,22 +507,16 @@ function __TS__InstanceOf(obj, classTbl)
498
507
  return false
499
508
  end
500
509
 
501
- function __TS__New(target, ...)
502
- local instance = setmetatable({}, target.prototype)
503
- instance:____constructor(...)
504
- return instance
505
- end
506
-
507
- function __TS__Class(self)
510
+ local function __TS__Class(self)
508
511
  local c = {prototype = {}}
509
512
  c.prototype.__index = c.prototype
510
513
  c.prototype.constructor = c
511
514
  return c
512
515
  end
513
516
 
514
- __TS__Unpack = table.unpack or unpack
517
+ local __TS__Unpack = table.unpack or unpack
515
518
 
516
- function __TS__FunctionBind(fn, thisArg, ...)
519
+ local function __TS__FunctionBind(fn, thisArg, ...)
517
520
  local boundArgs = {...}
518
521
  return function(____, ...)
519
522
  local args = {...}
@@ -531,184 +534,180 @@ function __TS__FunctionBind(fn, thisArg, ...)
531
534
  end
532
535
  end
533
536
 
534
- __TS__PromiseState = __TS__PromiseState or ({})
535
- __TS__PromiseState.Pending = 0
536
- __TS__PromiseState[__TS__PromiseState.Pending] = "Pending"
537
- __TS__PromiseState.Fulfilled = 1
538
- __TS__PromiseState[__TS__PromiseState.Fulfilled] = "Fulfilled"
539
- __TS__PromiseState.Rejected = 2
540
- __TS__PromiseState[__TS__PromiseState.Rejected] = "Rejected"
541
- function __TS__PromiseDeferred(self)
542
- local resolve
543
- local reject
544
- local promise = __TS__New(
545
- __TS__Promise,
546
- function(____, res, rej)
547
- resolve = res
548
- reject = rej
549
- end
550
- )
551
- return {promise = promise, resolve = resolve, reject = reject}
552
- end
553
- function __TS__IsPromiseLike(self, thing)
554
- return __TS__InstanceOf(thing, __TS__Promise)
555
- end
556
- __TS__Promise = __TS__Class()
557
- __TS__Promise.name = "__TS__Promise"
558
- function __TS__Promise.prototype.____constructor(self, executor)
559
- self.state = __TS__PromiseState.Pending
560
- self.fulfilledCallbacks = {}
561
- self.rejectedCallbacks = {}
562
- self.finallyCallbacks = {}
563
- do
564
- local function ____catch(e)
565
- self:reject(e)
566
- end
567
- local ____try, ____hasReturned = pcall(function()
568
- executor(
569
- _G,
570
- __TS__FunctionBind(self.resolve, self),
571
- __TS__FunctionBind(self.reject, self)
572
- )
573
- end)
574
- if not ____try then
575
- ____catch(____hasReturned)
537
+ local __TS__Promise
538
+ do
539
+ local function promiseDeferred(self)
540
+ local resolve
541
+ local reject
542
+ local promise = __TS__New(
543
+ __TS__Promise,
544
+ function(____, res, rej)
545
+ resolve = res
546
+ reject = rej
547
+ end
548
+ )
549
+ return {promise = promise, resolve = resolve, reject = reject}
550
+ end
551
+ local function isPromiseLike(self, thing)
552
+ return __TS__InstanceOf(thing, __TS__Promise)
553
+ end
554
+ __TS__Promise = __TS__Class()
555
+ __TS__Promise.name = "__TS__Promise"
556
+ function __TS__Promise.prototype.____constructor(self, executor)
557
+ self.state = 0
558
+ self.fulfilledCallbacks = {}
559
+ self.rejectedCallbacks = {}
560
+ self.finallyCallbacks = {}
561
+ do
562
+ local function ____catch(e)
563
+ self:reject(e)
564
+ end
565
+ local ____try, ____hasReturned = pcall(function()
566
+ executor(
567
+ nil,
568
+ __TS__FunctionBind(self.resolve, self),
569
+ __TS__FunctionBind(self.reject, self)
570
+ )
571
+ end)
572
+ if not ____try then
573
+ ____catch(____hasReturned)
574
+ end
576
575
  end
577
576
  end
578
- end
579
- function __TS__Promise.resolve(data)
580
- local promise = __TS__New(
581
- __TS__Promise,
582
- function()
577
+ function __TS__Promise.resolve(data)
578
+ local promise = __TS__New(
579
+ __TS__Promise,
580
+ function()
581
+ end
582
+ )
583
+ promise.state = 1
584
+ promise.value = data
585
+ return promise
586
+ end
587
+ function __TS__Promise.reject(reason)
588
+ local promise = __TS__New(
589
+ __TS__Promise,
590
+ function()
591
+ end
592
+ )
593
+ promise.state = 2
594
+ promise.rejectionReason = reason
595
+ return promise
596
+ end
597
+ __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
598
+ local ____promiseDeferred_result_0 = promiseDeferred(nil)
599
+ local promise = ____promiseDeferred_result_0.promise
600
+ local resolve = ____promiseDeferred_result_0.resolve
601
+ local reject = ____promiseDeferred_result_0.reject
602
+ local isFulfilled = self.state == 1
603
+ local isRejected = self.state == 2
604
+ if onFulfilled then
605
+ local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
606
+ __TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
607
+ if isFulfilled then
608
+ internalCallback(nil, self.value)
609
+ end
610
+ else
611
+ __TS__ArrayPush(
612
+ self.fulfilledCallbacks,
613
+ function() return resolve(nil, nil) end
614
+ )
583
615
  end
584
- )
585
- promise.state = __TS__PromiseState.Fulfilled
586
- promise.value = data
587
- return promise
588
- end
589
- function __TS__Promise.reject(reason)
590
- local promise = __TS__New(
591
- __TS__Promise,
592
- function()
616
+ if onRejected then
617
+ local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
618
+ __TS__ArrayPush(self.rejectedCallbacks, internalCallback)
619
+ if isRejected then
620
+ internalCallback(nil, self.rejectionReason)
621
+ end
593
622
  end
594
- )
595
- promise.state = __TS__PromiseState.Rejected
596
- promise.rejectionReason = reason
597
- return promise
598
- end
599
- __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
600
- local ____TS__PromiseDeferred_result_0 = __TS__PromiseDeferred(_G)
601
- local promise = ____TS__PromiseDeferred_result_0.promise
602
- local resolve = ____TS__PromiseDeferred_result_0.resolve
603
- local reject = ____TS__PromiseDeferred_result_0.reject
604
- local isFulfilled = self.state == __TS__PromiseState.Fulfilled
605
- local isRejected = self.state == __TS__PromiseState.Rejected
606
- if onFulfilled then
607
- local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
608
- __TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
609
623
  if isFulfilled then
610
- internalCallback(_G, self.value)
624
+ resolve(nil, self.value)
611
625
  end
612
- else
613
- __TS__ArrayPush(
614
- self.fulfilledCallbacks,
615
- function() return resolve(_G, nil) end
616
- )
617
- end
618
- if onRejected then
619
- local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
620
- __TS__ArrayPush(self.rejectedCallbacks, internalCallback)
621
626
  if isRejected then
622
- internalCallback(_G, self.rejectionReason)
627
+ reject(nil, self.rejectionReason)
623
628
  end
629
+ return promise
624
630
  end
625
- if isFulfilled then
626
- resolve(_G, self.value)
627
- end
628
- if isRejected then
629
- reject(_G, self.rejectionReason)
631
+ function __TS__Promise.prototype.catch(self, onRejected)
632
+ return self["then"](self, nil, onRejected)
630
633
  end
631
- return promise
632
- end
633
- function __TS__Promise.prototype.catch(self, onRejected)
634
- return self["then"](self, nil, onRejected)
635
- end
636
- function __TS__Promise.prototype.finally(self, onFinally)
637
- if onFinally then
638
- __TS__ArrayPush(self.finallyCallbacks, onFinally)
639
- if self.state ~= __TS__PromiseState.Pending then
640
- onFinally(_G)
634
+ function __TS__Promise.prototype.finally(self, onFinally)
635
+ if onFinally then
636
+ __TS__ArrayPush(self.finallyCallbacks, onFinally)
637
+ if self.state ~= 0 then
638
+ onFinally(nil)
639
+ end
641
640
  end
641
+ return self
642
642
  end
643
- return self
644
- end
645
- function __TS__Promise.prototype.resolve(self, data)
646
- if __TS__InstanceOf(data, __TS__Promise) then
647
- data["then"](
648
- data,
649
- function(____, v) return self:resolve(v) end,
650
- function(____, err) return self:reject(err) end
651
- )
652
- return
653
- end
654
- if self.state == __TS__PromiseState.Pending then
655
- self.state = __TS__PromiseState.Fulfilled
656
- self.value = data
657
- for ____, callback in ipairs(self.fulfilledCallbacks) do
658
- callback(_G, data)
643
+ function __TS__Promise.prototype.resolve(self, data)
644
+ if __TS__InstanceOf(data, __TS__Promise) then
645
+ data["then"](
646
+ data,
647
+ function(____, v) return self:resolve(v) end,
648
+ function(____, err) return self:reject(err) end
649
+ )
650
+ return
659
651
  end
660
- for ____, callback in ipairs(self.finallyCallbacks) do
661
- callback(_G)
652
+ if self.state == 0 then
653
+ self.state = 1
654
+ self.value = data
655
+ for ____, callback in ipairs(self.fulfilledCallbacks) do
656
+ callback(nil, data)
657
+ end
658
+ for ____, callback in ipairs(self.finallyCallbacks) do
659
+ callback(nil)
660
+ end
662
661
  end
663
662
  end
664
- end
665
- function __TS__Promise.prototype.reject(self, reason)
666
- if self.state == __TS__PromiseState.Pending then
667
- self.state = __TS__PromiseState.Rejected
668
- self.rejectionReason = reason
669
- for ____, callback in ipairs(self.rejectedCallbacks) do
670
- callback(_G, reason)
671
- end
672
- for ____, callback in ipairs(self.finallyCallbacks) do
673
- callback(_G)
663
+ function __TS__Promise.prototype.reject(self, reason)
664
+ if self.state == 0 then
665
+ self.state = 2
666
+ self.rejectionReason = reason
667
+ for ____, callback in ipairs(self.rejectedCallbacks) do
668
+ callback(nil, reason)
669
+ end
670
+ for ____, callback in ipairs(self.finallyCallbacks) do
671
+ callback(nil)
672
+ end
674
673
  end
675
674
  end
676
- end
677
- function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
678
- return function(____, value)
679
- do
680
- local function ____catch(e)
681
- reject(_G, e)
682
- end
683
- local ____try, ____hasReturned = pcall(function()
684
- self:handleCallbackData(
685
- f(_G, value),
686
- resolve,
687
- reject
688
- )
689
- end)
690
- if not ____try then
691
- ____catch(____hasReturned)
675
+ function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
676
+ return function(____, value)
677
+ do
678
+ local function ____catch(e)
679
+ reject(nil, e)
680
+ end
681
+ local ____try, ____hasReturned = pcall(function()
682
+ self:handleCallbackData(
683
+ f(nil, value),
684
+ resolve,
685
+ reject
686
+ )
687
+ end)
688
+ if not ____try then
689
+ ____catch(____hasReturned)
690
+ end
692
691
  end
693
692
  end
694
693
  end
695
- end
696
- function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject)
697
- if __TS__IsPromiseLike(_G, data) then
698
- local nextpromise = data
699
- if nextpromise.state == __TS__PromiseState.Fulfilled then
700
- resolve(_G, nextpromise.value)
701
- elseif nextpromise.state == __TS__PromiseState.Rejected then
702
- reject(_G, nextpromise.rejectionReason)
694
+ function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject)
695
+ if isPromiseLike(nil, data) then
696
+ local nextpromise = data
697
+ if nextpromise.state == 1 then
698
+ resolve(nil, nextpromise.value)
699
+ elseif nextpromise.state == 2 then
700
+ reject(nil, nextpromise.rejectionReason)
701
+ else
702
+ data["then"](data, resolve, reject)
703
+ end
703
704
  else
704
- data["then"](data, resolve, reject)
705
+ resolve(nil, data)
705
706
  end
706
- else
707
- resolve(_G, data)
708
707
  end
709
708
  end
710
709
 
711
- function __TS__AsyncAwaiter(generator)
710
+ local function __TS__AsyncAwaiter(generator)
712
711
  return __TS__New(
713
712
  __TS__Promise,
714
713
  function(____, resolve, reject)
@@ -725,9 +724,9 @@ function __TS__AsyncAwaiter(generator)
725
724
  function fulfilled(self, value)
726
725
  local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine, value)
727
726
  if success then
728
- step(_G, resultOrError, errorOrErrorHandler)
727
+ step(nil, resultOrError, errorOrErrorHandler)
729
728
  else
730
- reject(_G, errorOrErrorHandler)
729
+ reject(nil, errorOrErrorHandler)
731
730
  end
732
731
  end
733
732
  function rejected(self, handler)
@@ -736,47 +735,47 @@ function __TS__AsyncAwaiter(generator)
736
735
  local success, hasReturnedOrError, returnedValue = pcall(handler, value)
737
736
  if success then
738
737
  if hasReturnedOrError then
739
- resolve(_G, returnedValue)
738
+ resolve(nil, returnedValue)
740
739
  else
741
- step(_G, hasReturnedOrError, handler)
740
+ step(nil, hasReturnedOrError, handler)
742
741
  end
743
742
  else
744
- reject(_G, hasReturnedOrError)
743
+ reject(nil, hasReturnedOrError)
745
744
  end
746
745
  end
747
746
  else
748
747
  return function(____, value)
749
- reject(_G, value)
748
+ reject(nil, value)
750
749
  end
751
750
  end
752
751
  end
753
752
  function step(self, result, errorHandler)
754
753
  if coroutine.status(asyncCoroutine) == "dead" then
755
- resolve(_G, result)
754
+ resolve(nil, result)
756
755
  else
757
- local ____self_1 = adopt(_G, result)
756
+ local ____self_1 = adopt(nil, result)
758
757
  ____self_1["then"](
759
758
  ____self_1,
760
759
  fulfilled,
761
- rejected(_G, errorHandler)
760
+ rejected(nil, errorHandler)
762
761
  )
763
762
  end
764
763
  end
765
764
  asyncCoroutine = coroutine.create(generator)
766
765
  local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine)
767
766
  if success then
768
- step(_G, resultOrError, errorOrErrorHandler)
767
+ step(nil, resultOrError, errorOrErrorHandler)
769
768
  else
770
- reject(_G, errorOrErrorHandler)
769
+ reject(nil, errorOrErrorHandler)
771
770
  end
772
771
  end
773
772
  )
774
773
  end
775
- function __TS__Await(errorHandler, thing)
774
+ local function __TS__Await(errorHandler, thing)
776
775
  return coroutine.yield(errorHandler, thing)
777
776
  end
778
777
 
779
- function __TS__ClassExtends(target, base)
778
+ local function __TS__ClassExtends(target, base)
780
779
  target.____super = base
781
780
  local staticMetatable = setmetatable({__index = base}, base)
782
781
  setmetatable(target, staticMetatable)
@@ -801,7 +800,7 @@ function __TS__ClassExtends(target, base)
801
800
  end
802
801
  end
803
802
 
804
- function __TS__CloneDescriptor(____bindingPattern0)
803
+ local function __TS__CloneDescriptor(____bindingPattern0)
805
804
  local value
806
805
  local writable
807
806
  local set
@@ -830,7 +829,7 @@ function __TS__CloneDescriptor(____bindingPattern0)
830
829
  return descriptor
831
830
  end
832
831
 
833
- function __TS__ObjectGetOwnPropertyDescriptor(object, key)
832
+ local function __TS__ObjectGetOwnPropertyDescriptor(object, key)
834
833
  local metatable = getmetatable(object)
835
834
  if not metatable then
836
835
  return
@@ -841,84 +840,87 @@ function __TS__ObjectGetOwnPropertyDescriptor(object, key)
841
840
  return rawget(metatable, "_descriptors")[key]
842
841
  end
843
842
 
844
- function ____descriptorIndex(self, key)
845
- local value = rawget(self, key)
846
- if value ~= nil then
847
- return value
848
- end
849
- local metatable = getmetatable(self)
850
- while metatable do
851
- local rawResult = rawget(metatable, key)
852
- if rawResult ~= nil then
853
- return rawResult
854
- end
855
- local descriptors = rawget(metatable, "_descriptors")
856
- if descriptors then
857
- local descriptor = descriptors[key]
858
- if descriptor then
859
- if descriptor.get then
860
- return descriptor.get(self)
843
+ local __TS__SetDescriptor
844
+ do
845
+ local function descriptorIndex(self, key)
846
+ local value = rawget(self, key)
847
+ if value ~= nil then
848
+ return value
849
+ end
850
+ local metatable = getmetatable(self)
851
+ while metatable do
852
+ local rawResult = rawget(metatable, key)
853
+ if rawResult ~= nil then
854
+ return rawResult
855
+ end
856
+ local descriptors = rawget(metatable, "_descriptors")
857
+ if descriptors then
858
+ local descriptor = descriptors[key]
859
+ if descriptor then
860
+ if descriptor.get then
861
+ return descriptor.get(self)
862
+ end
863
+ return descriptor.value
861
864
  end
862
- return descriptor.value
863
865
  end
864
- end
865
- metatable = getmetatable(metatable)
866
- end
867
- end
868
- function ____descriptorNewindex(self, key, value)
869
- local metatable = getmetatable(self)
870
- while metatable do
871
- local descriptors = rawget(metatable, "_descriptors")
872
- if descriptors then
873
- local descriptor = descriptors[key]
874
- if descriptor then
875
- if descriptor.set then
876
- descriptor.set(self, value)
877
- else
878
- if descriptor.writable == false then
879
- error(
880
- ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
881
- 0
882
- )
866
+ metatable = getmetatable(metatable)
867
+ end
868
+ end
869
+ local function descriptorNewIndex(self, key, value)
870
+ local metatable = getmetatable(self)
871
+ while metatable do
872
+ local descriptors = rawget(metatable, "_descriptors")
873
+ if descriptors then
874
+ local descriptor = descriptors[key]
875
+ if descriptor then
876
+ if descriptor.set then
877
+ descriptor.set(self, value)
878
+ else
879
+ if descriptor.writable == false then
880
+ error(
881
+ ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
882
+ 0
883
+ )
884
+ end
885
+ descriptor.value = value
883
886
  end
884
- descriptor.value = value
887
+ return
885
888
  end
886
- return
887
889
  end
890
+ metatable = getmetatable(metatable)
888
891
  end
889
- metatable = getmetatable(metatable)
890
- end
891
- rawset(self, key, value)
892
- end
893
- function __TS__SetDescriptor(target, key, desc, isPrototype)
894
- if isPrototype == nil then
895
- isPrototype = false
896
- end
897
- local ____isPrototype_0
898
- if isPrototype then
899
- ____isPrototype_0 = target
900
- else
901
- ____isPrototype_0 = getmetatable(target)
902
- end
903
- local metatable = ____isPrototype_0
904
- if not metatable then
905
- metatable = {}
906
- setmetatable(target, metatable)
907
- end
908
- local value = rawget(target, key)
909
- if value ~= nil then
910
- rawset(target, key, nil)
892
+ rawset(self, key, value)
911
893
  end
912
- if not rawget(metatable, "_descriptors") then
913
- metatable._descriptors = {}
894
+ function __TS__SetDescriptor(target, key, desc, isPrototype)
895
+ if isPrototype == nil then
896
+ isPrototype = false
897
+ end
898
+ local ____isPrototype_0
899
+ if isPrototype then
900
+ ____isPrototype_0 = target
901
+ else
902
+ ____isPrototype_0 = getmetatable(target)
903
+ end
904
+ local metatable = ____isPrototype_0
905
+ if not metatable then
906
+ metatable = {}
907
+ setmetatable(target, metatable)
908
+ end
909
+ local value = rawget(target, key)
910
+ if value ~= nil then
911
+ rawset(target, key, nil)
912
+ end
913
+ if not rawget(metatable, "_descriptors") then
914
+ metatable._descriptors = {}
915
+ end
916
+ local descriptor = __TS__CloneDescriptor(desc)
917
+ metatable._descriptors[key] = descriptor
918
+ metatable.__index = descriptorIndex
919
+ metatable.__newindex = descriptorNewIndex
914
920
  end
915
- local descriptor = __TS__CloneDescriptor(desc)
916
- metatable._descriptors[key] = descriptor
917
- metatable.__index = ____descriptorIndex
918
- metatable.__newindex = ____descriptorNewindex
919
921
  end
920
922
 
921
- function __TS__ObjectAssign(to, ...)
923
+ local function __TS__ObjectAssign(to, ...)
922
924
  local sources = {...}
923
925
  if to == nil then
924
926
  return to
@@ -931,7 +933,7 @@ function __TS__ObjectAssign(to, ...)
931
933
  return to
932
934
  end
933
935
 
934
- function __TS__Decorate(decorators, target, key, desc)
936
+ local function __TS__Decorate(decorators, target, key, desc)
935
937
  local result = target
936
938
  do
937
939
  local i = #decorators
@@ -940,11 +942,11 @@ function __TS__Decorate(decorators, target, key, desc)
940
942
  if decorator then
941
943
  local oldResult = result
942
944
  if key == nil then
943
- result = decorator(_G, result)
945
+ result = decorator(nil, result)
944
946
  elseif desc == true then
945
947
  local value = rawget(target, key)
946
948
  local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
947
- local desc = decorator(_G, target, key, descriptor) or descriptor
949
+ local desc = decorator(nil, target, key, descriptor) or descriptor
948
950
  local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
949
951
  if isSimpleValue then
950
952
  rawset(target, key, desc.value)
@@ -956,9 +958,9 @@ function __TS__Decorate(decorators, target, key, desc)
956
958
  )
957
959
  end
958
960
  elseif desc == false then
959
- result = decorator(_G, target, key, desc)
961
+ result = decorator(nil, target, key, desc)
960
962
  else
961
- result = decorator(_G, target, key)
963
+ result = decorator(nil, target, key)
962
964
  end
963
965
  result = result or oldResult
964
966
  end
@@ -968,124 +970,17 @@ function __TS__Decorate(decorators, target, key, desc)
968
970
  return result
969
971
  end
970
972
 
971
- function __TS__DecorateParam(paramIndex, decorator)
972
- return function(____, target, key) return decorator(_G, target, key, paramIndex) end
973
+ local function __TS__DecorateParam(paramIndex, decorator)
974
+ return function(____, target, key) return decorator(nil, target, key, paramIndex) end
973
975
  end
974
976
 
975
- function __TS__ObjectGetOwnPropertyDescriptors(object)
976
- local metatable = getmetatable(object)
977
- if not metatable then
978
- return {}
979
- end
980
- return rawget(metatable, "_descriptors") or ({})
981
- end
982
-
983
- function __TS__GetErrorStack(self, constructor)
984
- local level = 1
985
- while true do
986
- local info = debug.getinfo(level, "f")
987
- level = level + 1
988
- if not info then
989
- level = 1
990
- break
991
- elseif info.func == constructor then
992
- break
993
- end
994
- end
995
- return debug.traceback(nil, level)
996
- end
997
- function __TS__WrapErrorToString(self, getDescription)
998
- return function(self)
999
- local description = getDescription(self)
1000
- local caller = debug.getinfo(3, "f")
1001
- if _VERSION == "Lua 5.1" or caller and caller.func ~= error then
1002
- return description
1003
- else
1004
- return (tostring(description) .. "\n") .. self.stack
1005
- end
1006
- end
1007
- end
1008
- function __TS__InitErrorClass(self, Type, name)
1009
- Type.name = name
1010
- return setmetatable(
1011
- Type,
1012
- {__call = function(____, _self, message) return __TS__New(Type, message) end}
1013
- )
1014
- end
1015
- local ____TS__InitErrorClass_3 = __TS__InitErrorClass
1016
- local ____G_2 = _G
1017
- ____class_0 = __TS__Class()
1018
- ____class_0.name = ""
1019
- function ____class_0.prototype.____constructor(self, message)
1020
- if message == nil then
1021
- message = ""
1022
- end
1023
- self.message = message
1024
- self.name = "Error"
1025
- self.stack = __TS__GetErrorStack(_G, self.constructor.new)
1026
- local metatable = getmetatable(self)
1027
- if not metatable.__errorToStringPatched then
1028
- metatable.__errorToStringPatched = true
1029
- metatable.__tostring = __TS__WrapErrorToString(_G, metatable.__tostring)
1030
- end
1031
- end
1032
- function ____class_0.prototype.__tostring(self)
1033
- local ____temp_1
1034
- if self.message ~= "" then
1035
- ____temp_1 = (self.name .. ": ") .. self.message
1036
- else
1037
- ____temp_1 = self.name
1038
- end
1039
- return ____temp_1
1040
- end
1041
- Error = ____TS__InitErrorClass_3(____G_2, ____class_0, "Error")
1042
- for ____, errorName in ipairs({
1043
- "RangeError",
1044
- "ReferenceError",
1045
- "SyntaxError",
1046
- "TypeError",
1047
- "URIError"
1048
- }) do
1049
- local ____G_7 = _G
1050
- local ____TS__InitErrorClass_6 = __TS__InitErrorClass
1051
- local ____G_5 = _G
1052
- local ____class_4 = __TS__Class()
1053
- ____class_4.name = ____class_4.name
1054
- __TS__ClassExtends(____class_4, Error)
1055
- function ____class_4.prototype.____constructor(self, ...)
1056
- Error.prototype.____constructor(self, ...)
1057
- self.name = errorName
1058
- end
1059
- ____G_7[errorName] = ____TS__InitErrorClass_6(____G_5, ____class_4, errorName)
1060
- end
1061
-
1062
- function __TS__Delete(target, key)
1063
- local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
1064
- local descriptor = descriptors[key]
1065
- if descriptor then
1066
- if not descriptor.configurable then
1067
- error(
1068
- __TS__New(
1069
- TypeError,
1070
- ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
1071
- ),
1072
- 0
1073
- )
1074
- end
1075
- descriptors[key] = nil
1076
- return true
1077
- end
1078
- target[key] = nil
1079
- return true
1080
- end
1081
-
1082
- function __TS__StringAccess(self, index)
977
+ local function __TS__StringAccess(self, index)
1083
978
  if index >= 0 and index < #self then
1084
979
  return string.sub(self, index + 1, index + 1)
1085
980
  end
1086
981
  end
1087
982
 
1088
- function __TS__DelegatedYield(iterable)
983
+ local function __TS__DelegatedYield(iterable)
1089
984
  if type(iterable) == "string" then
1090
985
  for index = 0, #iterable - 1 do
1091
986
  coroutine.yield(__TS__StringAccess(iterable, index))
@@ -1120,222 +1015,336 @@ function __TS__DelegatedYield(iterable)
1120
1015
  end
1121
1016
  end
1122
1017
 
1123
- function __TS__GeneratorIterator(self)
1124
- return self
1018
+ local function __TS__ObjectGetOwnPropertyDescriptors(object)
1019
+ local metatable = getmetatable(object)
1020
+ if not metatable then
1021
+ return {}
1022
+ end
1023
+ return rawget(metatable, "_descriptors") or ({})
1125
1024
  end
1126
- function __TS__GeneratorNext(self, ...)
1127
- local co = self.____coroutine
1128
- if coroutine.status(co) == "dead" then
1129
- return {done = true}
1025
+
1026
+ local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
1027
+ do
1028
+ local function getErrorStack(self, constructor)
1029
+ local level = 1
1030
+ while true do
1031
+ local info = debug.getinfo(level, "f")
1032
+ level = level + 1
1033
+ if not info then
1034
+ level = 1
1035
+ break
1036
+ elseif info.func == constructor then
1037
+ break
1038
+ end
1039
+ end
1040
+ return debug.traceback(nil, level)
1130
1041
  end
1131
- local status, value = coroutine.resume(co, ...)
1132
- if not status then
1133
- error(value, 0)
1042
+ local function wrapErrorToString(self, getDescription)
1043
+ return function(self)
1044
+ local description = getDescription(self)
1045
+ local caller = debug.getinfo(3, "f")
1046
+ if _VERSION == "Lua 5.1" or caller and caller.func ~= error then
1047
+ return description
1048
+ else
1049
+ return (tostring(description) .. "\n") .. self.stack
1050
+ end
1051
+ end
1134
1052
  end
1135
- return {
1136
- value = value,
1137
- done = coroutine.status(co) == "dead"
1138
- }
1139
- end
1140
- function __TS__Generator(fn)
1141
- return function(...)
1142
- local args = {...}
1143
- local argsLength = select("#", ...)
1144
- return {
1145
- ____coroutine = coroutine.create(function() return fn((unpack or table.unpack)(args, 1, argsLength)) end),
1146
- [Symbol.iterator] = __TS__GeneratorIterator,
1147
- next = __TS__GeneratorNext
1148
- }
1053
+ local function initErrorClass(self, Type, name)
1054
+ Type.name = name
1055
+ return setmetatable(
1056
+ Type,
1057
+ {__call = function(____, _self, message) return __TS__New(Type, message) end}
1058
+ )
1149
1059
  end
1060
+ local ____initErrorClass_2 = initErrorClass
1061
+ local ____class_0 = __TS__Class()
1062
+ ____class_0.name = ""
1063
+ function ____class_0.prototype.____constructor(self, message)
1064
+ if message == nil then
1065
+ message = ""
1066
+ end
1067
+ self.message = message
1068
+ self.name = "Error"
1069
+ self.stack = getErrorStack(nil, self.constructor.new)
1070
+ local metatable = getmetatable(self)
1071
+ if not metatable.__errorToStringPatched then
1072
+ metatable.__errorToStringPatched = true
1073
+ metatable.__tostring = wrapErrorToString(nil, metatable.__tostring)
1074
+ end
1075
+ end
1076
+ function ____class_0.prototype.__tostring(self)
1077
+ local ____temp_1
1078
+ if self.message ~= "" then
1079
+ ____temp_1 = (self.name .. ": ") .. self.message
1080
+ else
1081
+ ____temp_1 = self.name
1082
+ end
1083
+ return ____temp_1
1084
+ end
1085
+ Error = ____initErrorClass_2(nil, ____class_0, "Error")
1086
+ local function createErrorClass(self, name)
1087
+ local ____initErrorClass_4 = initErrorClass
1088
+ local ____class_3 = __TS__Class()
1089
+ ____class_3.name = ____class_3.name
1090
+ __TS__ClassExtends(____class_3, Error)
1091
+ function ____class_3.prototype.____constructor(self, ...)
1092
+ ____class_3.____super.prototype.____constructor(self, ...)
1093
+ self.name = name
1094
+ end
1095
+ return ____initErrorClass_4(nil, ____class_3, name)
1096
+ end
1097
+ RangeError = createErrorClass(nil, "RangeError")
1098
+ ReferenceError = createErrorClass(nil, "ReferenceError")
1099
+ SyntaxError = createErrorClass(nil, "SyntaxError")
1100
+ TypeError = createErrorClass(nil, "TypeError")
1101
+ URIError = createErrorClass(nil, "URIError")
1150
1102
  end
1151
1103
 
1152
- function __TS__InstanceOfObject(value)
1153
- local valueType = type(value)
1154
- return valueType == "table" or valueType == "function"
1104
+ local function __TS__Delete(target, key)
1105
+ local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
1106
+ local descriptor = descriptors[key]
1107
+ if descriptor then
1108
+ if not descriptor.configurable then
1109
+ error(
1110
+ __TS__New(
1111
+ TypeError,
1112
+ ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
1113
+ ),
1114
+ 0
1115
+ )
1116
+ end
1117
+ descriptors[key] = nil
1118
+ return true
1119
+ end
1120
+ target[key] = nil
1121
+ return true
1155
1122
  end
1156
1123
 
1157
- function __TS__IteratorGeneratorStep(self)
1158
- local co = self.____coroutine
1159
- local status, value = coroutine.resume(co)
1160
- if not status then
1161
- error(value, 0)
1162
- end
1163
- if coroutine.status(co) == "dead" then
1164
- return
1124
+ local __TS__Generator
1125
+ do
1126
+ local function generatorIterator(self)
1127
+ return self
1165
1128
  end
1166
- return true, value
1167
- end
1168
- function __TS__IteratorIteratorStep(self)
1169
- local result = self:next()
1170
- if result.done then
1171
- return
1129
+ local function generatorNext(self, ...)
1130
+ local co = self.____coroutine
1131
+ if coroutine.status(co) == "dead" then
1132
+ return {done = true}
1133
+ end
1134
+ local status, value = coroutine.resume(co, ...)
1135
+ if not status then
1136
+ error(value, 0)
1137
+ end
1138
+ return {
1139
+ value = value,
1140
+ done = coroutine.status(co) == "dead"
1141
+ }
1172
1142
  end
1173
- return true, result.value
1174
- end
1175
- function __TS__IteratorStringStep(self, index)
1176
- index = index + 1
1177
- if index > #self then
1178
- return
1143
+ function __TS__Generator(fn)
1144
+ return function(...)
1145
+ local args = {...}
1146
+ local argsLength = select("#", ...)
1147
+ return {
1148
+ ____coroutine = coroutine.create(function() return fn((unpack or table.unpack)(args, 1, argsLength)) end),
1149
+ [Symbol.iterator] = generatorIterator,
1150
+ next = generatorNext
1151
+ }
1152
+ end
1179
1153
  end
1180
- return index, string.sub(self, index, index)
1181
1154
  end
1182
- function __TS__Iterator(iterable)
1183
- if type(iterable) == "string" then
1184
- return __TS__IteratorStringStep, iterable, 0
1185
- elseif iterable.____coroutine ~= nil then
1186
- return __TS__IteratorGeneratorStep, iterable
1187
- elseif iterable[Symbol.iterator] then
1188
- local iterator = iterable[Symbol.iterator](iterable)
1189
- return __TS__IteratorIteratorStep, iterator
1190
- else
1191
- return ipairs(iterable)
1192
- end
1155
+
1156
+ local function __TS__InstanceOfObject(value)
1157
+ local valueType = type(value)
1158
+ return valueType == "table" or valueType == "function"
1193
1159
  end
1194
1160
 
1195
- Map = __TS__Class()
1196
- Map.name = "Map"
1197
- function Map.prototype.____constructor(self, entries)
1198
- self[Symbol.toStringTag] = "Map"
1199
- self.items = {}
1200
- self.size = 0
1201
- self.nextKey = {}
1202
- self.previousKey = {}
1203
- if entries == nil then
1204
- return
1161
+ local __TS__Iterator
1162
+ do
1163
+ local function iteratorGeneratorStep(self)
1164
+ local co = self.____coroutine
1165
+ local status, value = coroutine.resume(co)
1166
+ if not status then
1167
+ error(value, 0)
1168
+ end
1169
+ if coroutine.status(co) == "dead" then
1170
+ return
1171
+ end
1172
+ return true, value
1205
1173
  end
1206
- local iterable = entries
1207
- if iterable[Symbol.iterator] then
1208
- local iterator = iterable[Symbol.iterator](iterable)
1209
- while true do
1210
- local result = iterator:next()
1211
- if result.done then
1212
- break
1213
- end
1214
- local value = result.value
1215
- self:set(value[1], value[2])
1174
+ local function iteratorIteratorStep(self)
1175
+ local result = self:next()
1176
+ if result.done then
1177
+ return
1216
1178
  end
1217
- else
1218
- local array = entries
1219
- for ____, kvp in ipairs(array) do
1220
- self:set(kvp[1], kvp[2])
1221
- end
1222
- end
1223
- end
1224
- function Map.prototype.clear(self)
1225
- self.items = {}
1226
- self.nextKey = {}
1227
- self.previousKey = {}
1228
- self.firstKey = nil
1229
- self.lastKey = nil
1230
- self.size = 0
1231
- end
1232
- function Map.prototype.delete(self, key)
1233
- local contains = self:has(key)
1234
- if contains then
1235
- self.size = self.size - 1
1236
- local next = self.nextKey[key]
1237
- local previous = self.previousKey[key]
1238
- if next and previous then
1239
- self.nextKey[previous] = next
1240
- self.previousKey[next] = previous
1241
- elseif next then
1242
- self.firstKey = next
1243
- self.previousKey[next] = nil
1244
- elseif previous then
1245
- self.lastKey = previous
1246
- self.nextKey[previous] = nil
1179
+ return true, result.value
1180
+ end
1181
+ local function iteratorStringStep(self, index)
1182
+ index = index + 1
1183
+ if index > #self then
1184
+ return
1185
+ end
1186
+ return index, string.sub(self, index, index)
1187
+ end
1188
+ function __TS__Iterator(iterable)
1189
+ if type(iterable) == "string" then
1190
+ return iteratorStringStep, iterable, 0
1191
+ elseif iterable.____coroutine ~= nil then
1192
+ return iteratorGeneratorStep, iterable
1193
+ elseif iterable[Symbol.iterator] then
1194
+ local iterator = iterable[Symbol.iterator](iterable)
1195
+ return iteratorIteratorStep, iterator
1196
+ else
1197
+ return ipairs(iterable)
1198
+ end
1199
+ end
1200
+ end
1201
+
1202
+ local Map
1203
+ do
1204
+ Map = __TS__Class()
1205
+ Map.name = "Map"
1206
+ function Map.prototype.____constructor(self, entries)
1207
+ self[Symbol.toStringTag] = "Map"
1208
+ self.items = {}
1209
+ self.size = 0
1210
+ self.nextKey = {}
1211
+ self.previousKey = {}
1212
+ if entries == nil then
1213
+ return
1214
+ end
1215
+ local iterable = entries
1216
+ if iterable[Symbol.iterator] then
1217
+ local iterator = iterable[Symbol.iterator](iterable)
1218
+ while true do
1219
+ local result = iterator:next()
1220
+ if result.done then
1221
+ break
1222
+ end
1223
+ local value = result.value
1224
+ self:set(value[1], value[2])
1225
+ end
1247
1226
  else
1248
- self.firstKey = nil
1249
- self.lastKey = nil
1227
+ local array = entries
1228
+ for ____, kvp in ipairs(array) do
1229
+ self:set(kvp[1], kvp[2])
1230
+ end
1250
1231
  end
1251
- self.nextKey[key] = nil
1252
- self.previousKey[key] = nil
1253
1232
  end
1254
- self.items[key] = nil
1255
- return contains
1256
- end
1257
- function Map.prototype.forEach(self, callback)
1258
- for ____, key in __TS__Iterator(self:keys()) do
1259
- callback(_G, self.items[key], key, self)
1233
+ function Map.prototype.clear(self)
1234
+ self.items = {}
1235
+ self.nextKey = {}
1236
+ self.previousKey = {}
1237
+ self.firstKey = nil
1238
+ self.lastKey = nil
1239
+ self.size = 0
1240
+ end
1241
+ function Map.prototype.delete(self, key)
1242
+ local contains = self:has(key)
1243
+ if contains then
1244
+ self.size = self.size - 1
1245
+ local next = self.nextKey[key]
1246
+ local previous = self.previousKey[key]
1247
+ if next and previous then
1248
+ self.nextKey[previous] = next
1249
+ self.previousKey[next] = previous
1250
+ elseif next then
1251
+ self.firstKey = next
1252
+ self.previousKey[next] = nil
1253
+ elseif previous then
1254
+ self.lastKey = previous
1255
+ self.nextKey[previous] = nil
1256
+ else
1257
+ self.firstKey = nil
1258
+ self.lastKey = nil
1259
+ end
1260
+ self.nextKey[key] = nil
1261
+ self.previousKey[key] = nil
1262
+ end
1263
+ self.items[key] = nil
1264
+ return contains
1260
1265
  end
1261
- end
1262
- function Map.prototype.get(self, key)
1263
- return self.items[key]
1264
- end
1265
- function Map.prototype.has(self, key)
1266
- return self.nextKey[key] ~= nil or self.lastKey == key
1267
- end
1268
- function Map.prototype.set(self, key, value)
1269
- local isNewValue = not self:has(key)
1270
- if isNewValue then
1271
- self.size = self.size + 1
1266
+ function Map.prototype.forEach(self, callback)
1267
+ for ____, key in __TS__Iterator(self:keys()) do
1268
+ callback(nil, self.items[key], key, self)
1269
+ end
1272
1270
  end
1273
- self.items[key] = value
1274
- if self.firstKey == nil then
1275
- self.firstKey = key
1276
- self.lastKey = key
1277
- elseif isNewValue then
1278
- self.nextKey[self.lastKey] = key
1279
- self.previousKey[key] = self.lastKey
1280
- self.lastKey = key
1271
+ function Map.prototype.get(self, key)
1272
+ return self.items[key]
1281
1273
  end
1282
- return self
1283
- end
1284
- Map.prototype[Symbol.iterator] = function(self)
1285
- return self:entries()
1286
- end
1287
- function Map.prototype.entries(self)
1288
- local ____temp_0 = self
1289
- local items = ____temp_0.items
1290
- local nextKey = ____temp_0.nextKey
1291
- local key = self.firstKey
1292
- return {
1293
- [Symbol.iterator] = function(self)
1294
- return self
1295
- end,
1296
- next = function(self)
1297
- local result = {done = not key, value = {key, items[key]}}
1298
- key = nextKey[key]
1299
- return result
1300
- end
1301
- }
1302
- end
1303
- function Map.prototype.keys(self)
1304
- local nextKey = self.nextKey
1305
- local key = self.firstKey
1306
- return {
1307
- [Symbol.iterator] = function(self)
1308
- return self
1309
- end,
1310
- next = function(self)
1311
- local result = {done = not key, value = key}
1312
- key = nextKey[key]
1313
- return result
1274
+ function Map.prototype.has(self, key)
1275
+ return self.nextKey[key] ~= nil or self.lastKey == key
1276
+ end
1277
+ function Map.prototype.set(self, key, value)
1278
+ local isNewValue = not self:has(key)
1279
+ if isNewValue then
1280
+ self.size = self.size + 1
1314
1281
  end
1315
- }
1316
- end
1317
- function Map.prototype.values(self)
1318
- local ____temp_1 = self
1319
- local items = ____temp_1.items
1320
- local nextKey = ____temp_1.nextKey
1321
- local key = self.firstKey
1322
- return {
1323
- [Symbol.iterator] = function(self)
1324
- return self
1325
- end,
1326
- next = function(self)
1327
- local result = {done = not key, value = items[key]}
1328
- key = nextKey[key]
1329
- return result
1282
+ self.items[key] = value
1283
+ if self.firstKey == nil then
1284
+ self.firstKey = key
1285
+ self.lastKey = key
1286
+ elseif isNewValue then
1287
+ self.nextKey[self.lastKey] = key
1288
+ self.previousKey[key] = self.lastKey
1289
+ self.lastKey = key
1330
1290
  end
1331
- }
1291
+ return self
1292
+ end
1293
+ Map.prototype[Symbol.iterator] = function(self)
1294
+ return self:entries()
1295
+ end
1296
+ function Map.prototype.entries(self)
1297
+ local ____temp_0 = self
1298
+ local items = ____temp_0.items
1299
+ local nextKey = ____temp_0.nextKey
1300
+ local key = self.firstKey
1301
+ return {
1302
+ [Symbol.iterator] = function(self)
1303
+ return self
1304
+ end,
1305
+ next = function(self)
1306
+ local result = {done = not key, value = {key, items[key]}}
1307
+ key = nextKey[key]
1308
+ return result
1309
+ end
1310
+ }
1311
+ end
1312
+ function Map.prototype.keys(self)
1313
+ local nextKey = self.nextKey
1314
+ local key = self.firstKey
1315
+ return {
1316
+ [Symbol.iterator] = function(self)
1317
+ return self
1318
+ end,
1319
+ next = function(self)
1320
+ local result = {done = not key, value = key}
1321
+ key = nextKey[key]
1322
+ return result
1323
+ end
1324
+ }
1325
+ end
1326
+ function Map.prototype.values(self)
1327
+ local ____temp_1 = self
1328
+ local items = ____temp_1.items
1329
+ local nextKey = ____temp_1.nextKey
1330
+ local key = self.firstKey
1331
+ return {
1332
+ [Symbol.iterator] = function(self)
1333
+ return self
1334
+ end,
1335
+ next = function(self)
1336
+ local result = {done = not key, value = items[key]}
1337
+ key = nextKey[key]
1338
+ return result
1339
+ end
1340
+ }
1341
+ end
1342
+ Map[Symbol.species] = Map
1332
1343
  end
1333
- Map[Symbol.species] = Map
1334
- Map = Map
1335
1344
 
1336
- __TS__MathAtan2 = math.atan2 or math.atan
1345
+ local __TS__MathAtan2 = math.atan2 or math.atan
1337
1346
 
1338
- function __TS__MathSign(val)
1347
+ local function __TS__MathSign(val)
1339
1348
  if val > 0 then
1340
1349
  return 1
1341
1350
  elseif val < 0 then
@@ -1344,7 +1353,7 @@ function __TS__MathSign(val)
1344
1353
  return 0
1345
1354
  end
1346
1355
 
1347
- function __TS__Number(value)
1356
+ local function __TS__Number(value)
1348
1357
  local valueType = type(value)
1349
1358
  if valueType == "number" then
1350
1359
  return value
@@ -1371,57 +1380,60 @@ function __TS__Number(value)
1371
1380
  end
1372
1381
  end
1373
1382
 
1374
- function __TS__NumberIsFinite(value)
1383
+ local function __TS__NumberIsFinite(value)
1375
1384
  return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
1376
1385
  end
1377
1386
 
1378
- function __TS__NumberIsNaN(value)
1387
+ local function __TS__NumberIsNaN(value)
1379
1388
  return value ~= value
1380
1389
  end
1381
1390
 
1382
- ____radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
1383
- function __TS__NumberToString(self, radix)
1384
- if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then
1385
- return tostring(self)
1386
- end
1387
- radix = math.floor(radix)
1388
- if radix < 2 or radix > 36 then
1389
- error("toString() radix argument must be between 2 and 36", 0)
1390
- end
1391
- local integer, fraction = math.modf(math.abs(self))
1392
- local result = ""
1393
- if radix == 8 then
1394
- result = string.format("%o", integer)
1395
- elseif radix == 16 then
1396
- result = string.format("%x", integer)
1397
- else
1398
- repeat
1399
- do
1400
- result = __TS__StringAccess(____radixChars, integer % radix) .. result
1401
- integer = math.floor(integer / radix)
1402
- end
1403
- until not (integer ~= 0)
1404
- end
1405
- if fraction ~= 0 then
1406
- result = result .. "."
1407
- local delta = 1e-16
1408
- repeat
1409
- do
1410
- fraction = fraction * radix
1411
- delta = delta * radix
1412
- local digit = math.floor(fraction)
1413
- result = result .. __TS__StringAccess(____radixChars, digit)
1414
- fraction = fraction - digit
1415
- end
1416
- until not (fraction >= delta)
1417
- end
1418
- if self < 0 then
1419
- result = "-" .. result
1391
+ local __TS__NumberToString
1392
+ do
1393
+ local radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
1394
+ function __TS__NumberToString(self, radix)
1395
+ if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then
1396
+ return tostring(self)
1397
+ end
1398
+ radix = math.floor(radix)
1399
+ if radix < 2 or radix > 36 then
1400
+ error("toString() radix argument must be between 2 and 36", 0)
1401
+ end
1402
+ local integer, fraction = math.modf(math.abs(self))
1403
+ local result = ""
1404
+ if radix == 8 then
1405
+ result = string.format("%o", integer)
1406
+ elseif radix == 16 then
1407
+ result = string.format("%x", integer)
1408
+ else
1409
+ repeat
1410
+ do
1411
+ result = __TS__StringAccess(radixChars, integer % radix) .. result
1412
+ integer = math.floor(integer / radix)
1413
+ end
1414
+ until not (integer ~= 0)
1415
+ end
1416
+ if fraction ~= 0 then
1417
+ result = result .. "."
1418
+ local delta = 1e-16
1419
+ repeat
1420
+ do
1421
+ fraction = fraction * radix
1422
+ delta = delta * radix
1423
+ local digit = math.floor(fraction)
1424
+ result = result .. __TS__StringAccess(radixChars, digit)
1425
+ fraction = fraction - digit
1426
+ end
1427
+ until not (fraction >= delta)
1428
+ end
1429
+ if self < 0 then
1430
+ result = "-" .. result
1431
+ end
1432
+ return result
1420
1433
  end
1421
- return result
1422
1434
  end
1423
1435
 
1424
- function __TS__ObjectDefineProperty(target, key, desc)
1436
+ local function __TS__ObjectDefineProperty(target, key, desc)
1425
1437
  local ____temp_0
1426
1438
  if type(key) == "number" then
1427
1439
  ____temp_0 = key + 1
@@ -1481,7 +1493,7 @@ function __TS__ObjectDefineProperty(target, key, desc)
1481
1493
  return target
1482
1494
  end
1483
1495
 
1484
- function __TS__ObjectEntries(obj)
1496
+ local function __TS__ObjectEntries(obj)
1485
1497
  local result = {}
1486
1498
  for key in pairs(obj) do
1487
1499
  result[#result + 1] = {key, obj[key]}
@@ -1489,7 +1501,7 @@ function __TS__ObjectEntries(obj)
1489
1501
  return result
1490
1502
  end
1491
1503
 
1492
- function __TS__ObjectFromEntries(entries)
1504
+ local function __TS__ObjectFromEntries(entries)
1493
1505
  local obj = {}
1494
1506
  local iterable = entries
1495
1507
  if iterable[Symbol.iterator] then
@@ -1510,7 +1522,7 @@ function __TS__ObjectFromEntries(entries)
1510
1522
  return obj
1511
1523
  end
1512
1524
 
1513
- function __TS__ObjectKeys(obj)
1525
+ local function __TS__ObjectKeys(obj)
1514
1526
  local result = {}
1515
1527
  for key in pairs(obj) do
1516
1528
  result[#result + 1] = key
@@ -1518,7 +1530,7 @@ function __TS__ObjectKeys(obj)
1518
1530
  return result
1519
1531
  end
1520
1532
 
1521
- function __TS__ObjectRest(target, usedProperties)
1533
+ local function __TS__ObjectRest(target, usedProperties)
1522
1534
  local result = {}
1523
1535
  for property in pairs(target) do
1524
1536
  if not usedProperties[property] then
@@ -1528,7 +1540,7 @@ function __TS__ObjectRest(target, usedProperties)
1528
1540
  return result
1529
1541
  end
1530
1542
 
1531
- function __TS__ObjectValues(obj)
1543
+ local function __TS__ObjectValues(obj)
1532
1544
  local result = {}
1533
1545
  for key in pairs(obj) do
1534
1546
  result[#result + 1] = obj[key]
@@ -1536,7 +1548,7 @@ function __TS__ObjectValues(obj)
1536
1548
  return result
1537
1549
  end
1538
1550
 
1539
- function __TS__ParseFloat(numberString)
1551
+ local function __TS__ParseFloat(numberString)
1540
1552
  local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
1541
1553
  if infinityMatch then
1542
1554
  local ____temp_0
@@ -1551,7 +1563,7 @@ function __TS__ParseFloat(numberString)
1551
1563
  return number or 0 / 0
1552
1564
  end
1553
1565
 
1554
- function __TS__StringSubstr(self, from, length)
1566
+ local function __TS__StringSubstr(self, from, length)
1555
1567
  if from ~= from then
1556
1568
  from = 0
1557
1569
  end
@@ -1567,7 +1579,7 @@ function __TS__StringSubstr(self, from, length)
1567
1579
  return string.sub(self, from, length)
1568
1580
  end
1569
1581
 
1570
- function __TS__StringSubstring(self, start, ____end)
1582
+ local function __TS__StringSubstring(self, start, ____end)
1571
1583
  if ____end ~= ____end then
1572
1584
  ____end = 0
1573
1585
  end
@@ -1585,57 +1597,60 @@ function __TS__StringSubstring(self, start, ____end)
1585
1597
  return string.sub(self, start, ____end)
1586
1598
  end
1587
1599
 
1588
- __TS__parseInt_base_pattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
1589
- function __TS__ParseInt(numberString, base)
1590
- if base == nil then
1591
- base = 10
1592
- local hexMatch = string.match(numberString, "^%s*-?0[xX]")
1593
- if hexMatch then
1594
- base = 16
1595
- local ____string_match_result__0_0
1596
- if string.match(hexMatch, "-") then
1597
- ____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1598
- else
1599
- ____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1600
+ local __TS__ParseInt
1601
+ do
1602
+ local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
1603
+ function __TS__ParseInt(numberString, base)
1604
+ if base == nil then
1605
+ base = 10
1606
+ local hexMatch = string.match(numberString, "^%s*-?0[xX]")
1607
+ if hexMatch then
1608
+ base = 16
1609
+ local ____string_match_result__0_0
1610
+ if string.match(hexMatch, "-") then
1611
+ ____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1612
+ else
1613
+ ____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1614
+ end
1615
+ numberString = ____string_match_result__0_0
1600
1616
  end
1601
- numberString = ____string_match_result__0_0
1602
1617
  end
1603
- end
1604
- if base < 2 or base > 36 then
1605
- return 0 / 0
1606
- end
1607
- local ____temp_1
1608
- if base <= 10 then
1609
- ____temp_1 = __TS__StringSubstring(__TS__parseInt_base_pattern, 0, base)
1610
- else
1611
- ____temp_1 = __TS__StringSubstr(__TS__parseInt_base_pattern, 0, 10 + 2 * (base - 10))
1612
- end
1613
- local allowedDigits = ____temp_1
1614
- local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1615
- local number = tonumber(
1616
- string.match(numberString, pattern),
1617
- base
1618
- )
1619
- if number == nil then
1620
- return 0 / 0
1621
- end
1622
- if number >= 0 then
1623
- return math.floor(number)
1624
- else
1625
- return math.ceil(number)
1618
+ if base < 2 or base > 36 then
1619
+ return 0 / 0
1620
+ end
1621
+ local ____temp_1
1622
+ if base <= 10 then
1623
+ ____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, base)
1624
+ else
1625
+ ____temp_1 = __TS__StringSubstr(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1626
+ end
1627
+ local allowedDigits = ____temp_1
1628
+ local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1629
+ local number = tonumber(
1630
+ string.match(numberString, pattern),
1631
+ base
1632
+ )
1633
+ if number == nil then
1634
+ return 0 / 0
1635
+ end
1636
+ if number >= 0 then
1637
+ return math.floor(number)
1638
+ else
1639
+ return math.ceil(number)
1640
+ end
1626
1641
  end
1627
1642
  end
1628
1643
 
1629
- function __TS__PromiseAll(iterable)
1644
+ local function __TS__PromiseAll(iterable)
1630
1645
  local results = {}
1631
1646
  local toResolve = {}
1632
1647
  local numToResolve = 0
1633
1648
  local i = 0
1634
1649
  for ____, item in __TS__Iterator(iterable) do
1635
1650
  if __TS__InstanceOf(item, __TS__Promise) then
1636
- if item.state == __TS__PromiseState.Fulfilled then
1651
+ if item.state == 1 then
1637
1652
  results[i + 1] = item.value
1638
- elseif item.state == __TS__PromiseState.Rejected then
1653
+ elseif item.state == 2 then
1639
1654
  return __TS__Promise.reject(item.rejectionReason)
1640
1655
  else
1641
1656
  numToResolve = numToResolve + 1
@@ -1659,11 +1674,11 @@ function __TS__PromiseAll(iterable)
1659
1674
  results[index + 1] = data
1660
1675
  numToResolve = numToResolve - 1
1661
1676
  if numToResolve == 0 then
1662
- resolve(_G, results)
1677
+ resolve(nil, results)
1663
1678
  end
1664
1679
  end,
1665
1680
  function(____, reason)
1666
- reject(_G, reason)
1681
+ reject(nil, reason)
1667
1682
  end
1668
1683
  )
1669
1684
  end
@@ -1671,16 +1686,16 @@ function __TS__PromiseAll(iterable)
1671
1686
  )
1672
1687
  end
1673
1688
 
1674
- function __TS__PromiseAllSettled(iterable)
1689
+ local function __TS__PromiseAllSettled(iterable)
1675
1690
  local results = {}
1676
1691
  local toResolve = {}
1677
1692
  local numToResolve = 0
1678
1693
  local i = 0
1679
1694
  for ____, item in __TS__Iterator(iterable) do
1680
1695
  if __TS__InstanceOf(item, __TS__Promise) then
1681
- if item.state == __TS__PromiseState.Fulfilled then
1696
+ if item.state == 1 then
1682
1697
  results[i + 1] = {status = "fulfilled", value = item.value}
1683
- elseif item.state == __TS__PromiseState.Rejected then
1698
+ elseif item.state == 2 then
1684
1699
  results[i + 1] = {status = "rejected", reason = item.rejectionReason}
1685
1700
  else
1686
1701
  numToResolve = numToResolve + 1
@@ -1704,14 +1719,14 @@ function __TS__PromiseAllSettled(iterable)
1704
1719
  results[index + 1] = {status = "fulfilled", value = data}
1705
1720
  numToResolve = numToResolve - 1
1706
1721
  if numToResolve == 0 then
1707
- resolve(_G, results)
1722
+ resolve(nil, results)
1708
1723
  end
1709
1724
  end,
1710
1725
  function(____, reason)
1711
1726
  results[index + 1] = {status = "rejected", reason = reason}
1712
1727
  numToResolve = numToResolve - 1
1713
1728
  if numToResolve == 0 then
1714
- resolve(_G, results)
1729
+ resolve(nil, results)
1715
1730
  end
1716
1731
  end
1717
1732
  )
@@ -1720,14 +1735,14 @@ function __TS__PromiseAllSettled(iterable)
1720
1735
  )
1721
1736
  end
1722
1737
 
1723
- function __TS__PromiseAny(iterable)
1738
+ local function __TS__PromiseAny(iterable)
1724
1739
  local rejections = {}
1725
1740
  local pending = {}
1726
1741
  for ____, item in __TS__Iterator(iterable) do
1727
1742
  if __TS__InstanceOf(item, __TS__Promise) then
1728
- if item.state == __TS__PromiseState.Fulfilled then
1743
+ if item.state == 1 then
1729
1744
  return __TS__Promise.resolve(item.value)
1730
- elseif item.state == __TS__PromiseState.Rejected then
1745
+ elseif item.state == 2 then
1731
1746
  __TS__ArrayPush(rejections, item.rejectionReason)
1732
1747
  else
1733
1748
  __TS__ArrayPush(pending, item)
@@ -1747,13 +1762,13 @@ function __TS__PromiseAny(iterable)
1747
1762
  promise["then"](
1748
1763
  promise,
1749
1764
  function(____, data)
1750
- resolve(_G, data)
1765
+ resolve(nil, data)
1751
1766
  end,
1752
1767
  function(____, reason)
1753
1768
  __TS__ArrayPush(rejections, reason)
1754
1769
  numResolved = numResolved + 1
1755
1770
  if numResolved == #pending then
1756
- reject(_G, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
1771
+ reject(nil, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
1757
1772
  end
1758
1773
  end
1759
1774
  )
@@ -1762,13 +1777,13 @@ function __TS__PromiseAny(iterable)
1762
1777
  )
1763
1778
  end
1764
1779
 
1765
- function __TS__PromiseRace(iterable)
1780
+ local function __TS__PromiseRace(iterable)
1766
1781
  local pending = {}
1767
1782
  for ____, item in __TS__Iterator(iterable) do
1768
1783
  if __TS__InstanceOf(item, __TS__Promise) then
1769
- if item.state == __TS__PromiseState.Fulfilled then
1784
+ if item.state == 1 then
1770
1785
  return __TS__Promise.resolve(item.value)
1771
- elseif item.state == __TS__PromiseState.Rejected then
1786
+ elseif item.state == 2 then
1772
1787
  return __TS__Promise.reject(item.rejectionReason)
1773
1788
  else
1774
1789
  __TS__ArrayPush(pending, item)
@@ -1783,259 +1798,157 @@ function __TS__PromiseRace(iterable)
1783
1798
  for ____, promise in ipairs(pending) do
1784
1799
  promise["then"](
1785
1800
  promise,
1786
- function(____, value) return resolve(_G, value) end,
1787
- function(____, reason) return reject(_G, reason) end
1801
+ function(____, value) return resolve(nil, value) end,
1802
+ function(____, reason) return reject(nil, reason) end
1788
1803
  )
1789
1804
  end
1790
1805
  end
1791
1806
  )
1792
1807
  end
1793
1808
 
1794
- Set = __TS__Class()
1795
- Set.name = "Set"
1796
- function Set.prototype.____constructor(self, values)
1797
- self[Symbol.toStringTag] = "Set"
1798
- self.size = 0
1799
- self.nextKey = {}
1800
- self.previousKey = {}
1801
- if values == nil then
1802
- return
1803
- end
1804
- local iterable = values
1805
- if iterable[Symbol.iterator] then
1806
- local iterator = iterable[Symbol.iterator](iterable)
1807
- while true do
1808
- local result = iterator:next()
1809
- if result.done then
1810
- break
1809
+ local Set
1810
+ do
1811
+ Set = __TS__Class()
1812
+ Set.name = "Set"
1813
+ function Set.prototype.____constructor(self, values)
1814
+ self[Symbol.toStringTag] = "Set"
1815
+ self.size = 0
1816
+ self.nextKey = {}
1817
+ self.previousKey = {}
1818
+ if values == nil then
1819
+ return
1820
+ end
1821
+ local iterable = values
1822
+ if iterable[Symbol.iterator] then
1823
+ local iterator = iterable[Symbol.iterator](iterable)
1824
+ while true do
1825
+ local result = iterator:next()
1826
+ if result.done then
1827
+ break
1828
+ end
1829
+ self:add(result.value)
1811
1830
  end
1812
- self:add(result.value)
1813
- end
1814
- else
1815
- local array = values
1816
- for ____, value in ipairs(array) do
1817
- self:add(value)
1818
- end
1819
- end
1820
- end
1821
- function Set.prototype.add(self, value)
1822
- local isNewValue = not self:has(value)
1823
- if isNewValue then
1824
- self.size = self.size + 1
1825
- end
1826
- if self.firstKey == nil then
1827
- self.firstKey = value
1828
- self.lastKey = value
1829
- elseif isNewValue then
1830
- self.nextKey[self.lastKey] = value
1831
- self.previousKey[value] = self.lastKey
1832
- self.lastKey = value
1833
- end
1834
- return self
1835
- end
1836
- function Set.prototype.clear(self)
1837
- self.nextKey = {}
1838
- self.previousKey = {}
1839
- self.firstKey = nil
1840
- self.lastKey = nil
1841
- self.size = 0
1842
- end
1843
- function Set.prototype.delete(self, value)
1844
- local contains = self:has(value)
1845
- if contains then
1846
- self.size = self.size - 1
1847
- local next = self.nextKey[value]
1848
- local previous = self.previousKey[value]
1849
- if next and previous then
1850
- self.nextKey[previous] = next
1851
- self.previousKey[next] = previous
1852
- elseif next then
1853
- self.firstKey = next
1854
- self.previousKey[next] = nil
1855
- elseif previous then
1856
- self.lastKey = previous
1857
- self.nextKey[previous] = nil
1858
1831
  else
1859
- self.firstKey = nil
1860
- self.lastKey = nil
1832
+ local array = values
1833
+ for ____, value in ipairs(array) do
1834
+ self:add(value)
1835
+ end
1861
1836
  end
1862
- self.nextKey[value] = nil
1863
- self.previousKey[value] = nil
1864
- end
1865
- return contains
1866
- end
1867
- function Set.prototype.forEach(self, callback)
1868
- for ____, key in __TS__Iterator(self:keys()) do
1869
- callback(_G, key, key, self)
1870
1837
  end
1871
- end
1872
- function Set.prototype.has(self, value)
1873
- return self.nextKey[value] ~= nil or self.lastKey == value
1874
- end
1875
- Set.prototype[Symbol.iterator] = function(self)
1876
- return self:values()
1877
- end
1878
- function Set.prototype.entries(self)
1879
- local nextKey = self.nextKey
1880
- local key = self.firstKey
1881
- return {
1882
- [Symbol.iterator] = function(self)
1883
- return self
1884
- end,
1885
- next = function(self)
1886
- local result = {done = not key, value = {key, key}}
1887
- key = nextKey[key]
1888
- return result
1889
- end
1890
- }
1891
- end
1892
- function Set.prototype.keys(self)
1893
- local nextKey = self.nextKey
1894
- local key = self.firstKey
1895
- return {
1896
- [Symbol.iterator] = function(self)
1897
- return self
1898
- end,
1899
- next = function(self)
1900
- local result = {done = not key, value = key}
1901
- key = nextKey[key]
1902
- return result
1838
+ function Set.prototype.add(self, value)
1839
+ local isNewValue = not self:has(value)
1840
+ if isNewValue then
1841
+ self.size = self.size + 1
1903
1842
  end
1904
- }
1905
- end
1906
- function Set.prototype.values(self)
1907
- local nextKey = self.nextKey
1908
- local key = self.firstKey
1909
- return {
1910
- [Symbol.iterator] = function(self)
1911
- return self
1912
- end,
1913
- next = function(self)
1914
- local result = {done = not key, value = key}
1915
- key = nextKey[key]
1916
- return result
1843
+ if self.firstKey == nil then
1844
+ self.firstKey = value
1845
+ self.lastKey = value
1846
+ elseif isNewValue then
1847
+ self.nextKey[self.lastKey] = value
1848
+ self.previousKey[value] = self.lastKey
1849
+ self.lastKey = value
1917
1850
  end
1918
- }
1919
- end
1920
- Set[Symbol.species] = Set
1921
- Set = Set
1922
-
1923
- function __TS__SparseArrayNew(...)
1924
- local sparseArray = {...}
1925
- sparseArray.sparseLength = select("#", ...)
1926
- return sparseArray
1927
- end
1928
-
1929
- function __TS__SparseArrayPush(sparseArray, ...)
1930
- local args = {...}
1931
- local argsLen = select("#", ...)
1932
- local listLen = sparseArray.sparseLength
1933
- for i = 1, argsLen do
1934
- sparseArray[listLen + i] = args[i]
1935
- end
1936
- sparseArray.sparseLength = listLen + argsLen
1937
- end
1938
-
1939
- function __TS__SparseArraySpread(sparseArray)
1940
- local _unpack = unpack or table.unpack
1941
- return _unpack(sparseArray, 1, sparseArray.sparseLength)
1942
- end
1943
-
1944
- WeakMap = __TS__Class()
1945
- WeakMap.name = "WeakMap"
1946
- function WeakMap.prototype.____constructor(self, entries)
1947
- self[Symbol.toStringTag] = "WeakMap"
1948
- self.items = {}
1949
- setmetatable(self.items, {__mode = "k"})
1950
- if entries == nil then
1951
- return
1851
+ return self
1952
1852
  end
1953
- local iterable = entries
1954
- if iterable[Symbol.iterator] then
1955
- local iterator = iterable[Symbol.iterator](iterable)
1956
- while true do
1957
- local result = iterator:next()
1958
- if result.done then
1959
- break
1853
+ function Set.prototype.clear(self)
1854
+ self.nextKey = {}
1855
+ self.previousKey = {}
1856
+ self.firstKey = nil
1857
+ self.lastKey = nil
1858
+ self.size = 0
1859
+ end
1860
+ function Set.prototype.delete(self, value)
1861
+ local contains = self:has(value)
1862
+ if contains then
1863
+ self.size = self.size - 1
1864
+ local next = self.nextKey[value]
1865
+ local previous = self.previousKey[value]
1866
+ if next and previous then
1867
+ self.nextKey[previous] = next
1868
+ self.previousKey[next] = previous
1869
+ elseif next then
1870
+ self.firstKey = next
1871
+ self.previousKey[next] = nil
1872
+ elseif previous then
1873
+ self.lastKey = previous
1874
+ self.nextKey[previous] = nil
1875
+ else
1876
+ self.firstKey = nil
1877
+ self.lastKey = nil
1960
1878
  end
1961
- local value = result.value
1962
- self.items[value[1]] = value[2]
1879
+ self.nextKey[value] = nil
1880
+ self.previousKey[value] = nil
1963
1881
  end
1964
- else
1965
- for ____, kvp in ipairs(entries) do
1966
- self.items[kvp[1]] = kvp[2]
1882
+ return contains
1883
+ end
1884
+ function Set.prototype.forEach(self, callback)
1885
+ for ____, key in __TS__Iterator(self:keys()) do
1886
+ callback(nil, key, key, self)
1967
1887
  end
1968
1888
  end
1969
- end
1970
- function WeakMap.prototype.delete(self, key)
1971
- local contains = self:has(key)
1972
- self.items[key] = nil
1973
- return contains
1974
- end
1975
- function WeakMap.prototype.get(self, key)
1976
- return self.items[key]
1977
- end
1978
- function WeakMap.prototype.has(self, key)
1979
- return self.items[key] ~= nil
1980
- end
1981
- function WeakMap.prototype.set(self, key, value)
1982
- self.items[key] = value
1983
- return self
1984
- end
1985
- WeakMap[Symbol.species] = WeakMap
1986
- WeakMap = WeakMap
1987
-
1988
- WeakSet = __TS__Class()
1989
- WeakSet.name = "WeakSet"
1990
- function WeakSet.prototype.____constructor(self, values)
1991
- self[Symbol.toStringTag] = "WeakSet"
1992
- self.items = {}
1993
- setmetatable(self.items, {__mode = "k"})
1994
- if values == nil then
1995
- return
1889
+ function Set.prototype.has(self, value)
1890
+ return self.nextKey[value] ~= nil or self.lastKey == value
1996
1891
  end
1997
- local iterable = values
1998
- if iterable[Symbol.iterator] then
1999
- local iterator = iterable[Symbol.iterator](iterable)
2000
- while true do
2001
- local result = iterator:next()
2002
- if result.done then
2003
- break
1892
+ Set.prototype[Symbol.iterator] = function(self)
1893
+ return self:values()
1894
+ end
1895
+ function Set.prototype.entries(self)
1896
+ local nextKey = self.nextKey
1897
+ local key = self.firstKey
1898
+ return {
1899
+ [Symbol.iterator] = function(self)
1900
+ return self
1901
+ end,
1902
+ next = function(self)
1903
+ local result = {done = not key, value = {key, key}}
1904
+ key = nextKey[key]
1905
+ return result
2004
1906
  end
2005
- self.items[result.value] = true
2006
- end
2007
- else
2008
- for ____, value in ipairs(values) do
2009
- self.items[value] = true
2010
- end
1907
+ }
2011
1908
  end
1909
+ function Set.prototype.keys(self)
1910
+ local nextKey = self.nextKey
1911
+ local key = self.firstKey
1912
+ return {
1913
+ [Symbol.iterator] = function(self)
1914
+ return self
1915
+ end,
1916
+ next = function(self)
1917
+ local result = {done = not key, value = key}
1918
+ key = nextKey[key]
1919
+ return result
1920
+ end
1921
+ }
1922
+ end
1923
+ function Set.prototype.values(self)
1924
+ local nextKey = self.nextKey
1925
+ local key = self.firstKey
1926
+ return {
1927
+ [Symbol.iterator] = function(self)
1928
+ return self
1929
+ end,
1930
+ next = function(self)
1931
+ local result = {done = not key, value = key}
1932
+ key = nextKey[key]
1933
+ return result
1934
+ end
1935
+ }
1936
+ end
1937
+ Set[Symbol.species] = Set
2012
1938
  end
2013
- function WeakSet.prototype.add(self, value)
2014
- self.items[value] = true
2015
- return self
2016
- end
2017
- function WeakSet.prototype.delete(self, value)
2018
- local contains = self:has(value)
2019
- self.items[value] = nil
2020
- return contains
2021
- end
2022
- function WeakSet.prototype.has(self, value)
2023
- return self.items[value] == true
2024
- end
2025
- WeakSet[Symbol.species] = WeakSet
2026
- WeakSet = WeakSet
2027
1939
 
2028
- function __TS__SourceMapTraceBack(fileName, sourceMap)
1940
+ local function __TS__SourceMapTraceBack(fileName, sourceMap)
2029
1941
  _G.__TS__sourcemap = _G.__TS__sourcemap or ({})
2030
1942
  _G.__TS__sourcemap[fileName] = sourceMap
2031
1943
  if _G.__TS__originalTraceback == nil then
2032
- _G.__TS__originalTraceback = debug.traceback
1944
+ local originalTraceback = debug.traceback
1945
+ _G.__TS__originalTraceback = originalTraceback
2033
1946
  debug.traceback = function(thread, message, level)
2034
1947
  local trace
2035
1948
  if thread == nil and message == nil and level == nil then
2036
- trace = _G.__TS__originalTraceback()
1949
+ trace = originalTraceback()
2037
1950
  else
2038
- trace = _G.__TS__originalTraceback(thread, message, level)
1951
+ trace = originalTraceback(thread, message, level)
2039
1952
  end
2040
1953
  if type(trace) ~= "string" then
2041
1954
  return trace
@@ -2054,19 +1967,40 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
2054
1967
  local result = string.gsub(
2055
1968
  trace,
2056
1969
  "(%S+)%.lua:(%d+)",
2057
- function(file, line) return replacer(_G, file .. ".lua", file .. ".ts", line) end
1970
+ function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
2058
1971
  )
2059
1972
  result = string.gsub(
2060
1973
  result,
2061
1974
  "(%[string \"[^\"]+\"%]):(%d+)",
2062
- function(file, line) return replacer(_G, file, "unknown", line) end
1975
+ function(file, line) return replacer(nil, file, "unknown", line) end
2063
1976
  )
2064
1977
  return result
2065
1978
  end
2066
1979
  end
2067
1980
  end
2068
1981
 
2069
- function __TS__Spread(iterable)
1982
+ local function __TS__SparseArrayNew(...)
1983
+ local sparseArray = {...}
1984
+ sparseArray.sparseLength = select("#", ...)
1985
+ return sparseArray
1986
+ end
1987
+
1988
+ local function __TS__SparseArrayPush(sparseArray, ...)
1989
+ local args = {...}
1990
+ local argsLen = select("#", ...)
1991
+ local listLen = sparseArray.sparseLength
1992
+ for i = 1, argsLen do
1993
+ sparseArray[listLen + i] = args[i]
1994
+ end
1995
+ sparseArray.sparseLength = listLen + argsLen
1996
+ end
1997
+
1998
+ local function __TS__SparseArraySpread(sparseArray)
1999
+ local _unpack = unpack or table.unpack
2000
+ return _unpack(sparseArray, 1, sparseArray.sparseLength)
2001
+ end
2002
+
2003
+ local function __TS__Spread(iterable)
2070
2004
  local arr = {}
2071
2005
  if type(iterable) == "string" then
2072
2006
  do
@@ -2084,7 +2018,7 @@ function __TS__Spread(iterable)
2084
2018
  return __TS__Unpack(arr)
2085
2019
  end
2086
2020
 
2087
- function __TS__StringCharAt(self, pos)
2021
+ local function __TS__StringCharAt(self, pos)
2088
2022
  if pos ~= pos then
2089
2023
  pos = 0
2090
2024
  end
@@ -2094,7 +2028,7 @@ function __TS__StringCharAt(self, pos)
2094
2028
  return string.sub(self, pos + 1, pos + 1)
2095
2029
  end
2096
2030
 
2097
- function __TS__StringCharCodeAt(self, index)
2031
+ local function __TS__StringCharCodeAt(self, index)
2098
2032
  if index ~= index then
2099
2033
  index = 0
2100
2034
  end
@@ -2104,7 +2038,7 @@ function __TS__StringCharCodeAt(self, index)
2104
2038
  return string.byte(self, index + 1) or 0 / 0
2105
2039
  end
2106
2040
 
2107
- function __TS__StringConcat(str1, ...)
2041
+ local function __TS__StringConcat(str1, ...)
2108
2042
  local args = {...}
2109
2043
  local out = str1
2110
2044
  for ____, arg in ipairs(args) do
@@ -2113,14 +2047,14 @@ function __TS__StringConcat(str1, ...)
2113
2047
  return out
2114
2048
  end
2115
2049
 
2116
- function __TS__StringEndsWith(self, searchString, endPosition)
2050
+ local function __TS__StringEndsWith(self, searchString, endPosition)
2117
2051
  if endPosition == nil or endPosition > #self then
2118
2052
  endPosition = #self
2119
2053
  end
2120
2054
  return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
2121
2055
  end
2122
2056
 
2123
- function __TS__StringIncludes(self, searchString, position)
2057
+ local function __TS__StringIncludes(self, searchString, position)
2124
2058
  if not position then
2125
2059
  position = 1
2126
2060
  else
@@ -2130,7 +2064,7 @@ function __TS__StringIncludes(self, searchString, position)
2130
2064
  return index ~= nil
2131
2065
  end
2132
2066
 
2133
- function __TS__StringPadEnd(self, maxLength, fillString)
2067
+ local function __TS__StringPadEnd(self, maxLength, fillString)
2134
2068
  if fillString == nil then
2135
2069
  fillString = " "
2136
2070
  end
@@ -2157,7 +2091,7 @@ function __TS__StringPadEnd(self, maxLength, fillString)
2157
2091
  )
2158
2092
  end
2159
2093
 
2160
- function __TS__StringPadStart(self, maxLength, fillString)
2094
+ local function __TS__StringPadStart(self, maxLength, fillString)
2161
2095
  if fillString == nil then
2162
2096
  fillString = " "
2163
2097
  end
@@ -2184,7 +2118,7 @@ function __TS__StringPadStart(self, maxLength, fillString)
2184
2118
  ) .. self
2185
2119
  end
2186
2120
 
2187
- function __TS__StringReplace(source, searchValue, replaceValue)
2121
+ local function __TS__StringReplace(source, searchValue, replaceValue)
2188
2122
  local startPos, endPos = string.find(source, searchValue, nil, true)
2189
2123
  if not startPos then
2190
2124
  return source
@@ -2195,14 +2129,14 @@ function __TS__StringReplace(source, searchValue, replaceValue)
2195
2129
  if type(replaceValue) == "string" then
2196
2130
  ____temp_0 = replaceValue
2197
2131
  else
2198
- ____temp_0 = replaceValue(_G, searchValue, startPos - 1, source)
2132
+ ____temp_0 = replaceValue(nil, searchValue, startPos - 1, source)
2199
2133
  end
2200
2134
  local replacement = ____temp_0
2201
2135
  local after = sub(source, endPos + 1)
2202
2136
  return (before .. replacement) .. after
2203
2137
  end
2204
2138
 
2205
- function __TS__StringReplaceAll(source, searchValue, replaceValue)
2139
+ local function __TS__StringReplaceAll(source, searchValue, replaceValue)
2206
2140
  local replacer
2207
2141
  if type(replaceValue) == "string" then
2208
2142
  replacer = function() return replaceValue end
@@ -2213,11 +2147,11 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
2213
2147
  local partsIndex = 1
2214
2148
  local sub = string.sub
2215
2149
  if #searchValue == 0 then
2216
- parts[1] = replacer(_G, "", 0, source)
2150
+ parts[1] = replacer(nil, "", 0, source)
2217
2151
  partsIndex = 2
2218
2152
  for i = 1, #source do
2219
2153
  parts[partsIndex] = sub(source, i, i)
2220
- parts[partsIndex + 1] = replacer(_G, "", i, source)
2154
+ parts[partsIndex + 1] = replacer(nil, "", i, source)
2221
2155
  partsIndex = partsIndex + 2
2222
2156
  end
2223
2157
  else
@@ -2229,7 +2163,7 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
2229
2163
  break
2230
2164
  end
2231
2165
  parts[partsIndex] = sub(source, currentPos, startPos - 1)
2232
- parts[partsIndex + 1] = replacer(_G, searchValue, startPos - 1, source)
2166
+ parts[partsIndex + 1] = replacer(nil, searchValue, startPos - 1, source)
2233
2167
  partsIndex = partsIndex + 2
2234
2168
  currentPos = endPos + 1
2235
2169
  end
@@ -2238,7 +2172,7 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
2238
2172
  return table.concat(parts)
2239
2173
  end
2240
2174
 
2241
- function __TS__StringSlice(self, start, ____end)
2175
+ local function __TS__StringSlice(self, start, ____end)
2242
2176
  if start == nil or start ~= start then
2243
2177
  start = 0
2244
2178
  end
@@ -2254,7 +2188,7 @@ function __TS__StringSlice(self, start, ____end)
2254
2188
  return string.sub(self, start, ____end)
2255
2189
  end
2256
2190
 
2257
- function __TS__StringSplit(source, separator, limit)
2191
+ local function __TS__StringSplit(source, separator, limit)
2258
2192
  if limit == nil then
2259
2193
  limit = 4294967295
2260
2194
  end
@@ -2291,44 +2225,47 @@ function __TS__StringSplit(source, separator, limit)
2291
2225
  return out
2292
2226
  end
2293
2227
 
2294
- function __TS__StringStartsWith(self, searchString, position)
2228
+ local function __TS__StringStartsWith(self, searchString, position)
2295
2229
  if position == nil or position < 0 then
2296
2230
  position = 0
2297
2231
  end
2298
2232
  return string.sub(self, position + 1, #searchString + position) == searchString
2299
2233
  end
2300
2234
 
2301
- function __TS__StringTrim(self)
2235
+ local function __TS__StringTrim(self)
2302
2236
  local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1")
2303
2237
  return result
2304
2238
  end
2305
2239
 
2306
- function __TS__StringTrimEnd(self)
2240
+ local function __TS__StringTrimEnd(self)
2307
2241
  local result = string.gsub(self, "[%s ]*$", "")
2308
2242
  return result
2309
2243
  end
2310
2244
 
2311
- function __TS__StringTrimStart(self)
2245
+ local function __TS__StringTrimStart(self)
2312
2246
  local result = string.gsub(self, "^[%s ]*", "")
2313
2247
  return result
2314
2248
  end
2315
2249
 
2316
- ____symbolRegistry = {}
2317
- function __TS__SymbolRegistryFor(key)
2318
- if not ____symbolRegistry[key] then
2319
- ____symbolRegistry[key] = __TS__Symbol(key)
2250
+ local __TS__SymbolRegistryFor, __TS__SymbolRegistryKeyFor
2251
+ do
2252
+ local symbolRegistry = {}
2253
+ function __TS__SymbolRegistryFor(key)
2254
+ if not symbolRegistry[key] then
2255
+ symbolRegistry[key] = __TS__Symbol(key)
2256
+ end
2257
+ return symbolRegistry[key]
2320
2258
  end
2321
- return ____symbolRegistry[key]
2322
- end
2323
- function __TS__SymbolRegistryKeyFor(sym)
2324
- for key in pairs(____symbolRegistry) do
2325
- if ____symbolRegistry[key] == sym then
2326
- return key
2259
+ function __TS__SymbolRegistryKeyFor(sym)
2260
+ for key in pairs(symbolRegistry) do
2261
+ if symbolRegistry[key] == sym then
2262
+ return key
2263
+ end
2327
2264
  end
2328
2265
  end
2329
2266
  end
2330
2267
 
2331
- function __TS__TypeOf(value)
2268
+ local function __TS__TypeOf(value)
2332
2269
  local luaType = type(value)
2333
2270
  if luaType == "table" then
2334
2271
  return "object"
@@ -2339,3 +2276,197 @@ function __TS__TypeOf(value)
2339
2276
  end
2340
2277
  end
2341
2278
 
2279
+ local WeakMap
2280
+ do
2281
+ WeakMap = __TS__Class()
2282
+ WeakMap.name = "WeakMap"
2283
+ function WeakMap.prototype.____constructor(self, entries)
2284
+ self[Symbol.toStringTag] = "WeakMap"
2285
+ self.items = {}
2286
+ setmetatable(self.items, {__mode = "k"})
2287
+ if entries == nil then
2288
+ return
2289
+ end
2290
+ local iterable = entries
2291
+ if iterable[Symbol.iterator] then
2292
+ local iterator = iterable[Symbol.iterator](iterable)
2293
+ while true do
2294
+ local result = iterator:next()
2295
+ if result.done then
2296
+ break
2297
+ end
2298
+ local value = result.value
2299
+ self.items[value[1]] = value[2]
2300
+ end
2301
+ else
2302
+ for ____, kvp in ipairs(entries) do
2303
+ self.items[kvp[1]] = kvp[2]
2304
+ end
2305
+ end
2306
+ end
2307
+ function WeakMap.prototype.delete(self, key)
2308
+ local contains = self:has(key)
2309
+ self.items[key] = nil
2310
+ return contains
2311
+ end
2312
+ function WeakMap.prototype.get(self, key)
2313
+ return self.items[key]
2314
+ end
2315
+ function WeakMap.prototype.has(self, key)
2316
+ return self.items[key] ~= nil
2317
+ end
2318
+ function WeakMap.prototype.set(self, key, value)
2319
+ self.items[key] = value
2320
+ return self
2321
+ end
2322
+ WeakMap[Symbol.species] = WeakMap
2323
+ end
2324
+
2325
+ local WeakSet
2326
+ do
2327
+ WeakSet = __TS__Class()
2328
+ WeakSet.name = "WeakSet"
2329
+ function WeakSet.prototype.____constructor(self, values)
2330
+ self[Symbol.toStringTag] = "WeakSet"
2331
+ self.items = {}
2332
+ setmetatable(self.items, {__mode = "k"})
2333
+ if values == nil then
2334
+ return
2335
+ end
2336
+ local iterable = values
2337
+ if iterable[Symbol.iterator] then
2338
+ local iterator = iterable[Symbol.iterator](iterable)
2339
+ while true do
2340
+ local result = iterator:next()
2341
+ if result.done then
2342
+ break
2343
+ end
2344
+ self.items[result.value] = true
2345
+ end
2346
+ else
2347
+ for ____, value in ipairs(values) do
2348
+ self.items[value] = true
2349
+ end
2350
+ end
2351
+ end
2352
+ function WeakSet.prototype.add(self, value)
2353
+ self.items[value] = true
2354
+ return self
2355
+ end
2356
+ function WeakSet.prototype.delete(self, value)
2357
+ local contains = self:has(value)
2358
+ self.items[value] = nil
2359
+ return contains
2360
+ end
2361
+ function WeakSet.prototype.has(self, value)
2362
+ return self.items[value] == true
2363
+ end
2364
+ WeakSet[Symbol.species] = WeakSet
2365
+ end
2366
+
2367
+
2368
+ return {
2369
+ __TS__ArrayConcat = __TS__ArrayConcat,
2370
+ __TS__ArrayEntries = __TS__ArrayEntries,
2371
+ __TS__ArrayEvery = __TS__ArrayEvery,
2372
+ __TS__ArrayFilter = __TS__ArrayFilter,
2373
+ __TS__ArrayFind = __TS__ArrayFind,
2374
+ __TS__ArrayFindIndex = __TS__ArrayFindIndex,
2375
+ __TS__ArrayFlat = __TS__ArrayFlat,
2376
+ __TS__ArrayFlatMap = __TS__ArrayFlatMap,
2377
+ __TS__ArrayForEach = __TS__ArrayForEach,
2378
+ __TS__ArrayIncludes = __TS__ArrayIncludes,
2379
+ __TS__ArrayIndexOf = __TS__ArrayIndexOf,
2380
+ __TS__ArrayIsArray = __TS__ArrayIsArray,
2381
+ __TS__ArrayJoin = __TS__ArrayJoin,
2382
+ __TS__ArrayMap = __TS__ArrayMap,
2383
+ __TS__ArrayPush = __TS__ArrayPush,
2384
+ __TS__ArrayReduce = __TS__ArrayReduce,
2385
+ __TS__ArrayReduceRight = __TS__ArrayReduceRight,
2386
+ __TS__ArrayReverse = __TS__ArrayReverse,
2387
+ __TS__ArraySetLength = __TS__ArraySetLength,
2388
+ __TS__ArrayShift = __TS__ArrayShift,
2389
+ __TS__ArraySlice = __TS__ArraySlice,
2390
+ __TS__ArraySome = __TS__ArraySome,
2391
+ __TS__ArraySort = __TS__ArraySort,
2392
+ __TS__ArraySplice = __TS__ArraySplice,
2393
+ __TS__ArrayToObject = __TS__ArrayToObject,
2394
+ __TS__ArrayUnshift = __TS__ArrayUnshift,
2395
+ __TS__Promise = __TS__Promise,
2396
+ __TS__AsyncAwaiter = __TS__AsyncAwaiter,
2397
+ __TS__Await = __TS__Await,
2398
+ __TS__Class = __TS__Class,
2399
+ __TS__ClassExtends = __TS__ClassExtends,
2400
+ __TS__CloneDescriptor = __TS__CloneDescriptor,
2401
+ __TS__ObjectGetOwnPropertyDescriptor = __TS__ObjectGetOwnPropertyDescriptor,
2402
+ __TS__SetDescriptor = __TS__SetDescriptor,
2403
+ __TS__Decorate = __TS__Decorate,
2404
+ __TS__DecorateParam = __TS__DecorateParam,
2405
+ __TS__DelegatedYield = __TS__DelegatedYield,
2406
+ __TS__ObjectGetOwnPropertyDescriptors = __TS__ObjectGetOwnPropertyDescriptors,
2407
+ __TS__Delete = __TS__Delete,
2408
+ Error = Error,
2409
+ RangeError = RangeError,
2410
+ ReferenceError = ReferenceError,
2411
+ SyntaxError = SyntaxError,
2412
+ TypeError = TypeError,
2413
+ URIError = URIError,
2414
+ __TS__FunctionBind = __TS__FunctionBind,
2415
+ __TS__Generator = __TS__Generator,
2416
+ __TS__InstanceOf = __TS__InstanceOf,
2417
+ __TS__InstanceOfObject = __TS__InstanceOfObject,
2418
+ __TS__Iterator = __TS__Iterator,
2419
+ Map = Map,
2420
+ __TS__MathAtan2 = __TS__MathAtan2,
2421
+ __TS__MathSign = __TS__MathSign,
2422
+ __TS__New = __TS__New,
2423
+ __TS__Number = __TS__Number,
2424
+ __TS__NumberIsFinite = __TS__NumberIsFinite,
2425
+ __TS__NumberIsNaN = __TS__NumberIsNaN,
2426
+ __TS__NumberToString = __TS__NumberToString,
2427
+ __TS__ObjectAssign = __TS__ObjectAssign,
2428
+ __TS__ObjectDefineProperty = __TS__ObjectDefineProperty,
2429
+ __TS__ObjectEntries = __TS__ObjectEntries,
2430
+ __TS__ObjectFromEntries = __TS__ObjectFromEntries,
2431
+ __TS__ObjectKeys = __TS__ObjectKeys,
2432
+ __TS__ObjectRest = __TS__ObjectRest,
2433
+ __TS__ObjectValues = __TS__ObjectValues,
2434
+ __TS__ParseFloat = __TS__ParseFloat,
2435
+ __TS__ParseInt = __TS__ParseInt,
2436
+ __TS__PromiseAll = __TS__PromiseAll,
2437
+ __TS__PromiseAllSettled = __TS__PromiseAllSettled,
2438
+ __TS__PromiseAny = __TS__PromiseAny,
2439
+ __TS__PromiseRace = __TS__PromiseRace,
2440
+ Set = Set,
2441
+ __TS__SourceMapTraceBack = __TS__SourceMapTraceBack,
2442
+ __TS__SparseArrayNew = __TS__SparseArrayNew,
2443
+ __TS__SparseArrayPush = __TS__SparseArrayPush,
2444
+ __TS__SparseArraySpread = __TS__SparseArraySpread,
2445
+ __TS__Spread = __TS__Spread,
2446
+ __TS__StringAccess = __TS__StringAccess,
2447
+ __TS__StringCharAt = __TS__StringCharAt,
2448
+ __TS__StringCharCodeAt = __TS__StringCharCodeAt,
2449
+ __TS__StringConcat = __TS__StringConcat,
2450
+ __TS__StringEndsWith = __TS__StringEndsWith,
2451
+ __TS__StringIncludes = __TS__StringIncludes,
2452
+ __TS__StringPadEnd = __TS__StringPadEnd,
2453
+ __TS__StringPadStart = __TS__StringPadStart,
2454
+ __TS__StringReplace = __TS__StringReplace,
2455
+ __TS__StringReplaceAll = __TS__StringReplaceAll,
2456
+ __TS__StringSlice = __TS__StringSlice,
2457
+ __TS__StringSplit = __TS__StringSplit,
2458
+ __TS__StringStartsWith = __TS__StringStartsWith,
2459
+ __TS__StringSubstr = __TS__StringSubstr,
2460
+ __TS__StringSubstring = __TS__StringSubstring,
2461
+ __TS__StringTrim = __TS__StringTrim,
2462
+ __TS__StringTrimEnd = __TS__StringTrimEnd,
2463
+ __TS__StringTrimStart = __TS__StringTrimStart,
2464
+ __TS__Symbol = __TS__Symbol,
2465
+ Symbol = Symbol,
2466
+ __TS__SymbolRegistryFor = __TS__SymbolRegistryFor,
2467
+ __TS__SymbolRegistryKeyFor = __TS__SymbolRegistryKeyFor,
2468
+ __TS__TypeOf = __TS__TypeOf,
2469
+ __TS__Unpack = __TS__Unpack,
2470
+ WeakMap = WeakMap,
2471
+ WeakSet = WeakSet
2472
+ }