typescript-to-lua 1.1.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/CHANGELOG.md +28 -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 +5 -5
  6. package/dist/LuaPrinter.d.ts +11 -4
  7. package/dist/LuaPrinter.js +58 -15
  8. package/dist/cli/parse.d.ts +1 -1
  9. package/dist/cli/parse.js +14 -0
  10. package/dist/lualib/ArrayFlat.lua +1 -1
  11. package/dist/lualib/ArrayFlatMap.lua +1 -1
  12. package/dist/lualib/ArrayIsArray.lua +1 -1
  13. package/dist/lualib/ArrayReduce.lua +7 -1
  14. package/dist/lualib/ArrayReduceRight.lua +7 -1
  15. package/dist/lualib/ArraySetLength.lua +1 -1
  16. package/dist/lualib/ArraySplice.lua +5 -5
  17. package/dist/lualib/Await.lua +21 -13
  18. package/dist/lualib/CloneDescriptor.lua +7 -7
  19. package/dist/lualib/Decorate.lua +1 -1
  20. package/dist/lualib/DelegatedYield.lua +1 -3
  21. package/dist/lualib/Delete.lua +6 -6
  22. package/dist/lualib/Error.lua +47 -44
  23. package/dist/lualib/Generator.lua +1 -5
  24. package/dist/lualib/InstanceOf.lua +1 -1
  25. package/dist/lualib/InstanceOfObject.lua +1 -1
  26. package/dist/lualib/Map.lua +130 -134
  27. package/dist/lualib/Number.lua +1 -1
  28. package/dist/lualib/NumberIsFinite.lua +1 -1
  29. package/dist/lualib/NumberToString.lua +3 -5
  30. package/dist/lualib/ObjectDefineProperty.lua +40 -8
  31. package/dist/lualib/ParseFloat.lua +9 -5
  32. package/dist/lualib/ParseInt.lua +15 -3
  33. package/dist/lualib/Promise.lua +28 -24
  34. package/dist/lualib/Set.lua +119 -123
  35. package/dist/lualib/SetDescriptor.lua +7 -1
  36. package/dist/lualib/SourceMapTraceBack.lua +1 -1
  37. package/dist/lualib/SparseArrayNew.lua +5 -0
  38. package/dist/lualib/SparseArrayPush.lua +9 -0
  39. package/dist/lualib/SparseArraySpread.lua +4 -0
  40. package/dist/lualib/StringAccess.lua +1 -1
  41. package/dist/lualib/StringCharCodeAt.lua +1 -1
  42. package/dist/lualib/StringEndsWith.lua +2 -2
  43. package/dist/lualib/StringPadEnd.lua +2 -2
  44. package/dist/lualib/StringPadStart.lua +2 -2
  45. package/dist/lualib/StringReplace.lua +7 -1
  46. package/dist/lualib/StringSlice.lua +2 -2
  47. package/dist/lualib/StringSplit.lua +3 -3
  48. package/dist/lualib/StringStartsWith.lua +1 -1
  49. package/dist/lualib/StringSubstr.lua +1 -1
  50. package/dist/lualib/StringSubstring.lua +2 -2
  51. package/dist/lualib/Symbol.lua +3 -5
  52. package/dist/lualib/WeakMap.lua +40 -42
  53. package/dist/lualib/WeakSet.lua +36 -38
  54. package/dist/lualib/lualib_bundle.lua +795 -735
  55. package/dist/transformation/builtins/array.js +1 -2
  56. package/dist/transformation/builtins/function.js +6 -4
  57. package/dist/transformation/builtins/index.d.ts +1 -1
  58. package/dist/transformation/builtins/index.js +41 -6
  59. package/dist/transformation/builtins/object.d.ts +2 -1
  60. package/dist/transformation/builtins/object.js +1 -2
  61. package/dist/transformation/builtins/string.js +1 -2
  62. package/dist/transformation/context/context.d.ts +12 -0
  63. package/dist/transformation/context/context.js +102 -3
  64. package/dist/transformation/utils/diagnostics.d.ts +9 -6
  65. package/dist/transformation/utils/diagnostics.js +4 -3
  66. package/dist/transformation/utils/export.d.ts +3 -2
  67. package/dist/transformation/utils/export.js +10 -3
  68. package/dist/transformation/utils/language-extensions.d.ts +2 -0
  69. package/dist/transformation/utils/language-extensions.js +7 -1
  70. package/dist/transformation/utils/lua-ast.d.ts +0 -1
  71. package/dist/transformation/utils/lua-ast.js +14 -23
  72. package/dist/transformation/utils/preceding-statements.d.ts +3 -0
  73. package/dist/transformation/utils/preceding-statements.js +11 -0
  74. package/dist/transformation/utils/safe-names.d.ts +4 -2
  75. package/dist/transformation/utils/safe-names.js +11 -5
  76. package/dist/transformation/utils/scope.d.ts +3 -1
  77. package/dist/transformation/utils/scope.js +9 -1
  78. package/dist/transformation/utils/typescript/index.d.ts +1 -0
  79. package/dist/transformation/utils/typescript/index.js +16 -1
  80. package/dist/transformation/utils/typescript/types.d.ts +3 -1
  81. package/dist/transformation/utils/typescript/types.js +40 -13
  82. package/dist/transformation/visitors/access.d.ts +3 -0
  83. package/dist/transformation/visitors/access.js +63 -36
  84. package/dist/transformation/visitors/binary-expression/assignments.d.ts +3 -2
  85. package/dist/transformation/visitors/binary-expression/assignments.js +66 -57
  86. package/dist/transformation/visitors/binary-expression/compound.d.ts +5 -4
  87. package/dist/transformation/visitors/binary-expression/compound.js +66 -68
  88. package/dist/transformation/visitors/binary-expression/destructuring-assignments.d.ts +2 -2
  89. package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +54 -25
  90. package/dist/transformation/visitors/binary-expression/index.d.ts +3 -1
  91. package/dist/transformation/visitors/binary-expression/index.js +65 -23
  92. package/dist/transformation/visitors/call.d.ts +3 -2
  93. package/dist/transformation/visitors/call.js +95 -141
  94. package/dist/transformation/visitors/class/index.js +13 -9
  95. package/dist/transformation/visitors/class/new.js +4 -6
  96. package/dist/transformation/visitors/conditional.js +30 -37
  97. package/dist/transformation/visitors/delete.js +4 -0
  98. package/dist/transformation/visitors/errors.js +11 -9
  99. package/dist/transformation/visitors/expression-list.d.ts +7 -0
  100. package/dist/transformation/visitors/expression-list.js +120 -0
  101. package/dist/transformation/visitors/expression-statement.d.ts +3 -1
  102. package/dist/transformation/visitors/expression-statement.js +21 -19
  103. package/dist/transformation/visitors/function.d.ts +2 -0
  104. package/dist/transformation/visitors/function.js +63 -13
  105. package/dist/transformation/visitors/identifier.js +5 -0
  106. package/dist/transformation/visitors/language-extensions/index.d.ts +4 -0
  107. package/dist/transformation/visitors/language-extensions/index.js +17 -0
  108. package/dist/transformation/visitors/language-extensions/operators.d.ts +1 -1
  109. package/dist/transformation/visitors/language-extensions/operators.js +7 -2
  110. package/dist/transformation/visitors/language-extensions/pairsIterable.d.ts +5 -0
  111. package/dist/transformation/visitors/language-extensions/pairsIterable.js +53 -0
  112. package/dist/transformation/visitors/language-extensions/table.d.ts +1 -8
  113. package/dist/transformation/visitors/language-extensions/table.js +55 -53
  114. package/dist/transformation/visitors/literal.js +69 -16
  115. package/dist/transformation/visitors/loops/do-while.js +34 -8
  116. package/dist/transformation/visitors/loops/for-of.js +4 -0
  117. package/dist/transformation/visitors/loops/for.js +25 -5
  118. package/dist/transformation/visitors/loops/utils.d.ts +1 -0
  119. package/dist/transformation/visitors/loops/utils.js +19 -3
  120. package/dist/transformation/visitors/modules/export.js +4 -5
  121. package/dist/transformation/visitors/namespace.js +1 -1
  122. package/dist/transformation/visitors/optional-chaining.d.ts +16 -0
  123. package/dist/transformation/visitors/optional-chaining.js +172 -0
  124. package/dist/transformation/visitors/sourceFile.js +4 -1
  125. package/dist/transformation/visitors/spread.js +14 -7
  126. package/dist/transformation/visitors/switch.js +29 -9
  127. package/dist/transformation/visitors/template.js +5 -2
  128. package/dist/transformation/visitors/typeof.js +3 -1
  129. package/dist/transformation/visitors/variable-declaration.js +37 -8
  130. package/dist/transformation/visitors/void.d.ts +1 -4
  131. package/dist/transformation/visitors/void.js +7 -12
  132. package/dist/transpilation/resolve.js +1 -1
  133. package/dist/transpilation/transformers.js +4 -1
  134. package/dist/transpilation/utils.js +2 -1
  135. package/language-extensions/index.d.ts +11 -1
  136. package/package.json +5 -5
  137. package/dist/lualib/OptionalChainAccess.lua +0 -6
  138. package/dist/lualib/OptionalFunctionCall.lua +0 -6
  139. package/dist/lualib/OptionalMethodCall.lua +0 -11
  140. package/dist/transformation/utils/transform.d.ts +0 -8
  141. 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
