typescript-to-lua 1.1.1 → 1.2.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.
- package/CHANGELOG.md +16 -0
- package/dist/LuaAST.d.ts +1 -0
- package/dist/LuaAST.js +10 -2
- package/dist/LuaLib.d.ts +3 -3
- package/dist/LuaLib.js +4 -4
- package/dist/LuaPrinter.d.ts +11 -4
- package/dist/LuaPrinter.js +54 -11
- package/dist/lualib/ArrayFlat.lua +1 -1
- package/dist/lualib/ArrayFlatMap.lua +1 -1
- package/dist/lualib/ArrayIsArray.lua +1 -1
- package/dist/lualib/ArrayReduce.lua +7 -1
- package/dist/lualib/ArrayReduceRight.lua +7 -1
- package/dist/lualib/ArraySetLength.lua +1 -1
- package/dist/lualib/ArraySplice.lua +5 -5
- package/dist/lualib/Await.lua +14 -10
- package/dist/lualib/CloneDescriptor.lua +8 -8
- package/dist/lualib/Decorate.lua +1 -1
- package/dist/lualib/DelegatedYield.lua +1 -3
- package/dist/lualib/Delete.lua +6 -6
- package/dist/lualib/Error.lua +47 -44
- package/dist/lualib/Generator.lua +1 -5
- package/dist/lualib/InstanceOf.lua +1 -1
- package/dist/lualib/InstanceOfObject.lua +1 -1
- package/dist/lualib/Map.lua +130 -134
- package/dist/lualib/Number.lua +1 -1
- package/dist/lualib/NumberIsFinite.lua +1 -1
- package/dist/lualib/NumberToString.lua +3 -5
- package/dist/lualib/ObjectDefineProperty.lua +40 -8
- package/dist/lualib/ParseFloat.lua +9 -5
- package/dist/lualib/ParseInt.lua +15 -3
- package/dist/lualib/Promise.lua +18 -22
- package/dist/lualib/Set.lua +119 -123
- package/dist/lualib/SetDescriptor.lua +7 -1
- package/dist/lualib/SourceMapTraceBack.lua +1 -1
- package/dist/lualib/SparseArrayNew.lua +5 -0
- package/dist/lualib/SparseArrayPush.lua +9 -0
- package/dist/lualib/SparseArraySpread.lua +4 -0
- package/dist/lualib/StringAccess.lua +1 -1
- package/dist/lualib/StringCharCodeAt.lua +1 -1
- package/dist/lualib/StringEndsWith.lua +2 -2
- package/dist/lualib/StringPadEnd.lua +2 -2
- package/dist/lualib/StringPadStart.lua +2 -2
- package/dist/lualib/StringReplace.lua +7 -1
- package/dist/lualib/StringSlice.lua +2 -2
- package/dist/lualib/StringSplit.lua +3 -3
- package/dist/lualib/StringStartsWith.lua +1 -1
- package/dist/lualib/StringSubstr.lua +1 -1
- package/dist/lualib/StringSubstring.lua +2 -2
- package/dist/lualib/Symbol.lua +3 -5
- package/dist/lualib/WeakMap.lua +40 -42
- package/dist/lualib/WeakSet.lua +36 -38
- package/dist/lualib/lualib_bundle.lua +603 -555
- package/dist/transformation/builtins/array.js +1 -2
- package/dist/transformation/builtins/function.js +1 -2
- package/dist/transformation/builtins/index.d.ts +1 -1
- package/dist/transformation/builtins/index.js +37 -4
- package/dist/transformation/builtins/object.d.ts +2 -1
- package/dist/transformation/builtins/object.js +1 -2
- package/dist/transformation/builtins/string.js +1 -2
- package/dist/transformation/context/context.d.ts +12 -0
- package/dist/transformation/context/context.js +102 -3
- package/dist/transformation/utils/diagnostics.d.ts +6 -0
- package/dist/transformation/utils/diagnostics.js +3 -1
- package/dist/transformation/utils/lua-ast.d.ts +0 -1
- package/dist/transformation/utils/lua-ast.js +13 -22
- package/dist/transformation/utils/preceding-statements.d.ts +3 -0
- package/dist/transformation/utils/preceding-statements.js +11 -0
- package/dist/transformation/utils/scope.d.ts +1 -0
- package/dist/transformation/utils/scope.js +8 -1
- package/dist/transformation/utils/typescript/index.d.ts +1 -0
- package/dist/transformation/utils/typescript/index.js +16 -1
- package/dist/transformation/visitors/access.d.ts +3 -0
- package/dist/transformation/visitors/access.js +63 -36
- package/dist/transformation/visitors/binary-expression/assignments.d.ts +3 -2
- package/dist/transformation/visitors/binary-expression/assignments.js +66 -57
- package/dist/transformation/visitors/binary-expression/compound.d.ts +5 -4
- package/dist/transformation/visitors/binary-expression/compound.js +66 -68
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.d.ts +2 -2
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +54 -25
- package/dist/transformation/visitors/binary-expression/index.d.ts +3 -1
- package/dist/transformation/visitors/binary-expression/index.js +64 -20
- package/dist/transformation/visitors/call.d.ts +3 -2
- package/dist/transformation/visitors/call.js +109 -122
- package/dist/transformation/visitors/class/index.js +4 -7
- package/dist/transformation/visitors/class/new.js +4 -6
- package/dist/transformation/visitors/conditional.js +28 -14
- package/dist/transformation/visitors/delete.js +4 -0
- package/dist/transformation/visitors/expression-list.d.ts +7 -0
- package/dist/transformation/visitors/expression-list.js +120 -0
- package/dist/transformation/visitors/function.js +6 -8
- package/dist/transformation/visitors/identifier.js +4 -0
- package/dist/transformation/visitors/literal.js +69 -16
- package/dist/transformation/visitors/loops/do-while.js +34 -8
- package/dist/transformation/visitors/loops/for.js +25 -5
- package/dist/transformation/visitors/loops/utils.d.ts +1 -0
- package/dist/transformation/visitors/loops/utils.js +13 -2
- package/dist/transformation/visitors/modules/export.js +1 -1
- package/dist/transformation/visitors/optional-chaining.d.ts +16 -0
- package/dist/transformation/visitors/optional-chaining.js +172 -0
- package/dist/transformation/visitors/sourceFile.js +4 -1
- package/dist/transformation/visitors/switch.js +29 -9
- package/dist/transformation/visitors/template.js +5 -2
- package/dist/transformation/visitors/typeof.js +3 -1
- package/dist/transformation/visitors/variable-declaration.js +21 -7
- package/dist/transformation/visitors/void.js +4 -7
- package/dist/transpilation/transformers.js +4 -1
- package/dist/transpilation/utils.js +2 -1
- package/package.json +5 -5
- package/dist/lualib/OptionalChainAccess.lua +0 -6
- package/dist/lualib/OptionalFunctionCall.lua +0 -6
- package/dist/lualib/OptionalMethodCall.lua +0 -11
- package/dist/transformation/utils/transform.d.ts +0 -8
- package/dist/transformation/utils/transform.js +0 -14
package/dist/lualib/Map.lua
CHANGED
|
@@ -1,144 +1,140 @@
|
|
|
1
|
-
Map = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
end
|
|
13
|
-
local iterable = entries
|
|
14
|
-
if iterable[Symbol.iterator] then
|
|
15
|
-
local iterator = iterable[Symbol.iterator](iterable)
|
|
16
|
-
while true do
|
|
17
|
-
local result = iterator:next()
|
|
18
|
-
if result.done then
|
|
19
|
-
break
|
|
20
|
-
end
|
|
21
|
-
local value = result.value
|
|
22
|
-
self:set(value[1], value[2])
|
|
23
|
-
end
|
|
24
|
-
else
|
|
25
|
-
local array = entries
|
|
26
|
-
for ____, kvp in ipairs(array) do
|
|
27
|
-
self:set(kvp[1], kvp[2])
|
|
28
|
-
end
|
|
29
|
-
end
|
|
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
|
|
30
11
|
end
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
function Map.prototype.delete(self, key)
|
|
40
|
-
local contains = self:has(key)
|
|
41
|
-
if contains then
|
|
42
|
-
self.size = self.size - 1
|
|
43
|
-
local next = self.nextKey[key]
|
|
44
|
-
local previous = self.previousKey[key]
|
|
45
|
-
if next and previous then
|
|
46
|
-
self.nextKey[previous] = next
|
|
47
|
-
self.previousKey[next] = previous
|
|
48
|
-
elseif next then
|
|
49
|
-
self.firstKey = next
|
|
50
|
-
self.previousKey[next] = nil
|
|
51
|
-
elseif previous then
|
|
52
|
-
self.lastKey = previous
|
|
53
|
-
self.nextKey[previous] = nil
|
|
54
|
-
else
|
|
55
|
-
self.firstKey = nil
|
|
56
|
-
self.lastKey = nil
|
|
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
|
|
57
19
|
end
|
|
58
|
-
|
|
59
|
-
self
|
|
20
|
+
local value = result.value
|
|
21
|
+
self:set(value[1], value[2])
|
|
60
22
|
end
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
for ____, key in __TS__Iterator(
|
|
66
|
-
self:keys()
|
|
67
|
-
) do
|
|
68
|
-
callback(_G, self.items[key], key, self)
|
|
23
|
+
else
|
|
24
|
+
local array = entries
|
|
25
|
+
for ____, kvp in ipairs(array) do
|
|
26
|
+
self:set(kvp[1], kvp[2])
|
|
69
27
|
end
|
|
70
28
|
end
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
self.nextKey[
|
|
88
|
-
self.previousKey[
|
|
89
|
-
|
|
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
|
|
90
56
|
end
|
|
91
|
-
|
|
57
|
+
self.nextKey[key] = nil
|
|
58
|
+
self.previousKey[key] = nil
|
|
92
59
|
end
|
|
93
|
-
|
|
94
|
-
|
|
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)
|
|
95
66
|
end
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
key = nextKey[key]
|
|
108
|
-
return result
|
|
109
|
-
end
|
|
110
|
-
}
|
|
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
|
|
111
78
|
end
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
local result = {done = not key, value = key}
|
|
121
|
-
key = nextKey[key]
|
|
122
|
-
return result
|
|
123
|
-
end
|
|
124
|
-
}
|
|
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
|
|
125
87
|
end
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
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
|
|
106
|
+
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
|
|
120
|
+
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
|
+
}
|
|
138
|
+
end
|
|
139
|
+
Map[Symbol.species] = Map
|
|
140
|
+
Map = Map
|
package/dist/lualib/Number.lua
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
____radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
|
|
2
2
|
function __TS__NumberToString(self, radix)
|
|
3
|
-
if
|
|
3
|
+
if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then
|
|
4
4
|
return tostring(self)
|
|
5
5
|
end
|
|
6
6
|
radix = math.floor(radix)
|
|
7
|
-
if
|
|
7
|
+
if radix < 2 or radix > 36 then
|
|
8
8
|
error("toString() radix argument must be between 2 and 36", 0)
|
|
9
9
|
end
|
|
10
|
-
local integer, fraction = math.modf(
|
|
11
|
-
math.abs(self)
|
|
12
|
-
)
|
|
10
|
+
local integer, fraction = math.modf(math.abs(self))
|
|
13
11
|
local result = ""
|
|
14
12
|
if radix == 8 then
|
|
15
13
|
result = string.format("%o", integer)
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
function __TS__ObjectDefineProperty(target, key, desc)
|
|
2
|
-
local
|
|
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
|
|
3
9
|
local value = rawget(target, luaKey)
|
|
4
|
-
local hasGetterOrSetter =
|
|
10
|
+
local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
|
|
5
11
|
local descriptor
|
|
6
12
|
if hasGetterOrSetter then
|
|
7
13
|
if value ~= nil then
|
|
@@ -13,13 +19,39 @@ function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
13
19
|
descriptor = desc
|
|
14
20
|
else
|
|
15
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
|
|
16
48
|
descriptor = {
|
|
17
|
-
set =
|
|
18
|
-
get =
|
|
19
|
-
configurable =
|
|
20
|
-
enumerable =
|
|
21
|
-
writable =
|
|
22
|
-
value =
|
|
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
|
|
23
55
|
}
|
|
24
56
|
end
|
|
25
57
|
__TS__SetDescriptor(target, luaKey, descriptor)
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
function __TS__ParseFloat(numberString)
|
|
2
2
|
local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
|
|
3
3
|
if infinityMatch then
|
|
4
|
-
|
|
4
|
+
local ____temp_0
|
|
5
|
+
if __TS__StringAccess(infinityMatch, 0) == "-" then
|
|
6
|
+
____temp_0 = -math.huge
|
|
7
|
+
else
|
|
8
|
+
____temp_0 = math.huge
|
|
9
|
+
end
|
|
10
|
+
return ____temp_0
|
|
5
11
|
end
|
|
6
|
-
local number = tonumber(
|
|
7
|
-
|
|
8
|
-
)
|
|
9
|
-
return number or (0 / 0)
|
|
12
|
+
local number = tonumber(string.match(numberString, "^%s*(-?%d+%.?%d*)"))
|
|
13
|
+
return number or 0 / 0
|
|
10
14
|
end
|
package/dist/lualib/ParseInt.lua
CHANGED
|
@@ -5,13 +5,25 @@ function __TS__ParseInt(numberString, base)
|
|
|
5
5
|
local hexMatch = string.match(numberString, "^%s*-?0[xX]")
|
|
6
6
|
if hexMatch then
|
|
7
7
|
base = 16
|
|
8
|
-
|
|
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)
|
|
13
|
+
end
|
|
14
|
+
numberString = ____string_match_result__0_0
|
|
9
15
|
end
|
|
10
16
|
end
|
|
11
|
-
if
|
|
17
|
+
if base < 2 or base > 36 then
|
|
12
18
|
return 0 / 0
|
|
13
19
|
end
|
|
14
|
-
local
|
|
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
|
|
15
27
|
local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
|
|
16
28
|
local number = tonumber(
|
|
17
29
|
string.match(numberString, pattern),
|
package/dist/lualib/Promise.lua
CHANGED
|
@@ -31,15 +31,13 @@ function __TS__Promise.prototype.____constructor(self, executor)
|
|
|
31
31
|
local function ____catch(e)
|
|
32
32
|
self:reject(e)
|
|
33
33
|
end
|
|
34
|
-
local ____try, ____hasReturned = pcall(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
)
|
|
34
|
+
local ____try, ____hasReturned = pcall(function()
|
|
35
|
+
executor(
|
|
36
|
+
_G,
|
|
37
|
+
__TS__FunctionBind(self.resolve, self),
|
|
38
|
+
__TS__FunctionBind(self.reject, self)
|
|
39
|
+
)
|
|
40
|
+
end)
|
|
43
41
|
if not ____try then
|
|
44
42
|
____hasReturned, ____returnValue = ____catch(____hasReturned)
|
|
45
43
|
end
|
|
@@ -66,10 +64,10 @@ function __TS__Promise.reject(reason)
|
|
|
66
64
|
return promise
|
|
67
65
|
end
|
|
68
66
|
__TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
|
|
69
|
-
local
|
|
70
|
-
local promise =
|
|
71
|
-
local resolve =
|
|
72
|
-
local reject =
|
|
67
|
+
local ____TS__PromiseDeferred_result_0 = __TS__PromiseDeferred(_G)
|
|
68
|
+
local promise = ____TS__PromiseDeferred_result_0.promise
|
|
69
|
+
local resolve = ____TS__PromiseDeferred_result_0.resolve
|
|
70
|
+
local reject = ____TS__PromiseDeferred_result_0.reject
|
|
73
71
|
local isFulfilled = self.state == __TS__PromiseState.Fulfilled
|
|
74
72
|
local isRejected = self.state == __TS__PromiseState.Rejected
|
|
75
73
|
if onFulfilled then
|
|
@@ -141,15 +139,13 @@ function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve
|
|
|
141
139
|
local function ____catch(e)
|
|
142
140
|
reject(_G, e)
|
|
143
141
|
end
|
|
144
|
-
local ____try, ____hasReturned = pcall(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
end
|
|
152
|
-
)
|
|
142
|
+
local ____try, ____hasReturned = pcall(function()
|
|
143
|
+
self:handleCallbackData(
|
|
144
|
+
f(_G, value),
|
|
145
|
+
resolve,
|
|
146
|
+
reject
|
|
147
|
+
)
|
|
148
|
+
end)
|
|
153
149
|
if not ____try then
|
|
154
150
|
____hasReturned, ____returnValue = ____catch(____hasReturned)
|
|
155
151
|
end
|