isaacscript-common 1.2.97 → 1.2.98

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 (144) hide show
  1. package/dist/callbacks/itemPickup.lua +1 -2
  2. package/dist/callbacks/postBombInitLate.lua +1 -3
  3. package/dist/callbacks/postBoneSwing.lua +1 -4
  4. package/dist/callbacks/postCursedTeleport.lua +1 -3
  5. package/dist/callbacks/postEffectInitLate.lua +1 -3
  6. package/dist/callbacks/postEsauJr.lua +1 -2
  7. package/dist/callbacks/postFamiliarInitLate.lua +1 -3
  8. package/dist/callbacks/postFlip.lua +1 -2
  9. package/dist/callbacks/postGridEntity.lua +1 -4
  10. package/dist/callbacks/postGridEntityCollision.lua +1 -6
  11. package/dist/callbacks/postKnifeInitLate.lua +1 -3
  12. package/dist/callbacks/postLaserInitLate.lua +1 -3
  13. package/dist/callbacks/postNPCInitLate.lua +1 -3
  14. package/dist/callbacks/postPickupCollect.lua +1 -3
  15. package/dist/callbacks/postPickupInitLate.lua +1 -3
  16. package/dist/callbacks/postPlayerChangeHealth.lua +7 -6
  17. package/dist/callbacks/postPlayerChangeType.lua +1 -3
  18. package/dist/callbacks/postPlayerFatalDamage.lua +1 -2
  19. package/dist/callbacks/postPlayerInitLate.lua +1 -3
  20. package/dist/callbacks/postPlayerReordered.lua +1 -2
  21. package/dist/callbacks/postProjectileInitLate.lua +1 -3
  22. package/dist/callbacks/postPurchase.lua +1 -6
  23. package/dist/callbacks/postSlotInitUpdate.lua +1 -3
  24. package/dist/callbacks/postSlotRenderBroken.lua +1 -3
  25. package/dist/callbacks/postTearInitLate.lua +1 -3
  26. package/dist/callbacks/postTearInitVeryLate.lua +1 -3
  27. package/dist/callbacks/postTransformation.lua +1 -4
  28. package/dist/callbacks/postTrinketBreak.lua +1 -2
  29. package/dist/callbacks/preNewLevel.lua +1 -3
  30. package/dist/callbacks/subscriptions/postBombInitLate.lua +1 -2
  31. package/dist/callbacks/subscriptions/postBoneSwing.lua +1 -2
  32. package/dist/callbacks/subscriptions/postCursedTeleport.lua +1 -2
  33. package/dist/callbacks/subscriptions/postCustomRevive.lua +1 -2
  34. package/dist/callbacks/subscriptions/postEffectInitLate.lua +1 -2
  35. package/dist/callbacks/subscriptions/postEsauJr.lua +1 -2
  36. package/dist/callbacks/subscriptions/postFamiliarInitLate.lua +1 -2
  37. package/dist/callbacks/subscriptions/postFirstEsauJr.lua +1 -2
  38. package/dist/callbacks/subscriptions/postFirstFlip.lua +1 -2
  39. package/dist/callbacks/subscriptions/postFlip.lua +1 -2
  40. package/dist/callbacks/subscriptions/postGameStartedReordered.lua +1 -2
  41. package/dist/callbacks/subscriptions/postGridEntityBroken.lua +1 -2
  42. package/dist/callbacks/subscriptions/postGridEntityCollision.lua +1 -2
  43. package/dist/callbacks/subscriptions/postGridEntityInit.lua +1 -2
  44. package/dist/callbacks/subscriptions/postGridEntityRemove.lua +1 -2
  45. package/dist/callbacks/subscriptions/postGridEntityStateChange.lua +1 -2
  46. package/dist/callbacks/subscriptions/postGridEntityUpdate.lua +1 -2
  47. package/dist/callbacks/subscriptions/postItemPickup.lua +1 -2
  48. package/dist/callbacks/subscriptions/postKnifeInitLate.lua +1 -2
  49. package/dist/callbacks/subscriptions/postLaserInitLate.lua +1 -2
  50. package/dist/callbacks/subscriptions/postNPCInitLate.lua +1 -2
  51. package/dist/callbacks/subscriptions/postNewLevelReordered.lua +1 -2
  52. package/dist/callbacks/subscriptions/postNewRoomEarly.lua +1 -2
  53. package/dist/callbacks/subscriptions/postNewRoomReordered.lua +1 -2
  54. package/dist/callbacks/subscriptions/postPEffectUpdateReordered.lua +1 -2
  55. package/dist/callbacks/subscriptions/postPickupCollect.lua +1 -2
  56. package/dist/callbacks/subscriptions/postPickupInitLate.lua +1 -2
  57. package/dist/callbacks/subscriptions/postPlayerChangeHealth.lua +1 -2
  58. package/dist/callbacks/subscriptions/postPlayerChangeType.lua +1 -2
  59. package/dist/callbacks/subscriptions/postPlayerFatalDamage.lua +1 -2
  60. package/dist/callbacks/subscriptions/postPlayerInitLate.lua +1 -2
  61. package/dist/callbacks/subscriptions/postPlayerInitReordered.lua +1 -2
  62. package/dist/callbacks/subscriptions/postPlayerRenderReordered.lua +1 -2
  63. package/dist/callbacks/subscriptions/postPlayerUpdateReordered.lua +1 -2
  64. package/dist/callbacks/subscriptions/postProjectileInitLate.lua +1 -2
  65. package/dist/callbacks/subscriptions/postPurchase.lua +1 -2
  66. package/dist/callbacks/subscriptions/postSacrifice.lua +1 -2
  67. package/dist/callbacks/subscriptions/postSlotDestroyed.lua +1 -2
  68. package/dist/callbacks/subscriptions/postSlotInit.lua +1 -2
  69. package/dist/callbacks/subscriptions/postSlotRender.lua +1 -2
  70. package/dist/callbacks/subscriptions/postSlotUpdate.lua +1 -2
  71. package/dist/callbacks/subscriptions/postTearInitLate.lua +1 -2
  72. package/dist/callbacks/subscriptions/postTearInitVeryLate.lua +1 -2
  73. package/dist/callbacks/subscriptions/postTransformation.lua +1 -2
  74. package/dist/callbacks/subscriptions/postTrinketBreak.lua +1 -2
  75. package/dist/callbacks/subscriptions/preBerserkDeath.lua +1 -2
  76. package/dist/callbacks/subscriptions/preCustomRevive.lua +1 -2
  77. package/dist/callbacks/subscriptions/preItemPickup.lua +1 -2
  78. package/dist/callbacks/subscriptions/preNewLevel.lua +1 -2
  79. package/dist/constants.lua +1 -3
  80. package/dist/features/deployJSONRoom.lua +1 -6
  81. package/dist/features/disableInputs.lua +1 -5
  82. package/dist/features/getCollectibleItemPoolType.lua +1 -3
  83. package/dist/features/isPonyActive.lua +1 -3
  84. package/dist/features/preventCollectibleRotate.lua +1 -3
  85. package/dist/features/runInNFrames.lua +1 -4
  86. package/dist/features/saveDataManager/exports.lua +1 -3
  87. package/dist/features/saveDataManager/load.lua +1 -2
  88. package/dist/features/saveDataManager/main.lua +0 -2
  89. package/dist/features/saveDataManager/maps.lua +1 -3
  90. package/dist/features/saveDataManager/merge.lua +1 -4
  91. package/dist/features/saveDataManager/save.lua +1 -3
  92. package/dist/features/sirenHelpers.lua +1 -3
  93. package/dist/functions/array.lua +1 -8
  94. package/dist/functions/cards.lua +1 -2
  95. package/dist/functions/collectibleCacheFlag.lua +1 -6
  96. package/dist/functions/collectibleSet.lua +1 -3
  97. package/dist/functions/deepCopy.lua +1 -6
  98. package/dist/functions/deepCopyTests.lua +1 -5
  99. package/dist/functions/doors.lua +1 -6
  100. package/dist/functions/entity.lua +1 -6
  101. package/dist/functions/entitySpecific.lua +1 -2
  102. package/dist/functions/familiars.lua +1 -3
  103. package/dist/functions/flying.lua +1 -4
  104. package/dist/functions/globals.lua +1 -6
  105. package/dist/functions/gridEntity.lua +1 -7
  106. package/dist/functions/input.lua +1 -7
  107. package/dist/functions/jsonRoom.lua +1 -3
  108. package/dist/functions/log.lua +1 -6
  109. package/dist/functions/map.lua +1 -4
  110. package/dist/functions/math.lua +1 -2
  111. package/dist/functions/npc.lua +1 -5
  112. package/dist/functions/player.lua +4 -12
  113. package/dist/functions/playerHealth.lua +1 -3
  114. package/dist/functions/pocketItems.lua +1 -4
  115. package/dist/functions/positionVelocity.lua +1 -3
  116. package/dist/functions/rooms.lua +1 -9
  117. package/dist/functions/set.lua +1 -4
  118. package/dist/functions/string.lua +1 -4
  119. package/dist/functions/transformations.lua +1 -5
  120. package/dist/functions/trinketCacheFlag.lua +1 -5
  121. package/dist/functions/trinketSet.lua +1 -3
  122. package/dist/functions/utils.lua +1 -5
  123. package/dist/lualib_bundle.lua +1027 -1158
  124. package/dist/maps/cardDescriptionMap.lua +1 -3
  125. package/dist/maps/cardNameMap.lua +1 -3
  126. package/dist/maps/challengeNameMap.lua +1 -3
  127. package/dist/maps/collectibleDescriptionMap.lua +1 -3
  128. package/dist/maps/collectibleNameMap.lua +1 -3
  129. package/dist/maps/gridEntityTypeToBrokenStateMap.lua +1 -3
  130. package/dist/maps/gridEntityXMLMap.lua +1 -3
  131. package/dist/maps/pillEffectClassMap.lua +1 -3
  132. package/dist/maps/pillEffectNameMap.lua +1 -3
  133. package/dist/maps/pillEffectTypeMap.lua +1 -3
  134. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.lua +1 -3
  135. package/dist/maps/transformationNameMap.lua +1 -3
  136. package/dist/maps/trinketDescriptionMap.lua +1 -3
  137. package/dist/maps/trinketNameMap.lua +1 -3
  138. package/dist/patchErrorFunctions.lua +1 -4
  139. package/dist/sets/cards.lua +1 -3
  140. package/dist/types/DefaultMap.lua +1 -5
  141. package/dist/types/ModUpgraded.lua +1 -4
  142. package/dist/types/SerializationBrand.lua +1 -3
  143. package/dist/upgradeMod.lua +1 -2
  144. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- local function __TS__ArrayIsArray(value)