@@ -494,30 +504,244 @@ function __TS__New(target, ...)
494
504
  return instance
495
505
  end
496
506
 
507
+ function __TS__Class(self)
508
+ local c = {prototype = {}}
509
+ c.prototype.__index = c.prototype
510
+ c.prototype.constructor = c
511
+ return c
512
+ end
513
+
514
+ __TS__Unpack = table.unpack or unpack
515
+
516
+ function __TS__FunctionBind(fn, thisArg, ...)
517
+ local boundArgs = {...}
518
+ return function(____, ...)
519
+ local args = {...}
520
+ do
521
+ local i = 0
522
+ while i < #boundArgs do
523
+ table.insert(args, i + 1, boundArgs[i + 1])
524
+ i = i + 1
525
+ end
526
+ end
527
+ return fn(
528
+ thisArg,
529
+ __TS__Unpack(args)
530
+ )
531
+ end
532
+ end
533
+
534
+ __TS__PromiseState = __TS__PromiseState or ({})
535
+ __TS__PromiseState.Pending = 0
536
+ __TS__PromiseState[__TS__PromiseState.Pending] = "Pending"
537
+ __TS__PromiseState.Fulfilled = 1
538
+ __TS__PromiseState[__TS__PromiseState.Fulfilled] = "Fulfilled"
539
+ __TS__PromiseState.Rejected = 2
540
+ __TS__PromiseState[__TS__PromiseState.Rejected] = "Rejected"
541
+ function __TS__PromiseDeferred(self)
542
+ local resolve
543
+ local reject
544
+ local promise = __TS__New(
545
+ __TS__Promise,
546
+ function(____, res, rej)
547
+ resolve = res
548
+ reject = rej
549
+ end
550
+ )
551
+ return {promise = promise, resolve = resolve, reject = reject}
552
+ end
553
+ function __TS__IsPromiseLike(self, thing)
554
+ return __TS__InstanceOf(thing, __TS__Promise)
555
+ end
556
+ __TS__Promise = __TS__Class()
557
+ __TS__Promise.name = "__TS__Promise"
558
+ function __TS__Promise.prototype.____constructor(self, executor)
559
+ self.state = __TS__PromiseState.Pending
560
+ self.fulfilledCallbacks = {}
561
+ self.rejectedCallbacks = {}
562
+ self.finallyCallbacks = {}
563
+ do
564
+ local function ____catch(e)
565
+ self:reject(e)
566
+ end
567
+ local ____try, ____hasReturned = pcall(function()
568
+ executor(
569
+ _G,
570
+ __TS__FunctionBind(self.resolve, self),
571
+ __TS__FunctionBind(self.reject, self)
572
+ )
573
+ end)
574
+ if not ____try then
575
+ ____catch(____hasReturned)
576
+ 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()
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)
609
+ if isFulfilled then
610
+ internalCallback(_G, self.value)
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)
621
+ if isRejected then
622
+ internalCallback(_G, self.rejectionReason)
623
+ end
624
+ end
625
+ if isFulfilled then
626
+ resolve(_G, self.value)
627
+ 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)
641
+ end
642
+ end
643
+ return self
644
+ end
645
+ function __TS__Promise.prototype.resolve(self, data)
646
+ if __TS__InstanceOf(data, __TS__Promise) then
647
+ data["then"](
648
+ data,
649
+ function(____, v) return self:resolve(v) end,
650
+ function(____, err) return self:reject(err) end
651
+ )
652
+ return
653
+ end
654
+ if self.state == __TS__PromiseState.Pending then
655
+ self.state = __TS__PromiseState.Fulfilled
656
+ self.value = data
657
+ for ____, callback in ipairs(self.fulfilledCallbacks) do
658
+ callback(_G, data)
659
+ end
660
+ for ____, callback in ipairs(self.finallyCallbacks) do
661
+ callback(_G)
662
+ end
663
+ 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)
674
+ end
675
+ 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)
692
+ end
693
+ end
694
+ 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)
703
+ else
704
+ data["then"](data, resolve, reject)
705
+ end
706
+ else
707
+ resolve(_G, data)
708
+ end
709
+ end
710
+
497
711
  function __TS__AsyncAwaiter(generator)
