typescript-to-lua 1.3.3 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/CompilerOptions.d.ts +1 -1
  2. package/dist/CompilerOptions.js +0 -1
  3. package/dist/LuaLib.d.ts +13 -1
  4. package/dist/LuaLib.js +62 -65
  5. package/dist/LuaPrinter.js +13 -12
  6. package/dist/cli/parse.js +5 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +5 -1
  9. package/dist/lualib/ArrayConcat.lua +1 -1
  10. package/dist/lualib/ArrayEntries.lua +1 -1
  11. package/dist/lualib/ArrayEvery.lua +2 -2
  12. package/dist/lualib/ArrayFilter.lua +2 -2
  13. package/dist/lualib/ArrayFind.lua +2 -2
  14. package/dist/lualib/ArrayFindIndex.lua +2 -2
  15. package/dist/lualib/ArrayFlat.lua +1 -1
  16. package/dist/lualib/ArrayFlatMap.lua +2 -2
  17. package/dist/lualib/ArrayForEach.lua +2 -2
  18. package/dist/lualib/ArrayFrom.lua +32 -0
  19. package/dist/lualib/ArrayIncludes.lua +1 -1
  20. package/dist/lualib/ArrayIndexOf.lua +1 -1
  21. package/dist/lualib/ArrayIsArray.lua +1 -1
  22. package/dist/lualib/ArrayJoin.lua +1 -1
  23. package/dist/lualib/ArrayMap.lua +2 -2
  24. package/dist/lualib/ArrayPush.lua +1 -1
  25. package/dist/lualib/ArrayReduce.lua +2 -2
  26. package/dist/lualib/ArrayReduceRight.lua +2 -2
  27. package/dist/lualib/ArrayReverse.lua +1 -1
  28. package/dist/lualib/ArraySetLength.lua +1 -1
  29. package/dist/lualib/ArrayShift.lua +1 -1
  30. package/dist/lualib/ArraySlice.lua +1 -1
  31. package/dist/lualib/ArraySome.lua +2 -2
  32. package/dist/lualib/ArraySort.lua +2 -2
  33. package/dist/lualib/ArraySplice.lua +1 -1
  34. package/dist/lualib/ArrayToObject.lua +1 -1
  35. package/dist/lualib/ArrayUnshift.lua +1 -1
  36. package/dist/lualib/Await.lua +13 -13
  37. package/dist/lualib/Class.lua +1 -1
  38. package/dist/lualib/ClassExtends.lua +1 -1
  39. package/dist/lualib/CloneDescriptor.lua +1 -1
  40. package/dist/lualib/Decorate.lua +5 -5
  41. package/dist/lualib/DecorateParam.lua +2 -2
  42. package/dist/lualib/DelegatedYield.lua +1 -1
  43. package/dist/lualib/Delete.lua +1 -1
  44. package/dist/lualib/Error.lua +68 -69
  45. package/dist/lualib/FunctionBind.lua +1 -1
  46. package/dist/lualib/Generator.lua +26 -23
  47. package/dist/lualib/InstanceOf.lua +1 -1
  48. package/dist/lualib/InstanceOfObject.lua +1 -1
  49. package/dist/lualib/Iterator.lua +35 -32
  50. package/dist/lualib/Map.lua +131 -129
  51. package/dist/lualib/MathAtan2.lua +1 -1
  52. package/dist/lualib/MathSign.lua +1 -1
  53. package/dist/lualib/New.lua +1 -1
  54. package/dist/lualib/Number.lua +1 -1
  55. package/dist/lualib/NumberIsFinite.lua +1 -1
  56. package/dist/lualib/NumberIsNaN.lua +1 -1
  57. package/dist/lualib/NumberToString.lua +42 -39
  58. package/dist/lualib/ObjectAssign.lua +1 -1
  59. package/dist/lualib/ObjectDefineProperty.lua +1 -1
  60. package/dist/lualib/ObjectEntries.lua +1 -1
  61. package/dist/lualib/ObjectFromEntries.lua +1 -1
  62. package/dist/lualib/ObjectGetOwnPropertyDescriptor.lua +1 -1
  63. package/dist/lualib/ObjectGetOwnPropertyDescriptors.lua +1 -1
  64. package/dist/lualib/ObjectKeys.lua +1 -1
  65. package/dist/lualib/ObjectRest.lua +1 -1
  66. package/dist/lualib/ObjectValues.lua +1 -1
  67. package/dist/lualib/ParseFloat.lua +1 -1
  68. package/dist/lualib/ParseInt.lua +39 -36
  69. package/dist/lualib/Promise.lua +148 -152
  70. package/dist/lualib/PromiseAll.lua +5 -5
  71. package/dist/lualib/PromiseAllSettled.lua +5 -5
  72. package/dist/lualib/PromiseAny.lua +5 -5
  73. package/dist/lualib/PromiseRace.lua +5 -5
  74. package/dist/lualib/Set.lua +120 -118
  75. package/dist/lualib/SetDescriptor.lua +67 -64
  76. package/dist/lualib/SourceMapTraceBack.lua +7 -6
  77. package/dist/lualib/SparseArrayNew.lua +1 -1
  78. package/dist/lualib/SparseArrayPush.lua +1 -1
  79. package/dist/lualib/SparseArraySpread.lua +1 -1
  80. package/dist/lualib/Spread.lua +1 -1
  81. package/dist/lualib/StringAccess.lua +1 -1
  82. package/dist/lualib/StringCharAt.lua +1 -1
  83. package/dist/lualib/StringCharCodeAt.lua +1 -1
  84. package/dist/lualib/StringConcat.lua +1 -1
  85. package/dist/lualib/StringEndsWith.lua +1 -1
  86. package/dist/lualib/StringIncludes.lua +1 -1
  87. package/dist/lualib/StringPadEnd.lua +1 -1
  88. package/dist/lualib/StringPadStart.lua +1 -1
  89. package/dist/lualib/StringReplace.lua +2 -2
  90. package/dist/lualib/StringReplaceAll.lua +4 -4
  91. package/dist/lualib/StringSlice.lua +1 -1
  92. package/dist/lualib/StringSplit.lua +1 -1
  93. package/dist/lualib/StringStartsWith.lua +1 -1
  94. package/dist/lualib/StringSubstr.lua +1 -1
  95. package/dist/lualib/StringSubstring.lua +1 -1
  96. package/dist/lualib/StringTrim.lua +1 -1
  97. package/dist/lualib/StringTrimEnd.lua +1 -1
  98. package/dist/lualib/StringTrimStart.lua +1 -1
  99. package/dist/lualib/Symbol.lua +14 -11
  100. package/dist/lualib/SymbolRegistry.lua +13 -10
  101. package/dist/lualib/TypeOf.lua +1 -1
  102. package/dist/lualib/Unpack.lua +1 -1
  103. package/dist/lualib/WeakMap.lua +41 -39
  104. package/dist/lualib/WeakSet.lua +37 -35
  105. package/dist/lualib/lualib_bundle.lua +1096 -932
  106. package/dist/lualib/lualib_module_info.json +628 -0
  107. package/dist/lualib-build/plugin.d.ts +23 -0
  108. package/dist/lualib-build/plugin.js +138 -0
  109. package/dist/lualib-build/util.d.ts +19 -0
  110. package/dist/lualib-build/util.js +43 -0
  111. package/dist/transformation/builtins/array.d.ts +1 -1
  112. package/dist/transformation/builtins/array.js +5 -0
  113. package/dist/transformation/builtins/function.js +2 -1
  114. package/dist/transformation/builtins/index.d.ts +1 -0
  115. package/dist/transformation/builtins/index.js +63 -16
  116. package/dist/transformation/context/index.js +5 -1
  117. package/dist/transformation/utils/diagnostics.d.ts +3 -0
  118. package/dist/transformation/utils/diagnostics.js +2 -1
  119. package/dist/transformation/utils/typescript/index.js +5 -1
  120. package/dist/transformation/utils/typescript/types.d.ts +2 -0
  121. package/dist/transformation/utils/typescript/types.js +10 -1
  122. package/dist/transformation/visitors/class/index.js +1 -5
  123. package/dist/transformation/visitors/class/new.d.ts +1 -2
  124. package/dist/transformation/visitors/class/new.js +1 -40
  125. package/dist/transformation/visitors/conditional.js +15 -14
  126. package/dist/transformation/visitors/identifier.js +5 -0
  127. package/dist/transformation/visitors/literal.js +22 -0
  128. package/dist/transformation/visitors/modules/import.js +4 -14
  129. package/dist/transpilation/bundle.js +1 -1
  130. package/dist/transpilation/index.js +5 -1
  131. package/dist/transpilation/plugins.d.ts +19 -1
  132. package/dist/transpilation/plugins.js +6 -2
  133. package/dist/transpilation/resolve.js +2 -2
  134. package/dist/transpilation/transpile.d.ts +1 -1
  135. package/dist/transpilation/transpile.js +13 -5
  136. package/dist/transpilation/transpiler.js +25 -11
  137. package/dist/transpilation/utils.d.ts +2 -0
  138. package/package.json +12 -11
  139. package/CHANGELOG.md +0 -703