1
+ 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
- local function __TS__ArrayConcat(arr1, ...)
5
+ function __TS__ArrayConcat(arr1, ...)
6
6
  local args = {...}
7
7
  local out = {}
8
8
  for ____, val in ipairs(arr1) do
@@ -21,23 +21,7 @@ local function __TS__ArrayConcat(arr1, ...)
21
21
  return out
22
22
  end
23
23
 
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)
24
+ function __TS__ArrayEntries(array)
41
25
  local key = 0
42
26
  return {
43
27
  [Symbol.iterator] = function(self)
@@ -51,11 +35,11 @@ local function __TS__ArrayEntries(array)
51
35
  }
52
36
  end
53
37
 
54
- local function __TS__ArrayEvery(arr, callbackfn)
38
+ function __TS__ArrayEvery(arr, callbackfn)
55
39
  do
56
40
  local i = 0
57
41
  while i < #arr do
58
- if not callbackfn(nil, arr[i + 1], i, arr) then
42
+ if not callbackfn(_G, arr[i + 1], i, arr) then
59
43
  return false
60
44
  end
61
45
  i = i + 1
@@ -64,12 +48,12 @@ local function __TS__ArrayEvery(arr, callbackfn)
64
48
  return true
65
49
  end
66
50
 
67
- local function __TS__ArrayFilter(arr, callbackfn)
51
+ function __TS__ArrayFilter(arr, callbackfn)
68
52
  local result = {}
69
53
  do
70
54
  local i = 0
71
55
  while i < #arr do
72
- if callbackfn(nil, arr[i + 1], i, arr) then
56
+ if callbackfn(_G, arr[i + 1], i, arr) then
73
57
  result[#result + 1] = arr[i + 1]
74
58
  end
75
59
  i = i + 1
@@ -78,12 +62,22 @@ local function __TS__ArrayFilter(arr, callbackfn)
78
62
  return result
79
63
  end
80
64
 
81
- local function __TS__ArrayFind(arr, predicate)
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)
82
76
  local len = #arr
83
77
  local k = 0
84
78
  while k < len do
85
79
  local elem = arr[k + 1]
86
- if predicate(nil, elem, k, arr) then
80
+ if predicate(_G, elem, k, arr) then
87
81
  return elem
88
82
  end
89
83
  k = k + 1
@@ -91,12 +85,12 @@ local function __TS__ArrayFind(arr, predicate)
91
85
  return nil
92
86
  end
93
87
 
94
- local function __TS__ArrayFindIndex(arr, callbackFn)
88
+ function __TS__ArrayFindIndex(arr, callbackFn)
95
89
  do
96
90
  local i = 0
97
91
  local len = #arr
98
92
  while i < len do
99
- if callbackFn(nil, arr[i + 1], i, arr) then
93
+ if callbackFn(_G, arr[i + 1], i, arr) then
100
94
  return i
101
95
  end
102
96
  i = i + 1
@@ -105,52 +99,7 @@ local function __TS__ArrayFindIndex(arr, callbackFn)
105
99
  return -1
106
100
  end
107
101
 
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)
102
+ function __TS__ArrayIncludes(self, searchElement, fromIndex)
154
103
  if fromIndex == nil then
155
104
  fromIndex = 0
156
105
  end
@@ -170,7 +119,7 @@ local function __TS__ArrayIncludes(self, searchElement, fromIndex)
170
119
  return false
171
120
  end
172
121
 
173
- local function __TS__ArrayIndexOf(arr, searchElement, fromIndex)
122
+ function __TS__ArrayIndexOf(arr, searchElement, fromIndex)
174
123
  local len = #arr
175
124
  if len == 0 then
176
125
  return -1