498
712
  return __TS__New(
499
713
  __TS__Promise,
500
714
  function(____, resolve, reject)
501
715
  local adopt, fulfilled, rejected, step, asyncCoroutine
502
716
  function adopt(self, value)
503
- return ((__TS__InstanceOf(value, __TS__Promise) and (function() return value end)) or (function() return __TS__Promise.resolve(value) end))()
717
+ local ____temp_0
718
+ if __TS__InstanceOf(value, __TS__Promise) then
719
+ ____temp_0 = value
720
+ else
721
+ ____temp_0 = __TS__Promise.resolve(value)
722
+ end
723
+ return ____temp_0
504
724
  end
505
725
  function fulfilled(self, value)
506
726
  local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine, value)
507
727
  if success then
508
728
  step(_G, resultOrError, errorOrErrorHandler)
509
729
  else
510
- reject(_G, resultOrError)
730
+ reject(_G, errorOrErrorHandler)
511
731
  end
512
732
  end
513
733
  function rejected(self, handler)
514
734
  if handler then
515
735
  return function(____, value)
516
- local success, valueOrError = pcall(handler, value)
736
+ local success, hasReturnedOrError, returnedValue = pcall(handler, value)
517
737
  if success then
518
- step(_G, valueOrError, handler)
738
+ if hasReturnedOrError then
739
+ resolve(_G, returnedValue)
740
+ else
741
+ step(_G, hasReturnedOrError, handler)
742
+ end
519
743
  else
520
- reject(_G, valueOrError)
744
+ reject(_G, hasReturnedOrError)
521
745
  end
522
746
  end
523
747
  else
@@ -530,14 +754,12 @@ function __TS__AsyncAwaiter(generator)
530
754
  if coroutine.status(asyncCoroutine) == "dead" then
531
755
  resolve(_G, result)
532
756
  else
533
- (function()
534
- local ____self = adopt(_G, result)
535
- return ____self["then"](
536
- ____self,
537
- fulfilled,
538
- rejected(_G, errorHandler)
539
- )
540
- end)()
757
+ local ____self_1 = adopt(_G, result)
758
+ ____self_1["then"](
759
+ ____self_1,
760
+ fulfilled,
761
+ rejected(_G, errorHandler)
762
+ )
541
763
  end
542
764
  end
543
765
  asyncCoroutine = coroutine.create(generator)
@@ -554,13 +776,6 @@ function __TS__Await(errorHandler, thing)
554
776
  return coroutine.yield(errorHandler, thing)
555
777
  end
556
778
 
557
- function __TS__Class(self)
558
- local c = {prototype = {}}
559
- c.prototype.__index = c.prototype
560
- c.prototype.constructor = c
561
- return c
562
- end
563
-
564
779
  function __TS__ClassExtends(target, base)
565
780
  target.____super = base
566
781
  local staticMetatable = setmetatable({__index = base}, base)
@@ -587,21 +802,21 @@ function __TS__ClassExtends(target, base)
587
802
  end
588
803
 
589
804
  function __TS__CloneDescriptor(____bindingPattern0)
805
+ local value
806
+ local writable
807
+ local set
808
+ local get
809
+ local configurable
590
810
  local enumerable
591
811
  enumerable = ____bindingPattern0.enumerable
592
- local configurable
593
812
  configurable = ____bindingPattern0.configurable
594
- local get
595
813
  get = ____bindingPattern0.get
596
- local set
597
814
  set = ____bindingPattern0.set
598
- local writable
599
815
  writable = ____bindingPattern0.writable
600
- local value
601
816
  value = ____bindingPattern0.value
602
817
  local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
603
- local hasGetterOrSetter = (get ~= nil) or (set ~= nil)
604
- local hasValueOrWritableAttribute = (writable ~= nil) or (value ~= nil)
818
+ local hasGetterOrSetter = get ~= nil or set ~= nil
819
+ local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
605
820
  if hasGetterOrSetter and hasValueOrWritableAttribute then
606
821
  error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
607
822
  end
@@ -679,7 +894,13 @@ function __TS__SetDescriptor(target, key, desc, isPrototype)
679
894
  if isPrototype == nil then
680
895
  isPrototype = false
681
896
  end
