typescript-to-lua 1.10.0-beta.0 → 1.10.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/dist/transpilation/resolve.js +3 -3
- package/package.json +2 -2
- package/dist/lualib/ArrayConcat.lua +0 -22
- package/dist/lualib/ArrayEntries.lua +0 -13
- package/dist/lualib/ArrayEvery.lua +0 -8
- package/dist/lualib/ArrayFilter.lua +0 -11
- package/dist/lualib/ArrayFind.lua +0 -9
- package/dist/lualib/ArrayFindIndex.lua +0 -8
- package/dist/lualib/ArrayFlat.lua +0 -27
- package/dist/lualib/ArrayFlatMap.lua +0 -17
- package/dist/lualib/ArrayForEach.lua +0 -5
- package/dist/lualib/ArrayFrom.lua +0 -29
- package/dist/lualib/ArrayIncludes.lua +0 -19
- package/dist/lualib/ArrayIndexOf.lua +0 -24
- package/dist/lualib/ArrayIsArray.lua +0 -3
- package/dist/lualib/ArrayJoin.lua +0 -10
- package/dist/lualib/ArrayMap.lua +0 -7
- package/dist/lualib/ArrayPush.lua +0 -9
- package/dist/lualib/ArrayPushArray.lua +0 -8
- package/dist/lualib/ArrayReduce.lua +0 -23
- package/dist/lualib/ArrayReduceRight.lua +0 -23
- package/dist/lualib/ArrayReverse.lua +0 -12
- package/dist/lualib/ArraySetLength.lua +0 -12
- package/dist/lualib/ArraySlice.lua +0 -43
- package/dist/lualib/ArraySome.lua +0 -8
- package/dist/lualib/ArraySort.lua +0 -11
- package/dist/lualib/ArraySplice.lua +0 -77
- package/dist/lualib/ArrayToObject.lua +0 -7
- package/dist/lualib/ArrayUnshift.lua +0 -14
- package/dist/lualib/Await.lua +0 -54
- package/dist/lualib/Class.lua +0 -6
- package/dist/lualib/ClassExtends.lua +0 -24
- package/dist/lualib/CloneDescriptor.lua +0 -28
- package/dist/lualib/Decorate.lua +0 -36
- package/dist/lualib/DecorateParam.lua +0 -3
- package/dist/lualib/DelegatedYield.lua +0 -34
- package/dist/lualib/Delete.lua +0 -19
- package/dist/lualib/Error.lua +0 -77
- package/dist/lualib/FunctionBind.lua +0 -11
- package/dist/lualib/Generator.lua +0 -38
- package/dist/lualib/InstanceOf.lua +0 -18
- package/dist/lualib/InstanceOfObject.lua +0 -4
- package/dist/lualib/Iterator.lua +0 -40
- package/dist/lualib/LuaIteratorSpread.lua +0 -9
- package/dist/lualib/Map.lua +0 -140
- package/dist/lualib/MathAtan2.lua +0 -1
- package/dist/lualib/MathSign.lua +0 -8
- package/dist/lualib/New.lua +0 -5
- package/dist/lualib/Number.lua +0 -26
- package/dist/lualib/NumberIsFinite.lua +0 -3
- package/dist/lualib/NumberIsNaN.lua +0 -3
- package/dist/lualib/NumberToString.lua +0 -44
- package/dist/lualib/ObjectAssign.lua +0 -10
- package/dist/lualib/ObjectDefineProperty.lua +0 -59
- package/dist/lualib/ObjectEntries.lua +0 -9
- package/dist/lualib/ObjectFromEntries.lua +0 -20
- package/dist/lualib/ObjectGetOwnPropertyDescriptor.lua +0 -10
- package/dist/lualib/ObjectGetOwnPropertyDescriptors.lua +0 -7
- package/dist/lualib/ObjectKeys.lua +0 -9
- package/dist/lualib/ObjectRest.lua +0 -9
- package/dist/lualib/ObjectValues.lua +0 -9
- package/dist/lualib/ParseFloat.lua +0 -18
- package/dist/lualib/ParseInt.lua +0 -43
- package/dist/lualib/Promise.lua +0 -176
- package/dist/lualib/PromiseAll.lua +0 -44
- package/dist/lualib/PromiseAllSettled.lua +0 -48
- package/dist/lualib/PromiseAny.lua +0 -41
- package/dist/lualib/PromiseRace.lua +0 -28
- package/dist/lualib/Set.lua +0 -130
- package/dist/lualib/SetDescriptor.lua +0 -79
- package/dist/lualib/SourceMapTraceBack.lua +0 -54
- package/dist/lualib/SparseArrayNew.lua +0 -5
- package/dist/lualib/SparseArrayPush.lua +0 -9
- package/dist/lualib/SparseArraySpread.lua +0 -8
- package/dist/lualib/Spread.lua +0 -15
- package/dist/lualib/StringAccess.lua +0 -5
- package/dist/lualib/StringCharAt.lua +0 -9
- package/dist/lualib/StringCharCodeAt.lua +0 -13
- package/dist/lualib/StringEndsWith.lua +0 -6
- package/dist/lualib/StringIncludes.lua +0 -9
- package/dist/lualib/StringPadEnd.lua +0 -26
- package/dist/lualib/StringPadStart.lua +0 -26
- package/dist/lualib/StringReplace.lua +0 -20
- package/dist/lualib/StringReplaceAll.lua +0 -42
- package/dist/lualib/StringSlice.lua +0 -15
- package/dist/lualib/StringSplit.lua +0 -36
- package/dist/lualib/StringStartsWith.lua +0 -6
- package/dist/lualib/StringSubstr.lua +0 -15
- package/dist/lualib/StringSubstring.lua +0 -17
- package/dist/lualib/StringTrim.lua +0 -4
- package/dist/lualib/StringTrimEnd.lua +0 -4
- package/dist/lualib/StringTrimStart.lua +0 -4
- package/dist/lualib/Symbol.lua +0 -15
- package/dist/lualib/SymbolRegistry.lua +0 -17
- package/dist/lualib/TypeOf.lua +0 -10
- package/dist/lualib/Unpack.lua +0 -1
- package/dist/lualib/WeakMap.lua +0 -45
- package/dist/lualib/WeakSet.lua +0 -41
- package/dist/lualib/lualib_bundle.lua +0 -2518
- package/dist/lualib/lualib_module_info.json +0 -626
- package/dist/lualib/universal/universal/CountVarargs.lua +0 -3
- package/dist/lualib/universal/universal/Match.lua +0 -1
- package/dist/lualib/universal/universal/MathModf.lua +0 -1
- package/dist/lualib/universal/universal/SparseArraySpread.lua +0 -8
- package/dist/lualib/universal/universal/Unpack.lua +0 -1
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
local function __TS__ParseFloat(numberString)
|
|
2
|
-
local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
|
|
3
|
-
if infinityMatch then
|
|
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
|
|
11
|
-
end
|
|
12
|
-
local number = tonumber(string.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
|
package/dist/lualib/ParseInt.lua
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
|
|
17
|
-
end
|
|
18
|
-
end
|
|
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
|
|
42
|
-
end
|
|
43
|
-
end
|
package/dist/lualib/Promise.lua
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
local __TS__Promise
|
|
2
|
-
do
|
|
3
|
-
local function promiseDeferred(self)
|
|
4
|
-
local resolve
|
|
5
|
-
local reject
|
|
6
|
-
local promise = __TS__New(
|
|
7
|
-
__TS__Promise,
|
|
8
|
-
function(____, res, rej)
|
|
9
|
-
resolve = res
|
|
10
|
-
reject = rej
|
|
11
|
-
end
|
|
12
|
-
)
|
|
13
|
-
return {promise = promise, resolve = resolve, reject = reject}
|
|
14
|
-
end
|
|
15
|
-
local function isPromiseLike(self, thing)
|
|
16
|
-
return __TS__InstanceOf(thing, __TS__Promise)
|
|
17
|
-
end
|
|
18
|
-
__TS__Promise = __TS__Class()
|
|
19
|
-
__TS__Promise.name = "__TS__Promise"
|
|
20
|
-
function __TS__Promise.prototype.____constructor(self, executor)
|
|
21
|
-
self.state = 0
|
|
22
|
-
self.fulfilledCallbacks = {}
|
|
23
|
-
self.rejectedCallbacks = {}
|
|
24
|
-
self.finallyCallbacks = {}
|
|
25
|
-
do
|
|
26
|
-
local function ____catch(e)
|
|
27
|
-
self:reject(e)
|
|
28
|
-
end
|
|
29
|
-
local ____try, ____hasReturned = pcall(function()
|
|
30
|
-
executor(
|
|
31
|
-
nil,
|
|
32
|
-
__TS__FunctionBind(self.resolve, self),
|
|
33
|
-
__TS__FunctionBind(self.reject, self)
|
|
34
|
-
)
|
|
35
|
-
end)
|
|
36
|
-
if not ____try then
|
|
37
|
-
____catch(____hasReturned)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
function __TS__Promise.resolve(data)
|
|
42
|
-
local promise = __TS__New(
|
|
43
|
-
__TS__Promise,
|
|
44
|
-
function()
|
|
45
|
-
end
|
|
46
|
-
)
|
|
47
|
-
promise.state = 1
|
|
48
|
-
promise.value = data
|
|
49
|
-
return promise
|
|
50
|
-
end
|
|
51
|
-
function __TS__Promise.reject(reason)
|
|
52
|
-
local promise = __TS__New(
|
|
53
|
-
__TS__Promise,
|
|
54
|
-
function()
|
|
55
|
-
end
|
|
56
|
-
)
|
|
57
|
-
promise.state = 2
|
|
58
|
-
promise.rejectionReason = reason
|
|
59
|
-
return promise
|
|
60
|
-
end
|
|
61
|
-
__TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
|
|
62
|
-
local ____promiseDeferred_result_0 = promiseDeferred(nil)
|
|
63
|
-
local promise = ____promiseDeferred_result_0.promise
|
|
64
|
-
local resolve = ____promiseDeferred_result_0.resolve
|
|
65
|
-
local reject = ____promiseDeferred_result_0.reject
|
|
66
|
-
local isFulfilled = self.state == 1
|
|
67
|
-
local isRejected = self.state == 2
|
|
68
|
-
if onFulfilled then
|
|
69
|
-
local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
|
|
70
|
-
local ____self_fulfilledCallbacks_1 = self.fulfilledCallbacks
|
|
71
|
-
____self_fulfilledCallbacks_1[#____self_fulfilledCallbacks_1 + 1] = internalCallback
|
|
72
|
-
if isFulfilled then
|
|
73
|
-
internalCallback(nil, self.value)
|
|
74
|
-
end
|
|
75
|
-
else
|
|
76
|
-
local ____self_fulfilledCallbacks_2 = self.fulfilledCallbacks
|
|
77
|
-
____self_fulfilledCallbacks_2[#____self_fulfilledCallbacks_2 + 1] = function(____, v) return resolve(nil, v) end
|
|
78
|
-
end
|
|
79
|
-
if onRejected then
|
|
80
|
-
local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
|
|
81
|
-
local ____self_rejectedCallbacks_3 = self.rejectedCallbacks
|
|
82
|
-
____self_rejectedCallbacks_3[#____self_rejectedCallbacks_3 + 1] = internalCallback
|
|
83
|
-
if isRejected then
|
|
84
|
-
internalCallback(nil, self.rejectionReason)
|
|
85
|
-
end
|
|
86
|
-
else
|
|
87
|
-
local ____self_rejectedCallbacks_4 = self.rejectedCallbacks
|
|
88
|
-
____self_rejectedCallbacks_4[#____self_rejectedCallbacks_4 + 1] = function(____, err) return reject(nil, err) end
|
|
89
|
-
end
|
|
90
|
-
if isFulfilled then
|
|
91
|
-
resolve(nil, self.value)
|
|
92
|
-
end
|
|
93
|
-
if isRejected then
|
|
94
|
-
reject(nil, self.rejectionReason)
|
|
95
|
-
end
|
|
96
|
-
return promise
|
|
97
|
-
end
|
|
98
|
-
function __TS__Promise.prototype.catch(self, onRejected)
|
|
99
|
-
return self["then"](self, nil, onRejected)
|
|
100
|
-
end
|
|
101
|
-
function __TS__Promise.prototype.finally(self, onFinally)
|
|
102
|
-
if onFinally then
|
|
103
|
-
local ____self_finallyCallbacks_5 = self.finallyCallbacks
|
|
104
|
-
____self_finallyCallbacks_5[#____self_finallyCallbacks_5 + 1] = onFinally
|
|
105
|
-
if self.state ~= 0 then
|
|
106
|
-
onFinally(nil)
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
return self
|
|
110
|
-
end
|
|
111
|
-
function __TS__Promise.prototype.resolve(self, data)
|
|
112
|
-
if __TS__InstanceOf(data, __TS__Promise) then
|
|
113
|
-
data["then"](
|
|
114
|
-
data,
|
|
115
|
-
function(____, v) return self:resolve(v) end,
|
|
116
|
-
function(____, err) return self:reject(err) end
|
|
117
|
-
)
|
|
118
|
-
return
|
|
119
|
-
end
|
|
120
|
-
if self.state == 0 then
|
|
121
|
-
self.state = 1
|
|
122
|
-
self.value = data
|
|
123
|
-
for ____, callback in ipairs(self.fulfilledCallbacks) do
|
|
124
|
-
callback(nil, data)
|
|
125
|
-
end
|
|
126
|
-
for ____, callback in ipairs(self.finallyCallbacks) do
|
|
127
|
-
callback(nil)
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
function __TS__Promise.prototype.reject(self, reason)
|
|
132
|
-
if self.state == 0 then
|
|
133
|
-
self.state = 2
|
|
134
|
-
self.rejectionReason = reason
|
|
135
|
-
for ____, callback in ipairs(self.rejectedCallbacks) do
|
|
136
|
-
callback(nil, reason)
|
|
137
|
-
end
|
|
138
|
-
for ____, callback in ipairs(self.finallyCallbacks) do
|
|
139
|
-
callback(nil)
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
|
|
144
|
-
return function(____, value)
|
|
145
|
-
do
|
|
146
|
-
local function ____catch(e)
|
|
147
|
-
reject(nil, e)
|
|
148
|
-
end
|
|
149
|
-
local ____try, ____hasReturned = pcall(function()
|
|
150
|
-
self:handleCallbackData(
|
|
151
|
-
f(nil, value),
|
|
152
|
-
resolve,
|
|
153
|
-
reject
|
|
154
|
-
)
|
|
155
|
-
end)
|
|
156
|
-
if not ____try then
|
|
157
|
-
____catch(____hasReturned)
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject)
|
|
163
|
-
if isPromiseLike(nil, data) then
|
|
164
|
-
local nextpromise = data
|
|
165
|
-
if nextpromise.state == 1 then
|
|
166
|
-
resolve(nil, nextpromise.value)
|
|
167
|
-
elseif nextpromise.state == 2 then
|
|
168
|
-
reject(nil, nextpromise.rejectionReason)
|
|
169
|
-
else
|
|
170
|
-
data["then"](data, resolve, reject)
|
|
171
|
-
end
|
|
172
|
-
else
|
|
173
|
-
resolve(nil, data)
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
local function __TS__PromiseAll(iterable)
|
|
2
|
-
local results = {}
|
|
3
|
-
local toResolve = {}
|
|
4
|
-
local numToResolve = 0
|
|
5
|
-
local i = 0
|
|
6
|
-
for ____, item in __TS__Iterator(iterable) do
|
|
7
|
-
if __TS__InstanceOf(item, __TS__Promise) then
|
|
8
|
-
if item.state == 1 then
|
|
9
|
-
results[i + 1] = item.value
|
|
10
|
-
elseif item.state == 2 then
|
|
11
|
-
return __TS__Promise.reject(item.rejectionReason)
|
|
12
|
-
else
|
|
13
|
-
numToResolve = numToResolve + 1
|
|
14
|
-
toResolve[i] = item
|
|
15
|
-
end
|
|
16
|
-
else
|
|
17
|
-
results[i + 1] = item
|
|
18
|
-
end
|
|
19
|
-
i = i + 1
|
|
20
|
-
end
|
|
21
|
-
if numToResolve == 0 then
|
|
22
|
-
return __TS__Promise.resolve(results)
|
|
23
|
-
end
|
|
24
|
-
return __TS__New(
|
|
25
|
-
__TS__Promise,
|
|
26
|
-
function(____, resolve, reject)
|
|
27
|
-
for index, promise in pairs(toResolve) do
|
|
28
|
-
promise["then"](
|
|
29
|
-
promise,
|
|
30
|
-
function(____, data)
|
|
31
|
-
results[index + 1] = data
|
|
32
|
-
numToResolve = numToResolve - 1
|
|
33
|
-
if numToResolve == 0 then
|
|
34
|
-
resolve(nil, results)
|
|
35
|
-
end
|
|
36
|
-
end,
|
|
37
|
-
function(____, reason)
|
|
38
|
-
reject(nil, reason)
|
|
39
|
-
end
|
|
40
|
-
)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
)
|
|
44
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
local function __TS__PromiseAllSettled(iterable)
|
|
2
|
-
local results = {}
|
|
3
|
-
local toResolve = {}
|
|
4
|
-
local numToResolve = 0
|
|
5
|
-
local i = 0
|
|
6
|
-
for ____, item in __TS__Iterator(iterable) do
|
|
7
|
-
if __TS__InstanceOf(item, __TS__Promise) then
|
|
8
|
-
if item.state == 1 then
|
|
9
|
-
results[i + 1] = {status = "fulfilled", value = item.value}
|
|
10
|
-
elseif item.state == 2 then
|
|
11
|
-
results[i + 1] = {status = "rejected", reason = item.rejectionReason}
|
|
12
|
-
else
|
|
13
|
-
numToResolve = numToResolve + 1
|
|
14
|
-
toResolve[i] = item
|
|
15
|
-
end
|
|
16
|
-
else
|
|
17
|
-
results[i + 1] = {status = "fulfilled", value = item}
|
|
18
|
-
end
|
|
19
|
-
i = i + 1
|
|
20
|
-
end
|
|
21
|
-
if numToResolve == 0 then
|
|
22
|
-
return __TS__Promise.resolve(results)
|
|
23
|
-
end
|
|
24
|
-
return __TS__New(
|
|
25
|
-
__TS__Promise,
|
|
26
|
-
function(____, resolve)
|
|
27
|
-
for index, promise in pairs(toResolve) do
|
|
28
|
-
promise["then"](
|
|
29
|
-
promise,
|
|
30
|
-
function(____, data)
|
|
31
|
-
results[index + 1] = {status = "fulfilled", value = data}
|
|
32
|
-
numToResolve = numToResolve - 1
|
|
33
|
-
if numToResolve == 0 then
|
|
34
|
-
resolve(nil, results)
|
|
35
|
-
end
|
|
36
|
-
end,
|
|
37
|
-
function(____, reason)
|
|
38
|
-
results[index + 1] = {status = "rejected", reason = reason}
|
|
39
|
-
numToResolve = numToResolve - 1
|
|
40
|
-
if numToResolve == 0 then
|
|
41
|
-
resolve(nil, results)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
)
|
|
48
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
local function __TS__PromiseAny(iterable)
|
|
2
|
-
local rejections = {}
|
|
3
|
-
local pending = {}
|
|
4
|
-
for ____, item in __TS__Iterator(iterable) do
|
|
5
|
-
if __TS__InstanceOf(item, __TS__Promise) then
|
|
6
|
-
if item.state == 1 then
|
|
7
|
-
return __TS__Promise.resolve(item.value)
|
|
8
|
-
elseif item.state == 2 then
|
|
9
|
-
rejections[#rejections + 1] = item.rejectionReason
|
|
10
|
-
else
|
|
11
|
-
pending[#pending + 1] = item
|
|
12
|
-
end
|
|
13
|
-
else
|
|
14
|
-
return __TS__Promise.resolve(item)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
if #pending == 0 then
|
|
18
|
-
return __TS__Promise.reject("No promises to resolve with .any()")
|
|
19
|
-
end
|
|
20
|
-
local numResolved = 0
|
|
21
|
-
return __TS__New(
|
|
22
|
-
__TS__Promise,
|
|
23
|
-
function(____, resolve, reject)
|
|
24
|
-
for ____, promise in ipairs(pending) do
|
|
25
|
-
promise["then"](
|
|
26
|
-
promise,
|
|
27
|
-
function(____, data)
|
|
28
|
-
resolve(nil, data)
|
|
29
|
-
end,
|
|
30
|
-
function(____, reason)
|
|
31
|
-
rejections[#rejections + 1] = reason
|
|
32
|
-
numResolved = numResolved + 1
|
|
33
|
-
if numResolved == #pending then
|
|
34
|
-
reject(nil, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
)
|
|
41
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
local function __TS__PromiseRace(iterable)
|
|
2
|
-
local pending = {}
|
|
3
|
-
for ____, item in __TS__Iterator(iterable) do
|
|
4
|
-
if __TS__InstanceOf(item, __TS__Promise) then
|
|
5
|
-
if item.state == 1 then
|
|
6
|
-
return __TS__Promise.resolve(item.value)
|
|
7
|
-
elseif item.state == 2 then
|
|
8
|
-
return __TS__Promise.reject(item.rejectionReason)
|
|
9
|
-
else
|
|
10
|
-
pending[#pending + 1] = item
|
|
11
|
-
end
|
|
12
|
-
else
|
|
13
|
-
return __TS__Promise.resolve(item)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
return __TS__New(
|
|
17
|
-
__TS__Promise,
|
|
18
|
-
function(____, resolve, reject)
|
|
19
|
-
for ____, promise in ipairs(pending) do
|
|
20
|
-
promise["then"](
|
|
21
|
-
promise,
|
|
22
|
-
function(____, value) return resolve(nil, value) end,
|
|
23
|
-
function(____, reason) return reject(nil, reason) end
|
|
24
|
-
)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
)
|
|
28
|
-
end
|
package/dist/lualib/Set.lua
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
local Set
|
|
2
|
-
do
|
|
3
|
-
Set = __TS__Class()
|
|
4
|
-
Set.name = "Set"
|
|
5
|
-
function Set.prototype.____constructor(self, values)
|
|
6
|
-
self[Symbol.toStringTag] = "Set"
|
|
7
|
-
self.size = 0
|
|
8
|
-
self.nextKey = {}
|
|
9
|
-
self.previousKey = {}
|
|
10
|
-
if values == nil then
|
|
11
|
-
return
|
|
12
|
-
end
|
|
13
|
-
local iterable = values
|
|
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
|
-
self:add(result.value)
|
|
22
|
-
end
|
|
23
|
-
else
|
|
24
|
-
local array = values
|
|
25
|
-
for ____, value in ipairs(array) do
|
|
26
|
-
self:add(value)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
function Set.prototype.add(self, value)
|
|
31
|
-
local isNewValue = not self:has(value)
|
|
32
|
-
if isNewValue then
|
|
33
|
-
self.size = self.size + 1
|
|
34
|
-
end
|
|
35
|
-
if self.firstKey == nil then
|
|
36
|
-
self.firstKey = value
|
|
37
|
-
self.lastKey = value
|
|
38
|
-
elseif isNewValue then
|
|
39
|
-
self.nextKey[self.lastKey] = value
|
|
40
|
-
self.previousKey[value] = self.lastKey
|
|
41
|
-
self.lastKey = value
|
|
42
|
-
end
|
|
43
|
-
return self
|
|
44
|
-
end
|
|
45
|
-
function Set.prototype.clear(self)
|
|
46
|
-
self.nextKey = {}
|
|
47
|
-
self.previousKey = {}
|
|
48
|
-
self.firstKey = nil
|
|
49
|
-
self.lastKey = nil
|
|
50
|
-
self.size = 0
|
|
51
|
-
end
|
|
52
|
-
function Set.prototype.delete(self, value)
|
|
53
|
-
local contains = self:has(value)
|
|
54
|
-
if contains then
|
|
55
|
-
self.size = self.size - 1
|
|
56
|
-
local next = self.nextKey[value]
|
|
57
|
-
local previous = self.previousKey[value]
|
|
58
|
-
if next and previous then
|
|
59
|
-
self.nextKey[previous] = next
|
|
60
|
-
self.previousKey[next] = previous
|
|
61
|
-
elseif next then
|
|
62
|
-
self.firstKey = next
|
|
63
|
-
self.previousKey[next] = nil
|
|
64
|
-
elseif previous then
|
|
65
|
-
self.lastKey = previous
|
|
66
|
-
self.nextKey[previous] = nil
|
|
67
|
-
else
|
|
68
|
-
self.firstKey = nil
|
|
69
|
-
self.lastKey = nil
|
|
70
|
-
end
|
|
71
|
-
self.nextKey[value] = nil
|
|
72
|
-
self.previousKey[value] = nil
|
|
73
|
-
end
|
|
74
|
-
return contains
|
|
75
|
-
end
|
|
76
|
-
function Set.prototype.forEach(self, callback)
|
|
77
|
-
for ____, key in __TS__Iterator(self:keys()) do
|
|
78
|
-
callback(nil, key, key, self)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
function Set.prototype.has(self, value)
|
|
82
|
-
return self.nextKey[value] ~= nil or self.lastKey == value
|
|
83
|
-
end
|
|
84
|
-
Set.prototype[Symbol.iterator] = function(self)
|
|
85
|
-
return self:values()
|
|
86
|
-
end
|
|
87
|
-
function Set.prototype.entries(self)
|
|
88
|
-
local nextKey = self.nextKey
|
|
89
|
-
local key = self.firstKey
|
|
90
|
-
return {
|
|
91
|
-
[Symbol.iterator] = function(self)
|
|
92
|
-
return self
|
|
93
|
-
end,
|
|
94
|
-
next = function(self)
|
|
95
|
-
local result = {done = not key, value = {key, key}}
|
|
96
|
-
key = nextKey[key]
|
|
97
|
-
return result
|
|
98
|
-
end
|
|
99
|
-
}
|
|
100
|
-
end
|
|
101
|
-
function Set.prototype.keys(self)
|
|
102
|
-
local nextKey = self.nextKey
|
|
103
|
-
local key = self.firstKey
|
|
104
|
-
return {
|
|
105
|
-
[Symbol.iterator] = function(self)
|
|
106
|
-
return self
|
|
107
|
-
end,
|
|
108
|
-
next = function(self)
|
|
109
|
-
local result = {done = not key, value = key}
|
|
110
|
-
key = nextKey[key]
|
|
111
|
-
return result
|
|
112
|
-
end
|
|
113
|
-
}
|
|
114
|
-
end
|
|
115
|
-
function Set.prototype.values(self)
|
|
116
|
-
local nextKey = self.nextKey
|
|
117
|
-
local key = self.firstKey
|
|
118
|
-
return {
|
|
119
|
-
[Symbol.iterator] = function(self)
|
|
120
|
-
return self
|
|
121
|
-
end,
|
|
122
|
-
next = function(self)
|
|
123
|
-
local result = {done = not key, value = key}
|
|
124
|
-
key = nextKey[key]
|
|
125
|
-
return result
|
|
126
|
-
end
|
|
127
|
-
}
|
|
128
|
-
end
|
|
129
|
-
Set[Symbol.species] = Set
|
|
130
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
local __TS__SetDescriptor
|
|
2
|
-
do
|
|
3
|
-
local function descriptorIndex(self, key)
|
|
4
|
-
local value = rawget(self, key)
|
|
5
|
-
if value ~= nil then
|
|
6
|
-
return value
|
|
7
|
-
end
|
|
8
|
-
local metatable = getmetatable(self)
|
|
9
|
-
while metatable do
|
|
10
|
-
local rawResult = rawget(metatable, key)
|
|
11
|
-
if rawResult ~= nil then
|
|
12
|
-
return rawResult
|
|
13
|
-
end
|
|
14
|
-
local descriptors = rawget(metatable, "_descriptors")
|
|
15
|
-
if descriptors then
|
|
16
|
-
local descriptor = descriptors[key]
|
|
17
|
-
if descriptor then
|
|
18
|
-
if descriptor.get then
|
|
19
|
-
return descriptor.get(self)
|
|
20
|
-
end
|
|
21
|
-
return descriptor.value
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
metatable = getmetatable(metatable)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
local function descriptorNewIndex(self, key, value)
|
|
28
|
-
local metatable = getmetatable(self)
|
|
29
|
-
while metatable do
|
|
30
|
-
local descriptors = rawget(metatable, "_descriptors")
|
|
31
|
-
if descriptors then
|
|
32
|
-
local descriptor = descriptors[key]
|
|
33
|
-
if descriptor then
|
|
34
|
-
if descriptor.set then
|
|
35
|
-
descriptor.set(self, value)
|
|
36
|
-
else
|
|
37
|
-
if descriptor.writable == false then
|
|
38
|
-
error(
|
|
39
|
-
((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
|
|
40
|
-
0
|
|
41
|
-
)
|
|
42
|
-
end
|
|
43
|
-
descriptor.value = value
|
|
44
|
-
end
|
|
45
|
-
return
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
metatable = getmetatable(metatable)
|
|
49
|
-
end
|
|
50
|
-
rawset(self, key, value)
|
|
51
|
-
end
|
|
52
|
-
function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
53
|
-
if isPrototype == nil then
|
|
54
|
-
isPrototype = false
|
|
55
|
-
end
|
|
56
|
-
local ____isPrototype_0
|
|
57
|
-
if isPrototype then
|
|
58
|
-
____isPrototype_0 = target
|
|
59
|
-
else
|
|
60
|
-
____isPrototype_0 = getmetatable(target)
|
|
61
|
-
end
|
|
62
|
-
local metatable = ____isPrototype_0
|
|
63
|
-
if not metatable then
|
|
64
|
-
metatable = {}
|
|
65
|
-
setmetatable(target, metatable)
|
|
66
|
-
end
|
|
67
|
-
local value = rawget(target, key)
|
|
68
|
-
if value ~= nil then
|
|
69
|
-
rawset(target, key, nil)
|
|
70
|
-
end
|
|
71
|
-
if not rawget(metatable, "_descriptors") then
|
|
72
|
-
metatable._descriptors = {}
|
|
73
|
-
end
|
|
74
|
-
local descriptor = __TS__CloneDescriptor(desc)
|
|
75
|
-
metatable._descriptors[key] = descriptor
|
|
76
|
-
metatable.__index = descriptorIndex
|
|
77
|
-
metatable.__newindex = descriptorNewIndex
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
local function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
2
|
-
_G.__TS__sourcemap = _G.__TS__sourcemap or ({})
|
|
3
|
-
_G.__TS__sourcemap[fileName] = sourceMap
|
|
4
|
-
if _G.__TS__originalTraceback == nil then
|
|
5
|
-
local originalTraceback = debug.traceback
|
|
6
|
-
_G.__TS__originalTraceback = originalTraceback
|
|
7
|
-
debug.traceback = function(thread, message, level)
|
|
8
|
-
local trace
|
|
9
|
-
if thread == nil and message == nil and level == nil then
|
|
10
|
-
trace = originalTraceback()
|
|
11
|
-
else
|
|
12
|
-
trace = originalTraceback(thread, message, level)
|
|
13
|
-
end
|
|
14
|
-
if type(trace) ~= "string" then
|
|
15
|
-
return trace
|
|
16
|
-
end
|
|
17
|
-
local function replacer(____, file, srcFile, line)
|
|
18
|
-
local fileSourceMap = _G.__TS__sourcemap[file]
|
|
19
|
-
if fileSourceMap and fileSourceMap[line] then
|
|
20
|
-
local data = fileSourceMap[line]
|
|
21
|
-
if type(data) == "number" then
|
|
22
|
-
return (srcFile .. ":") .. tostring(data)
|
|
23
|
-
end
|
|
24
|
-
return (tostring(data.file) .. ":") .. tostring(data.line)
|
|
25
|
-
end
|
|
26
|
-
return (file .. ":") .. line
|
|
27
|
-
end
|
|
28
|
-
local result = string.gsub(
|
|
29
|
-
trace,
|
|
30
|
-
"(%S+)%.lua:(%d+)",
|
|
31
|
-
function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
|
|
32
|
-
)
|
|
33
|
-
local function stringReplacer(____, file, line)
|
|
34
|
-
local fileSourceMap = _G.__TS__sourcemap[file]
|
|
35
|
-
if fileSourceMap and fileSourceMap[line] then
|
|
36
|
-
local chunkName = string.match(file, "%[string \"([^\"]+)\"%]")
|
|
37
|
-
local sourceName = string.gsub(chunkName, ".lua$", ".ts")
|
|
38
|
-
local data = fileSourceMap[line]
|
|
39
|
-
if type(data) == "number" then
|
|
40
|
-
return (sourceName .. ":") .. tostring(data)
|
|
41
|
-
end
|
|
42
|
-
return (tostring(data.file) .. ":") .. tostring(data.line)
|
|
43
|
-
end
|
|
44
|
-
return (file .. ":") .. line
|
|
45
|
-
end
|
|
46
|
-
result = string.gsub(
|
|
47
|
-
result,
|
|
48
|
-
"(%[string \"[^\"]+\"%]):(%d+)",
|
|
49
|
-
function(file, line) return stringReplacer(nil, file, line) end
|
|
50
|
-
)
|
|
51
|
-
return result
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|