@@ -203,7 +152,7 @@ local function __TS__ArrayIndexOf(arr, searchElement, fromIndex)
203
152
  return -1
204
153
  end
205
154
 
206
- local function __TS__ArrayJoin(self, separator)
155
+ function __TS__ArrayJoin(self, separator)
207
156
  if separator == nil then
208
157
  separator = ","
209
158
  end
@@ -217,19 +166,19 @@ local function __TS__ArrayJoin(self, separator)
217
166
  return result
218
167
  end
219
168
 
220
- local function __TS__ArrayMap(arr, callbackfn)
169
+ function __TS__ArrayMap(arr, callbackfn)
221
170
  local newArray = {}
222
171
  do
223
172
  local i = 0
224
173
  while i < #arr do
225
- newArray[i + 1] = callbackfn(nil, arr[i + 1], i, arr)
174
+ newArray[i + 1] = callbackfn(_G, arr[i + 1], i, arr)
226
175
  i = i + 1
227
176
  end
228
177
  end
229
178
  return newArray
230
179
  end
231
180
 
232
- local function __TS__ArrayPush(arr, ...)
181
+ function __TS__ArrayPush(arr, ...)
233
182
  local items = {...}
234
183
  for ____, item in ipairs(items) do
235
184
  arr[#arr + 1] = item
@@ -237,7 +186,7 @@ local function __TS__ArrayPush(arr, ...)
237
186
  return #arr
238
187
  end
239
188
 
240
- local function __TS__ArrayReduce(arr, callbackFn, ...)
189
+ function __TS__ArrayReduce(arr, callbackFn, ...)
241
190
  local len = #arr
242
191
  local k = 0
243
192
  local accumulator = nil
@@ -251,7 +200,7 @@ local function __TS__ArrayReduce(arr, callbackFn, ...)
251
200
  end
252
201
  for i = k, len - 1 do
253
202
  accumulator = callbackFn(
254
- nil,
203
+ _G,
255
204
  accumulator,
256
205
  arr[i + 1],
257
206
  i,
@@ -261,7 +210,7 @@ local function __TS__ArrayReduce(arr, callbackFn, ...)
261
210
  return accumulator
262
211
  end
263
212
 
264
- local function __TS__ArrayReduceRight(arr, callbackFn, ...)
213
+ function __TS__ArrayReduceRight(arr, callbackFn, ...)
265
214
  local len = #arr
266
215
  local k = len - 1
267
216
  local accumulator = nil
@@ -275,7 +224,7 @@ local function __TS__ArrayReduceRight(arr, callbackFn, ...)
275
224
  end
276
225
  for i = k, 0, -1 do
277
226
  accumulator = callbackFn(
278
- nil,
227
+ _G,
279
228
  accumulator,
280
229
  arr[i + 1],
281
230
  i,
@@ -285,7 +234,7 @@ local function __TS__ArrayReduceRight(arr, callbackFn, ...)
285
234
  return accumulator
286
235
  end
287
236
 
288
- local function __TS__ArrayReverse(arr)
237
+ function __TS__ArrayReverse(arr)
289
238
  local i = 0
290
239
  local j = #arr - 1
291
240
  while i < j do
@@ -298,28 +247,35 @@ local function __TS__ArrayReverse(arr)
298
247
  return arr
299
248
  end
300
249
 
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
250
+ function __TS__ArrayShift(arr)
251
+ return table.remove(arr, 1)
252
+ end
253
+
254
+ function __TS__ArrayUnshift(arr, ...)
255
+ local items = {...}
308
256
  do
309
- local i = #arr - 1
310
- while i >= length do
311
- arr[i + 1] = nil
257
+ local i = #items - 1
258
+ while i >= 0 do
259
+ table.insert(arr, 1, items[i + 1])
312
260
  i = i - 1
313
261
  end
314
262
  end
315
- return length
263
+ return #arr
316
264
  end
317
265
 
318
- local function __TS__ArrayShift(arr)
319
- return table.remove(arr, 1)
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
320
276
  end
321
277
 
322
- local function __TS__ArraySlice(list, first, last)
278
+ function __TS__ArraySlice(list, first, last)
323
279
  local len = #list
324
280
  local relativeStart = first or 0
325
281
  local k
@@ -348,11 +304,11 @@ local function __TS__ArraySlice(list, first, last)
348
304
  return out
349
305
  end
350
306
 
351
- local function __TS__ArraySome(arr, callbackfn)
307
+ function __TS__ArraySome(arr, callbackfn)
352
308
  do
353
309
  local i = 0
354
310
  while i < #arr do
355
- if callbackfn(nil, arr[i + 1], i, arr) then
311
+ if callbackfn(_G, arr[i + 1], i, arr) then
356
312
  return true
357
313
  end
358
314
  i = i + 1
@@ -361,19 +317,7 @@ local function __TS__ArraySome(arr, callbackfn)
361
317
  return false
362
318
  end
363
319
 
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, ...)
320
+ function __TS__ArraySplice(list, ...)
377
321
  local len = #list
378
322
  local actualArgumentCount = select("#", ...)
379
323
  local start = select(1, ...)
@@ -458,7 +402,7 @@ local function __TS__ArraySplice(list, ...)
458
402
  return out
459
403
  end
460
404
 
461
- local function __TS__ArrayToObject(array)
405
+ function __TS__ArrayToObject(array)
462
406
  local object = {}
463
407
  do
464
408
  local i = 0
@@ -470,25 +414,72 @@ local function __TS__ArrayToObject(array)
470
414
  return object
471
415
  end
472
416
 
473
- local function __TS__ArrayUnshift(arr, ...)
474
- local items = {...}
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 = {}
475
437
  do
476
- local i = #items - 1
477
- while i >= 0 do
478
- table.insert(arr, 1, items[i + 1])
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
459
+ do
460
+ local i = #arr - 1
461
+ while i >= length do
462
+ arr[i + 1] = nil
479
463
  i = i - 1
480
464
  end
481
465
  end
482
- return #arr
466
+ return length
483
467
  end
484
468
 
485
- local function __TS__New(target, ...)
486
- local instance = setmetatable({}, target.prototype)
487
- instance:____constructor(...)
488
- return instance
469
+ ____symbolMetatable = {__tostring = function(self)
470
+ return ("Symbol(" .. (self.description or "")) .. ")"
471
+ end}
472
+ function __TS__Symbol(description)
473
+ return setmetatable({description = description}, ____symbolMetatable)
489
474
  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
+ }
490
481
 
491
- local function __TS__InstanceOf(obj, classTbl)
482
+ function __TS__InstanceOf(obj, classTbl)
492
483
  if type(classTbl) ~= "table" then
493
484
  error("Right-hand side of 'instanceof' is not an object", 0)
494
485
  end
@@ -507,16 +498,22 @@ local function __TS__InstanceOf(obj, classTbl)
507
498
  return false
508
499
  end
509
500
 
510
- local function __TS__Class(self)
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)
511
508
  local c = {prototype = {}}
512
509
  c.prototype.__index = c.prototype
513
510
  c.prototype.constructor = c
514
511
  return c
515
512
  end
516
513
 
517
- local __TS__Unpack = table.unpack or unpack
514
+ __TS__Unpack = table.unpack or unpack
518
515
 
