typescript-to-lua 1.1.1 → 1.3.2
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 +28 -0
- package/dist/LuaAST.d.ts +1 -0
- package/dist/LuaAST.js +10 -2
- package/dist/LuaLib.d.ts +4 -3
- package/dist/LuaLib.js +6 -5
- package/dist/LuaPrinter.d.ts +11 -4
- package/dist/LuaPrinter.js +58 -15
- 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 +21 -13
- package/dist/lualib/CloneDescriptor.lua +7 -7
- 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/MathSign.lua +8 -0
- 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 +28 -24
- 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 +804 -735
- package/dist/transformation/builtins/array.js +1 -2
- package/dist/transformation/builtins/function.js +6 -4
- package/dist/transformation/builtins/index.d.ts +1 -1
- package/dist/transformation/builtins/index.js +41 -6
- package/dist/transformation/builtins/math.js +7 -1
- 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 +9 -6
- package/dist/transformation/utils/diagnostics.js +4 -3
- package/dist/transformation/utils/language-extensions.d.ts +2 -0
- package/dist/transformation/utils/language-extensions.js +7 -1
- package/dist/transformation/utils/lua-ast.d.ts +0 -1
- package/dist/transformation/utils/lua-ast.js +14 -23
- package/dist/transformation/utils/preceding-statements.d.ts +3 -0
- package/dist/transformation/utils/preceding-statements.js +11 -0
- package/dist/transformation/utils/safe-names.d.ts +4 -2
- package/dist/transformation/utils/safe-names.js +11 -5
- package/dist/transformation/utils/scope.d.ts +3 -1
- package/dist/transformation/utils/scope.js +9 -1
- package/dist/transformation/utils/typescript/index.d.ts +1 -0
- package/dist/transformation/utils/typescript/index.js +16 -1
- package/dist/transformation/utils/typescript/types.d.ts +3 -1
- package/dist/transformation/utils/typescript/types.js +40 -13
- 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 +65 -23
- package/dist/transformation/visitors/call.d.ts +3 -2
- package/dist/transformation/visitors/call.js +95 -141
- package/dist/transformation/visitors/class/index.js +5 -8
- package/dist/transformation/visitors/class/members/constructor.js +3 -1
- package/dist/transformation/visitors/class/new.js +4 -6
- package/dist/transformation/visitors/conditional.js +30 -37
- package/dist/transformation/visitors/delete.js +4 -0
- package/dist/transformation/visitors/errors.js +11 -9
- package/dist/transformation/visitors/expression-list.d.ts +7 -0
- package/dist/transformation/visitors/expression-list.js +120 -0
- package/dist/transformation/visitors/expression-statement.d.ts +3 -1
- package/dist/transformation/visitors/expression-statement.js +21 -19
- package/dist/transformation/visitors/function.d.ts +2 -0
- package/dist/transformation/visitors/function.js +63 -13
- package/dist/transformation/visitors/identifier.js +5 -0
- package/dist/transformation/visitors/language-extensions/index.d.ts +4 -0
- package/dist/transformation/visitors/language-extensions/index.js +17 -0
- package/dist/transformation/visitors/language-extensions/operators.d.ts +1 -1
- package/dist/transformation/visitors/language-extensions/operators.js +7 -2
- package/dist/transformation/visitors/language-extensions/pairsIterable.d.ts +5 -0
- package/dist/transformation/visitors/language-extensions/pairsIterable.js +53 -0
- package/dist/transformation/visitors/language-extensions/table.d.ts +1 -8
- package/dist/transformation/visitors/language-extensions/table.js +55 -53
- package/dist/transformation/visitors/literal.js +69 -16
- package/dist/transformation/visitors/loops/do-while.js +34 -8
- package/dist/transformation/visitors/loops/for-of.js +4 -0
- 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 +19 -3
- package/dist/transformation/visitors/modules/export.js +1 -1
- package/dist/transformation/visitors/namespace.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/spread.js +14 -7
- 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 +37 -8
- package/dist/transformation/visitors/void.d.ts +1 -4
- package/dist/transformation/visitors/void.js +7 -12
- package/dist/transpilation/transformers.js +4 -1
- package/dist/transpilation/utils.js +2 -1
- package/language-extensions/index.d.ts +11 -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/Set.lua
CHANGED
|
@@ -1,132 +1,128 @@
|
|
|
1
|
-
Set = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
end
|
|
12
|
-
local iterable = values
|
|
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
|
-
self:add(result.value)
|
|
21
|
-
end
|
|
22
|
-
else
|
|
23
|
-
local array = values
|
|
24
|
-
for ____, value in ipairs(array) do
|
|
25
|
-
self:add(value)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
1
|
+
Set = __TS__Class()
|
|
2
|
+
Set.name = "Set"
|
|
3
|
+
function Set.prototype.____constructor(self, values)
|
|
4
|
+
self[Symbol.toStringTag] = "Set"
|
|
5
|
+
self.size = 0
|
|
6
|
+
self.nextKey = {}
|
|
7
|
+
self.previousKey = {}
|
|
8
|
+
if values == nil then
|
|
9
|
+
return
|
|
28
10
|
end
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
self.lastKey = value
|
|
37
|
-
elseif isNewValue then
|
|
38
|
-
self.nextKey[self.lastKey] = value
|
|
39
|
-
self.previousKey[value] = self.lastKey
|
|
40
|
-
self.lastKey = value
|
|
41
|
-
end
|
|
42
|
-
return self
|
|
43
|
-
end
|
|
44
|
-
function Set.prototype.clear(self)
|
|
45
|
-
self.nextKey = {}
|
|
46
|
-
self.previousKey = {}
|
|
47
|
-
self.firstKey = nil
|
|
48
|
-
self.lastKey = nil
|
|
49
|
-
self.size = 0
|
|
50
|
-
end
|
|
51
|
-
function Set.prototype.delete(self, value)
|
|
52
|
-
local contains = self:has(value)
|
|
53
|
-
if contains then
|
|
54
|
-
self.size = self.size - 1
|
|
55
|
-
local next = self.nextKey[value]
|
|
56
|
-
local previous = self.previousKey[value]
|
|
57
|
-
if next and previous then
|
|
58
|
-
self.nextKey[previous] = next
|
|
59
|
-
self.previousKey[next] = previous
|
|
60
|
-
elseif next then
|
|
61
|
-
self.firstKey = next
|
|
62
|
-
self.previousKey[next] = nil
|
|
63
|
-
elseif previous then
|
|
64
|
-
self.lastKey = previous
|
|
65
|
-
self.nextKey[previous] = nil
|
|
66
|
-
else
|
|
67
|
-
self.firstKey = nil
|
|
68
|
-
self.lastKey = nil
|
|
11
|
+
local iterable = values
|
|
12
|
+
if iterable[Symbol.iterator] then
|
|
13
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
14
|
+
while true do
|
|
15
|
+
local result = iterator:next()
|
|
16
|
+
if result.done then
|
|
17
|
+
break
|
|
69
18
|
end
|
|
70
|
-
self.
|
|
71
|
-
self.previousKey[value] = nil
|
|
19
|
+
self:add(result.value)
|
|
72
20
|
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
self:keys()
|
|
78
|
-
) do
|
|
79
|
-
callback(_G, key, key, self)
|
|
21
|
+
else
|
|
22
|
+
local array = values
|
|
23
|
+
for ____, value in ipairs(array) do
|
|
24
|
+
self:add(value)
|
|
80
25
|
end
|
|
81
26
|
end
|
|
82
|
-
|
|
83
|
-
|
|
27
|
+
end
|
|
28
|
+
function Set.prototype.add(self, value)
|
|
29
|
+
local isNewValue = not self:has(value)
|
|
30
|
+
if isNewValue then
|
|
31
|
+
self.size = self.size + 1
|
|
84
32
|
end
|
|
85
|
-
|
|
86
|
-
|
|
33
|
+
if self.firstKey == nil then
|
|
34
|
+
self.firstKey = value
|
|
35
|
+
self.lastKey = value
|
|
36
|
+
elseif isNewValue then
|
|
37
|
+
self.nextKey[self.lastKey] = value
|
|
38
|
+
self.previousKey[value] = self.lastKey
|
|
39
|
+
self.lastKey = value
|
|
87
40
|
end
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
41
|
+
return self
|
|
42
|
+
end
|
|
43
|
+
function Set.prototype.clear(self)
|
|
44
|
+
self.nextKey = {}
|
|
45
|
+
self.previousKey = {}
|
|
46
|
+
self.firstKey = nil
|
|
47
|
+
self.lastKey = nil
|
|
48
|
+
self.size = 0
|
|
49
|
+
end
|
|
50
|
+
function Set.prototype.delete(self, value)
|
|
51
|
+
local contains = self:has(value)
|
|
52
|
+
if contains then
|
|
53
|
+
self.size = self.size - 1
|
|
54
|
+
local next = self.nextKey[value]
|
|
55
|
+
local previous = self.previousKey[value]
|
|
56
|
+
if next and previous then
|
|
57
|
+
self.nextKey[previous] = next
|
|
58
|
+
self.previousKey[next] = previous
|
|
59
|
+
elseif next then
|
|
60
|
+
self.firstKey = next
|
|
61
|
+
self.previousKey[next] = nil
|
|
62
|
+
elseif previous then
|
|
63
|
+
self.lastKey = previous
|
|
64
|
+
self.nextKey[previous] = nil
|
|
65
|
+
else
|
|
66
|
+
self.firstKey = nil
|
|
67
|
+
self.lastKey = nil
|
|
68
|
+
end
|
|
69
|
+
self.nextKey[value] = nil
|
|
70
|
+
self.previousKey[value] = nil
|
|
101
71
|
end
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return self
|
|
108
|
-
end,
|
|
109
|
-
next = function(self)
|
|
110
|
-
local result = {done = not key, value = key}
|
|
111
|
-
key = nextKey[key]
|
|
112
|
-
return result
|
|
113
|
-
end
|
|
114
|
-
}
|
|
72
|
+
return contains
|
|
73
|
+
end
|
|
74
|
+
function Set.prototype.forEach(self, callback)
|
|
75
|
+
for ____, key in __TS__Iterator(self:keys()) do
|
|
76
|
+
callback(_G, key, key, self)
|
|
115
77
|
end
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
78
|
+
end
|
|
79
|
+
function Set.prototype.has(self, value)
|
|
80
|
+
return self.nextKey[value] ~= nil or self.lastKey == value
|
|
81
|
+
end
|
|
82
|
+
Set.prototype[Symbol.iterator] = function(self)
|
|
83
|
+
return self:values()
|
|
84
|
+
end
|
|
85
|
+
function Set.prototype.entries(self)
|
|
86
|
+
local nextKey = self.nextKey
|
|
87
|
+
local key = self.firstKey
|
|
88
|
+
return {
|
|
89
|
+
[Symbol.iterator] = function(self)
|
|
90
|
+
return self
|
|
91
|
+
end,
|
|
92
|
+
next = function(self)
|
|
93
|
+
local result = {done = not key, value = {key, key}}
|
|
94
|
+
key = nextKey[key]
|
|
95
|
+
return result
|
|
96
|
+
end
|
|
97
|
+
}
|
|
98
|
+
end
|
|
99
|
+
function Set.prototype.keys(self)
|
|
100
|
+
local nextKey = self.nextKey
|
|
101
|
+
local key = self.firstKey
|
|
102
|
+
return {
|
|
103
|
+
[Symbol.iterator] = function(self)
|
|
104
|
+
return self
|
|
105
|
+
end,
|
|
106
|
+
next = function(self)
|
|
107
|
+
local result = {done = not key, value = key}
|
|
108
|
+
key = nextKey[key]
|
|
109
|
+
return result
|
|
110
|
+
end
|
|
111
|
+
}
|
|
112
|
+
end
|
|
113
|
+
function Set.prototype.values(self)
|
|
114
|
+
local nextKey = self.nextKey
|
|
115
|
+
local key = self.firstKey
|
|
116
|
+
return {
|
|
117
|
+
[Symbol.iterator] = function(self)
|
|
118
|
+
return self
|
|
119
|
+
end,
|
|
120
|
+
next = function(self)
|
|
121
|
+
local result = {done = not key, value = key}
|
|
122
|
+
key = nextKey[key]
|
|
123
|
+
return result
|
|
124
|
+
end
|
|
125
|
+
}
|
|
126
|
+
end
|
|
127
|
+
Set[Symbol.species] = Set
|
|
128
|
+
Set = Set
|
|
@@ -51,7 +51,13 @@ function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
|
51
51
|
if isPrototype == nil then
|
|
52
52
|
isPrototype = false
|
|
53
53
|
end
|
|
54
|
-
local
|
|
54
|
+
local ____isPrototype_0
|
|
55
|
+
if isPrototype then
|
|
56
|
+
____isPrototype_0 = target
|
|
57
|
+
else
|
|
58
|
+
____isPrototype_0 = getmetatable(target)
|
|
59
|
+
end
|
|
60
|
+
local metatable = ____isPrototype_0
|
|
55
61
|
if not metatable then
|
|
56
62
|
metatable = {}
|
|
57
63
|
setmetatable(target, metatable)
|
|
@@ -5,7 +5,7 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
5
5
|
_G.__TS__originalTraceback = debug.traceback
|
|
6
6
|
debug.traceback = function(thread, message, level)
|
|
7
7
|
local trace
|
|
8
|
-
if
|
|
8
|
+
if thread == nil and message == nil and level == nil then
|
|
9
9
|
trace = _G.__TS__originalTraceback()
|
|
10
10
|
else
|
|
11
11
|
trace = _G.__TS__originalTraceback(thread, message, level)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function __TS__SparseArrayPush(sparseArray, ...)
|
|
2
|
+
local args = {...}
|
|
3
|
+
local argsLen = select("#", ...)
|
|
4
|
+
local listLen = sparseArray.sparseLength
|
|
5
|
+
for i = 1, argsLen do
|
|
6
|
+
sparseArray[listLen + i] = args[i]
|
|
7
|
+
end
|
|
8
|
+
sparseArray.sparseLength = listLen + argsLen
|
|
9
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function __TS__StringEndsWith(self, searchString, endPosition)
|
|
2
|
-
if
|
|
2
|
+
if endPosition == nil or endPosition > #self then
|
|
3
3
|
endPosition = #self
|
|
4
4
|
end
|
|
5
|
-
return string.sub(self,
|
|
5
|
+
return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
|
|
6
6
|
end
|
|
@@ -5,10 +5,10 @@ function __TS__StringPadEnd(self, maxLength, fillString)
|
|
|
5
5
|
if maxLength ~= maxLength then
|
|
6
6
|
maxLength = 0
|
|
7
7
|
end
|
|
8
|
-
if
|
|
8
|
+
if maxLength == -math.huge or maxLength == math.huge then
|
|
9
9
|
error("Invalid string length", 0)
|
|
10
10
|
end
|
|
11
|
-
if
|
|
11
|
+
if #self >= maxLength or #fillString == 0 then
|
|
12
12
|
return self
|
|
13
13
|
end
|
|
14
14
|
maxLength = maxLength - #self
|
|
@@ -5,10 +5,10 @@ function __TS__StringPadStart(self, maxLength, fillString)
|
|
|
5
5
|
if maxLength ~= maxLength then
|
|
6
6
|
maxLength = 0
|
|
7
7
|
end
|
|
8
|
-
if
|
|
8
|
+
if maxLength == -math.huge or maxLength == math.huge then
|
|
9
9
|
error("Invalid string length", 0)
|
|
10
10
|
end
|
|
11
|
-
if
|
|
11
|
+
if #self >= maxLength or #fillString == 0 then
|
|
12
12
|
return self
|
|
13
13
|
end
|
|
14
14
|
maxLength = maxLength - #self
|
|
@@ -5,7 +5,13 @@ function __TS__StringReplace(source, searchValue, replaceValue)
|
|
|
5
5
|
end
|
|
6
6
|
local sub = string.sub
|
|
7
7
|
local before = sub(source, 1, startPos - 1)
|
|
8
|
-
local
|
|
8
|
+
local ____temp_0
|
|
9
|
+
if type(replaceValue) == "string" then
|
|
10
|
+
____temp_0 = replaceValue
|
|
11
|
+
else
|
|
12
|
+
____temp_0 = replaceValue(_G, searchValue, startPos - 1, source)
|
|
13
|
+
end
|
|
14
|
+
local replacement = ____temp_0
|
|
9
15
|
local after = sub(source, endPos + 1)
|
|
10
16
|
return (before .. replacement) .. after
|
|
11
17
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function __TS__StringSlice(self, start, ____end)
|
|
2
|
-
if
|
|
2
|
+
if start == nil or start ~= start then
|
|
3
3
|
start = 0
|
|
4
4
|
end
|
|
5
5
|
if ____end ~= ____end then
|
|
@@ -8,7 +8,7 @@ function __TS__StringSlice(self, start, ____end)
|
|
|
8
8
|
if start >= 0 then
|
|
9
9
|
start = start + 1
|
|
10
10
|
end
|
|
11
|
-
if
|
|
11
|
+
if ____end ~= nil and ____end < 0 then
|
|
12
12
|
____end = ____end - 1
|
|
13
13
|
end
|
|
14
14
|
return string.sub(self, start, ____end)
|
|
@@ -8,8 +8,8 @@ function __TS__StringSplit(source, separator, limit)
|
|
|
8
8
|
local out = {}
|
|
9
9
|
local index = 0
|
|
10
10
|
local count = 0
|
|
11
|
-
if
|
|
12
|
-
while
|
|
11
|
+
if separator == nil or separator == "" then
|
|
12
|
+
while index < #source - 1 and count < limit do
|
|
13
13
|
out[count + 1] = __TS__StringAccess(source, index)
|
|
14
14
|
count = count + 1
|
|
15
15
|
index = index + 1
|
|
@@ -17,7 +17,7 @@ function __TS__StringSplit(source, separator, limit)
|
|
|
17
17
|
else
|
|
18
18
|
local separatorLength = #separator
|
|
19
19
|
local nextIndex = (string.find(source, separator, nil, true) or 0) - 1
|
|
20
|
-
while
|
|
20
|
+
while nextIndex >= 0 and count < limit do
|
|
21
21
|
out[count + 1] = __TS__StringSubstring(source, index, nextIndex)
|
|
22
22
|
count = count + 1
|
|
23
23
|
index = nextIndex + separatorLength
|
|
@@ -2,7 +2,7 @@ function __TS__StringSubstring(self, start, ____end)
|
|
|
2
2
|
if ____end ~= ____end then
|
|
3
3
|
____end = 0
|
|
4
4
|
end
|
|
5
|
-
if
|
|
5
|
+
if ____end ~= nil and start > ____end then
|
|
6
6
|
start, ____end = ____end, start
|
|
7
7
|
end
|
|
8
8
|
if start >= 0 then
|
|
@@ -10,7 +10,7 @@ function __TS__StringSubstring(self, start, ____end)
|
|
|
10
10
|
else
|
|
11
11
|
start = 1
|
|
12
12
|
end
|
|
13
|
-
if
|
|
13
|
+
if ____end ~= nil and ____end < 0 then
|
|
14
14
|
____end = 0
|
|
15
15
|
end
|
|
16
16
|
return string.sub(self, start, ____end)
|
package/dist/lualib/Symbol.lua
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
____symbolMetatable = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
end
|
|
5
|
-
}
|
|
1
|
+
____symbolMetatable = {__tostring = function(self)
|
|
2
|
+
return ("Symbol(" .. (self.description or "")) .. ")"
|
|
3
|
+
end}
|
|
6
4
|
function __TS__Symbol(description)
|
|
7
5
|
return setmetatable({description = description}, ____symbolMetatable)
|
|
8
6
|
end
|
package/dist/lualib/WeakMap.lua
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
|
-
WeakMap = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
break
|
|
18
|
-
end
|
|
19
|
-
local value = result.value
|
|
20
|
-
self.items[value[1]] = value[2]
|
|
21
|
-
end
|
|
22
|
-
else
|
|
23
|
-
for ____, kvp in ipairs(entries) do
|
|
24
|
-
self.items[kvp[1]] = kvp[2]
|
|
1
|
+
WeakMap = __TS__Class()
|
|
2
|
+
WeakMap.name = "WeakMap"
|
|
3
|
+
function WeakMap.prototype.____constructor(self, entries)
|
|
4
|
+
self[Symbol.toStringTag] = "WeakMap"
|
|
5
|
+
self.items = {}
|
|
6
|
+
setmetatable(self.items, {__mode = "k"})
|
|
7
|
+
if entries == nil then
|
|
8
|
+
return
|
|
9
|
+
end
|
|
10
|
+
local iterable = entries
|
|
11
|
+
if iterable[Symbol.iterator] then
|
|
12
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
13
|
+
while true do
|
|
14
|
+
local result = iterator:next()
|
|
15
|
+
if result.done then
|
|
16
|
+
break
|
|
25
17
|
end
|
|
18
|
+
local value = result.value
|
|
19
|
+
self.items[value[1]] = value[2]
|
|
20
|
+
end
|
|
21
|
+
else
|
|
22
|
+
for ____, kvp in ipairs(entries) do
|
|
23
|
+
self.items[kvp[1]] = kvp[2]
|
|
26
24
|
end
|
|
27
25
|
end
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
end
|
|
27
|
+
function WeakMap.prototype.delete(self, key)
|
|
28
|
+
local contains = self:has(key)
|
|
29
|
+
self.items[key] = nil
|
|
30
|
+
return contains
|
|
31
|
+
end
|
|
32
|
+
function WeakMap.prototype.get(self, key)
|
|
33
|
+
return self.items[key]
|
|
34
|
+
end
|
|
35
|
+
function WeakMap.prototype.has(self, key)
|
|
36
|
+
return self.items[key] ~= nil
|
|
37
|
+
end
|
|
38
|
+
function WeakMap.prototype.set(self, key, value)
|
|
39
|
+
self.items[key] = value
|
|
40
|
+
return self
|
|
41
|
+
end
|
|
42
|
+
WeakMap[Symbol.species] = WeakMap
|
|
43
|
+
WeakMap = WeakMap
|
package/dist/lualib/WeakSet.lua
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
WeakSet = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
break
|
|
18
|
-
end
|
|
19
|
-
self.items[result.value] = true
|
|
20
|
-
end
|
|
21
|
-
else
|
|
22
|
-
for ____, value in ipairs(values) do
|
|
23
|
-
self.items[value] = true
|
|
1
|
+
WeakSet = __TS__Class()
|
|
2
|
+
WeakSet.name = "WeakSet"
|
|
3
|
+
function WeakSet.prototype.____constructor(self, values)
|
|
4
|
+
self[Symbol.toStringTag] = "WeakSet"
|
|
5
|
+
self.items = {}
|
|
6
|
+
setmetatable(self.items, {__mode = "k"})
|
|
7
|
+
if values == nil then
|
|
8
|
+
return
|
|
9
|
+
end
|
|
10
|
+
local iterable = values
|
|
11
|
+
if iterable[Symbol.iterator] then
|
|
12
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
13
|
+
while true do
|
|
14
|
+
local result = iterator:next()
|
|
15
|
+
if result.done then
|
|
16
|
+
break
|
|
24
17
|
end
|
|
18
|
+
self.items[result.value] = true
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
for ____, value in ipairs(values) do
|
|
22
|
+
self.items[value] = true
|
|
25
23
|
end
|
|
26
24
|
end
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
end
|
|
26
|
+
function WeakSet.prototype.add(self, value)
|
|
27
|
+
self.items[value] = true
|
|
28
|
+
return self
|
|
29
|
+
end
|
|
30
|
+
function WeakSet.prototype.delete(self, value)
|
|
31
|
+
local contains = self:has(value)
|
|
32
|
+
self.items[value] = nil
|
|
33
|
+
return contains
|
|
34
|
+
end
|
|
35
|
+
function WeakSet.prototype.has(self, value)
|
|
36
|
+
return self.items[value] == true
|
|
37
|
+
end
|
|
38
|
+
WeakSet[Symbol.species] = WeakSet
|
|
39
|
+
WeakSet = WeakSet
|