@@ -1,140 +1,142 @@
1
- Map = __TS__Class()
2
- Map.name = "Map"
3
- function Map.prototype.____constructor(self, entries)
4
- self[Symbol.toStringTag] = "Map"
5
- self.items = {}
6
- self.size = 0
7
- self.nextKey = {}
8
- self.previousKey = {}
9
- if entries == nil then
10
- return
11
- end
12
- local iterable = entries
13
- if iterable[Symbol.iterator] then
14
- local iterator = iterable[Symbol.iterator](iterable)
15
- while true do
16
- local result = iterator:next()
17
- if result.done then
18
- break
19
- end
20
- local value = result.value
21
- self:set(value[1], value[2])
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
22
13
  end
23
- else
24
- local array = entries
25
- for ____, kvp in ipairs(array) do
26
- self:set(kvp[1], kvp[2])
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
27
30
  end
28
31
  end
29
- end
30
- function Map.prototype.clear(self)
31
- self.items = {}
32
- self.nextKey = {}
33
- self.previousKey = {}
34
- self.firstKey = nil
35
- self.lastKey = nil
36
- self.size = 0
37
- end
38
- function Map.prototype.delete(self, key)
39
- local contains = self:has(key)
40
- if contains then
41
- self.size = self.size - 1
42
- local next = self.nextKey[key]
43
- local previous = self.previousKey[key]
44
- if next and previous then
45
- self.nextKey[previous] = next
46
- self.previousKey[next] = previous
47
- elseif next then
48
- self.firstKey = next
49
- self.previousKey[next] = nil
50
- elseif previous then
51
- self.lastKey = previous
52
- self.nextKey[previous] = nil
53
- else
54
- self.firstKey = nil
55
- self.lastKey = nil
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
56
61
  end