519
- local function __TS__FunctionBind(fn, thisArg, ...)
516
+ function __TS__FunctionBind(fn, thisArg, ...)
520
517
  local boundArgs = {...}
521
518
  return function(____, ...)
522
519
  local args = {...}
@@ -534,180 +531,184 @@ local function __TS__FunctionBind(fn, thisArg, ...)
534
531
  end
535
532
  end
536
533
 
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
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
575
549
  end
576
- end
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
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)
614
572
  )
573
+ end)
574
+ if not ____try then
575
+ ____catch(____hasReturned)
615
576
  end
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
577
+ end
578
+ end
579
+ function __TS__Promise.resolve(data)
580
+ local promise = __TS__New(
581
+ __TS__Promise,
582
+ function()
583
+ 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()
622
593
  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)
623
609
  if isFulfilled then
624
- resolve(nil, self.value)
610
+ internalCallback(_G, self.value)
625
611
  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)
626
621
  if isRejected then
627
- reject(nil, self.rejectionReason)
622
+ internalCallback(_G, self.rejectionReason)
628
623
  end
629
- return promise
630
624
  end
631
- function __TS__Promise.prototype.catch(self, onRejected)
632
- return self["then"](self, nil, onRejected)
625
+ if isFulfilled then
626
+ resolve(_G, self.value)
633
627
  end
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
628
+ if isRejected then
629
+ reject(_G, self.rejectionReason)
630
+ 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)
640
641
  end
641
- return self
642
642
  end
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
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)
651
659
  end
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
660
+ for ____, callback in ipairs(self.finallyCallbacks) do
661
+ callback(_G)
661
662
  end
662
663
  end
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
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)
673
674
  end
674
675
  end
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
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)
691
692
  end
692
693
  end
693
694
  end
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
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)
704
703
  else
705
- resolve(nil, data)
704
+ data["then"](data, resolve, reject)
706
705
  end
706
+ else
707
+ resolve(_G, data)
707
708
  end
708
709
  end
709
710
 
710
- local function __TS__AsyncAwaiter(generator)
711
+ function __TS__AsyncAwaiter(generator)
711
712
  return __TS__New(
712
713
  __TS__Promise,
713
714
  function(____, resolve, reject)
@@ -724,9 +725,9 @@ local function __TS__AsyncAwaiter(generator)
724
725
  function fulfilled(self, value)
725
726
  local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine, value)
726
727
  if success then
727
- step(nil, resultOrError, errorOrErrorHandler)
728
+ step(_G, resultOrError, errorOrErrorHandler)
728
729
  else
729
- reject(nil, errorOrErrorHandler)
730
+ reject(_G, errorOrErrorHandler)
730
731
  end
731
732
  end
732
733
  function rejected(self, handler)
@@ -735,47 +736,47 @@ local function __TS__AsyncAwaiter(generator)
735
736
  local success, hasReturnedOrError, returnedValue = pcall(handler, value)
736
737
  if success then
737
738
  if hasReturnedOrError then
738
- resolve(nil, returnedValue)
739
+ resolve(_G, returnedValue)
739
740
  else
740
- step(nil, hasReturnedOrError, handler)
741
+ step(_G, hasReturnedOrError, handler)
741
742
  end
742
743
  else
743
- reject(nil, hasReturnedOrError)
744
+ reject(_G, hasReturnedOrError)
744
745
  end
745
746
  end
746
747
  else
747
748
  return function(____, value)
748
- reject(nil, value)
749
+ reject(_G, value)
749
750
  end
750
751
  end
751
752
  end
752
753
  function step(self, result, errorHandler)
753
754
  if coroutine.status(asyncCoroutine) == "dead" then
754
- resolve(nil, result)
755
+ resolve(_G, result)
755
756
  else
756
- local ____self_1 = adopt(nil, result)
757
+ local ____self_1 = adopt(_G, result)
757
758
  ____self_1["then"](
758
759
  ____self_1,
759
760
  fulfilled,
760
- rejected(nil, errorHandler)
761
+ rejected(_G, errorHandler)
761
762
  )
762
763
  end
763
764
  end
764
765
  asyncCoroutine = coroutine.create(generator)
765
766
  local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine)
766
767
  if success then
767
- step(nil, resultOrError, errorOrErrorHandler)
768
+ step(_G, resultOrError, errorOrErrorHandler)
768
769
  else
769
- reject(nil, errorOrErrorHandler)
770
+ reject(_G, errorOrErrorHandler)
770
771
  end
771
772
  end
772
773
  )
773
774
  end
774
- local function __TS__Await(errorHandler, thing)
775
+ function __TS__Await(errorHandler, thing)
775
776
  return coroutine.yield(errorHandler, thing)
776
777
  end
777
778
 
778
- local function __TS__ClassExtends(target, base)
779
+ function __TS__ClassExtends(target, base)
779
780
  target.____super = base
780
781
  local staticMetatable = setmetatable({__index = base}, base)
781
782
  setmetatable(target, staticMetatable)
@@ -800,7 +801,7 @@ local function __TS__ClassExtends(target, base)
800
801
  end
801
802
  end
802
803
 
803
- local function __TS__CloneDescriptor(____bindingPattern0)
804
+ function __TS__CloneDescriptor(____bindingPattern0)
804
805
  local value
805
806
  local writable
806
807
  local set
@@ -829,7 +830,7 @@ local function __TS__CloneDescriptor(____bindingPattern0)
829
830
  return descriptor
830
831
  end
831
832
 
832
- local function __TS__ObjectGetOwnPropertyDescriptor(object, key)
833
+ function __TS__ObjectGetOwnPropertyDescriptor(object, key)
833
834
  local metatable = getmetatable(object)
834
835
  if not metatable then
835
836
  return
@@ -840,87 +841,84 @@ local function __TS__ObjectGetOwnPropertyDescriptor(object, key)
840
841
  return rawget(metatable, "_descriptors")[key]
841
842
  end
842
843
 
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
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)
864
861
  end
862
+ return descriptor.value
865
863
  end
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
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
+ )
886
883
  end
887
- return
884
+ descriptor.value = value
888
885
  end
886
+ return
889
887
  end
890
- metatable = getmetatable(metatable)
891
888
  end
892
- rawset(self, key, value)
889
+ metatable = getmetatable(metatable)
893
890
  end
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
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)
920
907
  end
908
+ local value = rawget(target, key)
909
+ if value ~= nil then
910
+ rawset(target, key, nil)
911
+ end
912
+ if not rawget(metatable, "_descriptors") then
913
+ metatable._descriptors = {}
914
+ end
915
+ local descriptor = __TS__CloneDescriptor(desc)
916
+ metatable._descriptors[key] = descriptor
917
+ metatable.__index = ____descriptorIndex
918
+ metatable.__newindex = ____descriptorNewindex
921
919
  end
922
920
 
923
- local function __TS__ObjectAssign(to, ...)
921
+ function __TS__ObjectAssign(to, ...)
924
922
  local sources = {...}
925
923
  if to == nil then
926
924
  return to
@@ -933,7 +931,7 @@ local function __TS__ObjectAssign(to, ...)
933
931
  return to
934
932
  end
935
933
 
