typescript-to-lua 1.9.0 → 1.10.0-beta.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 (244) hide show
  1. package/dist/CompilerOptions.d.ts +1 -0
  2. package/dist/CompilerOptions.js +1 -0
  3. package/dist/LuaAST.d.ts +43 -37
  4. package/dist/LuaAST.js +48 -38
  5. package/dist/LuaLib.d.ts +12 -6
  6. package/dist/LuaLib.js +31 -21
  7. package/dist/LuaPrinter.d.ts +1 -0
  8. package/dist/LuaPrinter.js +10 -4
  9. package/dist/lualib/5.0/ArrayConcat.lua +22 -0
  10. package/dist/lualib/5.0/ArrayEntries.lua +13 -0
  11. package/dist/lualib/5.0/ArrayEvery.lua +8 -0
  12. package/dist/lualib/5.0/ArrayFilter.lua +11 -0
  13. package/dist/lualib/5.0/ArrayFind.lua +9 -0
  14. package/dist/lualib/5.0/ArrayFindIndex.lua +8 -0
  15. package/dist/lualib/5.0/ArrayFlat.lua +27 -0
  16. package/dist/lualib/5.0/ArrayFlatMap.lua +17 -0
  17. package/dist/lualib/5.0/ArrayForEach.lua +5 -0
  18. package/dist/lualib/5.0/ArrayFrom.lua +29 -0
  19. package/dist/lualib/5.0/ArrayIncludes.lua +19 -0
  20. package/dist/lualib/5.0/ArrayIndexOf.lua +24 -0
  21. package/dist/lualib/5.0/ArrayIsArray.lua +3 -0
  22. package/dist/lualib/5.0/ArrayJoin.lua +10 -0
  23. package/dist/lualib/5.0/ArrayMap.lua +7 -0
  24. package/dist/lualib/5.0/ArrayPush.lua +9 -0
  25. package/dist/lualib/5.0/ArrayPushArray.lua +8 -0
  26. package/dist/lualib/5.0/ArrayReduce.lua +23 -0
  27. package/dist/lualib/5.0/ArrayReduceRight.lua +23 -0
  28. package/dist/lualib/5.0/ArrayReverse.lua +12 -0
  29. package/dist/lualib/5.0/ArraySetLength.lua +12 -0
  30. package/dist/lualib/5.0/ArraySlice.lua +43 -0
  31. package/dist/lualib/5.0/ArraySome.lua +8 -0
  32. package/dist/lualib/5.0/ArraySort.lua +11 -0
  33. package/dist/lualib/5.0/ArraySplice.lua +77 -0
  34. package/dist/lualib/5.0/ArrayToObject.lua +7 -0
  35. package/dist/lualib/5.0/ArrayUnshift.lua +14 -0
  36. package/dist/lualib/5.0/Await.lua +54 -0
  37. package/dist/lualib/5.0/Class.lua +6 -0
  38. package/dist/lualib/5.0/ClassExtends.lua +24 -0
  39. package/dist/lualib/5.0/CloneDescriptor.lua +28 -0
  40. package/dist/lualib/5.0/CountVarargs.lua +4 -0
  41. package/dist/lualib/5.0/Decorate.lua +36 -0
  42. package/dist/lualib/5.0/DecorateParam.lua +3 -0
  43. package/dist/lualib/5.0/DelegatedYield.lua +34 -0
  44. package/dist/lualib/5.0/Delete.lua +19 -0
  45. package/dist/lualib/5.0/Error.lua +85 -0
  46. package/dist/lualib/5.0/FunctionBind.lua +11 -0
  47. package/dist/lualib/5.0/Generator.lua +34 -0
  48. package/dist/lualib/5.0/InstanceOf.lua +18 -0
  49. package/dist/lualib/5.0/InstanceOfObject.lua +4 -0
  50. package/dist/lualib/5.0/Iterator.lua +40 -0
  51. package/dist/lualib/5.0/LuaIteratorSpread.lua +9 -0
  52. package/dist/lualib/5.0/Map.lua +140 -0
  53. package/dist/lualib/5.0/Match.lua +13 -0
  54. package/dist/lualib/5.0/MathAtan2.lua +1 -0
  55. package/dist/lualib/5.0/MathModf.lua +10 -0
  56. package/dist/lualib/5.0/MathSign.lua +8 -0
  57. package/dist/lualib/5.0/Modulo50.lua +3 -0
  58. package/dist/lualib/5.0/New.lua +5 -0
  59. package/dist/lualib/5.0/Number.lua +26 -0
  60. package/dist/lualib/5.0/NumberIsFinite.lua +3 -0
  61. package/dist/lualib/5.0/NumberIsNaN.lua +3 -0
  62. package/dist/lualib/5.0/NumberToString.lua +47 -0
  63. package/dist/lualib/5.0/ObjectAssign.lua +10 -0
  64. package/dist/lualib/5.0/ObjectDefineProperty.lua +59 -0
  65. package/dist/lualib/5.0/ObjectEntries.lua +9 -0
  66. package/dist/lualib/5.0/ObjectFromEntries.lua +20 -0
  67. package/dist/lualib/5.0/ObjectGetOwnPropertyDescriptor.lua +10 -0
  68. package/dist/lualib/5.0/ObjectGetOwnPropertyDescriptors.lua +7 -0
  69. package/dist/lualib/5.0/ObjectKeys.lua +9 -0
  70. package/dist/lualib/5.0/ObjectRest.lua +9 -0
  71. package/dist/lualib/5.0/ObjectValues.lua +9 -0
  72. package/dist/lualib/5.0/ParseFloat.lua +18 -0
  73. package/dist/lualib/5.0/ParseInt.lua +49 -0
  74. package/dist/lualib/5.0/Promise.lua +176 -0
  75. package/dist/lualib/5.0/PromiseAll.lua +44 -0
  76. package/dist/lualib/5.0/PromiseAllSettled.lua +48 -0
  77. package/dist/lualib/5.0/PromiseAny.lua +41 -0
  78. package/dist/lualib/5.0/PromiseRace.lua +28 -0
  79. package/dist/lualib/5.0/Set.lua +130 -0
  80. package/dist/lualib/5.0/SetDescriptor.lua +79 -0
  81. package/dist/lualib/5.0/SourceMapTraceBack.lua +56 -0
  82. package/dist/lualib/5.0/SparseArrayNew.lua +5 -0
  83. package/dist/lualib/5.0/SparseArrayPush.lua +9 -0
  84. package/dist/lualib/5.0/SparseArraySpread.lua +3 -0
  85. package/dist/lualib/5.0/Spread.lua +15 -0
  86. package/dist/lualib/5.0/StringAccess.lua +5 -0
  87. package/dist/lualib/5.0/StringCharAt.lua +9 -0
  88. package/dist/lualib/5.0/StringCharCodeAt.lua +13 -0
  89. package/dist/lualib/5.0/StringEndsWith.lua +10 -0
  90. package/dist/lualib/5.0/StringIncludes.lua +9 -0
  91. package/dist/lualib/5.0/StringPadEnd.lua +26 -0
  92. package/dist/lualib/5.0/StringPadStart.lua +26 -0
  93. package/dist/lualib/5.0/StringReplace.lua +20 -0
  94. package/dist/lualib/5.0/StringReplaceAll.lua +42 -0
  95. package/dist/lualib/5.0/StringSlice.lua +15 -0
  96. package/dist/lualib/5.0/StringSplit.lua +36 -0
  97. package/dist/lualib/5.0/StringStartsWith.lua +10 -0
  98. package/dist/lualib/5.0/StringSubstr.lua +15 -0
  99. package/dist/lualib/5.0/StringSubstring.lua +17 -0
  100. package/dist/lualib/5.0/StringTrim.lua +4 -0
  101. package/dist/lualib/5.0/StringTrimEnd.lua +4 -0
  102. package/dist/lualib/5.0/StringTrimStart.lua +4 -0
  103. package/dist/lualib/5.0/Symbol.lua +15 -0
  104. package/dist/lualib/5.0/SymbolRegistry.lua +17 -0
  105. package/dist/lualib/5.0/TypeOf.lua +10 -0
  106. package/dist/lualib/5.0/Unpack.lua +1 -0
  107. package/dist/lualib/5.0/WeakMap.lua +45 -0
  108. package/dist/lualib/5.0/WeakSet.lua +41 -0
  109. package/dist/lualib/5.0/lualib_bundle.lua +2574 -0
  110. package/dist/lualib/5.0/lualib_module_info.json +672 -0
  111. package/dist/lualib/universal/ArrayConcat.lua +22 -0
  112. package/dist/lualib/universal/ArrayEntries.lua +13 -0
  113. package/dist/lualib/universal/ArrayEvery.lua +8 -0
  114. package/dist/lualib/universal/ArrayFilter.lua +11 -0
  115. package/dist/lualib/universal/ArrayFind.lua +9 -0
  116. package/dist/lualib/universal/ArrayFindIndex.lua +8 -0
  117. package/dist/lualib/universal/ArrayFlat.lua +27 -0
  118. package/dist/lualib/universal/ArrayFlatMap.lua +17 -0
  119. package/dist/lualib/universal/ArrayForEach.lua +5 -0
  120. package/dist/lualib/universal/ArrayFrom.lua +29 -0
  121. package/dist/lualib/universal/ArrayIncludes.lua +19 -0
  122. package/dist/lualib/universal/ArrayIndexOf.lua +24 -0
  123. package/dist/lualib/universal/ArrayIsArray.lua +3 -0
  124. package/dist/lualib/universal/ArrayJoin.lua +10 -0
  125. package/dist/lualib/universal/ArrayMap.lua +7 -0
  126. package/dist/lualib/universal/ArrayPush.lua +9 -0
  127. package/dist/lualib/universal/ArrayPushArray.lua +8 -0
  128. package/dist/lualib/universal/ArrayReduce.lua +23 -0
  129. package/dist/lualib/universal/ArrayReduceRight.lua +23 -0
  130. package/dist/lualib/universal/ArrayReverse.lua +12 -0
  131. package/dist/lualib/universal/ArraySetLength.lua +12 -0
  132. package/dist/lualib/universal/ArraySlice.lua +43 -0
  133. package/dist/lualib/universal/ArraySome.lua +8 -0
  134. package/dist/lualib/universal/ArraySort.lua +11 -0
  135. package/dist/lualib/universal/ArraySplice.lua +77 -0
  136. package/dist/lualib/universal/ArrayToObject.lua +7 -0
  137. package/dist/lualib/universal/ArrayUnshift.lua +14 -0
  138. package/dist/lualib/universal/Await.lua +54 -0
  139. package/dist/lualib/universal/Class.lua +6 -0
  140. package/dist/lualib/universal/ClassExtends.lua +24 -0
  141. package/dist/lualib/universal/CloneDescriptor.lua +28 -0
  142. package/dist/lualib/universal/CountVarargs.lua +3 -0
  143. package/dist/lualib/universal/Decorate.lua +36 -0
  144. package/dist/lualib/universal/DecorateParam.lua +3 -0
  145. package/dist/lualib/universal/DelegatedYield.lua +34 -0
  146. package/dist/lualib/universal/Delete.lua +19 -0
  147. package/dist/lualib/universal/Error.lua +82 -0
  148. package/dist/lualib/universal/FunctionBind.lua +11 -0
  149. package/dist/lualib/universal/Generator.lua +31 -0
  150. package/dist/lualib/universal/InstanceOf.lua +18 -0
  151. package/dist/lualib/universal/InstanceOfObject.lua +4 -0
  152. package/dist/lualib/universal/Iterator.lua +40 -0
  153. package/dist/lualib/universal/LuaIteratorSpread.lua +9 -0
  154. package/dist/lualib/universal/Map.lua +140 -0
  155. package/dist/lualib/universal/Match.lua +1 -0
  156. package/dist/lualib/universal/MathAtan2.lua +1 -0
  157. package/dist/lualib/universal/MathModf.lua +1 -0
  158. package/dist/lualib/universal/MathSign.lua +8 -0
  159. package/dist/lualib/universal/Modulo50.lua +3 -0
  160. package/dist/lualib/universal/New.lua +5 -0
  161. package/dist/lualib/universal/Number.lua +26 -0
  162. package/dist/lualib/universal/NumberIsFinite.lua +3 -0
  163. package/dist/lualib/universal/NumberIsNaN.lua +3 -0
  164. package/dist/lualib/universal/NumberToString.lua +44 -0
  165. package/dist/lualib/universal/ObjectAssign.lua +10 -0
  166. package/dist/lualib/universal/ObjectDefineProperty.lua +59 -0
  167. package/dist/lualib/universal/ObjectEntries.lua +9 -0
  168. package/dist/lualib/universal/ObjectFromEntries.lua +20 -0
  169. package/dist/lualib/universal/ObjectGetOwnPropertyDescriptor.lua +10 -0
  170. package/dist/lualib/universal/ObjectGetOwnPropertyDescriptors.lua +7 -0
  171. package/dist/lualib/universal/ObjectKeys.lua +9 -0
  172. package/dist/lualib/universal/ObjectRest.lua +9 -0
  173. package/dist/lualib/universal/ObjectValues.lua +9 -0
  174. package/dist/lualib/universal/ParseFloat.lua +18 -0
  175. package/dist/lualib/universal/ParseInt.lua +43 -0
  176. package/dist/lualib/universal/Promise.lua +176 -0
  177. package/dist/lualib/universal/PromiseAll.lua +44 -0
  178. package/dist/lualib/universal/PromiseAllSettled.lua +48 -0
  179. package/dist/lualib/universal/PromiseAny.lua +41 -0
  180. package/dist/lualib/universal/PromiseRace.lua +28 -0
  181. package/dist/lualib/universal/Set.lua +130 -0
  182. package/dist/lualib/universal/SetDescriptor.lua +79 -0
  183. package/dist/lualib/universal/SourceMapTraceBack.lua +56 -0
  184. package/dist/lualib/universal/SparseArrayNew.lua +5 -0
  185. package/dist/lualib/universal/SparseArrayPush.lua +9 -0
  186. package/dist/lualib/universal/SparseArraySpread.lua +8 -0
  187. package/dist/lualib/universal/Spread.lua +15 -0
  188. package/dist/lualib/universal/StringAccess.lua +5 -0
  189. package/dist/lualib/universal/StringCharAt.lua +9 -0
  190. package/dist/lualib/universal/StringCharCodeAt.lua +13 -0
  191. package/dist/lualib/universal/StringEndsWith.lua +6 -0
  192. package/dist/lualib/universal/StringIncludes.lua +9 -0
  193. package/dist/lualib/universal/StringPadEnd.lua +26 -0
  194. package/dist/lualib/universal/StringPadStart.lua +26 -0
  195. package/dist/lualib/universal/StringReplace.lua +20 -0
  196. package/dist/lualib/universal/StringReplaceAll.lua +42 -0
  197. package/dist/lualib/universal/StringSlice.lua +15 -0
  198. package/dist/lualib/universal/StringSplit.lua +36 -0
  199. package/dist/lualib/universal/StringStartsWith.lua +6 -0
  200. package/dist/lualib/universal/StringSubstr.lua +15 -0
  201. package/dist/lualib/universal/StringSubstring.lua +17 -0
  202. package/dist/lualib/universal/StringTrim.lua +4 -0
  203. package/dist/lualib/universal/StringTrimEnd.lua +4 -0
  204. package/dist/lualib/universal/StringTrimStart.lua +4 -0
  205. package/dist/lualib/universal/Symbol.lua +15 -0
  206. package/dist/lualib/universal/SymbolRegistry.lua +17 -0
  207. package/dist/lualib/universal/TypeOf.lua +10 -0
  208. package/dist/lualib/universal/Unpack.lua +1 -0
  209. package/dist/lualib/universal/WeakMap.lua +45 -0
  210. package/dist/lualib/universal/WeakSet.lua +41 -0
  211. package/dist/lualib/universal/lualib_bundle.lua +2534 -0
  212. package/dist/lualib/universal/lualib_module_info.json +671 -0
  213. package/dist/lualib/universal/universal/CountVarargs.lua +3 -0
  214. package/dist/lualib/universal/universal/Match.lua +1 -0
  215. package/dist/lualib/universal/universal/MathModf.lua +1 -0
  216. package/dist/lualib/universal/universal/SparseArraySpread.lua +8 -0
  217. package/dist/lualib/universal/universal/Unpack.lua +1 -0
  218. package/dist/lualib-build/plugin.js +12 -2
  219. package/dist/transformation/builtins/array.d.ts +1 -1
  220. package/dist/transformation/builtins/array.js +12 -2
  221. package/dist/transformation/builtins/function.js +4 -2
  222. package/dist/transformation/builtins/index.js +11 -3
  223. package/dist/transformation/builtins/string.d.ts +1 -1
  224. package/dist/transformation/builtins/string.js +8 -1
  225. package/dist/transformation/utils/diagnostics.d.ts +2 -4
  226. package/dist/transformation/utils/lua-ast.js +3 -1
  227. package/dist/transformation/utils/typescript/index.js +2 -2
  228. package/dist/transformation/visitors/binary-expression/bit.js +4 -2
  229. package/dist/transformation/visitors/binary-expression/index.js +4 -0
  230. package/dist/transformation/visitors/break-continue.js +4 -2
  231. package/dist/transformation/visitors/class/index.js +9 -4
  232. package/dist/transformation/visitors/class/members/fields.js +6 -2
  233. package/dist/transformation/visitors/class/members/method.js +4 -2
  234. package/dist/transformation/visitors/errors.js +4 -2
  235. package/dist/transformation/visitors/function.js +2 -1
  236. package/dist/transformation/visitors/language-extensions/operators.js +2 -1
  237. package/dist/transformation/visitors/literal.js +12 -4
  238. package/dist/transformation/visitors/modules/export.js +1 -1
  239. package/dist/transformation/visitors/spread.js +4 -1
  240. package/dist/transformation/visitors/typescript.js +1 -0
  241. package/dist/transpilation/bundle.js +11 -4
  242. package/dist/transpilation/transpiler.js +3 -1
  243. package/package.json +18 -18
  244. package/language-extensions/index.d.ts +0 -676
