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,34 @@
1
+ local __TS__Generator
2
+ do
3
+ local function generatorIterator(self)
4
+ return self
5
+ end
6
+ local function generatorNext(self, ...)
7
+ local co = self.____coroutine
8
+ if coroutine.status(co) == "dead" then
9
+ return {done = true}
10
+ end
11
+ local status, value = coroutine.resume(
12
+ co,
13
+ unpack(arg)
14
+ )
15
+ if not status then
16
+ error(value, 0)
17
+ end
18
+ return {
19
+ value = value,
20
+ done = coroutine.status(co) == "dead"
21
+ }
22
+ end
23
+ function __TS__Generator(fn)
24
+ return function(...)
25
+ local args = arg
26
+ local argsLength = __TS__CountVarargs(unpack(arg))
27
+ return {
28
+ ____coroutine = coroutine.create(function() return fn(__TS__Spread(__TS__Unpack(nil, args, 1, argsLength))) end),
29
+ [Symbol.iterator] = generatorIterator,
30
+ next = generatorNext
31
+ }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ local function __TS__InstanceOf(obj, classTbl)
2
+ if type(classTbl) ~= "table" then
3
+ error("Right-hand side of 'instanceof' is not an object", 0)
4
+ end
5
+ if classTbl[Symbol.hasInstance] ~= nil then
6
+ return not not classTbl[Symbol.hasInstance](classTbl, obj)
7
+ end
8
+ if type(obj) == "table" then
9
+ local luaClass = obj.constructor
10
+ while luaClass ~= nil do
11
+ if luaClass == classTbl then
12
+ return true
13
+ end
14
+ luaClass = luaClass.____super
15
+ end
16
+ end
17
+ return false
18
+ end
@@ -0,0 +1,4 @@
1
+ local function __TS__InstanceOfObject(value)
2
+ local valueType = type(value)
3
+ return valueType == "table" or valueType == "function"
4
+ end
@@ -0,0 +1,40 @@
1
+ local __TS__Iterator
2
+ do
3
+ local function iteratorGeneratorStep(self)
4
+ local co = self.____coroutine
5
+ local status, value = coroutine.resume(co)
6
+ if not status then
7
+ error(value, 0)
8
+ end
9
+ if coroutine.status(co) == "dead" then
10
+ return
11
+ end
12
+ return true, value
13
+ end
14
+ local function iteratorIteratorStep(self)
15
+ local result = self:next()
16
+ if result.done then
17
+ return
18
+ end
19
+ return true, result.value
20
+ end
21
+ local function iteratorStringStep(self, index)
22
+ index = index + 1
23
+ if index > string.len(self) then
24
+ return
25
+ end
26
+ return index, string.sub(self, index, index)
27
+ end
28
+ function __TS__Iterator(iterable)
29
+ if type(iterable) == "string" then
30
+ return iteratorStringStep, iterable, 0
31
+ elseif iterable.____coroutine ~= nil then
32
+ return iteratorGeneratorStep, iterable
33
+ elseif iterable[Symbol.iterator] then
34
+ local iterator = iterable[Symbol.iterator](iterable)
35
+ return iteratorIteratorStep, iterator
36
+ else
37
+ return ipairs(iterable)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,9 @@
1
+ local function __TS__LuaIteratorSpread(self, state, firstKey)
2
+ local results = {}
3
+ local key, value = self(state, firstKey)
4
+ while key do
5
+ results[table.getn(results) + 1] = {key, value}
6
+ key, value = self(state, key)
7
+ end
8
+ return unpack(results)
9
+ end
@@ -0,0 +1,140 @@
1
+ local Map
2
+ do
3
+ Map = __TS__Class()
4
+ Map.name = "Map"
5
+ function Map.prototype.____constructor(self, entries)
6
+ self[Symbol.toStringTag] = "Map"
7
+ self.items = {}
8
+ self.size = 0
9
+ self.nextKey = {}
10
+ self.previousKey = {}
11
+ if entries == nil then
12
+ return
13
+ end
14
+ local iterable = entries
15
+ if iterable[Symbol.iterator] then
16
+ local iterator = iterable[Symbol.iterator](iterable)
17
+ while true do
18
+ local result = iterator:next()
19
+ if result.done then
20
+ break
21
+ end
22
+ local value = result.value
23
+ self:set(value[1], value[2])
24
+ end
25
+ else
26
+ local array = entries
27
+ for ____, kvp in ipairs(array) do
28
+ self:set(kvp[1], kvp[2])
29
+ end
30
+ end
31
+ end
32
+ function Map.prototype.clear(self)
33
+ self.items = {}
34
+ self.nextKey = {}
35
+ self.previousKey = {}
36
+ self.firstKey = nil
37
+ self.lastKey = nil
38
+ self.size = 0
39
+ end
40
+ function Map.prototype.delete(self, key)
41
+ local contains = self:has(key)
42
+ if contains then
43
+ self.size = self.size - 1
44
+ local next = self.nextKey[key]
45
+ local previous = self.previousKey[key]
46
+ if next and previous then
47
+ self.nextKey[previous] = next
48
+ self.previousKey[next] = previous
49
+ elseif next then
50
+ self.firstKey = next
51
+ self.previousKey[next] = nil
52
+ elseif previous then
53
+ self.lastKey = previous
54
+ self.nextKey[previous] = nil
55
+ else
56
+ self.firstKey = nil
57
+ self.lastKey = nil
58
+ end
59
+ self.nextKey[key] = nil
60
+ self.previousKey[key] = nil
61
+ end
62
+ self.items[key] = nil
63
+ return contains
64
+ end
65
+ function Map.prototype.forEach(self, callback)
66
+ for ____, key in __TS__Iterator(self:keys()) do
67
+ callback(nil, self.items[key], key, self)
68
+ end
69
+ end
70
+ function Map.prototype.get(self, key)
71
+ return self.items[key]
72
+ end
73
+ function Map.prototype.has(self, key)
74
+ return self.nextKey[key] ~= nil or self.lastKey == key
75
+ end
76
+ function Map.prototype.set(self, key, value)
77
+ local isNewValue = not self:has(key)
78
+ if isNewValue then
79
+ self.size = self.size + 1
80
+ end
81
+ self.items[key] = value
82
+ if self.firstKey == nil then
83
+ self.firstKey = key
84
+ self.lastKey = key
85
+ elseif isNewValue then
86
+ self.nextKey[self.lastKey] = key
87
+ self.previousKey[key] = self.lastKey
88
+ self.lastKey = key
89
+ end
90
+ return self
91
+ end
92
+ Map.prototype[Symbol.iterator] = function(self)
93
+ return self:entries()
94
+ end
95
+ function Map.prototype.entries(self)
96
+ local items = self.items
97
+ local nextKey = self.nextKey
98
+ local key = self.firstKey
99
+ return {
100
+ [Symbol.iterator] = function(self)
101
+ return self
102
+ end,
103
+ next = function(self)
104
+ local result = {done = not key, value = {key, items[key]}}
105
+ key = nextKey[key]
106
+ return result
107
+ end
108
+ }
109
+ end
110
+ function Map.prototype.keys(self)
111
+ local nextKey = self.nextKey
112
+ local key = self.firstKey
113
+ return {
114
+ [Symbol.iterator] = function(self)
115
+ return self
116
+ end,
117
+ next = function(self)
118
+ local result = {done = not key, value = key}
119
+ key = nextKey[key]
120
+ return result
121
+ end
122
+ }
123
+ end
124
+ function Map.prototype.values(self)
125
+ local items = self.items
126
+ local nextKey = self.nextKey
127
+ local key = self.firstKey
128
+ return {
129
+ [Symbol.iterator] = function(self)
130
+ return self
131
+ end,
132
+ next = function(self)
133
+ local result = {done = not key, value = items[key]}
134
+ key = nextKey[key]
135
+ return result
136
+ end
137
+ }
138
+ end
139
+ Map[Symbol.species] = Map
140
+ end
@@ -0,0 +1,13 @@
1
+ local function __TS__Match(s, pattern, init)
2
+ local ____temp_0 = {string.find(s, pattern, init)}
3
+ local start = ____temp_0[1]
4
+ local ____end = ____temp_0[2]
5
+ local captures = __TS__ArraySlice(____temp_0, 2)
6
+ if start == nil or ____end == nil then
7
+ return
8
+ elseif table.getn(captures) <= 0 then
9
+ return __TS__StringSlice(s, start - 1, ____end)
10
+ else
11
+ return unpack(captures)
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ local __TS__MathAtan2 = math.atan2 or math.atan
@@ -0,0 +1,10 @@
1
+ local function __TS__MathModf(x)
2
+ local ____temp_0
3
+ if x > 0 then
4
+ ____temp_0 = math.floor(x)
5
+ else
6
+ ____temp_0 = math.ceil(x)
7
+ end
8
+ local integral = ____temp_0
9
+ return integral, x - integral
10
+ end
@@ -0,0 +1,8 @@
1
+ local function __TS__MathSign(val)
2
+ if val > 0 then
3
+ return 1
4
+ elseif val < 0 then
5
+ return -1
6
+ end
7
+ return 0
8
+ end
@@ -0,0 +1,3 @@
1
+ local function __TS__Modulo50(a, b)
2
+ return a - math.floor(a / b) * b
3
+ end
@@ -0,0 +1,5 @@
1
+ local function __TS__New(target, ...)
2
+ local instance = setmetatable({}, target.prototype)
3
+ instance:____constructor(unpack(arg))
4
+ return instance
5
+ end
@@ -0,0 +1,26 @@
1
+ local function __TS__Number(value)
2
+ local valueType = type(value)
3
+ if valueType == "number" then
4
+ return value
5
+ elseif valueType == "string" then
6
+ local numberValue = tonumber(value)
7
+ if numberValue then
8
+ return numberValue
9
+ end
10
+ if value == "Infinity" then
11
+ return 1 / 0
12
+ end
13
+ if value == "-Infinity" then
14
+ return -(1 / 0)
15
+ end
16
+ local stringWithoutSpaces = string.gsub(value, "%s", "")
17
+ if stringWithoutSpaces == "" then
18
+ return 0
19
+ end
20
+ return 0 / 0
21
+ elseif valueType == "boolean" then
22
+ return value and 1 or 0
23
+ else
24
+ return 0 / 0
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ local function __TS__NumberIsFinite(value)
2
+ return type(value) == "number" and value == value and value ~= 1 / 0 and value ~= -(1 / 0)
3
+ end
@@ -0,0 +1,3 @@
1
+ local function __TS__NumberIsNaN(value)
2
+ return value ~= value
3
+ end
@@ -0,0 +1,47 @@
1
+ local __TS__NumberToString
2
+ do
3
+ local radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
4
+ function __TS__NumberToString(self, radix)
5
+ if radix == nil or radix == 10 or self == 1 / 0 or self == -(1 / 0) or self ~= self then
6
+ return tostring(self)
7
+ end
8
+ radix = math.floor(radix)
9
+ if radix < 2 or radix > 36 then
10
+ error("toString() radix argument must be between 2 and 36", 0)
11
+ end
12
+ local integer, fraction = __TS__MathModf(math.abs(self))
13
+ local result = ""
14
+ if radix == 8 then
15
+ result = string.format("%o", integer)
16
+ elseif radix == 16 then
17
+ result = string.format("%x", integer)
18
+ else
19
+ repeat
20
+ do
21
+ result = __TS__StringAccess(
22
+ radixChars,
23
+ __TS__Modulo50(integer, radix)
24
+ ) .. result
25
+ integer = math.floor(integer / radix)
26
+ end
27
+ until not (integer ~= 0)
28
+ end
29
+ if fraction ~= 0 then
30
+ result = result .. "."
31
+ local delta = 1e-16
32
+ repeat
33
+ do
34
+ fraction = fraction * radix
35
+ delta = delta * radix
36
+ local digit = math.floor(fraction)
37
+ result = result .. __TS__StringAccess(radixChars, digit)
38
+ fraction = fraction - digit
39
+ end
40
+ until not (fraction >= delta)
41
+ end
42
+ if self < 0 then
43
+ result = "-" .. result
44
+ end
45
+ return result
46
+ end
47
+ end
@@ -0,0 +1,10 @@
1
+ local function __TS__ObjectAssign(target, ...)
2
+ local sources = arg
3
+ for i = 1, table.getn(sources) do
4
+ local source = sources[i]
5
+ for key in pairs(source) do
6
+ target[key] = source[key]
7
+ end
8
+ end
9
+ return target
10
+ end
@@ -0,0 +1,59 @@
1
+ local function __TS__ObjectDefineProperty(target, key, desc)
2
+ local ____temp_0
3
+ if type(key) == "number" then
4
+ ____temp_0 = key + 1
5
+ else
6
+ ____temp_0 = key
7
+ end
8
+ local luaKey = ____temp_0
9
+ local value = rawget(target, luaKey)
10
+ local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
11
+ local descriptor
12
+ if hasGetterOrSetter then
13
+ if value ~= nil then
14
+ error(
15
+ "Cannot redefine property: " .. tostring(key),
16
+ 0
17
+ )
18
+ end
19
+ descriptor = desc
20
+ else
21
+ local valueExists = value ~= nil
22
+ local ____desc_set_5 = desc.set
23
+ local ____desc_get_6 = desc.get
24
+ local ____temp_1
25
+ if desc.configurable ~= nil then
26
+ ____temp_1 = desc.configurable
27
+ else
28
+ ____temp_1 = valueExists
29
+ end
30
+ local ____temp_2
31
+ if desc.enumerable ~= nil then
32
+ ____temp_2 = desc.enumerable
33
+ else
34
+ ____temp_2 = valueExists
35
+ end
36
+ local ____temp_3
37
+ if desc.writable ~= nil then
38
+ ____temp_3 = desc.writable
39
+ else
40
+ ____temp_3 = valueExists
41
+ end
42
+ local ____temp_4
43
+ if desc.value ~= nil then
44
+ ____temp_4 = desc.value
45
+ else
46
+ ____temp_4 = value
47
+ end
48
+ descriptor = {
49
+ set = ____desc_set_5,
50
+ get = ____desc_get_6,
51
+ configurable = ____temp_1,
52
+ enumerable = ____temp_2,
53
+ writable = ____temp_3,
54
+ value = ____temp_4
55
+ }
56
+ end
57
+ __TS__SetDescriptor(target, luaKey, descriptor)
58
+ return target
59
+ end
@@ -0,0 +1,9 @@
1
+ local function __TS__ObjectEntries(obj)
2
+ local result = {}
3
+ local len = 0
4
+ for key in pairs(obj) do
5
+ len = len + 1
6
+ result[len] = {key, obj[key]}
7
+ end
8
+ return result
9
+ end
@@ -0,0 +1,20 @@
1
+ local function __TS__ObjectFromEntries(entries)
2
+ local obj = {}
3
+ local iterable = entries
4
+ if iterable[Symbol.iterator] then
5
+ local iterator = iterable[Symbol.iterator](iterable)
6
+ while true do
7
+ local result = iterator:next()
8
+ if result.done then
9
+ break
10
+ end
11
+ local value = result.value
12
+ obj[value[1]] = value[2]
13
+ end
14
+ else
15
+ for ____, entry in ipairs(entries) do
16
+ obj[entry[1]] = entry[2]
17
+ end
18
+ end
19
+ return obj
20
+ end
@@ -0,0 +1,10 @@
1
+ local function __TS__ObjectGetOwnPropertyDescriptor(object, key)
2
+ local metatable = getmetatable(object)
3
+ if not metatable then
4
+ return
5
+ end
6
+ if not rawget(metatable, "_descriptors") then
7
+ return
8
+ end
9
+ return rawget(metatable, "_descriptors")[key]
10
+ end
@@ -0,0 +1,7 @@
1
+ local function __TS__ObjectGetOwnPropertyDescriptors(object)
2
+ local metatable = getmetatable(object)
3
+ if not metatable then
4
+ return {}
5
+ end
6
+ return rawget(metatable, "_descriptors") or ({})
7
+ end
@@ -0,0 +1,9 @@
1
+ local function __TS__ObjectKeys(obj)
2
+ local result = {}
3
+ local len = 0
4
+ for key in pairs(obj) do
5
+ len = len + 1
6
+ result[len] = key
7
+ end
8
+ return result
9
+ end
@@ -0,0 +1,9 @@
1
+ local function __TS__ObjectRest(target, usedProperties)
2
+ local result = {}
3
+ for property in pairs(target) do
4
+ if not usedProperties[property] then
5
+ result[property] = target[property]
6
+ end
7
+ end
8
+ return result
9
+ end
@@ -0,0 +1,9 @@
1
+ local function __TS__ObjectValues(obj)
2
+ local result = {}
3
+ local len = 0
4
+ for key in pairs(obj) do
5
+ len = len + 1
6
+ result[len] = obj[key]
7
+ end
8
+ return result
9
+ end
@@ -0,0 +1,18 @@
1
+ local function __TS__ParseFloat(numberString)
2
+ local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
3
+ if infinityMatch then
4
+ local ____temp_0
5
+ if __TS__StringAccess(infinityMatch, 0) == "-" then
6
+ ____temp_0 = -(1 / 0)
7
+ else
8
+ ____temp_0 = 1 / 0
9
+ end
10
+ return ____temp_0
11
+ end
12
+ local number = tonumber(__TS__Match(numberString, "^%s*(-?%d+%.?%d*)"))
13
+ local ____number_1 = number
14
+ if ____number_1 == nil then
15
+ ____number_1 = 0 / 0
16
+ end
17
+ return ____number_1
18
+ end
@@ -0,0 +1,49 @@
1
+ local __TS__ParseInt
2
+ do
3
+ local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
4
+ function __TS__ParseInt(numberString, base)
5
+ if base == nil then
6
+ base = 10
7
+ local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
8
+ if hexMatch then
9
+ base = 16
10
+ local ____TS__Match_result__0_0
11
+ if __TS__Match(hexMatch, "-") then
12
+ ____TS__Match_result__0_0 = "-" .. __TS__StringSubstr(
13
+ numberString,
14
+ string.len(hexMatch)
15
+ )
16
+ else
17
+ ____TS__Match_result__0_0 = __TS__StringSubstr(
18
+ numberString,
19
+ string.len(hexMatch)
20
+ )
21
+ end
22
+ numberString = ____TS__Match_result__0_0
23
+ end
24
+ end
25
+ if base < 2 or base > 36 then
26
+ return 0 / 0
27
+ end
28
+ local ____temp_1
29
+ if base <= 10 then
30
+ ____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, base)
31
+ else
32
+ ____temp_1 = __TS__StringSubstr(parseIntBasePattern, 0, 10 + 2 * (base - 10))
33
+ end
34
+ local allowedDigits = ____temp_1
35
+ local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
36
+ local number = tonumber(
37
+ __TS__Match(numberString, pattern),
38
+ base
39
+ )
40
+ if number == nil then
41
+ return 0 / 0
42
+ end
43
+ if number >= 0 then
44
+ return math.floor(number)
45
+ else
46
+ return math.ceil(number)
47
+ end
48
+ end
49
+ end