57
- self.nextKey[key] = nil
58
- self.previousKey[key] = nil
62
+ self.items[key] = nil
63
+ return contains
59
64
  end
60
- self.items[key] = nil
61
- return contains
62
- end
63
- function Map.prototype.forEach(self, callback)
64
- for ____, key in __TS__Iterator(self:keys()) do
65
- callback(_G, self.items[key], key, self)
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
66
69
  end
67
- end
68
- function Map.prototype.get(self, key)
69
- return self.items[key]
70
- end
71
- function Map.prototype.has(self, key)
72
- return self.nextKey[key] ~= nil or self.lastKey == key
73
- end
74
- function Map.prototype.set(self, key, value)
75
- local isNewValue = not self:has(key)
76
- if isNewValue then
77
- self.size = self.size + 1
70
+ function Map.prototype.get(self, key)
71
+ return self.items[key]
78
72
  end
79
- self.items[key] = value
80
- if self.firstKey == nil then
81
- self.firstKey = key
82
- self.lastKey = key
83
- elseif isNewValue then
84
- self.nextKey[self.lastKey] = key
85
- self.previousKey[key] = self.lastKey
86
- self.lastKey = key
73
+ function Map.prototype.has(self, key)
74
+ return self.nextKey[key] ~= nil or self.lastKey == key
87
75
  end