682
- local metatable = ((isPrototype and (function() return target end)) or (function() return getmetatable(target) 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
683
904
  if not metatable then
684
905
  metatable = {}
685
906
  setmetatable(target, metatable)
@@ -724,7 +945,7 @@ function __TS__Decorate(decorators, target, key, desc)
724
945
  local value = rawget(target, key)
725
946
  local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
726
947
  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)
948
+ local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
728
949
  if isSimpleValue then
729
950
  rawset(target, key, desc.value)
730
951
  else
@@ -759,28 +980,107 @@ function __TS__ObjectGetOwnPropertyDescriptors(object)
759
980
  return rawget(metatable, "_descriptors") or ({})
760
981
  end
761
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
+
762
1062
  function __TS__Delete(target, key)
763
1063
  local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
764
1064
  local descriptor = descriptors[key]
765
1065
  if descriptor then
766
1066
  if not descriptor.configurable then
767
1067
  error(
768
- ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. ".",
1068
+ __TS__New(
1069
+ TypeError,
1070
+ ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
1071
+ ),
769
1072
  0
770
1073
  )
771
1074
  end
772
1075
  descriptors[key] = nil
773
1076
  return true
774
1077
  end
775
- if target[key] ~= nil then
776
- target[key] = nil
777
- return true
778
- end
779
- return false
1078
+ target[key] = nil
1079
+ return true
780
1080
  end
781
1081
 
782
1082
  function __TS__StringAccess(self, index)
783
- if (index >= 0) and (index < #self) then
1083
+ if index >= 0 and index < #self then
784
1084
  return string.sub(self, index + 1, index + 1)
785
1085
  end
786
1086
  end
@@ -788,9 +1088,7 @@ end
788
1088
  function __TS__DelegatedYield(iterable)
789
1089
  if type(iterable) == "string" then
790
1090
  for index = 0, #iterable - 1 do
791
- coroutine.yield(
792
- __TS__StringAccess(iterable, index)
793
- )
1091
+ coroutine.yield(__TS__StringAccess(iterable, index))
794
1092
  end
795
1093
  elseif iterable.____coroutine ~= nil then
796
1094
  local co = iterable.____coroutine
@@ -822,102 +1120,6 @@ function __TS__DelegatedYield(iterable)
822
1120
  end
823
1121
  end
824
1122
 
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
- __TS__Unpack = table.unpack or unpack
902
-
903
- function __TS__FunctionBind(fn, thisArg, ...)
904
- local boundArgs = {...}
905
- return function(____, ...)
906
- local args = {...}
907
- do
908
- local i = 0
909
- while i < #boundArgs do
910
- table.insert(args, i + 1, boundArgs[i + 1])
911
- i = i + 1
912
- end
913
- end
914
- return fn(
915
- thisArg,
916
- __TS__Unpack(args)
917
- )
918
- end
919
- end
920
-
921
1123
  function __TS__GeneratorIterator(self)
922
1124
  return self
923
1125
  end
@@ -940,11 +1142,7 @@ function __TS__Generator(fn)
940
1142
  local args = {...}
941
1143
  local argsLength = select("#", ...)
942
1144
  return {
943
- ____coroutine = coroutine.create(
944
- function() return fn(
945
- (unpack or table.unpack)(args, 1, argsLength)
946
- ) end
947
- ),
1145
+ ____coroutine = coroutine.create(function() return fn((unpack or table.unpack)(args, 1, argsLength)) end),
948
1146
  [Symbol.iterator] = __TS__GeneratorIterator,
949
1147
  next = __TS__GeneratorNext
950
1148
  }
@@ -953,7 +1151,7 @@ end
953
1151
 
954
1152
  function __TS__InstanceOfObject(value)
955
1153
  local valueType = type(value)
956
- return (valueType == "table") or (valueType == "function")
1154
+ return valueType == "table" or valueType == "function"
957
1155
  end
958
1156
 
959
1157
  function __TS__IteratorGeneratorStep(self)
@@ -994,150 +1192,146 @@ function __TS__Iterator(iterable)
994
1192
  end
995
1193
  end
996
1194
 
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
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
1026
1205
  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
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
1053
1213
  end
1054
- self.nextKey[key] = nil
1055
- self.previousKey[key] = nil
1214
+ local value = result.value
1215
+ self:set(value[1], value[2])
1056
1216
  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)
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
1065
1250
  end
1251
+ self.nextKey[key] = nil
1252
+ self.previousKey[key] = nil
1253
+ 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)
1066
1260
  end
1067
- function Map.prototype.get(self, key)
1068
- 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
1069
1272
  end
1070
- function Map.prototype.has(self, key)
1071
- 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
1072
1281
  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
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
1077
1300
  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
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
1086
1314
  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)()
1315
+ }
1316
+ end
1317
+ function Map.prototype.values(self)
1318
+ local ____temp_1 = self
1319
+ local items = ____temp_1.items
1320
+ local nextKey = ____temp_1.nextKey
1321
+ local key = self.firstKey
1322
+ return {
1323
+ [Symbol.iterator] = function(self)
1324
+ return self
1325
+ end,
1326
+ next = function(self)
1327
+ local result = {done = not key, value = items[key]}
1328
+ key = nextKey[key]
1329
+ return result
1330
+ end
1331
+ }
1332
+ end
1333
+ Map[Symbol.species] = Map
1334
+ Map = Map
1141
1335
 
1142
1336
  __TS__MathAtan2 = math.atan2 or math.atan
1143
1337
 
@@ -1162,14 +1356,14 @@ function __TS__Number(value)
1162
1356
  end
1163
1357
  return 0 / 0
1164
1358
  elseif valueType == "boolean" then
1165
- return (value and 1) or 0
1359
+ return value and 1 or 0
1166
1360
  else
1167
1361
  return 0 / 0
1168
1362
  end
1169
1363
  end
1170
1364
 
1171
1365
  function __TS__NumberIsFinite(value)
1172
- return (((type(value) == "number") and (value == value)) and (value ~= math.huge)) and (value ~= -math.huge)
1366
+ return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
1173
1367
  end
1174
1368
 
1175
1369
  function __TS__NumberIsNaN(value)
@@ -1178,16 +1372,14 @@ end
1178
1372
 
1179
1373
  ____radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
1180
1374
  function __TS__NumberToString(self, radix)
1181
- if ((((radix == nil) or (radix == 10)) or (self == math.huge)) or (self == -math.huge)) or (self ~= self) then
1375
+ if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then
1182
1376
  return tostring(self)
1183
1377
  end
1184
1378
  radix = math.floor(radix)
1185
- if (radix < 2) or (radix > 36) then
1379
+ if radix < 2 or radix > 36 then
1186
1380
  error("toString() radix argument must be between 2 and 36", 0)
1187
1381
  end
1188
- local integer, fraction = math.modf(
1189
- math.abs(self)
1190
- )
1382
+ local integer, fraction = math.modf(math.abs(self))
1191
1383
  local result = ""
1192
1384
  if radix == 8 then
1193
1385
  result = string.format("%o", integer)
@@ -1221,9 +1413,15 @@ function __TS__NumberToString(self, radix)
1221
1413
  end
1222
1414
 
1223
1415
  function __TS__ObjectDefineProperty(target, key, desc)
1224
- local luaKey = (((type(key) == "number") and (function() return key + 1 end)) or (function() return key end))()
1416
+ local ____temp_0
1417
+ if type(key) == "number" then
1418
+ ____temp_0 = key + 1
1419
+ else
1420
+ ____temp_0 = key
1421
+ end
1422
+ local luaKey = ____temp_0
1225
1423
  local value = rawget(target, luaKey)
1226
- local hasGetterOrSetter = (desc.get ~= nil) or (desc.set ~= nil)
1424
+ local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
1227
1425
  local descriptor
1228
1426
  if hasGetterOrSetter then
1229
1427
  if value ~= nil then
@@ -1235,13 +1433,39 @@ function __TS__ObjectDefineProperty(target, key, desc)
1235
1433
  descriptor = desc
1236
1434
  else
1237
1435
  local valueExists = value ~= nil
