typescript-to-lua 1.3.2 → 1.4.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/CompilerOptions.d.ts +1 -1
- package/dist/CompilerOptions.js +0 -1
- package/dist/LuaLib.d.ts +12 -1
- package/dist/LuaLib.js +61 -65
- package/dist/LuaPrinter.js +9 -8
- package/dist/cli/parse.js +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/dist/lualib/ArrayConcat.lua +1 -1
- package/dist/lualib/ArrayEntries.lua +1 -1
- package/dist/lualib/ArrayEvery.lua +2 -2
- package/dist/lualib/ArrayFilter.lua +2 -2
- package/dist/lualib/ArrayFind.lua +2 -2
- package/dist/lualib/ArrayFindIndex.lua +2 -2
- package/dist/lualib/ArrayFlat.lua +1 -1
- package/dist/lualib/ArrayFlatMap.lua +2 -2
- package/dist/lualib/ArrayForEach.lua +2 -2
- package/dist/lualib/ArrayIncludes.lua +1 -1
- package/dist/lualib/ArrayIndexOf.lua +1 -1
- package/dist/lualib/ArrayIsArray.lua +1 -1
- package/dist/lualib/ArrayJoin.lua +1 -1
- package/dist/lualib/ArrayMap.lua +2 -2
- package/dist/lualib/ArrayPush.lua +1 -1
- package/dist/lualib/ArrayReduce.lua +2 -2
- package/dist/lualib/ArrayReduceRight.lua +2 -2
- package/dist/lualib/ArrayReverse.lua +1 -1
- package/dist/lualib/ArraySetLength.lua +1 -1
- package/dist/lualib/ArrayShift.lua +1 -1
- package/dist/lualib/ArraySlice.lua +1 -1
- package/dist/lualib/ArraySome.lua +2 -2
- package/dist/lualib/ArraySort.lua +2 -2
- package/dist/lualib/ArraySplice.lua +1 -1
- package/dist/lualib/ArrayToObject.lua +1 -1
- package/dist/lualib/ArrayUnshift.lua +1 -1
- package/dist/lualib/Await.lua +13 -13
- package/dist/lualib/Class.lua +1 -1
- package/dist/lualib/ClassExtends.lua +1 -1
- package/dist/lualib/CloneDescriptor.lua +1 -1
- package/dist/lualib/Decorate.lua +5 -5
- package/dist/lualib/DecorateParam.lua +2 -2
- package/dist/lualib/DelegatedYield.lua +1 -1
- package/dist/lualib/Delete.lua +1 -1
- package/dist/lualib/Error.lua +68 -69
- package/dist/lualib/FunctionBind.lua +1 -1
- package/dist/lualib/Generator.lua +26 -23
- package/dist/lualib/InstanceOf.lua +1 -1
- package/dist/lualib/InstanceOfObject.lua +1 -1
- package/dist/lualib/Iterator.lua +35 -32
- package/dist/lualib/Map.lua +131 -129
- package/dist/lualib/MathAtan2.lua +1 -1
- package/dist/lualib/MathSign.lua +1 -1
- package/dist/lualib/New.lua +1 -1
- package/dist/lualib/Number.lua +1 -1
- package/dist/lualib/NumberIsFinite.lua +1 -1
- package/dist/lualib/NumberIsNaN.lua +1 -1
- package/dist/lualib/NumberToString.lua +42 -39
- package/dist/lualib/ObjectAssign.lua +1 -1
- package/dist/lualib/ObjectDefineProperty.lua +1 -1
- package/dist/lualib/ObjectEntries.lua +1 -1
- package/dist/lualib/ObjectFromEntries.lua +1 -1
- package/dist/lualib/ObjectGetOwnPropertyDescriptor.lua +1 -1
- package/dist/lualib/ObjectGetOwnPropertyDescriptors.lua +1 -1
- package/dist/lualib/ObjectKeys.lua +1 -1
- package/dist/lualib/ObjectRest.lua +1 -1
- package/dist/lualib/ObjectValues.lua +1 -1
- package/dist/lualib/ParseFloat.lua +1 -1
- package/dist/lualib/ParseInt.lua +39 -36
- package/dist/lualib/Promise.lua +148 -152
- package/dist/lualib/PromiseAll.lua +5 -5
- package/dist/lualib/PromiseAllSettled.lua +5 -5
- package/dist/lualib/PromiseAny.lua +5 -5
- package/dist/lualib/PromiseRace.lua +5 -5
- package/dist/lualib/Set.lua +120 -118
- package/dist/lualib/SetDescriptor.lua +67 -64
- package/dist/lualib/SourceMapTraceBack.lua +7 -6
- package/dist/lualib/SparseArrayNew.lua +1 -1
- package/dist/lualib/SparseArrayPush.lua +1 -1
- package/dist/lualib/SparseArraySpread.lua +1 -1
- package/dist/lualib/Spread.lua +1 -1
- package/dist/lualib/StringAccess.lua +1 -1
- package/dist/lualib/StringCharAt.lua +1 -1
- package/dist/lualib/StringCharCodeAt.lua +1 -1
- package/dist/lualib/StringConcat.lua +1 -1
- package/dist/lualib/StringEndsWith.lua +1 -1
- package/dist/lualib/StringIncludes.lua +1 -1
- package/dist/lualib/StringPadEnd.lua +1 -1
- package/dist/lualib/StringPadStart.lua +1 -1
- package/dist/lualib/StringReplace.lua +2 -2
- package/dist/lualib/StringReplaceAll.lua +4 -4
- package/dist/lualib/StringSlice.lua +1 -1
- package/dist/lualib/StringSplit.lua +1 -1
- package/dist/lualib/StringStartsWith.lua +1 -1
- package/dist/lualib/StringSubstr.lua +1 -1
- package/dist/lualib/StringSubstring.lua +1 -1
- package/dist/lualib/StringTrim.lua +1 -1
- package/dist/lualib/StringTrimEnd.lua +1 -1
- package/dist/lualib/StringTrimStart.lua +1 -1
- package/dist/lualib/Symbol.lua +14 -11
- package/dist/lualib/SymbolRegistry.lua +13 -10
- package/dist/lualib/TypeOf.lua +1 -1
- package/dist/lualib/Unpack.lua +1 -1
- package/dist/lualib/WeakMap.lua +41 -39
- package/dist/lualib/WeakSet.lua +37 -35
- package/dist/lualib/lualib_bundle.lua +1054 -924
- package/dist/lualib/lualib_module_info.json +619 -0
- package/dist/lualib-build/plugin.d.ts +23 -0
- package/dist/lualib-build/plugin.js +138 -0
- package/dist/lualib-build/util.d.ts +19 -0
- package/dist/lualib-build/util.js +43 -0
- package/dist/transformation/builtins/function.js +2 -1
- package/dist/transformation/builtins/index.d.ts +1 -0
- package/dist/transformation/builtins/index.js +63 -16
- package/dist/transformation/context/index.js +5 -1
- package/dist/transformation/utils/diagnostics.d.ts +3 -0
- package/dist/transformation/utils/diagnostics.js +2 -1
- package/dist/transformation/utils/typescript/index.js +5 -1
- package/dist/transformation/utils/typescript/types.d.ts +2 -0
- package/dist/transformation/utils/typescript/types.js +10 -1
- package/dist/transformation/visitors/class/index.js +1 -5
- package/dist/transformation/visitors/class/members/constructor.js +1 -3
- package/dist/transformation/visitors/class/members/fields.js +12 -8
- package/dist/transformation/visitors/class/new.d.ts +1 -2
- package/dist/transformation/visitors/class/new.js +1 -40
- package/dist/transformation/visitors/conditional.js +15 -14
- package/dist/transformation/visitors/identifier.js +5 -0
- package/dist/transformation/visitors/literal.js +22 -0
- package/dist/transformation/visitors/modules/import.js +4 -14
- package/dist/transpilation/bundle.js +1 -1
- package/dist/transpilation/index.js +5 -1
- package/dist/transpilation/plugins.d.ts +11 -0
- package/dist/transpilation/resolve.js +2 -2
- package/dist/transpilation/transpile.js +13 -0
- package/dist/transpilation/transpiler.js +6 -2
- package/package.json +12 -11
- package/CHANGELOG.md +0 -703
package/dist/lualib/Decorate.lua
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function __TS__Decorate(decorators, target, key, desc)
|
|
1
|
+
local function __TS__Decorate(decorators, target, key, desc)
|
|
2
2
|
local result = target
|
|
3
3
|
do
|
|
4
4
|
local i = #decorators
|
|
@@ -7,11 +7,11 @@ function __TS__Decorate(decorators, target, key, desc)
|
|
|
7
7
|
if decorator then
|
|
8
8
|
local oldResult = result
|
|
9
9
|
if key == nil then
|
|
10
|
-
result = decorator(
|
|
10
|
+
result = decorator(nil, result)
|
|
11
11
|
elseif desc == true then
|
|
12
12
|
local value = rawget(target, key)
|
|
13
13
|
local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
|
|
14
|
-
local desc = decorator(
|
|
14
|
+
local desc = decorator(nil, target, key, descriptor) or descriptor
|
|
15
15
|
local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
|
|
16
16
|
if isSimpleValue then
|
|
17
17
|
rawset(target, key, desc.value)
|
|
@@ -23,9 +23,9 @@ function __TS__Decorate(decorators, target, key, desc)
|
|
|
23
23
|
)
|
|
24
24
|
end
|
|
25
25
|
elseif desc == false then
|
|
26
|
-
result = decorator(
|
|
26
|
+
result = decorator(nil, target, key, desc)
|
|
27
27
|
else
|
|
28
|
-
result = decorator(
|
|
28
|
+
result = decorator(nil, target, key)
|
|
29
29
|
end
|
|
30
30
|
result = result or oldResult
|
|
31
31
|
end
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
function __TS__DecorateParam(paramIndex, decorator)
|
|
2
|
-
return function(____, target, key) return decorator(
|
|
1
|
+
local function __TS__DecorateParam(paramIndex, decorator)
|
|
2
|
+
return function(____, target, key) return decorator(nil, target, key, paramIndex) end
|
|
3
3
|
end
|
package/dist/lualib/Delete.lua
CHANGED
package/dist/lualib/Error.lua
CHANGED
|
@@ -1,78 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
local
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
level = 1
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
|
|
2
|
+
do
|
|
3
|
+
local function getErrorStack(self, constructor)
|
|
4
|
+
local level = 1
|
|
5
|
+
while true do
|
|
6
|
+
local info = debug.getinfo(level, "f")
|
|
7
|
+
level = level + 1
|
|
8
|
+
if not info then
|
|
9
|
+
level = 1
|
|
10
|
+
break
|
|
11
|
+
elseif info.func == constructor then
|
|
12
|
+
break
|
|
13
|
+
end
|
|
11
14
|
end
|
|
15
|
+
return debug.traceback(nil, level)
|
|
12
16
|
end
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return (tostring(description) .. "\n") .. self.stack
|
|
17
|
+
local function wrapErrorToString(self, getDescription)
|
|
18
|
+
return function(self)
|
|
19
|
+
local description = getDescription(self)
|
|
20
|
+
local caller = debug.getinfo(3, "f")
|
|
21
|
+
if _VERSION == "Lua 5.1" or caller and caller.func ~= error then
|
|
22
|
+
return description
|
|
23
|
+
else
|
|
24
|
+
return (tostring(description) .. "\n") .. self.stack
|
|
25
|
+
end
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
local ____TS__InitErrorClass_3 = __TS__InitErrorClass
|
|
34
|
-
local ____G_2 = _G
|
|
35
|
-
____class_0 = __TS__Class()
|
|
36
|
-
____class_0.name = ""
|
|
37
|
-
function ____class_0.prototype.____constructor(self, message)
|
|
38
|
-
if message == nil then
|
|
39
|
-
message = ""
|
|
28
|
+
local function initErrorClass(self, Type, name)
|
|
29
|
+
Type.name = name
|
|
30
|
+
return setmetatable(
|
|
31
|
+
Type,
|
|
32
|
+
{__call = function(____, _self, message) return __TS__New(Type, message) end}
|
|
33
|
+
)
|
|
40
34
|
end
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
local ____initErrorClass_2 = initErrorClass
|
|
36
|
+
local ____class_0 = __TS__Class()
|
|
37
|
+
____class_0.name = ""
|
|
38
|
+
function ____class_0.prototype.____constructor(self, message)
|
|
39
|
+
if message == nil then
|
|
40
|
+
message = ""
|
|
41
|
+
end
|
|
42
|
+
self.message = message
|
|
43
|
+
self.name = "Error"
|
|
44
|
+
self.stack = getErrorStack(nil, self.constructor.new)
|
|
45
|
+
local metatable = getmetatable(self)
|
|
46
|
+
if not metatable.__errorToStringPatched then
|
|
47
|
+
metatable.__errorToStringPatched = true
|
|
48
|
+
metatable.__tostring = wrapErrorToString(nil, metatable.__tostring)
|
|
49
|
+
end
|
|
48
50
|
end
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
function ____class_0.prototype.__tostring(self)
|
|
52
|
+
local ____temp_1
|
|
53
|
+
if self.message ~= "" then
|
|
54
|
+
____temp_1 = (self.name .. ": ") .. self.message
|
|
55
|
+
else
|
|
56
|
+
____temp_1 = self.name
|
|
57
|
+
end
|
|
58
|
+
return ____temp_1
|
|
56
59
|
end
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
local ____TS__InitErrorClass_6 = __TS__InitErrorClass
|
|
69
|
-
local ____G_5 = _G
|
|
70
|
-
local ____class_4 = __TS__Class()
|
|
71
|
-
____class_4.name = ____class_4.name
|
|
72
|
-
__TS__ClassExtends(____class_4, Error)
|
|
73
|
-
function ____class_4.prototype.____constructor(self, ...)
|
|
74
|
-
Error.prototype.____constructor(self, ...)
|
|
75
|
-
self.name = errorName
|
|
60
|
+
Error = ____initErrorClass_2(nil, ____class_0, "Error")
|
|
61
|
+
local function createErrorClass(self, name)
|
|
62
|
+
local ____initErrorClass_4 = initErrorClass
|
|
63
|
+
local ____class_3 = __TS__Class()
|
|
64
|
+
____class_3.name = ____class_3.name
|
|
65
|
+
__TS__ClassExtends(____class_3, Error)
|
|
66
|
+
function ____class_3.prototype.____constructor(self, ...)
|
|
67
|
+
____class_3.____super.prototype.____constructor(self, ...)
|
|
68
|
+
self.name = name
|
|
69
|
+
end
|
|
70
|
+
return ____initErrorClass_4(nil, ____class_3, name)
|
|
76
71
|
end
|
|
77
|
-
|
|
72
|
+
RangeError = createErrorClass(nil, "RangeError")
|
|
73
|
+
ReferenceError = createErrorClass(nil, "ReferenceError")
|
|
74
|
+
SyntaxError = createErrorClass(nil, "SyntaxError")
|
|
75
|
+
TypeError = createErrorClass(nil, "TypeError")
|
|
76
|
+
URIError = createErrorClass(nil, "URIError")
|
|
78
77
|
end
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
local co = self.____coroutine
|
|
6
|
-
if coroutine.status(co) == "dead" then
|
|
7
|
-
return {done = true}
|
|
8
|
-
end
|
|
9
|
-
local status, value = coroutine.resume(co, ...)
|
|
10
|
-
if not status then
|
|
11
|
-
error(value, 0)
|
|
1
|
+
local __TS__Generator
|
|
2
|
+
do
|
|
3
|
+
local function generatorIterator(self)
|
|
4
|
+
return self
|
|
12
5
|
end
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
local function generatorNext(self, ...)
|
|
7
|
+
local co = self.____coroutine
|
|
8
|
+
if coroutine.status(co) == "dead" then
|
|
9
|
+
return {done = true}
|
|
10
|
+
end
|
|
11
|
+
local status, value = coroutine.resume(co, ...)
|
|
12
|
+
if not status then
|
|
13
|
+
error(value, 0)
|
|
14
|
+
end
|
|
22
15
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
next = __TS__GeneratorNext
|
|
16
|
+
value = value,
|
|
17
|
+
done = coroutine.status(co) == "dead"
|
|
26
18
|
}
|
|
27
19
|
end
|
|
20
|
+
function __TS__Generator(fn)
|
|
21
|
+
return function(...)
|
|
22
|
+
local args = {...}
|
|
23
|
+
local argsLength = select("#", ...)
|
|
24
|
+
return {
|
|
25
|
+
____coroutine = coroutine.create(function() return fn((unpack or table.unpack)(args, 1, argsLength)) end),
|
|
26
|
+
[Symbol.iterator] = generatorIterator,
|
|
27
|
+
next = generatorNext
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
end
|
|
28
31
|
end
|
package/dist/lualib/Iterator.lua
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
local
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
local __TS__Iterator
|
|
2
|
+
do
|
|
3
|
+
local function iteratorGeneratorStep(self)
|
|
4
|
+
local co = self.____coroutine
|
|
5
|
+
local status, value = coroutine.resume(co)
|
|
6
|
+
if not status then
|
|
7
|
+
error(value, 0)
|
|
8
|
+
end
|
|
9
|
+
if coroutine.status(co) == "dead" then
|
|
10
|
+
return
|
|
11
|
+
end
|
|
12
|
+
return true, value
|
|
6
13
|
end
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
local function iteratorIteratorStep(self)
|
|
15
|
+
local result = self:next()
|
|
16
|
+
if result.done then
|
|
17
|
+
return
|
|
18
|
+
end
|
|
19
|
+
return true, result.value
|
|
9
20
|
end
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
end
|
|
17
|
-
return true, result.value
|
|
18
|
-
end
|
|
19
|
-
function __TS__IteratorStringStep(self, index)
|
|
20
|
-
index = index + 1
|
|
21
|
-
if index > #self then
|
|
22
|
-
return
|
|
21
|
+
local function iteratorStringStep(self, index)
|
|
22
|
+
index = index + 1
|
|
23
|
+
if index > #self then
|
|
24
|
+
return
|
|
25
|
+
end
|
|
26
|
+
return index, string.sub(self, index, index)
|
|
23
27
|
end
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return ipairs(iterable)
|
|
28
|
+
function __TS__Iterator(iterable)
|
|
29
|
+
if type(iterable) == "string" then
|
|
30
|
+
return iteratorStringStep, iterable, 0
|
|
31
|
+
elseif iterable.____coroutine ~= nil then
|
|
32
|
+
return iteratorGeneratorStep, iterable
|
|
33
|
+
elseif iterable[Symbol.iterator] then
|
|
34
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
35
|
+
return iteratorIteratorStep, iterator
|
|
36
|
+
else
|
|
37
|
+
return ipairs(iterable)
|
|
38
|
+
end
|
|
36
39
|
end
|
|
37
40
|
end
|
package/dist/lualib/Map.lua
CHANGED
|
@@ -1,140 +1,142 @@
|
|
|
1
|
-
Map
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
self
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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.
|
|
58
|
-
|
|
62
|
+
self.items[key] = nil
|
|
63
|
+
return contains
|
|
59
64
|
end
|
|
60
|
-
self
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
68
|
-
|
|
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
|
|
80
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
package/dist/lualib/MathSign.lua
CHANGED
package/dist/lualib/New.lua
CHANGED
package/dist/lualib/Number.lua
CHANGED