88
- return self
89
- end
90
- Map.prototype[Symbol.iterator] = function(self)
91
- return self:entries()
92
- end
93
- function Map.prototype.entries(self)
94
- local ____temp_0 = self
95
- local items = ____temp_0.items
96
- local nextKey = ____temp_0.nextKey
97
- local key = self.firstKey
98
- return {
99
- [Symbol.iterator] = function(self)
100
- return self
101
- end,
102
- next = function(self)
103
- local result = {done = not key, value = {key, items[key]}}
104
- key = nextKey[key]
105
- return result
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
106
80
  end
107
- }
108
- end
109
- function Map.prototype.keys(self)
110
- local nextKey = self.nextKey
111
- local key = self.firstKey
112
- return {
113
- [Symbol.iterator] = function(self)
114
- return self
115
- end,
116
- next = function(self)
117
- local result = {done = not key, value = key}
118
- key = nextKey[key]
119
- return result
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
120
89
  end
121
- }
122
- end
123
- function Map.prototype.values(self)
124
- local ____temp_1 = self
125
- local items = ____temp_1.items
126
- local nextKey = ____temp_1.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
- }
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 ____temp_0 = self
97
+ local items = ____temp_0.items
98
+ local nextKey = ____temp_0.nextKey
99
+ local key = self.firstKey
100
+ return {
101
+ [Symbol.iterator] = function(self)
102
+ return self
103
+ end,
104
+ next = function(self)
105
+ local result = {done = not key, value = {key, items[key]}}
106
+ key = nextKey[key]
107
+ return result
108
+ end
109
+ }
110
+ end
111
+ function Map.prototype.keys(self)
112
+ local nextKey = self.nextKey
113
+ local key = self.firstKey
114
+ return {
115
+ [Symbol.iterator] = function(self)
116
+ return self
117
+ end,
118
+ next = function(self)
119
+ local result = {done = not key, value = key}
120
+ key = nextKey[key]
121
+ return result
122
+ end
123
+ }
124
+ end
125
+ function Map.prototype.values(self)
126
+ local ____temp_1 = self
127
+ local items = ____temp_1.items
128
+ local nextKey = ____temp_1.nextKey
129
+ local key = self.firstKey
130
+ return {
131
+ [Symbol.iterator] = function(self)
132
+ return self
133
+ end,
134
+ next = function(self)
135
+ local result = {done = not key, value = items[key]}
136
+ key = nextKey[key]
137
+ return result
138
+ end
139
+ }
140
+ end
141
+ Map[Symbol.species] = Map
138
142
  end
139
- Map[Symbol.species] = Map
140
- Map = Map
@@ -1 +1 @@
1
- __TS__MathAtan2 = math.atan2 or math.atan
1
+ local __TS__MathAtan2 = math.atan2 or math.atan
@@ -1,4 +1,4 @@
1
- function __TS__MathSign(val)
1
+ local function __TS__MathSign(val)
2
2
  if val > 0 then
3
3
  return 1
4
4
  elseif val < 0 then
@@ -1,4 +1,4 @@
1
- function __TS__New(target, ...)
1
+ local function __TS__New(target, ...)
2
2
  local instance = setmetatable({}, target.prototype)