1436
+ local ____desc_set_5 = desc.set
1437
+ local ____desc_get_6 = desc.get
1438
+ local ____temp_1
1439
+ if desc.configurable ~= nil then
1440
+ ____temp_1 = desc.configurable
1441
+ else
1442
+ ____temp_1 = valueExists
1443
+ end
1444
+ local ____temp_2
1445
+ if desc.enumerable ~= nil then
1446
+ ____temp_2 = desc.enumerable
1447
+ else
1448
+ ____temp_2 = valueExists
1449
+ end
1450
+ local ____temp_3
1451
+ if desc.writable ~= nil then
1452
+ ____temp_3 = desc.writable
1453
+ else
1454
+ ____temp_3 = valueExists
1455
+ end
1456
+ local ____temp_4
1457
+ if desc.value ~= nil then
1458
+ ____temp_4 = desc.value
1459
+ else
1460
+ ____temp_4 = value
1461
+ end
1238
1462
  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))()
1463
+ set = ____desc_set_5,
1464
+ get = ____desc_get_6,
1465
+ configurable = ____temp_1,
1466
+ enumerable = ____temp_2,
1467
+ writable = ____temp_3,
1468
+ value = ____temp_4
1245
1469
  }
1246
1470
  end
1247
1471
  __TS__SetDescriptor(target, luaKey, descriptor)
@@ -1303,41 +1527,19 @@ function __TS__ObjectValues(obj)
1303
1527
  return result
1304
1528
  end
1305
1529
 
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
1530
  function __TS__ParseFloat(numberString)
1333
1531
  local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
1334
1532
  if infinityMatch then
1335
- return (((__TS__StringAccess(infinityMatch, 0) == "-") and (function() return -math.huge end)) or (function() return math.huge end))()
1533
+ local ____temp_0
1534
+ if __TS__StringAccess(infinityMatch, 0) == "-" then
1535
+ ____temp_0 = -math.huge
1536
+ else
1537
+ ____temp_0 = math.huge
1538
+ end
1539
+ return ____temp_0
1336
1540
  end
1337
- local number = tonumber(
1338
- string.match(numberString, "^%s*(-?%d+%.?%d*)")
1339
- )
1340
- return number or (0 / 0)
1541
+ local number = tonumber(string.match(numberString, "^%s*(-?%d+%.?%d*)"))
1542
+ return number or 0 / 0
1341
1543
  end
1342
1544
 
1343
1545
  function __TS__StringSubstr(self, from, length)
@@ -1345,7 +1547,7 @@ function __TS__StringSubstr(self, from, length)
1345
1547
  from = 0
1346
1548
  end
1347
1549
  if length ~= nil then
1348
- if (length ~= length) or (length <= 0) then
1550
+ if length ~= length or length <= 0 then
1349
1551
  return ""
1350
1552
  end
1351
1553
  length = length + from
@@ -1360,7 +1562,7 @@ function __TS__StringSubstring(self, start, ____end)
1360
1562
  if ____end ~= ____end then
1361
1563
  ____end = 0
1362
1564
  end
1363
- if (____end ~= nil) and (start > ____end) then
1565
+ if ____end ~= nil and start > ____end then
1364
1566
  start, ____end = ____end, start
1365
1567
  end
1366
1568
  if start >= 0 then
@@ -1368,7 +1570,7 @@ function __TS__StringSubstring(self, start, ____end)
1368
1570
  else
1369
1571
  start = 1
1370
1572
  end
1371
- if (____end ~= nil) and (____end < 0) then
1573
+ if ____end ~= nil and ____end < 0 then
1372
1574
  ____end = 0
1373
1575
  end
1374
1576
  return string.sub(self, start, ____end)
@@ -1381,13 +1583,25 @@ function __TS__ParseInt(numberString, base)
1381
1583
  local hexMatch = string.match(numberString, "^%s*-?0[xX]")
1382
1584
  if hexMatch then
1383
1585
  base = 16