936
- local function __TS__Decorate(decorators, target, key, desc)
934
+ function __TS__Decorate(decorators, target, key, desc)
937
935
  local result = target
938
936
  do
939
937
  local i = #decorators
@@ -942,11 +940,11 @@ local function __TS__Decorate(decorators, target, key, desc)
942
940
  if decorator then
943
941
  local oldResult = result
944
942
  if key == nil then
945
- result = decorator(nil, result)
943
+ result = decorator(_G, result)
946
944
  elseif desc == true then
947
945
  local value = rawget(target, key)
948
946
  local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
949
- local desc = decorator(nil, target, key, descriptor) or descriptor
947
+ local desc = decorator(_G, target, key, descriptor) or descriptor
950
948
  local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
951
949
  if isSimpleValue then
952
950
  rawset(target, key, desc.value)
@@ -958,9 +956,9 @@ local function __TS__Decorate(decorators, target, key, desc)
958
956
  )
959
957
  end
960
958
  elseif desc == false then
961
- result = decorator(nil, target, key, desc)
959
+ result = decorator(_G, target, key, desc)
962
960
  else
963
- result = decorator(nil, target, key)
961
+ result = decorator(_G, target, key)
964
962
  end
965
963
  result = result or oldResult
966
964
  end
@@ -970,17 +968,124 @@ local function __TS__Decorate(decorators, target, key, desc)
970
968
  return result
971
969
  end
972
970
 
973
- local function __TS__DecorateParam(paramIndex, decorator)
974
- return function(____, target, key) return decorator(nil, target, key, paramIndex) end
971
+ function __TS__DecorateParam(paramIndex, decorator)
972
+ return function(____, target, key) return decorator(_G, target, key, paramIndex) end
975
973
  end
976
974
 
977
- local function __TS__StringAccess(self, index)
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)
978
1083
  if index >= 0 and index < #self then
979
1084
  return string.sub(self, index + 1, index + 1)
980
1085
  end
981
1086
  end
982
1087
 
983
- local function __TS__DelegatedYield(iterable)
1088
+ function __TS__DelegatedYield(iterable)
984
1089
  if type(iterable) == "string" then
985
1090
  for index = 0, #iterable - 1 do
986
1091
  coroutine.yield(__TS__StringAccess(iterable, index))
@@ -1015,336 +1120,222 @@ local function __TS__DelegatedYield(iterable)
1015
1120
  end
1016
1121
  end
1017
1122
 
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 ({})
1123
+ function __TS__GeneratorIterator(self)
1124
+ return self
1024
1125
  end
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)
1126
+ function __TS__GeneratorNext(self, ...)
1127
+ local co = self.____coroutine
1128
+ if coroutine.status(co) == "dead" then
1129
+ return {done = true}
1041
1130
  end
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
1131
+ local status, value = coroutine.resume(co, ...)
1132
+ if not status then
1133
+ error(value, 0)
1052
1134
  end
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
- )
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)
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
+ }
1096
1149
  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")
1102
1150
  end
1103
1151
 
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
1152
+ function __TS__InstanceOfObject(value)
1153
+ local valueType = type(value)
1154
+ return valueType == "table" or valueType == "function"
1122
1155
  end
1123
1156
 
1124
- local __TS__Generator
1125
- do
1126
- local function generatorIterator(self)
1127
- return self
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)
1128
1162
  end
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
- }
1163
+ if coroutine.status(co) == "dead" then
1164
+ return
1142
1165
  end
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
1166
+ return true, value
1167
+ end
1168
+ function __TS__IteratorIteratorStep(self)
1169
+ local result = self:next()
1170
+ if result.done then
1171
+ return
1153
1172
  end
1173
+ return true, result.value
1154
1174
  end
1155
-
1156
- local function __TS__InstanceOfObject(value)
1157
- local valueType = type(value)
1158
- return valueType == "table" or valueType == "function"
1175
+ function __TS__IteratorStringStep(self, index)
1176
+ index = index + 1
1177
+ if index > #self then
1178
+ return
1179
+ end
1180
+ return index, string.sub(self, index, index)
1181
+ 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
1159
1193
  end
1160
1194
 
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
1173
- end
1174
- local function iteratorIteratorStep(self)
1175
- local result = self:next()
1176
- if result.done then
1177
- return
1178
- end
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)
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
1187
1205
  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
1226
- else
1227
- local array = entries
1228
- for ____, kvp in ipairs(array) do
1229
- self:set(kvp[1], kvp[2])
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
1230
1213
  end
1214
+ local value = result.value
1215
+ self:set(value[1], value[2])
1231
1216
  end
1232
- end
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
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
1247
+ else
1248
+ self.firstKey = nil
1249
+ self.lastKey = nil
1262
1250
  end
1263
- self.items[key] = nil
1264
- return contains
1251
+ self.nextKey[key] = nil
1252
+ self.previousKey[key] = nil
1265
1253
  end
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
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)
1270
1260
  end
1271
- function Map.prototype.get(self, key)
1272
- return self.items[key]
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
1273
1272
  end
1274
- function Map.prototype.has(self, key)
1275
- return self.nextKey[key] ~= nil or self.lastKey == key
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
1276
1281
  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
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
1281
1300
  end
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
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
1290
1314
  end
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
1315
+ }
1343
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
1330
+ end
1331
+ }
1332
+ end
1333
+ Map[Symbol.species] = Map
1334
+ Map = Map
1344
1335
 
1345
- local __TS__MathAtan2 = math.atan2 or math.atan
1336
+ __TS__MathAtan2 = math.atan2 or math.atan
1346
1337
 
1347
- local function __TS__MathSign(val)
1338
+ function __TS__MathSign(val)
1348
1339
  if val > 0 then
1349
1340
  return 1
1350
1341
  elseif val < 0 then
@@ -1353,7 +1344,7 @@ local function __TS__MathSign(val)
1353
1344
  return 0
1354
1345
  end
1355
1346
 
1356
- local function __TS__Number(value)
1347
+ function __TS__Number(value)
1357
1348
  local valueType = type(value)
1358
1349
  if valueType == "number" then
1359
1350
  return value
@@ -1380,60 +1371,57 @@ local function __TS__Number(value)
1380
1371
  end
1381
1372
  end
1382
1373
 
1383
- local function __TS__NumberIsFinite(value)
1374
+ function __TS__NumberIsFinite(value)
1384
1375
  return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
1385
1376
  end
1386
1377
 
1387
- local function __TS__NumberIsNaN(value)
1378
+ function __TS__NumberIsNaN(value)
1388
1379
  return value ~= value
1389
1380
  end
1390
1381
 
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
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)
1433
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
1420
+ end
1421
+ return result
1434
1422
  end
1435
1423
 
1436
- local function __TS__ObjectDefineProperty(target, key, desc)
1424
+ function __TS__ObjectDefineProperty(target, key, desc)
1437
1425
  local ____temp_0
1438
1426
  if type(key) == "number" then
1439
1427
  ____temp_0 = key + 1
@@ -1493,7 +1481,7 @@ local function __TS__ObjectDefineProperty(target, key, desc)
1493
1481
  return target
1494
1482
  end
1495
1483
 
1496
- local function __TS__ObjectEntries(obj)
1484
+ function __TS__ObjectEntries(obj)
1497
1485
  local result = {}
