typescript-to-lua 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/LuaAST.d.ts +1 -0
  3. package/dist/LuaAST.js +10 -2
  4. package/dist/LuaLib.d.ts +3 -3
  5. package/dist/LuaLib.js +4 -4
  6. package/dist/LuaPrinter.d.ts +11 -4
  7. package/dist/LuaPrinter.js +54 -11
  8. package/dist/lualib/ArrayFlat.lua +1 -1
  9. package/dist/lualib/ArrayFlatMap.lua +1 -1
  10. package/dist/lualib/ArrayIsArray.lua +1 -1
  11. package/dist/lualib/ArrayReduce.lua +7 -1
  12. package/dist/lualib/ArrayReduceRight.lua +7 -1
  13. package/dist/lualib/ArraySetLength.lua +1 -1
  14. package/dist/lualib/ArraySplice.lua +5 -5
  15. package/dist/lualib/Await.lua +14 -10
  16. package/dist/lualib/CloneDescriptor.lua +8 -8
  17. package/dist/lualib/Decorate.lua +1 -1
  18. package/dist/lualib/DelegatedYield.lua +1 -3
  19. package/dist/lualib/Delete.lua +6 -6
  20. package/dist/lualib/Error.lua +47 -44
  21. package/dist/lualib/Generator.lua +1 -5
  22. package/dist/lualib/InstanceOf.lua +1 -1
  23. package/dist/lualib/InstanceOfObject.lua +1 -1
  24. package/dist/lualib/Map.lua +130 -134
  25. package/dist/lualib/Number.lua +1 -1
  26. package/dist/lualib/NumberIsFinite.lua +1 -1
  27. package/dist/lualib/NumberToString.lua +3 -5
  28. package/dist/lualib/ObjectDefineProperty.lua +40 -8
  29. package/dist/lualib/ParseFloat.lua +9 -5
  30. package/dist/lualib/ParseInt.lua +15 -3
  31. package/dist/lualib/Promise.lua +18 -22
  32. package/dist/lualib/Set.lua +119 -123
  33. package/dist/lualib/SetDescriptor.lua +7 -1
  34. package/dist/lualib/SourceMapTraceBack.lua +1 -1
  35. package/dist/lualib/SparseArrayNew.lua +5 -0
  36. package/dist/lualib/SparseArrayPush.lua +9 -0
  37. package/dist/lualib/SparseArraySpread.lua +4 -0
  38. package/dist/lualib/StringAccess.lua +1 -1
  39. package/dist/lualib/StringCharCodeAt.lua +1 -1
  40. package/dist/lualib/StringEndsWith.lua +2 -2
  41. package/dist/lualib/StringPadEnd.lua +2 -2
  42. package/dist/lualib/StringPadStart.lua +2 -2
  43. package/dist/lualib/StringReplace.lua +7 -1
  44. package/dist/lualib/StringSlice.lua +2 -2
  45. package/dist/lualib/StringSplit.lua +3 -3
  46. package/dist/lualib/StringStartsWith.lua +1 -1
  47. package/dist/lualib/StringSubstr.lua +1 -1
  48. package/dist/lualib/StringSubstring.lua +2 -2
  49. package/dist/lualib/Symbol.lua +3 -5
  50. package/dist/lualib/WeakMap.lua +40 -42
  51. package/dist/lualib/WeakSet.lua +36 -38
  52. package/dist/lualib/lualib_bundle.lua +603 -555
  53. package/dist/transformation/builtins/array.js +1 -2
  54. package/dist/transformation/builtins/function.js +1 -2
  55. package/dist/transformation/builtins/index.d.ts +1 -1
  56. package/dist/transformation/builtins/index.js +37 -4
  57. package/dist/transformation/builtins/object.d.ts +2 -1
  58. package/dist/transformation/builtins/object.js +1 -2
  59. package/dist/transformation/builtins/string.js +1 -2
  60. package/dist/transformation/context/context.d.ts +12 -0
  61. package/dist/transformation/context/context.js +102 -3
  62. package/dist/transformation/utils/diagnostics.d.ts +6 -0
  63. package/dist/transformation/utils/diagnostics.js +3 -1
  64. package/dist/transformation/utils/lua-ast.d.ts +0 -1
  65. package/dist/transformation/utils/lua-ast.js +13 -22
  66. package/dist/transformation/utils/preceding-statements.d.ts +3 -0
  67. package/dist/transformation/utils/preceding-statements.js +11 -0
  68. package/dist/transformation/utils/scope.d.ts +1 -0
  69. package/dist/transformation/utils/scope.js +8 -1
  70. package/dist/transformation/utils/typescript/index.d.ts +1 -0
  71. package/dist/transformation/utils/typescript/index.js +16 -1
  72. package/dist/transformation/visitors/access.d.ts +3 -0
  73. package/dist/transformation/visitors/access.js +63 -36
  74. package/dist/transformation/visitors/binary-expression/assignments.d.ts +3 -2
  75. package/dist/transformation/visitors/binary-expression/assignments.js +66 -57
  76. package/dist/transformation/visitors/binary-expression/compound.d.ts +5 -4
  77. package/dist/transformation/visitors/binary-expression/compound.js +66 -68
  78. package/dist/transformation/visitors/binary-expression/destructuring-assignments.d.ts +2 -2
  79. package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +54 -25
  80. package/dist/transformation/visitors/binary-expression/index.d.ts +3 -1
  81. package/dist/transformation/visitors/binary-expression/index.js +64 -20
  82. package/dist/transformation/visitors/call.d.ts +3 -2
  83. package/dist/transformation/visitors/call.js +109 -122
  84. package/dist/transformation/visitors/class/index.js +4 -7
  85. package/dist/transformation/visitors/class/new.js +4 -6
  86. package/dist/transformation/visitors/conditional.js +28 -14
  87. package/dist/transformation/visitors/delete.js +4 -0
  88. package/dist/transformation/visitors/expression-list.d.ts +7 -0
  89. package/dist/transformation/visitors/expression-list.js +120 -0
  90. package/dist/transformation/visitors/function.js +6 -8
  91. package/dist/transformation/visitors/identifier.js +4 -0
  92. package/dist/transformation/visitors/literal.js +69 -16
  93. package/dist/transformation/visitors/loops/do-while.js +34 -8
  94. package/dist/transformation/visitors/loops/for.js +25 -5
  95. package/dist/transformation/visitors/loops/utils.d.ts +1 -0
  96. package/dist/transformation/visitors/loops/utils.js +13 -2
  97. package/dist/transformation/visitors/modules/export.js +1 -1
  98. package/dist/transformation/visitors/optional-chaining.d.ts +16 -0
  99. package/dist/transformation/visitors/optional-chaining.js +172 -0
  100. package/dist/transformation/visitors/sourceFile.js +4 -1
  101. package/dist/transformation/visitors/switch.js +29 -9
  102. package/dist/transformation/visitors/template.js +5 -2
  103. package/dist/transformation/visitors/typeof.js +3 -1
  104. package/dist/transformation/visitors/variable-declaration.js +21 -7
  105. package/dist/transformation/visitors/void.js +4 -7
  106. package/dist/transpilation/transformers.js +4 -1
  107. package/dist/transpilation/utils.js +2 -1
  108. package/package.json +5 -5
  109. package/dist/lualib/OptionalChainAccess.lua +0 -6
  110. package/dist/lualib/OptionalFunctionCall.lua +0 -6
  111. package/dist/lualib/OptionalMethodCall.lua +0 -11
  112. package/dist/transformation/utils/transform.d.ts +0 -8
  113. package/dist/transformation/utils/transform.js +0 -14
@@ -1,5 +1,5 @@
1
1
  function __TS__ArrayIsArray(value)
2
- return (type(value) == "table") and ((value[1] ~= nil) or (next(value, nil) == nil))
2
+ return type(value) == "table" and (value[1] ~= nil or next(value, nil) == nil)
3
3
  end
4
4
 
5
5
  function __TS__ArrayConcat(arr1, ...)
@@ -199,7 +199,13 @@ function __TS__ArrayReduce(arr, callbackFn, ...)
199
199
  error("Reduce of empty array with no initial value", 0)
200
200
  end
201
201
  for i = k, len - 1 do
202
- accumulator = callbackFn(_G, accumulator, arr[i + 1], i, arr)
202
+ accumulator = callbackFn(
203
+ _G,
204
+ accumulator,
205
+ arr[i + 1],
206
+ i,
207
+ arr
208
+ )
203
209
  end
204
210
  return accumulator