1384
- numberString = ((string.match(hexMatch, "-") and (function() return "-" .. __TS__StringSubstr(numberString, #hexMatch) end)) or (function() return __TS__StringSubstr(numberString, #hexMatch) end))()
1586
+ local ____string_match_result__0_0
1587
+ if string.match(hexMatch, "-") then
1588
+ ____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
1589
+ else
1590
+ ____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
1591
+ end
1592
+ numberString = ____string_match_result__0_0
1385
1593
  end
1386
1594
  end
1387
- if (base < 2) or (base > 36) then
1595
+ if base < 2 or base > 36 then
1388
1596
  return 0 / 0
1389
1597
  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))()
1598
+ local ____temp_1
1599
+ if base <= 10 then
1600
+ ____temp_1 = __TS__StringSubstring(__TS__parseInt_base_pattern, 0, base)
1601
+ else
1602
+ ____temp_1 = __TS__StringSubstr(__TS__parseInt_base_pattern, 0, 10 + 2 * (base - 10))
1603
+ end
1604
+ local allowedDigits = ____temp_1
1391
1605
  local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1392
1606
  local number = tonumber(
1393
1607
  string.match(numberString, pattern),
@@ -1403,179 +1617,6 @@ function __TS__ParseInt(numberString, base)
1403
1617
  end
1404
1618
  end
1405
1619
 
1406
- __TS__PromiseState = __TS__PromiseState or ({})
1407
- __TS__PromiseState.Pending = 0
1408
- __TS__PromiseState[__TS__PromiseState.Pending] = "Pending"
1409
- __TS__PromiseState.Fulfilled = 1
1410
- __TS__PromiseState[__TS__PromiseState.Fulfilled] = "Fulfilled"
1411
- __TS__PromiseState.Rejected = 2
1412
- __TS__PromiseState[__TS__PromiseState.Rejected] = "Rejected"
1413
- function __TS__PromiseDeferred(self)
1414
- local resolve
1415
- local reject
1416
- local promise = __TS__New(
1417
- __TS__Promise,
1418
- function(____, res, rej)
1419
- resolve = res
1420
- reject = rej
1421
- end
1422
- )
1423
- return {promise = promise, resolve = resolve, reject = reject}
1424
- end
1425
- function __TS__IsPromiseLike(self, thing)
1426
- return __TS__InstanceOf(thing, __TS__Promise)
1427
- end
1428
- __TS__Promise = __TS__Class()
1429
- __TS__Promise.name = "__TS__Promise"
1430
- function __TS__Promise.prototype.____constructor(self, executor)
1431
- self.state = __TS__PromiseState.Pending
1432
- self.fulfilledCallbacks = {}
1433
- self.rejectedCallbacks = {}
1434
- self.finallyCallbacks = {}
1435
- do
1436
- local function ____catch(e)
1437
- self:reject(e)
1438
- 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
- )
1448
- if not ____try then
1449
- ____hasReturned, ____returnValue = ____catch(____hasReturned)
1450
- end
1451
- end
1452
- end
1453
- function __TS__Promise.resolve(data)
1454
- local promise = __TS__New(
1455
- __TS__Promise,
1456
- function()
1457
- end
1458
- )
1459
- promise.state = __TS__PromiseState.Fulfilled
1460
- promise.value = data
1461
- return promise
1462
- end
1463
- function __TS__Promise.reject(reason)
1464
- local promise = __TS__New(
1465
- __TS__Promise,
1466
- function()
1467
- end
1468
- )
1469
- promise.state = __TS__PromiseState.Rejected
1470
- promise.rejectionReason = reason
1471
- return promise
1472
- end
1473
- __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
1478
- local isFulfilled = self.state == __TS__PromiseState.Fulfilled
1479
- local isRejected = self.state == __TS__PromiseState.Rejected
1480
- if onFulfilled then
1481
- local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
1482
- __TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
1483
- if isFulfilled then
1484
- internalCallback(_G, self.value)
1485
- end
1486
- else
1487
- __TS__ArrayPush(
1488
- self.fulfilledCallbacks,
1489
- function() return resolve(_G, nil) end
1490
- )
1491
- end
1492
- if onRejected then
1493
- local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
1494
- __TS__ArrayPush(self.rejectedCallbacks, internalCallback)
1495
- if isRejected then
1496
- internalCallback(_G, self.rejectionReason)
1497
- end
1498
- end
1499
- if isFulfilled then
1500
- resolve(_G, self.value)
1501
- end
1502
- if isRejected then
1503
- reject(_G, self.rejectionReason)
1504
- end
1505
- return promise
1506
- end
1507
- function __TS__Promise.prototype.catch(self, onRejected)
1508
- return self["then"](self, nil, onRejected)
1509
- end
1510
- function __TS__Promise.prototype.finally(self, onFinally)
1511
- if onFinally then
1512
- __TS__ArrayPush(self.finallyCallbacks, onFinally)
1513
- if self.state ~= __TS__PromiseState.Pending then
1514
- onFinally(_G)
1515
- end
1516
- end
1517
- return self
1518
- end
1519
- function __TS__Promise.prototype.resolve(self, data)
1520
- if self.state == __TS__PromiseState.Pending then
1521
- self.state = __TS__PromiseState.Fulfilled
1522
- self.value = data
1523
- for ____, callback in ipairs(self.fulfilledCallbacks) do
1524
- callback(_G, data)
1525
- end
1526
- for ____, callback in ipairs(self.finallyCallbacks) do
1527
- callback(_G)
1528
- end
1529
- end
1530
- end
1531
- function __TS__Promise.prototype.reject(self, reason)
1532
- if self.state == __TS__PromiseState.Pending then
1533
- self.state = __TS__PromiseState.Rejected
1534
- self.rejectionReason = reason
1535
- for ____, callback in ipairs(self.rejectedCallbacks) do
1536
- callback(_G, reason)
1537
- end
1538
- for ____, callback in ipairs(self.finallyCallbacks) do
1539
- callback(_G)
1540
- end
1541
- end
1542
- end
1543
- function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
1544
- return function(____, value)
1545
- do
1546
- local function ____catch(e)
1547
- reject(_G, e)
1548
- end
1549
- local ____try, ____hasReturned = pcall(
1550
- function()
1551
- self:handleCallbackData(
1552
- f(_G, value),
1553
- resolve,
1554
- reject
1555
- )
1556
- end
1557
- )
1558
- if not ____try then
1559
- ____hasReturned, ____returnValue = ____catch(____hasReturned)
1560
- end
1561
- end
1562
- end
1563
- end
1564
- function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject)
1565
- if __TS__IsPromiseLike(_G, data) then
1566
- local nextpromise = data
1567
- if nextpromise.state == __TS__PromiseState.Fulfilled then
1568
- resolve(_G, nextpromise.value)
1569
- elseif nextpromise.state == __TS__PromiseState.Rejected then
1570
- reject(_G, nextpromise.rejectionReason)
1571
- else
1572
- data["then"](data, resolve, reject)
1573
- end
1574
- else
1575
- resolve(_G, data)
1576
- end
1577
- end
1578
-
1579
1620
  function __TS__PromiseAll(iterable)
1580
1621
  local results = {}
1581
1622
  local toResolve = {}
@@ -1741,226 +1782,239 @@ function __TS__PromiseRace(iterable)
1741
1782
  )
1742
1783
  end
1743
1784
 
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
1785
+ Set = __TS__Class()
1786
+ Set.name = "Set"
1787
+ function Set.prototype.____constructor(self, values)
1788
+ self[Symbol.toStringTag] = "Set"
1789
+ self.size = 0
1790
+ self.nextKey = {}
1791
+ self.previousKey = {}
1792
+ if values == nil then
1793
+ return
1786
1794
  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
1795
+ local iterable = values
1796
+ if iterable[Symbol.iterator] then
1797
+ local iterator = iterable[Symbol.iterator](iterable)
1798
+ while true do
1799
+ local result = iterator:next()
1800
+ if result.done then
1801
+ break
1812
1802
  end
1813
- self.nextKey[value] = nil
1814
- self.previousKey[value] = nil
1803
+ self:add(result.value)
1815
1804
  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)
1805
+ else
1806
+ local array = values
1807
+ for ____, value in ipairs(array) do
1808
+ self:add(value)
1823
1809
  end
1824
1810
  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
- }
1811
+ end
1812
+ function Set.prototype.add(self, value)
1813
+ local isNewValue = not self:has(value)
1814
+ if isNewValue then
1815
+ self.size = self.size + 1
1858
1816
  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
- }
1817
+ if self.firstKey == nil then
1818
+ self.firstKey = value
1819
+ self.lastKey = value
1820
+ elseif isNewValue then
1821
+ self.nextKey[self.lastKey] = value
1822
+ self.previousKey[value] = self.lastKey
1823
+ self.lastKey = value
1872
1824
  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