3
3
  instance:____constructor(...)
4
4
  return instance
@@ -1,4 +1,4 @@
1
- function __TS__Number(value)
1
+ local function __TS__Number(value)
2
2
  local valueType = type(value)
3
3
  if valueType == "number" then
4
4
  return value
@@ -1,3 +1,3 @@
1
- function __TS__NumberIsFinite(value)
1
+ local function __TS__NumberIsFinite(value)
2
2
  return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
3
3
  end
@@ -1,3 +1,3 @@
1
- function __TS__NumberIsNaN(value)
1
+ local function __TS__NumberIsNaN(value)
2
2
  return value ~= value
3
3
  end
@@ -1,41 +1,44 @@
1
- ____radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
2
- function __TS__NumberToString(self, radix)
3
- if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then
4
- return tostring(self)
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 == math.huge or self == -math.huge 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 = math.modf(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(radixChars, integer % radix) .. result
22
+ integer = math.floor(integer / radix)
23
+ end
24
+ until not (integer ~= 0)
25
+ end
26
+ if fraction ~= 0 then
27
+ result = result .. "."
28
+ local delta = 1e-16
29
+ repeat
30
+ do
31
+ fraction = fraction * radix
32
+ delta = delta * radix
33
+ local digit = math.floor(fraction)
34
+ result = result .. __TS__StringAccess(radixChars, digit)
35
+ fraction = fraction - digit
36
+ end
37
+ until not (fraction >= delta)
38
+ end
39
+ if self < 0 then
40
+ result = "-" .. result
41
+ end
42
+ return result
5
43
  end
6
- radix = math.floor(radix)
7
- if radix < 2 or radix > 36 then
8
- error("toString() radix argument must be between 2 and 36", 0)
9
- end
10
- local integer, fraction = math.modf(math.abs(self))
11
- local result = ""
12
- if radix == 8 then
13
- result = string.format("%o", integer)
14
- elseif radix == 16 then
15
- result = string.format("%x", integer)
16
- else
17
- repeat
18
- do
19
- result = __TS__StringAccess(____radixChars, integer % radix) .. result
20
- integer = math.floor(integer / radix)
21
- end
22
- until not (integer ~= 0)
23
- end
24
- if fraction ~= 0 then
25
- result = result .. "."
26
- local delta = 1e-16
27
- repeat
28
- do
29
- fraction = fraction * radix
30
- delta = delta * radix
31
- local digit = math.floor(fraction)
32
- result = result .. __TS__StringAccess(____radixChars, digit)
33
- fraction = fraction - digit
34
- end
35
- until not (fraction >= delta)
36
- end
37
- if self < 0 then
38
- result = "-" .. result
39
- end
40
- return result
41
44
  end
@@ -1,4 +1,4 @@
1
- function __TS__ObjectAssign(to, ...)
1
+ local function __TS__ObjectAssign(to, ...)
2
2
  local sources = {...}
3
3
  if to == nil then
4
4
  return to
@@ -1,4 +1,4 @@
1
- function __TS__ObjectDefineProperty(target, key, desc)
1
+ local function __TS__ObjectDefineProperty(target, key, desc)
2
2
  local ____temp_0
3
3
  if type(key) == "number" then
4
4
  ____temp_0 = key + 1
@@ -1,4 +1,4 @@
1
- function __TS__ObjectEntries(obj)
1
+ local function __TS__ObjectEntries(obj)
2
2
  local result = {}
3
3
  for key in pairs(obj) do
4
4
  result[#result + 1] = {key, obj[key]}
@@ -1,4 +1,4 @@
1
- function __TS__ObjectFromEntries(entries)
1
+ local function __TS__ObjectFromEntries(entries)
2
2
  local obj = {}
3
3
  local iterable = entries
4
4
  if iterable[Symbol.iterator] then
@@ -1,4 +1,4 @@
1
- function __TS__ObjectGetOwnPropertyDescriptor(object, key)
1
+ local function __TS__ObjectGetOwnPropertyDescriptor(object, key)
2
2
  local metatable = getmetatable(object)
3
3
  if not metatable then
4
4
  return
@@ -1,4 +1,4 @@
1
- function __TS__ObjectGetOwnPropertyDescriptors(object)
1
+ local function __TS__ObjectGetOwnPropertyDescriptors(object)
2
2
  local metatable = getmetatable(object)
3
3
  if not metatable then
4
4
  return {}
@@ -1,4 +1,4 @@
1
- function __TS__ObjectKeys(obj)
1
+ local function __TS__ObjectKeys(obj)
2
2
  local result = {}
3
3
  for key in pairs(obj) do
4
4
  result[#result + 1] = key
@@ -1,4 +1,4 @@
1
- function __TS__ObjectRest(target, usedProperties)
1
+ local function __TS__ObjectRest(target, usedProperties)
2
2
  local result = {}
3
3
  for property in pairs(target) do
4
4
  if not usedProperties[property] then
@@ -1,4 +1,4 @@
1
- function __TS__ObjectValues(obj)
1
+ local function __TS__ObjectValues(obj)
2
2
  local result = {}
3
3
  for key in pairs(obj) do
4
4
  result[#result + 1] = obj[key]
@@ -1,4 +1,4 @@
1
- function __TS__ParseFloat(numberString)
1
+ local function __TS__ParseFloat(numberString)
2
2
  local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
3
3
  if infinityMatch then
4
4
  local ____temp_0
@@ -1,40 +1,43 @@
1
- __TS__parseInt_base_pattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
2
- function __TS__ParseInt(numberString, base)
3
- if base == nil then
4
- base = 10
5
- local hexMatch = string.match(numberString, "^%s*-?0[xX]")
6
- if hexMatch then
7
- base = 16
8
- local ____string_match_result__0_0
9
- if string.match(hexMatch, "-") then
10
- ____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
11
- else
12
- ____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
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 = string.match(numberString, "^%s*-?0[xX]")
8
+ if hexMatch then
9
+ base = 16
10
+ local ____string_match_result__0_0
11
+ if string.match(hexMatch, "-") then
12
+ ____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
13
+ else
14
+ ____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
15
+ end
16
+ numberString = ____string_match_result__0_0
13
17
  end
14
- numberString = ____string_match_result__0_0
15
18
  end
16
- end
17
- if base < 2 or base > 36 then
18
- return 0 / 0
19
- end
20
- local ____temp_1
21
- if base <= 10 then
22
- ____temp_1 = __TS__StringSubstring(__TS__parseInt_base_pattern, 0, base)
23
- else
24
- ____temp_1 = __TS__StringSubstr(__TS__parseInt_base_pattern, 0, 10 + 2 * (base - 10))
25
- end
26
- local allowedDigits = ____temp_1
27
- local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
28
- local number = tonumber(
29
- string.match(numberString, pattern),
30
- base
31
- )
32
- if number == nil then
33
- return 0 / 0
34
- end
35
- if number >= 0 then
36
- return math.floor(number)
37
- else
38
- return math.ceil(number)
19
+ if base < 2 or base > 36 then
20
+ return 0 / 0
21
+ end
22
+ local ____temp_1
23
+ if base <= 10 then
24
+ ____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, base)
25
+ else
26
+ ____temp_1 = __TS__StringSubstr(parseIntBasePattern, 0, 10 + 2 * (base - 10))
27
+ end
28
+ local allowedDigits = ____temp_1
29
+ local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
30
+ local number = tonumber(
31
+ string.match(numberString, pattern),
32
+ base
33
+ )
34
+ if number == nil then
35
+ return 0 / 0
36
+ end
37
+ if number >= 0 then
38
+ return math.floor(number)
39
+ else
40
+ return math.ceil(number)
41
+ end
39
42
  end
40
43
  end