205
211
  end
@@ -217,7 +223,13 @@ function __TS__ArrayReduceRight(arr, callbackFn, ...)
217
223
  error("Reduce of empty array with no initial value", 0)
218
224
  end
219
225
  for i = k, 0, -1 do
220
- accumulator = callbackFn(_G, accumulator, arr[i + 1], i, arr)
226
+ accumulator = callbackFn(
227
+ _G,
228
+ accumulator,
229
+ arr[i + 1],
230
+ i,
231
+ arr
232
+ )
221
233
  end
222
234
  return accumulator
223
235
  end
@@ -342,7 +354,7 @@ function __TS__ArraySplice(list, ...)
342
354
  if itemCount < actualDeleteCount then
343
355
  do
344
356
  local k = actualStart
345
- while k < (len - actualDeleteCount) do
357
+ while k < len - actualDeleteCount do
346
358
  local from = k + actualDeleteCount
347
359
  local to = k + itemCount
348
360
  if list[from + 1] then
@@ -355,7 +367,7 @@ function __TS__ArraySplice(list, ...)
355
367
  end
356
368
  do
357
369
  local k = len
358
- while k > ((len - actualDeleteCount) + itemCount) do
370
+ while k > len - actualDeleteCount + itemCount do
359
371
  list[k] = nil
360
372
  k = k - 1
361
373
  end
@@ -364,8 +376,8 @@ function __TS__ArraySplice(list, ...)
364
376
  do
365
377
  local k = len - actualDeleteCount
366
378
  while k > actualStart do
367
- local from = (k + actualDeleteCount) - 1
368
- local to = (k + itemCount) - 1
379
+ local from = k + actualDeleteCount - 1
380
+ local to = k + itemCount - 1
369
381
  if list[from + 1] then
370
382
  list[to + 1] = list[from + 1]
371
383
  else
@@ -382,7 +394,7 @@ function __TS__ArraySplice(list, ...)
382
394
  end
383
395
  do
384
396
  local k = #list - 1
385
- while k >= ((len - actualDeleteCount) + itemCount) do
397
+ while k >= len - actualDeleteCount + itemCount do
386
398
  list[k + 1] = nil
387
399
  k = k - 1
388
400
  end
@@ -408,7 +420,7 @@ function __TS__ArrayFlat(array, depth)
408
420
  end
409
421
  local result = {}
410
422
  for ____, value in ipairs(array) do