1825
+ return self
1826
+ end
1827
+ function Set.prototype.clear(self)
1828
+ self.nextKey = {}
1829
+ self.previousKey = {}
1830
+ self.firstKey = nil
1831
+ self.lastKey = nil
1832
+ self.size = 0
1833
+ end
1834
+ function Set.prototype.delete(self, value)
1835
+ local contains = self:has(value)
1836
+ if contains then
1837
+ self.size = self.size - 1
1838
+ local next = self.nextKey[value]
1839
+ local previous = self.previousKey[value]
1840
+ if next and previous then
1841
+ self.nextKey[previous] = next
1842
+ self.previousKey[next] = previous
1843
+ elseif next then
1844
+ self.firstKey = next
1845
+ self.previousKey[next] = nil
1846
+ elseif previous then
1847
+ self.lastKey = previous
1848
+ self.nextKey[previous] = nil
1898
1849
  else
1899
- for ____, kvp in ipairs(entries) do
1900
- self.items[kvp[1]] = kvp[2]
1901
- end
1850
+ self.firstKey = nil
1851
+ self.lastKey = nil
1902
1852
  end
1853
+ self.nextKey[value] = nil
1854
+ self.previousKey[value] = nil
1903
1855
  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]
1856
+ return contains
1857
+ end
1858
+ function Set.prototype.forEach(self, callback)
1859
+ for ____, key in __TS__Iterator(self:keys()) do
1860
+ callback(_G, key, key, self)
1911
1861
  end
1912
- function WeakMap.prototype.has(self, key)
1913
- return self.items[key] ~= nil
1862
+ end
1863
+ function Set.prototype.has(self, value)
1864
+ return self.nextKey[value] ~= nil or self.lastKey == value
1865
+ end
1866
+ Set.prototype[Symbol.iterator] = function(self)
1867
+ return self:values()
1868
+ end
1869
+ function Set.prototype.entries(self)
1870
+ local nextKey = self.nextKey
1871
+ local key = self.firstKey
1872
+ return {
1873
+ [Symbol.iterator] = function(self)
1874
+ return self
1875
+ end,
1876
+ next = function(self)
1877
+ local result = {done = not key, value = {key, key}}
1878
+ key = nextKey[key]
1879
+ return result
1880
+ end
1881
+ }
1882
+ end
1883
+ function Set.prototype.keys(self)
1884
+ local nextKey = self.nextKey
1885
+ local key = self.firstKey
1886
+ return {
1887
+ [Symbol.iterator] = function(self)
1888
+ return self
1889
+ end,
1890
+ next = function(self)
1891
+ local result = {done = not key, value = key}
1892
+ key = nextKey[key]
1893
+ return result
1894
+ end
1895
+ }
1896
+ end
1897
+ function Set.prototype.values(self)
1898
+ local nextKey = self.nextKey
1899
+ local key = self.firstKey
1900
+ return {
1901
+ [Symbol.iterator] = function(self)
1902
+ return self
1903
+ end,
1904
+ next = function(self)
1905
+ local result = {done = not key, value = key}
1906
+ key = nextKey[key]
1907
+ return result
1908
+ end
1909
+ }
1910
+ end
1911
+ Set[Symbol.species] = Set
1912
+ Set = Set
1913
+
1914
+ function __TS__SparseArrayNew(...)
1915
+ local sparseArray = {...}
1916
+ sparseArray.sparseLength = select("#", ...)
1917
+ return sparseArray
1918
+ end
1919
+
1920
+ function __TS__SparseArrayPush(sparseArray, ...)
1921
+ local args = {...}
1922
+ local argsLen = select("#", ...)
1923
+ local listLen = sparseArray.sparseLength
1924
+ for i = 1, argsLen do
1925
+ sparseArray[listLen + i] = args[i]
1914
1926
  end
1915
- function WeakMap.prototype.set(self, key, value)
1916
- self.items[key] = value
1917
- return self
1927
+ sparseArray.sparseLength = listLen + argsLen
1928
+ end
1929
+
1930
+ function __TS__SparseArraySpread(sparseArray)
1931
+ local _unpack = unpack or table.unpack
1932
+ return _unpack(sparseArray, 1, sparseArray.sparseLength)
1933
+ end
1934
+
1935
+ WeakMap = __TS__Class()
1936
+ WeakMap.name = "WeakMap"
1937
+ function WeakMap.prototype.____constructor(self, entries)
1938
+ self[Symbol.toStringTag] = "WeakMap"
1939
+ self.items = {}
1940
+ setmetatable(self.items, {__mode = "k"})
1941
+ if entries == nil then
1942
+ return
1918
1943
  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
1944
+ local iterable = entries
1945
+ if iterable[Symbol.iterator] then
1946
+ local iterator = iterable[Symbol.iterator](iterable)
1947
+ while true do
1948
+ local result = iterator:next()
1949
+ if result.done then
1950
+ break
1946
1951
  end
1952
+ local value = result.value
1953
+ self.items[value[1]] = value[2]
1954
+ end
1955
+ else
1956
+ for ____, kvp in ipairs(entries) do
1957
+ self.items[kvp[1]] = kvp[2]
1947
1958
  end
1948
1959
  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
1960
+ end
1961
+ function WeakMap.prototype.delete(self, key)
1962
+ local contains = self:has(key)
1963
+ self.items[key] = nil
1964
+ return contains
1965
+ end
1966
+ function WeakMap.prototype.get(self, key)
1967
+ return self.items[key]
1968
+ end
1969
+ function WeakMap.prototype.has(self, key)
1970
+ return self.items[key] ~= nil
1971
+ end
1972
+ function WeakMap.prototype.set(self, key, value)
1973
+ self.items[key] = value
1974
+ return self
1975
+ end
1976
+ WeakMap[Symbol.species] = WeakMap
1977
+ WeakMap = WeakMap
1978
+
1979
+ WeakSet = __TS__Class()
1980
+ WeakSet.name = "WeakSet"
1981
+ function WeakSet.prototype.____constructor(self, values)
1982
+ self[Symbol.toStringTag] = "WeakSet"
1983
+ self.items = {}
1984
+ setmetatable(self.items, {__mode = "k"})
1985
+ if values == nil then
1986
+ return
1957
1987
  end
1958
- function WeakSet.prototype.has(self, value)
1959
- return self.items[value] == true
1988
+ local iterable = values
1989
+ if iterable[Symbol.iterator] then
1990
+ local iterator = iterable[Symbol.iterator](iterable)
1991
+ while true do
1992
+ local result = iterator:next()
1993
+ if result.done then
1994
+ break
1995
+ end
1996
+ self.items[result.value] = true
1997
+ end
1998
+ else
1999
+ for ____, value in ipairs(values) do
2000
+ self.items[value] = true
2001
+ end
1960
2002
  end
