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