411
- if (depth > 0) and __TS__ArrayIsArray(value) then
423
+ if depth > 0 and __TS__ArrayIsArray(value) then
412
424
  result = __TS__ArrayConcat(
413
425
  result,
414
426
  __TS__ArrayFlat(value, depth - 1)
@@ -426,7 +438,7 @@ function __TS__ArrayFlatMap(array, callback)
426
438
  local i = 0
427
439
  while i < #array do
428
440
  local value = callback(_G, array[i + 1], i, array)
429
- if (type(value) == "table") and __TS__ArrayIsArray(value) then
441
+ if type(value) == "table" and __TS__ArrayIsArray(value) then
430
442
  result = __TS__ArrayConcat(result, value)
431
443
  else
432
444
  result[#result + 1] = value
@@ -438,7 +450,7 @@ function __TS__ArrayFlatMap(array, callback)
438
450
  end
439
451
 
440
452
  function __TS__ArraySetLength(arr, length)
441
- if (((length < 0) or (length ~= length)) or (length == math.huge)) or (math.floor(length) ~= length) then
453
+ if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then
442
454
  error(
443
455
  "invalid array length: " .. tostring(length),
444
456
  0
@@ -454,11 +466,9 @@ function __TS__ArraySetLength(arr, length)
454
466
  return length
455
467
  end
456
468
 
457
- ____symbolMetatable = {
458
- __tostring = function(self)
459
- return ("Symbol(" .. (self.description or "")) .. ")"
460
- end
461
- }
469
+ ____symbolMetatable = {__tostring = function(self)
470
+ return ("Symbol(" .. (self.description or "")) .. ")"
471
+ end}
462
472
  function __TS__Symbol(description)
463
473
  return setmetatable({description = description}, ____symbolMetatable)
464
474
  end
@@ -474,7 +484,7 @@ function __TS__InstanceOf(obj, classTbl)
474
484
  error("Right-hand side of 'instanceof' is not an object", 0)
475
485
  end
476
486
  if classTbl[Symbol.hasInstance] ~= nil then
477
- return not (not classTbl[Symbol.hasInstance](classTbl, obj))
487
+ return not not classTbl[Symbol.hasInstance](classTbl, obj)
478
488
  end
479
489
  if type(obj) == "table" then
480
490
  local luaClass = obj.constructor
@@ -500,14 +510,20 @@ function __TS__AsyncAwaiter(generator)
500
510
  function(____, resolve, reject)
501
511
  local adopt, fulfilled, rejected, step, asyncCoroutine
502
512
  function adopt(self, value)
503
- return ((__TS__InstanceOf(value, __TS__Promise) and (function() return value end)) or (function() return __TS__Promise.resolve(value) end))()
513
+ local ____temp_0
514
+ if __TS__InstanceOf(value, __TS__Promise) then
515
+ ____temp_0 = value
516
+ else
517
+ ____temp_0 = __TS__Promise.resolve(value)
518
+ end
519
+ return ____temp_0
504
520
  end
505
521
  function fulfilled(self, value)
506
522
  local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine, value)
507
523
  if success then
508
524
  step(_G, resultOrError, errorOrErrorHandler)
509
525
  else
510
- reject(_G, resultOrError)
526
+ reject(_G, errorOrErrorHandler)
511
527
  end
512
528
  end
513
529
  function rejected(self, handler)
@@ -530,14 +546,12 @@ function __TS__AsyncAwaiter(generator)
530
546
  if coroutine.status(asyncCoroutine) == "dead" then
531
547
  resolve(_G, result)
532
548
  else
533
- (function()
534
- local ____self = adopt(_G, result)
535
- return ____self["then"](
536
- ____self,
537
- fulfilled,
538
- rejected(_G, errorHandler)
539
- )
540
- end)()
549
+ local ____self_1 = adopt(_G, result)
550
+ ____self_1["then"](
551
+ ____self_1,
552
+ fulfilled,
553
+ rejected(_G, errorHandler)
554
+ )
541
555
  end
542
556
  end
543
557
  asyncCoroutine = coroutine.create(generator)
@@ -586,22 +600,22 @@ function __TS__ClassExtends(target, base)
586
600
  end
587
601
  end
588
602
 
603
+ local value
604
+ local writable
605
+ local set
606
+ local get
607
+ local configurable
608
+ local enumerable
589
609
  function __TS__CloneDescriptor(____bindingPattern0)
590
- local enumerable
591
610
  enumerable = ____bindingPattern0.enumerable
592
- local configurable
593
611
  configurable = ____bindingPattern0.configurable
594
- local get
595
612
  get = ____bindingPattern0.get
596
- local set
597
613
  set = ____bindingPattern0.set
598
- local writable
599
614
  writable = ____bindingPattern0.writable
600
- local value
601
615
  value = ____bindingPattern0.value
602
616
  local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
603
- local hasGetterOrSetter = (get ~= nil) or (set ~= nil)
604
- local hasValueOrWritableAttribute = (writable ~= nil) or (value ~= nil)
617
+ local hasGetterOrSetter = get ~= nil or set ~= nil
618
+ local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
605
619
  if hasGetterOrSetter and hasValueOrWritableAttribute then
606
620
  error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
607
621
  end
@@ -679,7 +693,13 @@ function __TS__SetDescriptor(target, key, desc, isPrototype)
679
693
  if isPrototype == nil then
680
694
  isPrototype = false
681
695
  end
682
- local metatable = ((isPrototype and (function() return target end)) or (function() return getmetatable(target) end))()
696
+ local ____isPrototype_0
697
+ if isPrototype then
698
+ ____isPrototype_0 = target
699
+ else
700
+ ____isPrototype_0 = getmetatable(target)
701
+ end
702
+ local metatable = ____isPrototype_0
683
703
  if not metatable then
684
704
  metatable = {}
685
705
  setmetatable(target, metatable)
@@ -724,7 +744,7 @@ function __TS__Decorate(decorators, target, key, desc)
724
744
  local value = rawget(target, key)
725
745
  local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
726
746
  local desc = decorator(_G, target, key, descriptor) or descriptor
727
- local isSimpleValue = (((desc.configurable == true) and (desc.writable == true)) and (not desc.get)) and (not desc.set)
747
+ local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
728
748
  if isSimpleValue then
729
749
  rawset(target, key, desc.value)
730
750
  else
@@ -759,28 +779,107 @@ function __TS__ObjectGetOwnPropertyDescriptors(object)
759
779
  return rawget(metatable, "_descriptors") or ({})
760
780
  end
761
781
 
782
+ function __TS__GetErrorStack(self, constructor)
783
+ local level = 1
784
+ while true do
785
+ local info = debug.getinfo(level, "f")
786
+ level = level + 1
787
+ if not info then
788
+ level = 1
789
+ break
790
+ elseif info.func == constructor then
791
+ break
792
+ end
793
+ end
794
+ return debug.traceback(nil, level)
795
+ end
796
+ function __TS__WrapErrorToString(self, getDescription)
797
+ return function(self)
798
+ local description = getDescription(self)
799
+ local caller = debug.getinfo(3, "f")
800
+ if _VERSION == "Lua 5.1" or caller and caller.func ~= error then
801
+ return description
802
+ else
803
+ return (tostring(description) .. "\n") .. self.stack
804
+ end
805
+ end
806
+ end
807
+ function __TS__InitErrorClass(self, Type, name)
808
+ Type.name = name
809
+ return setmetatable(
810
+ Type,
811
+ {__call = function(____, _self, message) return __TS__New(Type, message) end}
812
+ )
813
+ end
814
+ local ____TS__InitErrorClass_3 = __TS__InitErrorClass
815
+ local ____G_2 = _G
816
+ ____class_0 = __TS__Class()
817
+ ____class_0.name = ""
818
+ function ____class_0.prototype.____constructor(self, message)
819
+ if message == nil then
820
+ message = ""
821
+ end
822
+ self.message = message
823
+ self.name = "Error"
824
+ self.stack = __TS__GetErrorStack(_G, self.constructor.new)
825
+ local metatable = getmetatable(self)
826
+ if not metatable.__errorToStringPatched then
827
+ metatable.__errorToStringPatched = true
828
+ metatable.__tostring = __TS__WrapErrorToString(_G, metatable.__tostring)
829
+ end
830
+ end
831
+ function ____class_0.prototype.__tostring(self)
832
+ local ____temp_1
833
+ if self.message ~= "" then
834
+ ____temp_1 = (self.name .. ": ") .. self.message
835
+ else
836
+ ____temp_1 = self.name
837
+ end
838
+ return ____temp_1
839
+ end
840
+ Error = ____TS__InitErrorClass_3(____G_2, ____class_0, "Error")
841
+ for ____, errorName in ipairs({
842
+ "RangeError",
843
+ "ReferenceError",
844
+ "SyntaxError",
845
+ "TypeError",
846
+ "URIError"
847
+ }) do
848
+ local ____G_7 = _G
849
+ local ____TS__InitErrorClass_6 = __TS__InitErrorClass
850
+ local ____G_5 = _G
851
+ local ____class_4 = __TS__Class()
852
+ ____class_4.name = ____class_4.name
853
+ __TS__ClassExtends(____class_4, Error)
854
+ function ____class_4.prototype.____constructor(self, ...)
855
+ Error.prototype.____constructor(self, ...)
856
+ self.name = errorName
857
+ end
858
+ ____G_7[errorName] = ____TS__InitErrorClass_6(____G_5, ____class_4, errorName)
859
+ end
860
+
762
861
  function __TS__Delete(target, key)
763
862
  local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
764
863
  local descriptor = descriptors[key]
765
864
  if descriptor then
766
865
  if not descriptor.configurable then
767
866
  error(
768
- ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. ".",
867
+ __TS__New(
868
+ TypeError,
869
+ ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
870
+ ),
769
871
  0
770
872
  )
771
873
  end
772
874
  descriptors[key] = nil
773
875
  return true
774
876
  end
775
- if target[key] ~= nil then
776
- target[key] = nil
777
- return true
778
- end
779
- return false
877
+ target[key] = nil
878
+ return true
780
879
  end
781
880
 
782
881
  function __TS__StringAccess(self, index)
783
- if (index >= 0) and (index < #self) then
882
+ if index >= 0 and index < #self then
784
883
  return string.sub(self, index + 1, index + 1)
785
884
  end
786
885
  end
@@ -788,9 +887,7 @@ end
788
887
  function __TS__DelegatedYield(iterable)
789
888
  if type(iterable) == "string" then
790
889
  for index = 0, #iterable - 1 do
791
- coroutine.yield(
792
- __TS__StringAccess(iterable, index)
793
- )
890
+ coroutine.yield(__TS__StringAccess(iterable, index))
794
891
  end
795
892
  elseif iterable.____coroutine ~= nil then
796
893
  local co = iterable.____coroutine
@@ -822,82 +919,6 @@ function __TS__DelegatedYield(iterable)
822
919
  end
823
920
  end
824
921
 
825
- function __TS__GetErrorStack(self, constructor)
826
- local level = 1
827
- while true do
828
- local info = debug.getinfo(level, "f")
829
- level = level + 1
830
- if not info then
831
- level = 1
832
- break
833
- elseif info.func == constructor then
834
- break
835
- end
836
- end
837
- return debug.traceback(nil, level)
838
- end
839
- function __TS__WrapErrorToString(self, getDescription)
840
- return function(self)
841
- local description = getDescription(self)
842
- local caller = debug.getinfo(3, "f")
843
- if (_VERSION == "Lua 5.1") or (caller and (caller.func ~= error)) then
844
- return description
845
- else
846
- return (tostring(description) .. "\n") .. self.stack
847
- end
848
- end
849
- end
850
- function __TS__InitErrorClass(self, Type, name)
851
- Type.name = name
852
- return setmetatable(
853
- Type,
854
- {
855
- __call = function(____, _self, message) return __TS__New(Type, message) end
856
- }
857
- )
858
- end
859
- Error = __TS__InitErrorClass(
860
- _G,
861
- (function()
862
- local ____ = __TS__Class()
863
- ____.name = ""
864
- function ____.prototype.____constructor(self, message)
865
- if message == nil then
866
- message = ""
867
- end
868
- self.message = message
869
- self.name = "Error"
870
- self.stack = __TS__GetErrorStack(_G, self.constructor.new)
871
- local metatable = getmetatable(self)
872
- if not metatable.__errorToStringPatched then
873
- metatable.__errorToStringPatched = true
874
- metatable.__tostring = __TS__WrapErrorToString(_G, metatable.__tostring)
875
- end
876
- end
877
- function ____.prototype.__tostring(self)
878
- return (((self.message ~= "") and (function() return (self.name .. ": ") .. self.message end)) or (function() return self.name end))()
879
- end
880
- return ____
881
- end)(),
882
- "Error"
883
- )
884
- for ____, errorName in ipairs({"RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError"}) do
885
- _G[errorName] = __TS__InitErrorClass(
886
- _G,
887
- (function()
888
- local ____ = __TS__Class()
889
- ____.name = ____.name
890
- __TS__ClassExtends(____, Error)
891
- function ____.prototype.____constructor(self, ...)
892
- Error.prototype.____constructor(self, ...)
893
- self.name = errorName
894
- end
895
- return ____
896
- end)(),
897
- errorName
898
- )
899
- end
900
-
901
922
  __TS__Unpack = table.unpack or unpack
902
923
 
903
924
  function __TS__FunctionBind(fn, thisArg, ...)
@@ -940,11 +961,7 @@ function __TS__Generator(fn)
940
961
  local args = {...}
941
962
  local argsLength = select("#", ...)
942
963
  return {
943
- ____coroutine = coroutine.create(
944
- function() return fn(
945
- (unpack or table.unpack)(args, 1, argsLength)
946
- ) end
947
- ),
964
+ ____coroutine = coroutine.create(function() return fn((unpack or table.unpack)(args, 1, argsLength)) end),
948
965
  [Symbol.iterator] = __TS__GeneratorIterator,
949
966
  next = __TS__GeneratorNext
950
967
  }
@@ -953,7 +970,7 @@ end
953
970
 
954
971
  function __TS__InstanceOfObject(value)
955
972
  local valueType = type(value)
956
- return (valueType == "table") or (valueType == "function")
973
+ return valueType == "table" or valueType == "function"
957
974
  end
958
975
 
959
976
  function __TS__IteratorGeneratorStep(self)
@@ -994,150 +1011,146 @@ function __TS__Iterator(iterable)
994
1011
  end
995
1012
  end
996
1013
 
997
- Map = (function()
998
- local Map = __TS__Class()
999
- Map.name = "Map"
1000
- function Map.prototype.____constructor(self, entries)
1001
- self[Symbol.toStringTag] = "Map"
1002
- self.items = {}
1003
- self.size = 0
1004
- self.nextKey = {}
1005
- self.previousKey = {}
1006
- if entries == nil then
1007
- return
1008
- end
1009
- local iterable = entries
1010
- if iterable[Symbol.iterator] then
1011
- local iterator = iterable[Symbol.iterator](iterable)
1012
- while true do
1013
- local result = iterator:next()
1014
- if result.done then
1015
- break
1016
- end
1017
- local value = result.value
1018
- self:set(value[1], value[2])
1019
- end
1020
- else
1021
- local array = entries
1022
- for ____, kvp in ipairs(array) do
1023
- self:set(kvp[1], kvp[2])
1024
- end
1025
- end
1014
+ Map = __TS__Class()
1015
+ Map.name = "Map"
1016
+ function Map.prototype.____constructor(self, entries)
1017
+ self[Symbol.toStringTag] = "Map"
1018
+ self.items = {}
1019
+ self.size = 0
1020
+ self.nextKey = {}
1021
+ self.previousKey = {}
1022
+ if entries == nil then
1023
+ return
1026
1024
  end
1027
- function Map.prototype.clear(self)
1028
- self.items = {}
1029
- self.nextKey = {}
1030
- self.previousKey = {}
1031
- self.firstKey = nil
1032
- self.lastKey = nil
1033
- self.size = 0
1034
- end
1035
- function Map.prototype.delete(self, key)
1036
- local contains = self:has(key)
1037
- if contains then
1038
- self.size = self.size - 1
1039
- local next = self.nextKey[key]
1040
- local previous = self.previousKey[key]
1041
- if next and previous then
1042
- self.nextKey[previous] = next
1043
- self.previousKey[next] = previous
1044
- elseif next then
1045
- self.firstKey = next
1046
- self.previousKey[next] = nil
1047
- elseif previous then
1048
- self.lastKey = previous
1049
- self.nextKey[previous] = nil
1050
- else
1051
- self.firstKey = nil
1052
- self.lastKey = nil
1025
+ local iterable = entries
1026
+ if iterable[Symbol.iterator] then
1027
+ local iterator = iterable[Symbol.iterator](iterable)
1028
+ while true do
1029
+ local result = iterator:next()
1030
+ if result.done then
1031
+ break
1053
1032
  end
1054
- self.nextKey[key] = nil
1055
- self.previousKey[key] = nil
1033
+ local value = result.value
1034
+ self:set(value[1], value[2])
1056
1035
  end
1057
- self.items[key] = nil
1058
- return contains
1059
- end
1060
- function Map.prototype.forEach(self, callback)
1061
- for ____, key in __TS__Iterator(
1062
- self:keys()
1063
- ) do
1064
- callback(_G, self.items[key], key, self)
1036
+ else
1037
+ local array = entries
1038
+ for ____, kvp in ipairs(array) do
1039
+ self:set(kvp[1], kvp[2])
1040
+ end
1041
+ end
1042
+ end
1043
+ function Map.prototype.clear(self)
1044
+ self.items = {}
1045
+ self.nextKey = {}
1046
+ self.previousKey = {}
1047
+ self.firstKey = nil
1048
+ self.lastKey = nil
1049
+ self.size = 0
1050
+ end
1051
+ function Map.prototype.delete(self, key)
1052
+ local contains = self:has(key)
1053
+ if contains then
1054
+ self.size = self.size - 1
1055
+ local next = self.nextKey[key]
1056
+ local previous = self.previousKey[key]
1057
+ if next and previous then
1058
+ self.nextKey[previous] = next
1059
+ self.previousKey[next] = previous
1060
+ elseif next then
1061
+ self.firstKey = next
1062
+ self.previousKey[next] = nil
1063
+ elseif previous then
1064
+ self.lastKey = previous
1065
+ self.nextKey[previous] = nil
1066
+ else
1067
+ self.firstKey = nil
1068
+ self.lastKey = nil
1065
1069
  end
1070
+ self.nextKey[key] = nil
1071
+ self.previousKey[key] = nil
1072
+ end
1073
+ self.items[key] = nil
1074
+ return contains
1075
+ end
1076
+ function Map.prototype.forEach(self, callback)
1077
+ for ____, key in __TS__Iterator(self:keys()) do
1078
+ callback(_G, self.items[key], key, self)
1066
1079
  end
1067
- function Map.prototype.get(self, key)
1068
- return self.items[key]
1080
+ end
1081
+ function Map.prototype.get(self, key)
1082
+ return self.items[key]
1083
+ end
1084
+ function Map.prototype.has(self, key)
1085
+ return self.nextKey[key] ~= nil or self.lastKey == key
1086
+ end
1087
+ function Map.prototype.set(self, key, value)
1088
+ local isNewValue = not self:has(key)
1089
+ if isNewValue then
1090
+ self.size = self.size + 1
1069
1091
  end
1070
- function Map.prototype.has(self, key)
1071
- return (self.nextKey[key] ~= nil) or (self.lastKey == key)
1092
+ self.items[key] = value
1093
+ if self.firstKey == nil then
1094
+ self.firstKey = key
1095
+ self.lastKey = key
1096
+ elseif isNewValue then
1097
+ self.nextKey[self.lastKey] = key
1098
+ self.previousKey[key] = self.lastKey
1099
+ self.lastKey = key
1072
1100
  end
1073
- function Map.prototype.set(self, key, value)
1074
- local isNewValue = not self:has(key)
1075
- if isNewValue then
1076
- self.size = self.size + 1
1101
+ return self
1102
+ end
1103
+ Map.prototype[Symbol.iterator] = function(self)
1104
+ return self:entries()
1105
+ end
1106
+ function Map.prototype.entries(self)
1107
+ local ____temp_0 = self
1108
+ local items = ____temp_0.items
1109
+ local nextKey = ____temp_0.nextKey
1110
+ local key = self.firstKey
1111
+ return {
1112
+ [Symbol.iterator] = function(self)
1113
+ return self
1114
+ end,
1115
+ next = function(self)
1116
+ local result = {done = not key, value = {key, items[key]}}
1117
+ key = nextKey[key]
1118
+ return result
1077
1119
  end
1078
- self.items[key] = value
1079
- if self.firstKey == nil then
1080
- self.firstKey = key
1081
- self.lastKey = key
1082
- elseif isNewValue then
1083
- self.nextKey[self.lastKey] = key
1084
- self.previousKey[key] = self.lastKey
1085
- self.lastKey = key
1120
+ }
1121
+ end
1122
+ function Map.prototype.keys(self)
1123
+ local nextKey = self.nextKey
1124
+ local key = self.firstKey
1125
+ return {
1126
+ [Symbol.iterator] = function(self)
1127
+ return self
1128
+ end,
1129
+ next = function(self)
1130
+ local result = {done = not key, value = key}
1131
+ key = nextKey[key]
1132
+ return result
1086
1133
  end
1087
- return self
1088
- end
1089
- Map.prototype[Symbol.iterator] = function(self)
1090
- return self:entries()
1091
- end
1092
- function Map.prototype.entries(self)
1093
- local ____ = self
1094
- local items = ____.items
1095
- local nextKey = ____.nextKey
1096
- local key = self.firstKey
1097
- return {
1098
- [Symbol.iterator] = function(self)
1099
- return self
1100
- end,
1101
- next = function(self)
1102
- local result = {done = not key, value = {key, items[key]}}
1103
- key = nextKey[key]
1104
- return result
1105
- end
1106
- }
1107
- end
1108
- function Map.prototype.keys(self)
1109
- local nextKey = self.nextKey
1110
- local key = self.firstKey
1111
- return {
1112
- [Symbol.iterator] = function(self)
1113
- return self
1114
- end,
1115
- next = function(self)
1116
- local result = {done = not key, value = key}
1117
- key = nextKey[key]
1118
- return result
1119
- end
1120
- }
1121
- end
1122
- function Map.prototype.values(self)
1123
- local ____ = self
1124
- local items = ____.items
1125
- local nextKey = ____.nextKey
1126
- local key = self.firstKey
1127
- return {
1128
- [Symbol.iterator] = function(self)
1129
- return self
1130
- end,
1131
- next = function(self)
1132
- local result = {done = not key, value = items[key]}
1133
- key = nextKey[key]
1134
- return result
1135
- end
1136
- }
1137
- end
1138
- Map[Symbol.species] = Map
1139
- return Map
1140
- end)()
1134
+ }
1135
+ end
1136
+ function Map.prototype.values(self)
1137
+ local ____temp_1 = self
1138
+ local items = ____temp_1.items
1139
+ local nextKey = ____temp_1.nextKey
1140
+ local key = self.firstKey
1141
+ return {
1142
+ [Symbol.iterator] = function(self)
1143
+ return self
1144
+ end,
1145
+ next = function(self)
1146
+ local result = {done = not key, value = items[key]}
1147
+ key = nextKey[key]
1148
+ return result
1149
+ end
1150
+ }
1151
+ end
1152
+ Map[Symbol.species] = Map
1153
+ Map = Map
1141
1154
 
1142
1155
  __TS__MathAtan2 = math.atan2 or math.atan
1143
1156
 
@@ -1162,14 +1175,14 @@ function __TS__Number(value)
1162
1175
  end
1163
1176
  return 0 / 0
1164
1177
  elseif valueType == "boolean" then
1165
- return (value and 1) or 0
1178
+ return value and 1 or 0
1166
1179
  else
1167
1180
  return 0 / 0
1168
1181
  end
1169
1182
  end
1170
1183
 
1171
1184
  function __TS__NumberIsFinite(value)
1172
- return (((type(value) == "number") and (value == value)) and (value ~= math.huge)) and (value ~= -math.huge)
1185
+ return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
1173
1186
  end
1174
1187
 
1175
1188
  function __TS__NumberIsNaN(value)
@@ -1178,16 +1191,14 @@ end
1178
1191
 
1179
1192
  ____radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
1180
1193
  function __TS__NumberToString(self, radix)
1181
- if ((((radix == nil) or (radix == 10)) or (self == math.huge)) or (self == -math.huge)) or (self ~= self) then
1194
+ if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then
1182
1195
  return tostring(self)
1183
1196
  end
1184
1197
  radix = math.floor(radix)
1185
- if (radix < 2) or (radix > 36) then
1198
+ if radix < 2 or radix > 36 then
1186
1199
  error("toString() radix argument must be between 2 and 36", 0)
1187
1200
  end
1188
- local integer, fraction = math.modf(
1189
- math.abs(self)
1190
- )
1201
+ local integer, fraction = math.modf(math.abs(self))
1191
1202
  local result = ""
1192
1203
  if radix == 8 then
1193
1204
  result = string.format("%o", integer)
@@ -1221,9 +1232,15 @@ function __TS__NumberToString(self, radix)
1221
1232
  end
1222
1233
 
1223
1234
  function __TS__ObjectDefineProperty(target, key, desc)
1224
- local luaKey = (((type(key) == "number") and (function() return key + 1 end)) or (function() return key end))()
1235
+ local ____temp_0
1236
+ if type(key) == "number" then
1237
+ ____temp_0 = key + 1
1238
+ else
1239
+ ____temp_0 = key
1240
+ end
1241
+ local luaKey = ____temp_0
1225
1242
  local value = rawget(target, luaKey)
1226
- local hasGetterOrSetter = (desc.get ~= nil) or (desc.set ~= nil)
1243
+ local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
1227
1244
  local descriptor
1228
1245
  if hasGetterOrSetter then
1229
1246
  if value ~= nil then
@@ -1235,13 +1252,39 @@ function __TS__ObjectDefineProperty(target, key, desc)
1235
1252
  descriptor = desc
1236
1253
  else
1237
1254
  local valueExists = value ~= nil
1255
+ local ____desc_set_5 = desc.set
1256
+ local ____desc_get_6 = desc.get
1257
+ local ____temp_1
1258
+ if desc.configurable ~= nil then
1259
+ ____temp_1 = desc.configurable
1260
+ else
1261
+ ____temp_1 = valueExists
1262
+ end
1263
+ local ____temp_2
1264
+ if desc.enumerable ~= nil then
1265
+ ____temp_2 = desc.enumerable
1266
+ else
1267
+ ____temp_2 = valueExists
1268
+ end
1269
+ local ____temp_3
1270
+ if desc.writable ~= nil then
1271
+ ____temp_3 = desc.writable
1272
+ else
1273
+ ____temp_3 = valueExists
1274
+ end
1275
+ local ____temp_4
1276
+ if desc.value ~= nil then
1277
+ ____temp_4 = desc.value
1278
+ else
1279
+ ____temp_4 = value
1280
+ end
1238
1281
  descriptor = {
1239
- set = desc.set,
1240
- get = desc.get,
1241
- configurable = (((desc.configurable ~= nil) and (function() return desc.configurable end)) or (function() return valueExists end))(),
1242
- enumerable = (((desc.enumerable ~= nil) and (function() return desc.enumerable end)) or (function() return valueExists end))(),
1243
- writable = (((desc.writable ~= nil) and (function() return desc.writable end)) or (function() return valueExists end))(),
1244
- value = (((desc.value ~= nil) and (function() return desc.value end)) or (function() return value end))()
1282
+ set = ____desc_set_5,
1283
+ get = ____desc_get_6,
1284
+ configurable = ____temp_1,
1285
+ enumerable = ____temp_2,
1286
+ writable = ____temp_3,
1287
+ value = ____temp_4
1245
1288
  }
1246
1289
  end
1247
1290
  __TS__SetDescriptor(target, luaKey, descriptor)
@@ -1303,41 +1346,19 @@ function __TS__ObjectValues(obj)
1303
1346
  return result
1304
1347
  end
1305
1348
 
1306
- function __TS__OptionalChainAccess(____table, key)
1307
- if ____table then
1308
- return ____table[key]
1309
- end
1310
- return nil
1311
- end
1312
-
1313
- function __TS__OptionalFunctionCall(f, ...)
1314
- if f then
1315
- return f(...)
1316
- end
1317
- return nil
1318
- end
1319
-
1320
- function __TS__OptionalMethodCall(____table, methodName, isMethodOptional, ...)
1321
- if ____table then
1322
- local method = ____table[methodName]
1323
- if method then
1324
- return method(____table, ...)
1325
- elseif not isMethodOptional then
1326
- error(methodName .. " is not a function", 0)
1327
- end
1328
- end
1329
- return nil
1330
- end
1331
-
1332
1349
  function __TS__ParseFloat(numberString)
1333
1350
  local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
1334
1351
  if infinityMatch then
1335
- return (((__TS__StringAccess(infinityMatch, 0) == "-") and (function() return -math.huge end)) or (function() return math.huge end))()
1352
+ local ____temp_0
1353
+ if __TS__StringAccess(infinityMatch, 0) == "-" then
1354
+ ____temp_0 = -math.huge
1355
+ else
1356
+ ____temp_0 = math.huge
1357
+ end
1358
+ return ____temp_0
1336
1359
  end
1337
- local number = tonumber(
1338
- string.match(numberString, "^%s*(-?%d+%.?%d*)")
1339
- )
1340
- return number or (0 / 0)
1360
+ local number = tonumber(string.match(numberString, "^%s*(-?%d+%.?%d*)"))
1361
+ return number or 0 / 0
1341
1362
  end
1342
1363
 
1343
1364
  function __TS__StringSubstr(self, from, length)
@@ -1345,7 +1366,7 @@ function __TS__StringSubstr(self, from, length)
1345
1366
  from = 0
1346
1367
  end
1347
1368
  if length ~= nil then
1348
- if (length ~= length) or (length <= 0) then
1369
+ if length ~= length or length <= 0 then
1349
1370
  return ""
1350
1371
  end
1351
1372
  length = length + from
@@ -1360,7 +1381,7 @@ function __TS__StringSubstring(self, start, ____end)
1360
1381
  if ____end ~= ____end then
1361
1382
  ____end = 0
1362
1383
  end
1363
- if (____end ~= nil) and (start > ____end) then
1384
+ if ____end ~= nil and start > ____end then
1364
1385
  start, ____end = ____end, start
1365
1386
  end
1366
1387
  if start >= 0 then
@@ -1368,7 +1389,7 @@ function __TS__StringSubstring(self, start, ____end)
1368
1389
  else
1369
1390
  start = 1
1370
1391
  end
1371
- if (____end ~= nil) and (____end < 0) then
1392
+ if ____end ~= nil and ____end < 0 then
1372
1393
  ____end = 0
1373
1394
  end
1374
1395
  return string.sub(self, start, ____end)
@@ -1381,13 +1402,25 @@ function __TS__ParseInt(numberString, base)
1381
1402
  local hexMatch = string.match(numberString, "^%s*-?0[xX]")
1382
1403
  if hexMatch then
1383
1404
  base = 16
1384
- numberString = ((string.match(hexMatch, "-") and (function() return "-" .. __TS__StringSubstr(numberString, #hexMatch) end)) or (function() return __TS__StringSubstr(numberString, #hexMatch) end))()
1405
+ local ____string_match_result__0_0
1406
+ if string.match(hexMatch, "-") then
1407
+ ____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1408
+ else
1409
+ ____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1410
+ end
1411
+ numberString = ____string_match_result__0_0
1385
1412
  end
1386
1413
  end
1387
- if (base < 2) or (base > 36) then
1414
+ if base < 2 or base > 36 then
1388
1415
  return 0 / 0
1389
1416
  end
1390
- local allowedDigits = (((base <= 10) and (function() return __TS__StringSubstring(__TS__parseInt_base_pattern, 0, base) end)) or (function() return __TS__StringSubstr(__TS__parseInt_base_pattern, 0, 10 + (2 * (base - 10))) end))()
1417
+ local ____temp_1
1418
+ if base <= 10 then
1419
+ ____temp_1 = __TS__StringSubstring(__TS__parseInt_base_pattern, 0, base)
1420
+ else
1421
+ ____temp_1 = __TS__StringSubstr(__TS__parseInt_base_pattern, 0, 10 + 2 * (base - 10))
1422
+ end
1423
+ local allowedDigits = ____temp_1
1391
1424
  local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1392
1425
  local number = tonumber(
1393
1426
  string.match(numberString, pattern),
@@ -1436,15 +1469,13 @@ function __TS__Promise.prototype.____constructor(self, executor)
1436
1469
  local function ____catch(e)
1437
1470
  self:reject(e)
1438
1471
  end
1439
- local ____try, ____hasReturned = pcall(
1440
- function()
1441
- executor(
1442
- _G,
1443
- __TS__FunctionBind(self.resolve, self),
1444
- __TS__FunctionBind(self.reject, self)
1445
- )
1446
- end
1447
- )
1472
+ local ____try, ____hasReturned = pcall(function()
1473
+ executor(
1474
+ _G,
1475
+ __TS__FunctionBind(self.resolve, self),
1476
+ __TS__FunctionBind(self.reject, self)
1477
+ )
1478
+ end)
1448
1479
  if not ____try then
1449
1480
  ____hasReturned, ____returnValue = ____catch(____hasReturned)
1450
1481
  end
@@ -1471,10 +1502,10 @@ function __TS__Promise.reject(reason)
1471
1502
  return promise
1472
1503
  end
1473
1504
  __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
1474
- local ____ = __TS__PromiseDeferred(_G)
1475
- local promise = ____.promise
1476
- local resolve = ____.resolve
1477
- local reject = ____.reject
1505
+ local ____TS__PromiseDeferred_result_0 = __TS__PromiseDeferred(_G)
1506
+ local promise = ____TS__PromiseDeferred_result_0.promise
1507
+ local resolve = ____TS__PromiseDeferred_result_0.resolve
1508
+ local reject = ____TS__PromiseDeferred_result_0.reject
1478
1509
  local isFulfilled = self.state == __TS__PromiseState.Fulfilled
1479
1510
  local isRejected = self.state == __TS__PromiseState.Rejected
1480
1511
  if onFulfilled then
@@ -1546,15 +1577,13 @@ function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve
1546
1577
  local function ____catch(e)
1547
1578
  reject(_G, e)
1548
1579
  end
1549
- local ____try, ____hasReturned = pcall(
1550
- function()
1551
- self:handleCallbackData(
1552
- f(_G, value),
1553
- resolve,
1554
- reject
1555
- )
1556
- end
1557
- )
1580
+ local ____try, ____hasReturned = pcall(function()
1581
+ self:handleCallbackData(
1582
+ f(_G, value),
1583
+ resolve,
1584
+ reject
1585
+ )
1586
+ end)
1558
1587
  if not ____try then
1559
1588
  ____hasReturned, ____returnValue = ____catch(____hasReturned)
1560
1589
  end
@@ -1741,226 +1770,239 @@ function __TS__PromiseRace(iterable)
1741
1770
  )
1742
1771
  end
1743
1772
 
1744
- Set = (function()
1745
- local Set = __TS__Class()
1746
- Set.name = "Set"
1747
- function Set.prototype.____constructor(self, values)
1748
- self[Symbol.toStringTag] = "Set"
1749
- self.size = 0
1750
- self.nextKey = {}
1751
- self.previousKey = {}
1752
- if values == nil then
1753
- return
1754
- end
1755
- local iterable = values
1756
- if iterable[Symbol.iterator] then
1757
- local iterator = iterable[Symbol.iterator](iterable)
1758
- while true do
1759
- local result = iterator:next()
1760
- if result.done then
1761
- break
1762
- end
1763
- self:add(result.value)
1764
- end
1765
- else
1766
- local array = values
1767
- for ____, value in ipairs(array) do
1768
- self:add(value)
1769
- end
1770
- end
1771
- end
1772
- function Set.prototype.add(self, value)
1773
- local isNewValue = not self:has(value)
1774
- if isNewValue then
1775
- self.size = self.size + 1
1776
- end
1777
- if self.firstKey == nil then
1778
- self.firstKey = value
1779
- self.lastKey = value
1780
- elseif isNewValue then
1781
- self.nextKey[self.lastKey] = value
1782
- self.previousKey[value] = self.lastKey
1783
- self.lastKey = value
1784
- end
1785
- return self
1773
+ Set = __TS__Class()
1774
+ Set.name = "Set"
1775
+ function Set.prototype.____constructor(self, values)
1776
+ self[Symbol.toStringTag] = "Set"
1777
+ self.size = 0
1778
+ self.nextKey = {}
1779
+ self.previousKey = {}
1780
+ if values == nil then
1781
+ return
1786
1782
  end
1787
- function Set.prototype.clear(self)
1788
- self.nextKey = {}
1789
- self.previousKey = {}
1790
- self.firstKey = nil
1791
- self.lastKey = nil
1792
- self.size = 0
1793
- end
1794
- function Set.prototype.delete(self, value)
1795
- local contains = self:has(value)
1796
- if contains then
1797
- self.size = self.size - 1
1798
- local next = self.nextKey[value]
1799
- local previous = self.previousKey[value]
1800
- if next and previous then
1801
- self.nextKey[previous] = next
1802
- self.previousKey[next] = previous
1803
- elseif next then
1804
- self.firstKey = next
1805
- self.previousKey[next] = nil
1806
- elseif previous then
1807
- self.lastKey = previous
1808
- self.nextKey[previous] = nil
1809
- else
1810
- self.firstKey = nil
1811
- self.lastKey = nil
1783
+ local iterable = values
1784
+ if iterable[Symbol.iterator] then
1785
+ local iterator = iterable[Symbol.iterator](iterable)
1786
+ while true do
1787
+ local result = iterator:next()
1788
+ if result.done then
1789
+ break
1812
1790
  end
1813
- self.nextKey[value] = nil
1814
- self.previousKey[value] = nil
1791
+ self:add(result.value)
1815
1792
  end
1816
- return contains
1817
- end
1818
- function Set.prototype.forEach(self, callback)
1819
- for ____, key in __TS__Iterator(
1820
- self:keys()
1821
- ) do
1822
- callback(_G, key, key, self)
1793
+ else
1794
+ local array = values
1795
+ for ____, value in ipairs(array) do
1796
+ self:add(value)
1823
1797
  end
1824
1798
  end
1825
- function Set.prototype.has(self, value)
1826
- return (self.nextKey[value] ~= nil) or (self.lastKey == value)
1827
- end
1828
- Set.prototype[Symbol.iterator] = function(self)
1829
- return self:values()
1830
- end
1831
- function Set.prototype.entries(self)
1832
- local nextKey = self.nextKey
1833
- local key = self.firstKey
1834
- return {
1835
- [Symbol.iterator] = function(self)
1836
- return self
1837
- end,
1838
- next = function(self)
1839
- local result = {done = not key, value = {key, key}}
1840
- key = nextKey[key]
1841
- return result
1842
- end
1843
- }
1844
- end
1845
- function Set.prototype.keys(self)
1846
- local nextKey = self.nextKey
1847
- local key = self.firstKey
1848
- return {
1849
- [Symbol.iterator] = function(self)
1850
- return self
1851
- end,
1852
- next = function(self)
1853
- local result = {done = not key, value = key}
1854
- key = nextKey[key]
1855
- return result
1856
- end
1857
- }
1799
+ end
1800
+ function Set.prototype.add(self, value)
1801
+ local isNewValue = not self:has(value)
1802
+ if isNewValue then
1803
+ self.size = self.size + 1
1858
1804
  end
1859
- function Set.prototype.values(self)
1860
- local nextKey = self.nextKey
1861
- local key = self.firstKey
1862
- return {
1863
- [Symbol.iterator] = function(self)
1864
- return self
1865
- end,
1866
- next = function(self)
1867
- local result = {done = not key, value = key}
1868
- key = nextKey[key]
1869
- return result
1870
- end
1871
- }
1805
+ if self.firstKey == nil then
1806
+ self.firstKey = value
1807
+ self.lastKey = value
1808
+ elseif isNewValue then
1809
+ self.nextKey[self.lastKey] = value
1810
+ self.previousKey[value] = self.lastKey
1811
+ self.lastKey = value
1872
1812
  end
1873
- Set[Symbol.species] = Set
1874
- return Set
1875
- end)()
1876
-
1877
- WeakMap = (function()
1878
- local WeakMap = __TS__Class()
1879
- WeakMap.name = "WeakMap"
1880
- function WeakMap.prototype.____constructor(self, entries)
1881
- self[Symbol.toStringTag] = "WeakMap"
1882
- self.items = {}
1883
- setmetatable(self.items, {__mode = "k"})
1884
- if entries == nil then
1885
- return
1886
- end
1887
- local iterable = entries
1888
- if iterable[Symbol.iterator] then
1889
- local iterator = iterable[Symbol.iterator](iterable)
1890
- while true do
1891
- local result = iterator:next()
1892
- if result.done then
1893
- break
1894
- end
1895
- local value = result.value
1896
- self.items[value[1]] = value[2]
1897
- end
1813
+ return self
1814
+ end
1815
+ function Set.prototype.clear(self)
1816
+ self.nextKey = {}
1817
+ self.previousKey = {}
1818
+ self.firstKey = nil
1819
+ self.lastKey = nil
1820
+ self.size = 0
1821
+ end
1822
+ function Set.prototype.delete(self, value)
1823
+ local contains = self:has(value)
1824
+ if contains then
1825
+ self.size = self.size - 1
1826
+ local next = self.nextKey[value]
1827
+ local previous = self.previousKey[value]
1828
+ if next and previous then
1829
+ self.nextKey[previous] = next
1830
+ self.previousKey[next] = previous
1831
+ elseif next then
1832
+ self.firstKey = next
1833
+ self.previousKey[next] = nil
1834
+ elseif previous then
1835
+ self.lastKey = previous
1836
+ self.nextKey[previous] = nil
1898
1837
  else
1899
- for ____, kvp in ipairs(entries) do
1900
- self.items[kvp[1]] = kvp[2]
1901
- end
1838
+ self.firstKey = nil
1839
+ self.lastKey = nil
1902
1840
  end
1841
+ self.nextKey[value] = nil
1842
+ self.previousKey[value] = nil
1903
1843
  end
1904
- function WeakMap.prototype.delete(self, key)
1905
- local contains = self:has(key)
1906
- self.items[key] = nil
1907
- return contains
1908
- end
1909
- function WeakMap.prototype.get(self, key)
1910
- return self.items[key]
1844
+ return contains
1845
+ end
1846
+ function Set.prototype.forEach(self, callback)
1847
+ for ____, key in __TS__Iterator(self:keys()) do
1848
+ callback(_G, key, key, self)
1911
1849
  end
1912
- function WeakMap.prototype.has(self, key)
1913
- return self.items[key] ~= nil
1850
+ end
1851
+ function Set.prototype.has(self, value)
1852
+ return self.nextKey[value] ~= nil or self.lastKey == value
1853
+ end
1854
+ Set.prototype[Symbol.iterator] = function(self)
1855
+ return self:values()
1856
+ end
1857
+ function Set.prototype.entries(self)
1858
+ local nextKey = self.nextKey
1859
+ local key = self.firstKey
1860
+ return {
1861
+ [Symbol.iterator] = function(self)
1862
+ return self
1863
+ end,
1864
+ next = function(self)
1865
+ local result = {done = not key, value = {key, key}}
1866
+ key = nextKey[key]
1867
+ return result
1868
+ end
1869
+ }
1870
+ end
1871
+ function Set.prototype.keys(self)
1872
+ local nextKey = self.nextKey
1873
+ local key = self.firstKey
1874
+ return {
1875
+ [Symbol.iterator] = function(self)
1876
+ return self
1877
+ end,
1878
+ next = function(self)
1879
+ local result = {done = not key, value = key}
1880
+ key = nextKey[key]
1881
+ return result
1882
+ end
1883
+ }
1884
+ end
1885
+ function Set.prototype.values(self)
1886
+ local nextKey = self.nextKey
1887
+ local key = self.firstKey
1888
+ return {
1889
+ [Symbol.iterator] = function(self)
1890
+ return self
1891
+ end,
1892
+ next = function(self)
1893
+ local result = {done = not key, value = key}
1894
+ key = nextKey[key]
1895
+ return result
1896
+ end
1897
+ }
1898
+ end
1899
+ Set[Symbol.species] = Set
1900
+ Set = Set
1901
+
1902
+ function __TS__SparseArrayNew(...)
1903
+ local sparseArray = {...}
1904
+ sparseArray.sparseLength = select("#", ...)
1905
+ return sparseArray
1906
+ end
1907
+
1908
+ function __TS__SparseArrayPush(sparseArray, ...)
1909
+ local args = {...}
1910
+ local argsLen = select("#", ...)
1911
+ local listLen = sparseArray.sparseLength
1912
+ for i = 1, argsLen do
1913
+ sparseArray[listLen + i] = args[i]
1914
1914
  end
1915
- function WeakMap.prototype.set(self, key, value)
1916
- self.items[key] = value
1917
- return self
1915
+ sparseArray.sparseLength = listLen + argsLen
1916
+ end
1917
+
1918
+ function __TS__SparseArraySpread(sparseArray)
1919
+ local _unpack = unpack or table.unpack
1920
+ return _unpack(sparseArray, 1, sparseArray.sparseLength)
1921
+ end
1922
+
1923
+ WeakMap = __TS__Class()
1924
+ WeakMap.name = "WeakMap"
1925
+ function WeakMap.prototype.____constructor(self, entries)
1926
+ self[Symbol.toStringTag] = "WeakMap"
1927
+ self.items = {}
1928
+ setmetatable(self.items, {__mode = "k"})
1929
+ if entries == nil then
1930
+ return
1918
1931
  end
1919
- WeakMap[Symbol.species] = WeakMap
1920
- return WeakMap
1921
- end)()
1922
-
1923
- WeakSet = (function()
1924
- local WeakSet = __TS__Class()
1925
- WeakSet.name = "WeakSet"
1926
- function WeakSet.prototype.____constructor(self, values)
1927
- self[Symbol.toStringTag] = "WeakSet"
1928
- self.items = {}
1929
- setmetatable(self.items, {__mode = "k"})
1930
- if values == nil then
1931
- return
1932
- end
1933
- local iterable = values
1934
- if iterable[Symbol.iterator] then
1935
- local iterator = iterable[Symbol.iterator](iterable)
1936
- while true do
1937
- local result = iterator:next()
1938
- if result.done then
1939
- break
1940
- end
1941
- self.items[result.value] = true
1942
- end
1943
- else
1944
- for ____, value in ipairs(values) do
1945
- self.items[value] = true
1932
+ local iterable = entries
1933
+ if iterable[Symbol.iterator] then
1934
+ local iterator = iterable[Symbol.iterator](iterable)
1935
+ while true do
1936
+ local result = iterator:next()
1937
+ if result.done then
1938
+ break
1946
1939
  end
1940
+ local value = result.value
1941
+ self.items[value[1]] = value[2]
1942
+ end
1943
+ else
1944
+ for ____, kvp in ipairs(entries) do
1945
+ self.items[kvp[1]] = kvp[2]
1947
1946
  end
1948
1947
  end
1949
- function WeakSet.prototype.add(self, value)
1950
- self.items[value] = true
1951
- return self
1952
- end
1953
- function WeakSet.prototype.delete(self, value)
1954
- local contains = self:has(value)
1955
- self.items[value] = nil
1956
- return contains
1948
+ end
1949
+ function WeakMap.prototype.delete(self, key)
1950
+ local contains = self:has(key)
1951
+ self.items[key] = nil
1952
+ return contains
1953
+ end
1954
+ function WeakMap.prototype.get(self, key)
1955
+ return self.items[key]
1956
+ end
1957
+ function WeakMap.prototype.has(self, key)
1958
+ return self.items[key] ~= nil
1959
+ end
1960
+ function WeakMap.prototype.set(self, key, value)
1961
+ self.items[key] = value
1962
+ return self
1963
+ end
1964
+ WeakMap[Symbol.species] = WeakMap
1965
+ WeakMap = WeakMap
1966
+
1967
+ WeakSet = __TS__Class()
1968
+ WeakSet.name = "WeakSet"
1969
+ function WeakSet.prototype.____constructor(self, values)
1970
+ self[Symbol.toStringTag] = "WeakSet"
1971
+ self.items = {}
1972
+ setmetatable(self.items, {__mode = "k"})
1973
+ if values == nil then
1974
+ return
1957
1975
  end
1958
- function WeakSet.prototype.has(self, value)
1959
- return self.items[value] == true
1976
+ local iterable = values
1977
+ if iterable[Symbol.iterator] then
1978
+ local iterator = iterable[Symbol.iterator](iterable)
1979
+ while true do
1980
+ local result = iterator:next()
1981
+ if result.done then
1982
+ break
1983
+ end
1984
+ self.items[result.value] = true
1985
+ end
1986
+ else
1987
+ for ____, value in ipairs(values) do
1988
+ self.items[value] = true
1989
+ end
1960
1990
  end
1961
- WeakSet[Symbol.species] = WeakSet
1962
- return WeakSet
1963
- end)()
1991
+ end
1992
+ function WeakSet.prototype.add(self, value)
1993
+ self.items[value] = true
1994
+ return self
1995
+ end
1996
+ function WeakSet.prototype.delete(self, value)
1997
+ local contains = self:has(value)
1998
+ self.items[value] = nil
1999
+ return contains
2000
+ end
2001
+ function WeakSet.prototype.has(self, value)
2002
+ return self.items[value] == true
2003
+ end
2004
+ WeakSet[Symbol.species] = WeakSet
2005
+ WeakSet = WeakSet
1964
2006
 
1965
2007
  function __TS__SourceMapTraceBack(fileName, sourceMap)
1966
2008
  _G.__TS__sourcemap = _G.__TS__sourcemap or ({})
@@ -1969,7 +2011,7 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
1969
2011
  _G.__TS__originalTraceback = debug.traceback
1970
2012
  debug.traceback = function(thread, message, level)
1971
2013
  local trace
1972
- if ((thread == nil) and (message == nil)) and (level == nil) then
2014
+ if thread == nil and message == nil and level == nil then
1973
2015
  trace = _G.__TS__originalTraceback()
1974
2016
  else
1975
2017
  trace = _G.__TS__originalTraceback(thread, message, level)
@@ -2038,7 +2080,7 @@ function __TS__StringCharCodeAt(self, index)
2038
2080
  if index < 0 then
2039
2081
  return 0 / 0
2040
2082
  end
2041
- return string.byte(self, index + 1) or (0 / 0)
2083
+ return string.byte(self, index + 1) or 0 / 0
2042
2084
  end
2043
2085
 
2044
2086
  function __TS__StringConcat(str1, ...)
@@ -2051,10 +2093,10 @@ function __TS__StringConcat(str1, ...)
2051
2093
  end
2052
2094
 
2053
2095
  function __TS__StringEndsWith(self, searchString, endPosition)
2054
- if (endPosition == nil) or (endPosition > #self) then
2096
+ if endPosition == nil or endPosition > #self then
2055
2097
  endPosition = #self
2056
2098
  end
2057
- return string.sub(self, (endPosition - #searchString) + 1, endPosition) == searchString
2099
+ return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
2058
2100
  end
2059
2101
 
2060
2102
  function __TS__StringIncludes(self, searchString, position)
@@ -2074,10 +2116,10 @@ function __TS__StringPadEnd(self, maxLength, fillString)
2074
2116
  if maxLength ~= maxLength then
2075
2117
  maxLength = 0
2076
2118
  end
2077
- if (maxLength == -math.huge) or (maxLength == math.huge) then
2119
+ if maxLength == -math.huge or maxLength == math.huge then
2078
2120
  error("Invalid string length", 0)
2079
2121
  end
2080
- if (#self >= maxLength) or (#fillString == 0) then
2122
+ if #self >= maxLength or #fillString == 0 then
2081
2123
  return self
2082
2124
  end
2083
2125
  maxLength = maxLength - #self
@@ -2101,10 +2143,10 @@ function __TS__StringPadStart(self, maxLength, fillString)
2101
2143
  if maxLength ~= maxLength then
2102
2144
  maxLength = 0
2103
2145
  end
2104
- if (maxLength == -math.huge) or (maxLength == math.huge) then
2146
+ if maxLength == -math.huge or maxLength == math.huge then
2105
2147
  error("Invalid string length", 0)
2106
2148
  end
2107
- if (#self >= maxLength) or (#fillString == 0) then
2149
+ if #self >= maxLength or #fillString == 0 then
2108
2150
  return self
2109
2151
  end
2110
2152
  maxLength = maxLength - #self
@@ -2128,7 +2170,13 @@ function __TS__StringReplace(source, searchValue, replaceValue)
2128
2170
  end
2129
2171
  local sub = string.sub
2130
2172
  local before = sub(source, 1, startPos - 1)
2131
- local replacement = (((type(replaceValue) == "string") and (function() return replaceValue end)) or (function() return replaceValue(_G, searchValue, startPos - 1, source) end))()
2173
+ local ____temp_0
2174
+ if type(replaceValue) == "string" then
2175
+ ____temp_0 = replaceValue
2176
+ else
2177
+ ____temp_0 = replaceValue(_G, searchValue, startPos - 1, source)
2178
+ end
2179
+ local replacement = ____temp_0
2132
2180
  local after = sub(source, endPos + 1)
2133
2181
  return (before .. replacement) .. after
2134
2182
  end
@@ -2170,7 +2218,7 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
2170
2218
  end
2171
2219
 
2172
2220
  function __TS__StringSlice(self, start, ____end)
2173
- if (start == nil) or (start ~= start) then
2221
+ if start == nil or start ~= start then
2174
2222
  start = 0
2175
2223
  end
2176
2224
  if ____end ~= ____end then
@@ -2179,7 +2227,7 @@ function __TS__StringSlice(self, start, ____end)
2179
2227
  if start >= 0 then
2180
2228
  start = start + 1
2181
2229
  end
2182
- if (____end ~= nil) and (____end < 0) then
2230
+ if ____end ~= nil and ____end < 0 then
2183
2231
  ____end = ____end - 1
2184
2232
  end
2185
2233
  return string.sub(self, start, ____end)
@@ -2195,8 +2243,8 @@ function __TS__StringSplit(source, separator, limit)
2195
2243
  local out = {}
2196
2244
  local index = 0
2197
2245
  local count = 0
2198
- if (separator == nil) or (separator == "") then
2199
- while (index < (#source - 1)) and (count < limit) do
2246
+ if separator == nil or separator == "" then
2247
+ while index < #source - 1 and count < limit do
2200
2248
  out[count + 1] = __TS__StringAccess(source, index)
2201
2249
  count = count + 1
2202
2250
  index = index + 1
@@ -2204,7 +2252,7 @@ function __TS__StringSplit(source, separator, limit)
2204
2252
  else
2205
2253
  local separatorLength = #separator
2206
2254
  local nextIndex = (string.find(source, separator, nil, true) or 0) - 1
2207
- while (nextIndex >= 0) and (count < limit) do
2255
+ while nextIndex >= 0 and count < limit do
2208
2256
  out[count + 1] = __TS__StringSubstring(source, index, nextIndex)
2209
2257
  count = count + 1
2210
2258
  index = nextIndex + separatorLength
@@ -2223,7 +2271,7 @@ function __TS__StringSplit(source, separator, limit)
2223
2271
  end
2224
2272
 
2225
2273
  function __TS__StringStartsWith(self, searchString, position)
2226
- if (position == nil) or (position < 0) then
2274
+ if position == nil or position < 0 then
2227
2275
  position = 0
2228
2276
  end
2229
2277
  return string.sub(self, position + 1, #searchString + position) == searchString