@@ -0,0 +1,19 @@
1
+ local function __TS__ArrayIncludes(self, searchElement, fromIndex)
2
+ if fromIndex == nil then
3
+ fromIndex = 0
4
+ end
5
+ local len = table.getn(self)
6
+ local k = fromIndex
7
+ if fromIndex < 0 then
8
+ k = len + fromIndex
9
+ end
10
+ if k < 0 then
11
+ k = 0
12
+ end
13
+ for i = k + 1, len do
14
+ if self[i] == searchElement then
15
+ return true
16
+ end
17
+ end
18
+ return false
19
+ end
@@ -0,0 +1,24 @@
1
+ local function __TS__ArrayIndexOf(self, searchElement, fromIndex)
2
+ if fromIndex == nil then
3
+ fromIndex = 0
4
+ end
5
+ local len = table.getn(self)
6
+ if len == 0 then
7
+ return -1
8
+ end
9
+ if fromIndex >= len then
10
+ return -1
11
+ end
12
+ if fromIndex < 0 then
13
+ fromIndex = len + fromIndex
14
+ if fromIndex < 0 then
15
+ fromIndex = 0
16
+ end
17
+ end
18
+ for i = fromIndex + 1, len do
19
+ if self[i] == searchElement then
20
+ return i - 1
21
+ end
22
+ end
23
+ return -1
24
+ end
@@ -0,0 +1,3 @@
1
+ local function __TS__ArrayIsArray(value)
2
+ return type(value) == "table" and (value[1] ~= nil or next(value) == nil)
3
+ end
@@ -0,0 +1,10 @@
1
+ local function __TS__ArrayJoin(self, separator)
2
+ if separator == nil then
3
+ separator = ","
4
+ end
5
+ local parts = {}
6
+ for i = 1, table.getn(self) do
7
+ parts[i] = tostring(self[i])
8
+ end
9
+ return table.concat(parts, separator)
10
+ end
@@ -0,0 +1,7 @@
1
+ local function __TS__ArrayMap(self, callbackfn, thisArg)
2
+ local result = {}
3
+ for i = 1, table.getn(self) do
4
+ result[i] = callbackfn(thisArg, self[i], i - 1, self)
5
+ end
6
+ return result
7
+ end
@@ -0,0 +1,9 @@
1
+ local function __TS__ArrayPush(self, ...)
2
+ local items = arg
3
+ local len = table.getn(self)
4
+ for i = 1, table.getn(items) do
5
+ len = len + 1
6
+ self[len] = items[i]
7
+ end
8
+ return len
9
+ end
@@ -0,0 +1,8 @@
1
+ local function __TS__ArrayPushArray(self, items)
2
+ local len = table.getn(self)
3
+ for i = 1, table.getn(items) do
4
+ len = len + 1
5
+ self[len] = items[i]
6
+ end
7
+ return len
8
+ end
@@ -0,0 +1,23 @@
1
+ local function __TS__ArrayReduce(self, callbackFn, ...)
2
+ local len = table.getn(self)
3
+ local k = 0
4
+ local accumulator = nil
5
+ if __TS__CountVarargs(unpack(arg)) ~= 0 then
6
+ accumulator = unpack(arg)
7
+ elseif len > 0 then
8
+ accumulator = self[1]
9
+ k = 1
10
+ else
11
+ error("Reduce of empty array with no initial value", 0)
12
+ end
13
+ for i = k + 1, len do
14
+ accumulator = callbackFn(
15
+ nil,
16
+ accumulator,
17
+ self[i],
18
+ i - 1,
19
+ self
20
+ )
21
+ end
22
+ return accumulator
23
+ end
@@ -0,0 +1,23 @@
1
+ local function __TS__ArrayReduceRight(self, callbackFn, ...)
2
+ local len = table.getn(self)
3
+ local k = len - 1
4
+ local accumulator = nil
5
+ if __TS__CountVarargs(unpack(arg)) ~= 0 then
6
+ accumulator = unpack(arg)
7
+ elseif len > 0 then
8
+ accumulator = self[k + 1]
9
+ k = k - 1
10
+ else
11
+ error("Reduce of empty array with no initial value", 0)
12
+ end
13
+ for i = k + 1, 1, -1 do
14
+ accumulator = callbackFn(
15
+ nil,
16
+ accumulator,
17
+ self[i],
18
+ i - 1,
19
+ self
20
+ )
21
+ end
22
+ return accumulator
23
+ end
@@ -0,0 +1,12 @@
1
+ local function __TS__ArrayReverse(self)
2
+ local i = 1
3
+ local j = table.getn(self)
4
+ while i < j do
5
+ local temp = self[j]
6
+ self[j] = self[i]
7
+ self[i] = temp
8
+ i = i + 1
9
+ j = j - 1
10
+ end
11
+ return self
12
+ end
@@ -0,0 +1,12 @@
1
+ local function __TS__ArraySetLength(self, length)
2
+ if length < 0 or length ~= length or length == 1 / 0 or math.floor(length) ~= length then
3
+ error(
4
+ "invalid array length: " .. tostring(length),
5
+ 0
6
+ )
7
+ end
8
+ for i = length + 1, table.getn(self) do
9
+ self[i] = nil
10
+ end
11
+ return length
12
+ end
@@ -0,0 +1,43 @@
1
+ local function __TS__ArraySlice(self, first, last)
2
+ local len = table.getn(self)
3
+ local ____first_0 = first
4
+ if ____first_0 == nil then
5
+ ____first_0 = 0
6
+ end
7
+ first = ____first_0
8
+ if first < 0 then
9
+ first = len + first
10
+ if first < 0 then
11
+ first = 0
12
+ end
13
+ else
14
+ if first > len then
15
+ first = len
16
+ end
17
+ end
18
+ local ____last_1 = last
19
+ if ____last_1 == nil then
20
+ ____last_1 = len
21
+ end
22
+ last = ____last_1
23
+ if last < 0 then
24
+ last = len + last
25
+ if last < 0 then
26
+ last = 0
27
+ end
28
+ else
29
+ if last > len then
30
+ last = len
31
+ end
32
+ end
33
+ local out = {}
34
+ first = first + 1
35
+ last = last + 1
36
+ local n = 1
37
+ while first < last do
38
+ out[n] = self[first]
39
+ first = first + 1
40
+ n = n + 1
41
+ end
42
+ return out
43
+ end
@@ -0,0 +1,8 @@
1
+ local function __TS__ArraySome(self, callbackfn, thisArg)
2
+ for i = 1, table.getn(self) do
3
+ if callbackfn(thisArg, self[i], i - 1, self) then
4
+ return true
5
+ end
6
+ end
7
+ return false
8
+ end
@@ -0,0 +1,11 @@
1
+ local function __TS__ArraySort(self, compareFn)
2
+ if compareFn ~= nil then
3
+ table.sort(
4
+ self,
5
+ function(a, b) return compareFn(nil, a, b) < 0 end
6
+ )
7
+ else
8
+ table.sort(self)
9
+ end
10
+ return self
11
+ end
@@ -0,0 +1,77 @@
1
+ local function __TS__ArraySplice(self, ...)
2
+ local args = arg
3
+ local len = table.getn(self)
4
+ local actualArgumentCount = __TS__CountVarargs(unpack(arg))
5
+ local start = args[1]
6
+ local deleteCount = args[2]
7
+ if start < 0 then
8
+ start = len + start
9
+ if start < 0 then
10
+ start = 0
11
+ end
12
+ elseif start > len then
13
+ start = len
14
+ end
15
+ local itemCount = actualArgumentCount - 2
16
+ if itemCount < 0 then
17
+ itemCount = 0
18
+ end
19
+ local actualDeleteCount
20
+ if actualArgumentCount == 0 then
21
+ actualDeleteCount = 0
22
+ elseif actualArgumentCount == 1 then
23
+ actualDeleteCount = len - start
24
+ else
25
+ local ____deleteCount_0 = deleteCount
26
+ if ____deleteCount_0 == nil then
27
+ ____deleteCount_0 = 0
28
+ end
29
+ actualDeleteCount = ____deleteCount_0
30
+ if actualDeleteCount < 0 then
31
+ actualDeleteCount = 0
32
+ end
33
+ if actualDeleteCount > len - start then
34
+ actualDeleteCount = len - start
35
+ end
36
+ end
37
+ local out = {}
38
+ for k = 1, actualDeleteCount do
39
+ local from = start + k
40
+ if self[from] ~= nil then
41
+ out[k] = self[from]
42
+ end
43
+ end
44
+ if itemCount < actualDeleteCount then
45
+ for k = start + 1, len - actualDeleteCount do
46
+ local from = k + actualDeleteCount
47
+ local to = k + itemCount
48
+ if self[from] then
49
+ self[to] = self[from]
50
+ else
51
+ self[to] = nil
52
+ end
53
+ end
54
+ for k = len - actualDeleteCount + itemCount + 1, len do
55
+ self[k] = nil
56
+ end
57
+ elseif itemCount > actualDeleteCount then
58
+ for k = len - actualDeleteCount, start + 1, -1 do
59
+ local from = k + actualDeleteCount
60
+ local to = k + itemCount
61
+ if self[from] then
62
+ self[to] = self[from]
63
+ else
64
+ self[to] = nil
65
+ end
66
+ end
67
+ end
68
+ local j = start + 1
69
+ for i = 3, actualArgumentCount do
70
+ self[j] = args[i]
71
+ j = j + 1
72
+ end
73
+ for k = table.getn(self), len - actualDeleteCount + itemCount + 1, -1 do
74
+ self[k] = nil
75
+ end
76
+ return out
77
+ end
@@ -0,0 +1,7 @@
1
+ local function __TS__ArrayToObject(self)
2
+ local object = {}
3
+ for i = 1, table.getn(self) do
4
+ object[i - 1] = self[i]
5
+ end
6
+ return object
7
+ end
@@ -0,0 +1,14 @@
1
+ local function __TS__ArrayUnshift(self, ...)
2
+ local items = arg
3
+ local numItemsToInsert = table.getn(items)
4
+ if numItemsToInsert == 0 then
5
+ return table.getn(self)
6
+ end
7
+ for i = table.getn(self), 1, -1 do
8
+ self[i + numItemsToInsert] = self[i]
9
+ end
10
+ for i = 1, numItemsToInsert do
11
+ self[i] = items[i]
12
+ end
13
+ return table.getn(self)
14
+ end
@@ -0,0 +1,54 @@
1
+ local function __TS__AsyncAwaiter(generator)
2
+ return __TS__New(
3
+ __TS__Promise,
4
+ function(____, resolve, reject)
5
+ local adopt, fulfilled, step, resolved, asyncCoroutine
6
+ function adopt(self, value)
7
+ local ____temp_0
8
+ if __TS__InstanceOf(value, __TS__Promise) then
9
+ ____temp_0 = value
10
+ else
11
+ ____temp_0 = __TS__Promise.resolve(value)
12
+ end
13
+ return ____temp_0
14
+ end
15
+ function fulfilled(self, value)
16
+ local success, resultOrError = coroutine.resume(asyncCoroutine, value)
17
+ if success then
18
+ step(nil, resultOrError)
19
+ else
20
+ reject(nil, resultOrError)
21
+ end
22
+ end
23
+ function step(self, result)
24
+ if resolved then
25
+ return
26
+ end
27
+ if coroutine.status(asyncCoroutine) == "dead" then
28
+ resolve(nil, result)
29
+ else
30
+ local ____self_1 = adopt(nil, result)
31
+ ____self_1["then"](____self_1, fulfilled, reject)
32
+ end
33
+ end
34
+ resolved = false
35
+ asyncCoroutine = coroutine.create(generator)
36
+ local success, resultOrError = coroutine.resume(
37
+ asyncCoroutine,
38
+ function(____, v)
39
+ resolved = true
40
+ local ____self_2 = adopt(nil, v)
41
+ ____self_2["then"](____self_2, resolve, reject)
42
+ end
43
+ )
44
+ if success then
45
+ step(nil, resultOrError)
46
+ else
47
+ reject(nil, resultOrError)
48
+ end
49
+ end
50
+ )
51
+ end
52
+ local function __TS__Await(thing)
53
+ return coroutine.yield(thing)
54
+ end
@@ -0,0 +1,6 @@
1
+ local function __TS__Class(self)
2
+ local c = {prototype = {}}
3
+ c.prototype.__index = c.prototype
4
+ c.prototype.constructor = c
5
+ return c
6
+ end
@@ -0,0 +1,24 @@
1
+ local function __TS__ClassExtends(target, base)
2
+ target.____super = base
3
+ local staticMetatable = setmetatable({__index = base}, base)
4
+ setmetatable(target, staticMetatable)
5
+ local baseMetatable = getmetatable(base)
6
+ if baseMetatable then
7
+ if type(baseMetatable.__index) == "function" then
8
+ staticMetatable.__index = baseMetatable.__index
9
+ end
10
+ if type(baseMetatable.__newindex) == "function" then
11
+ staticMetatable.__newindex = baseMetatable.__newindex
12
+ end
13
+ end
14
+ setmetatable(target.prototype, base.prototype)
15
+ if type(base.prototype.__index) == "function" then
16
+ target.prototype.__index = base.prototype.__index
17
+ end
18
+ if type(base.prototype.__newindex) == "function" then
19
+ target.prototype.__newindex = base.prototype.__newindex
20
+ end
21
+ if type(base.prototype.__tostring) == "function" then
22
+ target.prototype.__tostring = base.prototype.__tostring
23
+ end
24
+ end
@@ -0,0 +1,28 @@
1
+ local function __TS__CloneDescriptor(____bindingPattern0)
2
+ local value
3
+ local writable
4
+ local set
5
+ local get
6
+ local configurable
7
+ local enumerable
8
+ enumerable = ____bindingPattern0.enumerable
9
+ configurable = ____bindingPattern0.configurable
10
+ get = ____bindingPattern0.get
11
+ set = ____bindingPattern0.set
12
+ writable = ____bindingPattern0.writable
13
+ value = ____bindingPattern0.value
14
+ local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
15
+ local hasGetterOrSetter = get ~= nil or set ~= nil
16
+ local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
17
+ if hasGetterOrSetter and hasValueOrWritableAttribute then
18
+ error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
19
+ end
20
+ if get or set then
21
+ descriptor.get = get
22
+ descriptor.set = set
23
+ else
24
+ descriptor.value = value
25
+ descriptor.writable = writable == true
26
+ end
27
+ return descriptor
28
+ end
@@ -0,0 +1,4 @@
1
+ local function __TS__CountVarargs(...)
2
+ local args = arg
3
+ return table.getn(args)
4
+ end
@@ -0,0 +1,36 @@
1
+ local function __TS__Decorate(decorators, target, key, desc)
2
+ local result = target
3
+ do
4
+ local i = table.getn(decorators)
5
+ while i >= 0 do
6
+ local decorator = decorators[i + 1]
7
+ if decorator then
8
+ local oldResult = result
9
+ if key == nil then
10
+ result = decorator(nil, result)
11
+ elseif desc == true then
12
+ local value = rawget(target, key)
13
+ local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
14
+ local desc = decorator(nil, target, key, descriptor) or descriptor
15
+ local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
16
+ if isSimpleValue then
17
+ rawset(target, key, desc.value)
18
+ else
19
+ __TS__SetDescriptor(
20
+ target,
21
+ key,
22
+ __TS__ObjectAssign({}, descriptor, desc)
23
+ )
24
+ end
25
+ elseif desc == false then
26
+ result = decorator(nil, target, key, desc)
27
+ else
28
+ result = decorator(nil, target, key)
29
+ end
30
+ result = result or oldResult
31
+ end
32
+ i = i - 1
33
+ end
34
+ end
35
+ return result
36
+ end
@@ -0,0 +1,3 @@
1
+ local function __TS__DecorateParam(paramIndex, decorator)
2
+ return function(____, target, key) return decorator(nil, target, key, paramIndex) end
3
+ end
@@ -0,0 +1,34 @@
1
+ local function __TS__DelegatedYield(iterable)
2
+ if type(iterable) == "string" then
3
+ for index = 0, string.len(iterable) - 1 do
4
+ coroutine.yield(__TS__StringAccess(iterable, index))
5
+ end
6
+ elseif iterable.____coroutine ~= nil then
7
+ local co = iterable.____coroutine
8
+ while true do
9
+ local status, value = coroutine.resume(co)
10
+ if not status then
11
+ error(value, 0)
12
+ end
13
+ if coroutine.status(co) == "dead" then
14
+ return value
15
+ else
16
+ coroutine.yield(value)
17
+ end
18
+ end
19
+ elseif iterable[Symbol.iterator] then
20
+ local iterator = iterable[Symbol.iterator](iterable)
21
+ while true do
22
+ local result = iterator:next()
23
+ if result.done then
24
+ return result.value
25
+ else
26
+ coroutine.yield(result.value)
27
+ end
28
+ end
29
+ else
30
+ for ____, value in ipairs(iterable) do
31
+ coroutine.yield(value)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ local function __TS__Delete(target, key)
2
+ local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
3
+ local descriptor = descriptors[key]
4
+ if descriptor then
5
+ if not descriptor.configurable then
6
+ error(
7
+ __TS__New(
8
+ TypeError,
9
+ ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
10
+ ),
11
+ 0
12
+ )
13
+ end
14
+ descriptors[key] = nil
15
+ return true
16
+ end
17
+ target[key] = nil
18
+ return true
19
+ end
@@ -0,0 +1,85 @@
1
+ local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
2
+ do
3
+ local function getErrorStack(self, constructor)
4
+ local level = 1
5
+ while true do
6
+ local info = debug.getinfo(level, "f")
7
+ level = level + 1
8
+ if not info then
9
+ level = 1
10
+ break
11
+ elseif info.func == constructor then
12
+ break
13
+ end
14
+ end
15
+ if __TS__StringIncludes(_VERSION, "Lua 5.0") then
16
+ return debug.traceback(("[Level " .. tostring(level)) .. "]")
17
+ else
18
+ return debug.traceback(nil, level)
19
+ end
20
+ end
21
+ local function wrapErrorToString(self, getDescription)
22
+ return function(self)
23
+ local description = getDescription(self)
24
+ local caller = debug.getinfo(3, "f")
25
+ local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0") or _VERSION == "Lua 5.1"
26
+ if isClassicLua or caller and caller.func ~= error then
27
+ return description
28
+ else
29
+ return (tostring(description) .. "\n") .. self.stack
30
+ end
31
+ end
32
+ end
33
+ local function initErrorClass(self, Type, name)
34
+ Type.name = name
35
+ return setmetatable(
36
+ Type,
37
+ {__call = function(____, _self, message) return __TS__New(Type, message) end}
38
+ )
39
+ end
40
+ local ____initErrorClass_2 = initErrorClass
41
+ local ____class_0 = __TS__Class()
42
+ ____class_0.name = ""
43
+ function ____class_0.prototype.____constructor(self, message)
44
+ if message == nil then
45
+ message = ""
46
+ end
47
+ self.message = message
48
+ self.name = "Error"
49
+ self.stack = getErrorStack(nil, self.constructor.new)
50
+ local metatable = getmetatable(self)
51
+ if not metatable.__errorToStringPatched then
52
+ metatable.__errorToStringPatched = true
53
+ metatable.__tostring = wrapErrorToString(nil, metatable.__tostring)
54
+ end
55
+ end
56
+ function ____class_0.prototype.__tostring(self)
57
+ local ____temp_1
58
+ if self.message ~= "" then
59
+ ____temp_1 = (self.name .. ": ") .. self.message
60
+ else
61
+ ____temp_1 = self.name
62
+ end
63
+ return ____temp_1
64
+ end
65
+ Error = ____initErrorClass_2(nil, ____class_0, "Error")
66
+ local function createErrorClass(self, name)
67
+ local ____initErrorClass_4 = initErrorClass
68
+ local ____class_3 = __TS__Class()
69
+ ____class_3.name = ____class_3.name
70
+ __TS__ClassExtends(____class_3, Error)
71
+ function ____class_3.prototype.____constructor(self, ...)
72
+ ____class_3.____super.prototype.____constructor(
73
+ self,
74
+ unpack(arg)
75
+ )
76
+ self.name = name
77
+ end
78
+ return ____initErrorClass_4(nil, ____class_3, name)
79
+ end
80
+ RangeError = createErrorClass(nil, "RangeError")
81
+ ReferenceError = createErrorClass(nil, "ReferenceError")
82
+ SyntaxError = createErrorClass(nil, "SyntaxError")
83
+ TypeError = createErrorClass(nil, "TypeError")
84
+ URIError = createErrorClass(nil, "URIError")
85
+ end
@@ -0,0 +1,11 @@
1
+ local function __TS__FunctionBind(fn, ...)
2
+ local boundArgs = arg
3
+ return function(____, ...)
4
+ local args = arg
5
+ __TS__ArrayUnshift(
6
+ args,
7
+ unpack(boundArgs)
8
+ )
9
+ return fn(unpack(args))
10
+ end
11
+ end