1498
1486
  for key in pairs(obj) do
1499
1487
  result[#result + 1] = {key, obj[key]}
@@ -1501,7 +1489,7 @@ local function __TS__ObjectEntries(obj)
1501
1489
  return result
1502
1490
  end
1503
1491
 
1504
- local function __TS__ObjectFromEntries(entries)
1492
+ function __TS__ObjectFromEntries(entries)
1505
1493
  local obj = {}
1506
1494
  local iterable = entries
1507
1495
  if iterable[Symbol.iterator] then
@@ -1522,7 +1510,7 @@ local function __TS__ObjectFromEntries(entries)
1522
1510
  return obj
1523
1511
  end
1524
1512
 
1525
- local function __TS__ObjectKeys(obj)
1513
+ function __TS__ObjectKeys(obj)
1526
1514
  local result = {}
1527
1515
  for key in pairs(obj) do
1528
1516
  result[#result + 1] = key
@@ -1530,7 +1518,7 @@ local function __TS__ObjectKeys(obj)
1530
1518
  return result
1531
1519
  end
1532
1520
 
1533
- local function __TS__ObjectRest(target, usedProperties)
1521
+ function __TS__ObjectRest(target, usedProperties)
1534
1522
  local result = {}
1535
1523
  for property in pairs(target) do
1536
1524
  if not usedProperties[property] then
@@ -1540,7 +1528,7 @@ local function __TS__ObjectRest(target, usedProperties)
1540
1528
  return result
1541
1529
  end
1542
1530
 
1543
- local function __TS__ObjectValues(obj)
1531
+ function __TS__ObjectValues(obj)
1544
1532
  local result = {}
1545
1533
  for key in pairs(obj) do
1546
1534
  result[#result + 1] = obj[key]
@@ -1548,7 +1536,7 @@ local function __TS__ObjectValues(obj)
1548
1536
  return result
1549
1537
  end
1550
1538
 
1551
- local function __TS__ParseFloat(numberString)
1539
+ function __TS__ParseFloat(numberString)
1552
1540
  local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
1553
1541
  if infinityMatch then
1554
1542
  local ____temp_0
@@ -1563,7 +1551,7 @@ local function __TS__ParseFloat(numberString)
1563
1551
  return number or 0 / 0
1564
1552
  end
1565
1553
 
1566
- local function __TS__StringSubstr(self, from, length)
1554
+ function __TS__StringSubstr(self, from, length)
1567
1555
  if from ~= from then
1568
1556
  from = 0
1569
1557
  end
@@ -1579,7 +1567,7 @@ local function __TS__StringSubstr(self, from, length)
1579
1567
  return string.sub(self, from, length)
1580
1568
  end
1581
1569
 
1582
- local function __TS__StringSubstring(self, start, ____end)
1570
+ function __TS__StringSubstring(self, start, ____end)
1583
1571
  if ____end ~= ____end then
1584
1572
  ____end = 0
1585
1573
  end
@@ -1597,60 +1585,57 @@ local function __TS__StringSubstring(self, start, ____end)
1597
1585
  return string.sub(self, start, ____end)
1598
1586
  end
1599
1587
 
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
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)
1616
1600
  end
1601
+ numberString = ____string_match_result__0_0
1617
1602
  end
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
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)
1641
1626
  end
1642
1627
  end
1643
1628
 
1644
- local function __TS__PromiseAll(iterable)
1629
+ function __TS__PromiseAll(iterable)
1645
1630
  local results = {}
1646
1631
  local toResolve = {}
1647
1632
  local numToResolve = 0
1648
1633
  local i = 0
1649
1634
  for ____, item in __TS__Iterator(iterable) do
1650
1635
  if __TS__InstanceOf(item, __TS__Promise) then
1651
- if item.state == 1 then
1636
+ if item.state == __TS__PromiseState.Fulfilled then
1652
1637
  results[i + 1] = item.value
1653
- elseif item.state == 2 then
1638
+ elseif item.state == __TS__PromiseState.Rejected then
1654
1639
  return __TS__Promise.reject(item.rejectionReason)
1655
1640
  else
1656
1641
  numToResolve = numToResolve + 1
@@ -1674,11 +1659,11 @@ local function __TS__PromiseAll(iterable)
1674
1659
  results[index + 1] = data
1675
1660
  numToResolve = numToResolve - 1
1676
1661
  if numToResolve == 0 then
1677
- resolve(nil, results)
1662
+ resolve(_G, results)
1678
1663
  end
1679
1664
  end,
1680
1665
  function(____, reason)
1681
- reject(nil, reason)
1666
+ reject(_G, reason)
1682
1667
  end
1683
1668
  )
1684
1669
  end
@@ -1686,16 +1671,16 @@ local function __TS__PromiseAll(iterable)
1686
1671
  )
1687
1672
  end
1688
1673
 
1689
- local function __TS__PromiseAllSettled(iterable)
1674
+ function __TS__PromiseAllSettled(iterable)
1690
1675
  local results = {}
1691
1676
  local toResolve = {}
1692
1677
  local numToResolve = 0
1693
1678
  local i = 0
1694
1679
  for ____, item in __TS__Iterator(iterable) do
1695
1680
  if __TS__InstanceOf(item, __TS__Promise) then
1696
- if item.state == 1 then
1681
+ if item.state == __TS__PromiseState.Fulfilled then
1697
1682
  results[i + 1] = {status = "fulfilled", value = item.value}
1698
- elseif item.state == 2 then
1683
+ elseif item.state == __TS__PromiseState.Rejected then
1699
1684
  results[i + 1] = {status = "rejected", reason = item.rejectionReason}
1700
1685
  else
1701
1686
  numToResolve = numToResolve + 1
@@ -1719,14 +1704,14 @@ local function __TS__PromiseAllSettled(iterable)
1719
1704
  results[index + 1] = {status = "fulfilled", value = data}
1720
1705
  numToResolve = numToResolve - 1
1721
1706
  if numToResolve == 0 then
1722
- resolve(nil, results)
1707
+ resolve(_G, results)
1723
1708
  end
1724
1709
  end,
1725
1710
  function(____, reason)
1726
1711
  results[index + 1] = {status = "rejected", reason = reason}
1727
1712
  numToResolve = numToResolve - 1
1728
1713
  if numToResolve == 0 then
1729
- resolve(nil, results)
1714
+ resolve(_G, results)
1730
1715
  end
1731
1716
  end
1732
1717
  )
@@ -1735,14 +1720,14 @@ local function __TS__PromiseAllSettled(iterable)
1735
1720
  )
1736
1721
  end
1737
1722
 
1738
- local function __TS__PromiseAny(iterable)
1723
+ function __TS__PromiseAny(iterable)
1739
1724
  local rejections = {}
1740
1725
  local pending = {}
1741
1726
  for ____, item in __TS__Iterator(iterable) do
1742
1727
  if __TS__InstanceOf(item, __TS__Promise) then
1743
- if item.state == 1 then
1728
+ if item.state == __TS__PromiseState.Fulfilled then
1744
1729
  return __TS__Promise.resolve(item.value)
1745
- elseif item.state == 2 then
1730
+ elseif item.state == __TS__PromiseState.Rejected then
1746
1731
  __TS__ArrayPush(rejections, item.rejectionReason)