1961
- WeakSet[Symbol.species] = WeakSet
1962
- return WeakSet
1963
- end)()
2003
+ end
2004
+ function WeakSet.prototype.add(self, value)
2005
+ self.items[value] = true
2006
+ return self
2007
+ end
2008
+ function WeakSet.prototype.delete(self, value)
2009
+ local contains = self:has(value)
2010
+ self.items[value] = nil
2011
+ return contains
2012
+ end
2013
+ function WeakSet.prototype.has(self, value)
2014
+ return self.items[value] == true
2015
+ end
2016
+ WeakSet[Symbol.species] = WeakSet
2017
+ WeakSet = WeakSet
1964
2018
 
1965
2019
  function __TS__SourceMapTraceBack(fileName, sourceMap)
1966
2020
  _G.__TS__sourcemap = _G.__TS__sourcemap or ({})
@@ -1969,7 +2023,7 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
1969
2023
  _G.__TS__originalTraceback = debug.traceback
1970
2024
  debug.traceback = function(thread, message, level)
1971
2025
  local trace
1972
- if ((thread == nil) and (message == nil)) and (level == nil) then
2026
+ if thread == nil and message == nil and level == nil then
1973
2027
  trace = _G.__TS__originalTraceback()
1974
2028
  else
1975
2029
  trace = _G.__TS__originalTraceback(thread, message, level)
@@ -2038,7 +2092,7 @@ function __TS__StringCharCodeAt(self, index)
2038
2092
  if index < 0 then
2039
2093
  return 0 / 0
2040
2094
  end
2041
- return string.byte(self, index + 1) or (0 / 0)
2095
+ return string.byte(self, index + 1) or 0 / 0
2042
2096
  end
2043
2097
 
2044
2098
  function __TS__StringConcat(str1, ...)
@@ -2051,10 +2105,10 @@ function __TS__StringConcat(str1, ...)
2051
2105
  end
2052
2106
 
2053
2107
  function __TS__StringEndsWith(self, searchString, endPosition)
2054
- if (endPosition == nil) or (endPosition > #self) then
2108
+ if endPosition == nil or endPosition > #self then
2055
2109
  endPosition = #self
2056
2110
  end
2057
- return string.sub(self, (endPosition - #searchString) + 1, endPosition) == searchString
2111
+ return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
2058
2112
  end
2059
2113
 
2060
2114
  function __TS__StringIncludes(self, searchString, position)
@@ -2074,10 +2128,10 @@ function __TS__StringPadEnd(self, maxLength, fillString)
2074
2128
  if maxLength ~= maxLength then
2075
2129
  maxLength = 0
2076
2130
  end
2077
- if (maxLength == -math.huge) or (maxLength == math.huge) then
2131
+ if maxLength == -math.huge or maxLength == math.huge then
2078
2132
  error("Invalid string length", 0)
2079
2133
  end
2080
- if (#self >= maxLength) or (#fillString == 0) then
2134
+ if #self >= maxLength or #fillString == 0 then
2081
2135
  return self
2082
2136
  end
2083
2137
  maxLength = maxLength - #self
@@ -2101,10 +2155,10 @@ function __TS__StringPadStart(self, maxLength, fillString)
2101
2155
  if maxLength ~= maxLength then
2102
2156
  maxLength = 0
2103
2157
  end
2104
- if (maxLength == -math.huge) or (maxLength == math.huge) then
2158
+ if maxLength == -math.huge or maxLength == math.huge then
2105
2159
  error("Invalid string length", 0)
2106
2160
  end
2107
- if (#self >= maxLength) or (#fillString == 0) then
2161
+ if #self >= maxLength or #fillString == 0 then
2108
2162
  return self
2109
2163
  end
2110
2164
  maxLength = maxLength - #self
@@ -2128,7 +2182,13 @@ function __TS__StringReplace(source, searchValue, replaceValue)
2128
2182
  end
2129
2183
  local sub = string.sub
2130
2184
  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))()
2185
+ local ____temp_0
2186
+ if type(replaceValue) == "string" then
2187
+ ____temp_0 = replaceValue
2188
+ else
2189
+ ____temp_0 = replaceValue(_G, searchValue, startPos - 1, source)
2190
+ end
2191
+ local replacement = ____temp_0
2132
2192
  local after = sub(source, endPos + 1)
2133
2193
  return (before .. replacement) .. after
2134
2194
  end
@@ -2170,7 +2230,7 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
2170
2230
  end
2171
2231
 
2172
2232
  function __TS__StringSlice(self, start, ____end)
2173
- if (start == nil) or (start ~= start) then
2233
+ if start == nil or start ~= start then
2174
2234
  start = 0
2175
2235
  end
2176
2236
  if ____end ~= ____end then
@@ -2179,7 +2239,7 @@ function __TS__StringSlice(self, start, ____end)
2179
2239
  if start >= 0 then
2180
2240
  start = start + 1
2181
2241
  end
2182
- if (____end ~= nil) and (____end < 0) then
2242
+ if ____end ~= nil and ____end < 0 then
2183
2243
  ____end = ____end - 1
2184
2244
  end
2185
2245
  return string.sub(self, start, ____end)
@@ -2195,8 +2255,8 @@ function __TS__StringSplit(source, separator, limit)
2195
2255
  local out = {}
2196
2256
  local index = 0
2197
2257
  local count = 0
2198
- if (separator == nil) or (separator == "") then
2199
- while (index < (#source - 1)) and (count < limit) do
2258
+ if separator == nil or separator == "" then
2259
+ while index < #source - 1 and count < limit do
2200
2260
  out[count + 1] = __TS__StringAccess(source, index)
2201
2261
  count = count + 1
2202
2262
  index = index + 1
@@ -2204,7 +2264,7 @@ function __TS__StringSplit(source, separator, limit)
2204
2264
  else
2205
2265
  local separatorLength = #separator
2206
2266
  local nextIndex = (string.find(source, separator, nil, true) or 0) - 1
2207
- while (nextIndex >= 0) and (count < limit) do
2267
+ while nextIndex >= 0 and count < limit do
2208
2268
  out[count + 1] = __TS__StringSubstring(source, index, nextIndex)
2209
2269
  count = count + 1
2210
2270
  index = nextIndex + separatorLength
@@ -2223,7 +2283,7 @@ function __TS__StringSplit(source, separator, limit)
2223
2283
  end
2224
2284
 
2225
2285
  function __TS__StringStartsWith(self, searchString, position)
2226
- if (position == nil) or (position < 0) then
2286
+ if position == nil or position < 0 then
2227
2287
  position = 0
2228
2288
  end
2229
2289
  return string.sub(self, position + 1, #searchString + position) == searchString