1747
1732
  else
1748
1733
  __TS__ArrayPush(pending, item)
@@ -1762,13 +1747,13 @@ local function __TS__PromiseAny(iterable)
1762
1747
  promise["then"](
1763
1748
  promise,
1764
1749
  function(____, data)
1765
- resolve(nil, data)
1750
+ resolve(_G, data)
1766
1751
  end,
1767
1752
  function(____, reason)
1768
1753
  __TS__ArrayPush(rejections, reason)
1769
1754
  numResolved = numResolved + 1
1770
1755
  if numResolved == #pending then
1771
- reject(nil, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
1756
+ reject(_G, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
1772
1757
  end
1773
1758
  end
1774
1759
  )
@@ -1777,13 +1762,13 @@ local function __TS__PromiseAny(iterable)
1777
1762
  )
1778
1763
  end
1779
1764
 
1780
- local function __TS__PromiseRace(iterable)
1765
+ function __TS__PromiseRace(iterable)
1781
1766
  local pending = {}
1782
1767
  for ____, item in __TS__Iterator(iterable) do
1783
1768
  if __TS__InstanceOf(item, __TS__Promise) then
1784
- if item.state == 1 then
1769
+ if item.state == __TS__PromiseState.Fulfilled then
1785
1770
  return __TS__Promise.resolve(item.value)
1786
- elseif item.state == 2 then
1771
+ elseif item.state == __TS__PromiseState.Rejected then
1787
1772
  return __TS__Promise.reject(item.rejectionReason)
1788
1773
  else
1789
1774
  __TS__ArrayPush(pending, item)
@@ -1798,157 +1783,259 @@ local function __TS__PromiseRace(iterable)
1798
1783
  for ____, promise in ipairs(pending) do
1799
1784
  promise["then"](
1800
1785
  promise,
1801
- function(____, value) return resolve(nil, value) end,
1802
- function(____, reason) return reject(nil, reason) end
1786
+ function(____, value) return resolve(_G, value) end,
1787
+ function(____, reason) return reject(_G, reason) end
1803
1788
  )
1804
1789
  end
1805
1790
  end
1806
1791
  )
1807
1792
  end
1808
1793
 
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)
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
1830
1811
  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
1831
1858
  else
1832
- local array = values
1833
- for ____, value in ipairs(array) do
1834
- self:add(value)
1835
- end
1859
+ self.firstKey = nil
1860
+ self.lastKey = nil
1836
1861
  end
1862
+ self.nextKey[value] = nil
1863
+ self.previousKey[value] = nil
1837
1864
  end
1838
- function Set.prototype.add(self, value)
1839
- local isNewValue = not self:has(value)
1840
- if isNewValue then
1841
- self.size = self.size + 1
1842
- end
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
1850
- end
1851
- return self
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)
1852
1870
  end
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
1878
- end
1879
- self.nextKey[value] = nil
1880
- self.previousKey[value] = nil
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
1881
1889
  end
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)
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
1887
1903
  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
1917
+ 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]
1888
1935
  end
1889
- function Set.prototype.has(self, value)
1890
- return self.nextKey[value] ~= nil or self.lastKey == value
1891
- end
1892
- Set.prototype[Symbol.iterator] = function(self)
1893
- return self:values()
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
1894
1952
  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
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
1906
1960
  end
1907
- }
1961
+ local value = result.value
1962
+ self.items[value[1]] = value[2]
1963
+ end
1964
+ else
1965
+ for ____, kvp in ipairs(entries) do
1966
+ self.items[kvp[1]] = kvp[2]
1967
+ end
1908
1968
  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
- }
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
1922
1996
  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
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
1934
2004
  end
1935
- }
2005
+ self.items[result.value] = true
2006
+ end
2007
+ else
2008
+ for ____, value in ipairs(values) do
2009
+ self.items[value] = true
2010
+ end
1936
2011
  end
1937
- Set[Symbol.species] = Set
1938
2012
  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
1939
2027
 
1940
- local function __TS__SourceMapTraceBack(fileName, sourceMap)
2028
+ function __TS__SourceMapTraceBack(fileName, sourceMap)
1941
2029
  _G.__TS__sourcemap = _G.__TS__sourcemap or ({})
1942
2030
  _G.__TS__sourcemap[fileName] = sourceMap
1943
2031
  if _G.__TS__originalTraceback == nil then
1944
- local originalTraceback = debug.traceback
1945
- _G.__TS__originalTraceback = originalTraceback
2032
+ _G.__TS__originalTraceback = debug.traceback
1946
2033
  debug.traceback = function(thread, message, level)
1947
2034
  local trace
1948
2035
  if thread == nil and message == nil and level == nil then
1949
- trace = originalTraceback()
2036
+ trace = _G.__TS__originalTraceback()
1950
2037
  else
1951
- trace = originalTraceback(thread, message, level)
2038
+ trace = _G.__TS__originalTraceback(thread, message, level)
1952
2039
  end
1953
2040
  if type(trace) ~= "string" then
1954
2041
  return trace
@@ -1967,40 +2054,19 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
1967
2054
  local result = string.gsub(
1968
2055
  trace,
1969
2056
  "(%S+)%.lua:(%d+)",
1970
- function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
2057
+ function(file, line) return replacer(_G, file .. ".lua", file .. ".ts", line) end
1971
2058
  )
1972
2059
  result = string.gsub(
1973
2060
  result,
1974
2061
  "(%[string \"[^\"]+\"%]):(%d+)",
1975
- function(file, line) return replacer(nil, file, "unknown", line) end
2062
+ function(file, line) return replacer(_G, file, "unknown", line) end
1976
2063
  )
1977
2064
  return result
1978
2065
  end
1979
2066
  end
1980
2067
  end
1981
2068
 
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)
2069
+ function __TS__Spread(iterable)
2004
2070
  local arr = {}
2005
2071
  if type(iterable) == "string" then
2006
2072
  do
@@ -2018,7 +2084,7 @@ local function __TS__Spread(iterable)
2018
2084
  return __TS__Unpack(arr)
2019
2085
  end
2020
2086
 
2021
- local function __TS__StringCharAt(self, pos)
2087
+ function __TS__StringCharAt(self, pos)
2022
2088
  if pos ~= pos then
2023
2089
  pos = 0
2024
2090
  end
@@ -2028,7 +2094,7 @@ local function __TS__StringCharAt(self, pos)
2028
2094
  return string.sub(self, pos + 1, pos + 1)
2029
2095
  end
2030
2096
 
2031
- local function __TS__StringCharCodeAt(self, index)
2097
+ function __TS__StringCharCodeAt(self, index)
2032
2098
  if index ~= index then
2033
2099
  index = 0
2034
2100
  end
@@ -2038,7 +2104,7 @@ local function __TS__StringCharCodeAt(self, index)
2038
2104
  return string.byte(self, index + 1) or 0 / 0
2039
2105
  end
2040
2106
 
2041
- local function __TS__StringConcat(str1, ...)
2107
+ function __TS__StringConcat(str1, ...)
2042
2108
  local args = {...}
2043
2109
  local out = str1
2044
2110
  for ____, arg in ipairs(args) do
@@ -2047,14 +2113,14 @@ local function __TS__StringConcat(str1, ...)
2047
2113
  return out
2048
2114
  end
2049
2115
 
2050
- local function __TS__StringEndsWith(self, searchString, endPosition)
2116
+ function __TS__StringEndsWith(self, searchString, endPosition)
2051
2117
  if endPosition == nil or endPosition > #self then
2052
2118
  endPosition = #self
2053
2119
  end
2054
2120
  return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
2055
2121
  end
2056
2122
 
2057
- local function __TS__StringIncludes(self, searchString, position)
2123
+ function __TS__StringIncludes(self, searchString, position)
2058
2124
  if not position then
2059
2125
  position = 1
2060
2126
  else
@@ -2064,7 +2130,7 @@ local function __TS__StringIncludes(self, searchString, position)
2064
2130
  return index ~= nil
2065
2131
  end
2066
2132
 
2067
- local function __TS__StringPadEnd(self, maxLength, fillString)
2133
+ function __TS__StringPadEnd(self, maxLength, fillString)
2068
2134
  if fillString == nil then
2069
2135
  fillString = " "
2070
2136
  end
@@ -2091,7 +2157,7 @@ local function __TS__StringPadEnd(self, maxLength, fillString)
2091
2157
  )
2092
2158
  end
2093
2159
 
2094
- local function __TS__StringPadStart(self, maxLength, fillString)
2160
+ function __TS__StringPadStart(self, maxLength, fillString)
2095
2161
  if fillString == nil then
2096
2162
  fillString = " "
2097
2163
  end
@@ -2118,7 +2184,7 @@ local function __TS__StringPadStart(self, maxLength, fillString)
2118
2184
  ) .. self
2119
2185
  end
2120
2186
 
2121
- local function __TS__StringReplace(source, searchValue, replaceValue)
2187
+ function __TS__StringReplace(source, searchValue, replaceValue)
2122
2188
  local startPos, endPos = string.find(source, searchValue, nil, true)
2123
2189
  if not startPos then
2124
2190
  return source
@@ -2129,14 +2195,14 @@ local function __TS__StringReplace(source, searchValue, replaceValue)
2129
2195
  if type(replaceValue) == "string" then
2130
2196
  ____temp_0 = replaceValue
2131
2197
  else
2132
- ____temp_0 = replaceValue(nil, searchValue, startPos - 1, source)
2198
+ ____temp_0 = replaceValue(_G, searchValue, startPos - 1, source)
2133
2199
  end
2134
2200
  local replacement = ____temp_0
2135
2201
  local after = sub(source, endPos + 1)
2136
2202
  return (before .. replacement) .. after
2137
2203
  end
2138
2204
 
2139
- local function __TS__StringReplaceAll(source, searchValue, replaceValue)
2205
+ function __TS__StringReplaceAll(source, searchValue, replaceValue)
2140
2206
  local replacer
2141
2207
  if type(replaceValue) == "string" then
2142
2208
  replacer = function() return replaceValue end
@@ -2147,11 +2213,11 @@ local function __TS__StringReplaceAll(source, searchValue, replaceValue)
2147
2213
  local partsIndex = 1
2148
2214
  local sub = string.sub
2149
2215
  if #searchValue == 0 then
2150
- parts[1] = replacer(nil, "", 0, source)
2216
+ parts[1] = replacer(_G, "", 0, source)
2151
2217
  partsIndex = 2
2152
2218
  for i = 1, #source do
2153
2219
  parts[partsIndex] = sub(source, i, i)
2154
- parts[partsIndex + 1] = replacer(nil, "", i, source)
2220
+ parts[partsIndex + 1] = replacer(_G, "", i, source)
2155
2221
  partsIndex = partsIndex + 2
2156
2222
  end
2157
2223
  else
@@ -2163,7 +2229,7 @@ local function __TS__StringReplaceAll(source, searchValue, replaceValue)
2163
2229
  break
2164
2230
  end
2165
2231
  parts[partsIndex] = sub(source, currentPos, startPos - 1)
2166
- parts[partsIndex + 1] = replacer(nil, searchValue, startPos - 1, source)
2232
+ parts[partsIndex + 1] = replacer(_G, searchValue, startPos - 1, source)
2167
2233
  partsIndex = partsIndex + 2
2168
2234
  currentPos = endPos + 1
2169
2235
  end
@@ -2172,7 +2238,7 @@ local function __TS__StringReplaceAll(source, searchValue, replaceValue)
2172
2238
  return table.concat(parts)
2173
2239
  end
2174
2240
 
2175
- local function __TS__StringSlice(self, start, ____end)
2241
+ function __TS__StringSlice(self, start, ____end)
2176
2242
  if start == nil or start ~= start then
2177
2243
  start = 0
2178
2244
  end
@@ -2188,7 +2254,7 @@ local function __TS__StringSlice(self, start, ____end)
2188
2254
  return string.sub(self, start, ____end)
2189
2255
  end
2190
2256
 
2191
- local function __TS__StringSplit(source, separator, limit)
2257
+ function __TS__StringSplit(source, separator, limit)
2192
2258
  if limit == nil then
2193
2259
  limit = 4294967295
2194
2260
  end
@@ -2225,47 +2291,44 @@ local function __TS__StringSplit(source, separator, limit)
2225
2291
  return out
2226
2292
  end
2227
2293
 
2228
- local function __TS__StringStartsWith(self, searchString, position)
2294
+ function __TS__StringStartsWith(self, searchString, position)
2229
2295
  if position == nil or position < 0 then
2230
2296
  position = 0
2231
2297
  end
2232
2298
  return string.sub(self, position + 1, #searchString + position) == searchString
2233
2299
  end
2234
2300
 
2235
- local function __TS__StringTrim(self)
2301
+ function __TS__StringTrim(self)
2236
2302
  local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1")
2237
2303
  return result
2238
2304
  end
2239
2305
 
2240
- local function __TS__StringTrimEnd(self)
2306
+ function __TS__StringTrimEnd(self)
2241
2307
  local result = string.gsub(self, "[%s ]*$", "")
2242
2308
  return result
2243
2309
  end
2244
2310
 
2245
- local function __TS__StringTrimStart(self)
2311
+ function __TS__StringTrimStart(self)
2246
2312
  local result = string.gsub(self, "^[%s ]*", "")
2247
2313
  return result
2248
2314
  end
2249
2315
 
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]
2316
+ ____symbolRegistry = {}
2317
+ function __TS__SymbolRegistryFor(key)
2318
+ if not ____symbolRegistry[key] then
2319
+ ____symbolRegistry[key] = __TS__Symbol(key)
2258
2320
  end
2259
- function __TS__SymbolRegistryKeyFor(sym)
2260
- for key in pairs(symbolRegistry) do
2261
- if symbolRegistry[key] == sym then
2262
- return key
2263
- 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
2264
2327
  end
2265
2328
  end
2266
2329
  end
2267
2330
 
2268
- local function __TS__TypeOf(value)
2331
+ function __TS__TypeOf(value)
2269
2332
  local luaType = type(value)
2270
2333
  if luaType == "table" then
2271
2334
  return "object"
@@ -2276,197 +2339,3 @@ local function __TS__TypeOf(value)
2276
2339
  end
2277
2340
  end
2278
2341
 
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
- }