typescript-to-lua 1.10.0-beta.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/lualib/5.0/Generator.lua +1 -1
  2. package/dist/lualib/5.0/SparseArraySpread.lua +1 -1
  3. package/dist/lualib/5.0/Unpack.lua +18 -1
  4. package/dist/lualib/5.0/lualib_bundle.lua +32 -15
  5. package/dist/lualib/5.0/lualib_module_info.json +3 -1
  6. package/dist/transformation/utils/diagnostics.js +1 -1
  7. package/dist/transformation/visitors/conditional.js +4 -0
  8. package/dist/transpilation/resolve.js +3 -3
  9. package/package.json +2 -2
  10. package/dist/lualib/ArrayConcat.lua +0 -22
  11. package/dist/lualib/ArrayEntries.lua +0 -13
  12. package/dist/lualib/ArrayEvery.lua +0 -8
  13. package/dist/lualib/ArrayFilter.lua +0 -11
  14. package/dist/lualib/ArrayFind.lua +0 -9
  15. package/dist/lualib/ArrayFindIndex.lua +0 -8
  16. package/dist/lualib/ArrayFlat.lua +0 -27
  17. package/dist/lualib/ArrayFlatMap.lua +0 -17
  18. package/dist/lualib/ArrayForEach.lua +0 -5
  19. package/dist/lualib/ArrayFrom.lua +0 -29
  20. package/dist/lualib/ArrayIncludes.lua +0 -19
  21. package/dist/lualib/ArrayIndexOf.lua +0 -24
  22. package/dist/lualib/ArrayIsArray.lua +0 -3
  23. package/dist/lualib/ArrayJoin.lua +0 -10
  24. package/dist/lualib/ArrayMap.lua +0 -7
  25. package/dist/lualib/ArrayPush.lua +0 -9
  26. package/dist/lualib/ArrayPushArray.lua +0 -8
  27. package/dist/lualib/ArrayReduce.lua +0 -23
  28. package/dist/lualib/ArrayReduceRight.lua +0 -23
  29. package/dist/lualib/ArrayReverse.lua +0 -12
  30. package/dist/lualib/ArraySetLength.lua +0 -12
  31. package/dist/lualib/ArraySlice.lua +0 -43
  32. package/dist/lualib/ArraySome.lua +0 -8
  33. package/dist/lualib/ArraySort.lua +0 -11
  34. package/dist/lualib/ArraySplice.lua +0 -77
  35. package/dist/lualib/ArrayToObject.lua +0 -7
  36. package/dist/lualib/ArrayUnshift.lua +0 -14
  37. package/dist/lualib/Await.lua +0 -54
  38. package/dist/lualib/Class.lua +0 -6
  39. package/dist/lualib/ClassExtends.lua +0 -24
  40. package/dist/lualib/CloneDescriptor.lua +0 -28
  41. package/dist/lualib/Decorate.lua +0 -36
  42. package/dist/lualib/DecorateParam.lua +0 -3
  43. package/dist/lualib/DelegatedYield.lua +0 -34
  44. package/dist/lualib/Delete.lua +0 -19
  45. package/dist/lualib/Error.lua +0 -77
  46. package/dist/lualib/FunctionBind.lua +0 -11
  47. package/dist/lualib/Generator.lua +0 -38
  48. package/dist/lualib/InstanceOf.lua +0 -18
  49. package/dist/lualib/InstanceOfObject.lua +0 -4
  50. package/dist/lualib/Iterator.lua +0 -40
  51. package/dist/lualib/LuaIteratorSpread.lua +0 -9
  52. package/dist/lualib/Map.lua +0 -140
  53. package/dist/lualib/MathAtan2.lua +0 -1
  54. package/dist/lualib/MathSign.lua +0 -8
  55. package/dist/lualib/New.lua +0 -5
  56. package/dist/lualib/Number.lua +0 -26
  57. package/dist/lualib/NumberIsFinite.lua +0 -3
  58. package/dist/lualib/NumberIsNaN.lua +0 -3
  59. package/dist/lualib/NumberToString.lua +0 -44
  60. package/dist/lualib/ObjectAssign.lua +0 -10
  61. package/dist/lualib/ObjectDefineProperty.lua +0 -59
  62. package/dist/lualib/ObjectEntries.lua +0 -9
  63. package/dist/lualib/ObjectFromEntries.lua +0 -20
  64. package/dist/lualib/ObjectGetOwnPropertyDescriptor.lua +0 -10
  65. package/dist/lualib/ObjectGetOwnPropertyDescriptors.lua +0 -7
  66. package/dist/lualib/ObjectKeys.lua +0 -9
  67. package/dist/lualib/ObjectRest.lua +0 -9
  68. package/dist/lualib/ObjectValues.lua +0 -9
  69. package/dist/lualib/ParseFloat.lua +0 -18
  70. package/dist/lualib/ParseInt.lua +0 -43
  71. package/dist/lualib/Promise.lua +0 -176
  72. package/dist/lualib/PromiseAll.lua +0 -44
  73. package/dist/lualib/PromiseAllSettled.lua +0 -48
  74. package/dist/lualib/PromiseAny.lua +0 -41
  75. package/dist/lualib/PromiseRace.lua +0 -28
  76. package/dist/lualib/Set.lua +0 -130
  77. package/dist/lualib/SetDescriptor.lua +0 -79
  78. package/dist/lualib/SourceMapTraceBack.lua +0 -54
  79. package/dist/lualib/SparseArrayNew.lua +0 -5
  80. package/dist/lualib/SparseArrayPush.lua +0 -9
  81. package/dist/lualib/SparseArraySpread.lua +0 -8
  82. package/dist/lualib/Spread.lua +0 -15
  83. package/dist/lualib/StringAccess.lua +0 -5
  84. package/dist/lualib/StringCharAt.lua +0 -9
  85. package/dist/lualib/StringCharCodeAt.lua +0 -13
  86. package/dist/lualib/StringEndsWith.lua +0 -6
  87. package/dist/lualib/StringIncludes.lua +0 -9
  88. package/dist/lualib/StringPadEnd.lua +0 -26
  89. package/dist/lualib/StringPadStart.lua +0 -26
  90. package/dist/lualib/StringReplace.lua +0 -20
  91. package/dist/lualib/StringReplaceAll.lua +0 -42
  92. package/dist/lualib/StringSlice.lua +0 -15
  93. package/dist/lualib/StringSplit.lua +0 -36
  94. package/dist/lualib/StringStartsWith.lua +0 -6
  95. package/dist/lualib/StringSubstr.lua +0 -15
  96. package/dist/lualib/StringSubstring.lua +0 -17
  97. package/dist/lualib/StringTrim.lua +0 -4
  98. package/dist/lualib/StringTrimEnd.lua +0 -4
  99. package/dist/lualib/StringTrimStart.lua +0 -4
  100. package/dist/lualib/Symbol.lua +0 -15
  101. package/dist/lualib/SymbolRegistry.lua +0 -17
  102. package/dist/lualib/TypeOf.lua +0 -10
  103. package/dist/lualib/Unpack.lua +0 -1
  104. package/dist/lualib/WeakMap.lua +0 -45
  105. package/dist/lualib/WeakSet.lua +0 -41
  106. package/dist/lualib/lualib_bundle.lua +0 -2518
  107. package/dist/lualib/lualib_module_info.json +0 -626
  108. package/dist/lualib/universal/universal/CountVarargs.lua +0 -3
  109. package/dist/lualib/universal/universal/Match.lua +0 -1
  110. package/dist/lualib/universal/universal/MathModf.lua +0 -1
  111. package/dist/lualib/universal/universal/SparseArraySpread.lua +0 -8
  112. package/dist/lualib/universal/universal/Unpack.lua +0 -1
@@ -1,77 +0,0 @@
1
- local function __TS__ArraySplice(self, ...)
2
- local args = {...}
3
- local len = #self
4
- local actualArgumentCount = select("#", ...)
5
- local start = args[1]
6
- local deleteCount = args[2]
7
- if start < 0 then
8
- start = len + start
9
- if start < 0 then
10
- start = 0
11
- end
12
- elseif start > len then
13
- start = len
14
- end
15
- local itemCount = actualArgumentCount - 2
16
- if itemCount < 0 then
17
- itemCount = 0
18
- end
19
- local actualDeleteCount
20
- if actualArgumentCount == 0 then
21
- actualDeleteCount = 0
22
- elseif actualArgumentCount == 1 then
23
- actualDeleteCount = len - start
24
- else
25
- local ____deleteCount_0 = deleteCount
26
- if ____deleteCount_0 == nil then
27
- ____deleteCount_0 = 0
28
- end
29
- actualDeleteCount = ____deleteCount_0
30
- if actualDeleteCount < 0 then
31
- actualDeleteCount = 0
32
- end
33
- if actualDeleteCount > len - start then
34
- actualDeleteCount = len - start
35
- end
36
- end
37
- local out = {}
38
- for k = 1, actualDeleteCount do
39
- local from = start + k
40
- if self[from] ~= nil then
41
- out[k] = self[from]
42
- end
43
- end
44
- if itemCount < actualDeleteCount then
45
- for k = start + 1, len - actualDeleteCount do
46
- local from = k + actualDeleteCount
47
- local to = k + itemCount
48
- if self[from] then
49
- self[to] = self[from]
50
- else
51
- self[to] = nil
52
- end
53
- end
54
- for k = len - actualDeleteCount + itemCount + 1, len do
55
- self[k] = nil
56
- end
57
- elseif itemCount > actualDeleteCount then
58
- for k = len - actualDeleteCount, start + 1, -1 do
59
- local from = k + actualDeleteCount
60
- local to = k + itemCount
61
- if self[from] then
62
- self[to] = self[from]
63
- else
64
- self[to] = nil
65
- end
66
- end
67
- end
68
- local j = start + 1
69
- for i = 3, actualArgumentCount do
70
- self[j] = args[i]
71
- j = j + 1
72
- end
73
- for k = #self, len - actualDeleteCount + itemCount + 1, -1 do
74
- self[k] = nil
75
- end
76
- return out
77
- end
@@ -1,7 +0,0 @@
1
- local function __TS__ArrayToObject(self)
2
- local object = {}
3
- for i = 1, #self do
4
- object[i - 1] = self[i]
5
- end
6
- return object
7
- end
@@ -1,14 +0,0 @@
1
- local function __TS__ArrayUnshift(self, ...)
2
- local items = {...}
3
- local numItemsToInsert = #items
4
- if numItemsToInsert == 0 then
5
- return #self
6
- end
7
- for i = #self, 1, -1 do
8
- self[i + numItemsToInsert] = self[i]
9
- end
10
- for i = 1, numItemsToInsert do
11
- self[i] = items[i]
12
- end
13
- return #self
14
- end
@@ -1,54 +0,0 @@
1
- local function __TS__AsyncAwaiter(generator)
2
- return __TS__New(
3
- __TS__Promise,
4
- function(____, resolve, reject)
5
- local adopt, fulfilled, step, resolved, asyncCoroutine
6
- function adopt(self, value)
7
- local ____temp_0
8
- if __TS__InstanceOf(value, __TS__Promise) then
9
- ____temp_0 = value
10
- else
11
- ____temp_0 = __TS__Promise.resolve(value)
12
- end
13
- return ____temp_0
14
- end
15
- function fulfilled(self, value)
16
- local success, resultOrError = coroutine.resume(asyncCoroutine, value)
17
- if success then
18
- step(nil, resultOrError)
19
- else
20
- reject(nil, resultOrError)
21
- end
22
- end
23
- function step(self, result)
24
- if resolved then
25
- return
26
- end
27
- if coroutine.status(asyncCoroutine) == "dead" then
28
- resolve(nil, result)
29
- else
30
- local ____self_1 = adopt(nil, result)
31
- ____self_1["then"](____self_1, fulfilled, reject)
32
- end
33
- end
34
- resolved = false
35
- asyncCoroutine = coroutine.create(generator)
36
- local success, resultOrError = coroutine.resume(
37
- asyncCoroutine,
38
- function(____, v)
39
- resolved = true
40
- local ____self_2 = adopt(nil, v)
41
- ____self_2["then"](____self_2, resolve, reject)
42
- end
43
- )
44
- if success then
45
- step(nil, resultOrError)
46
- else
47
- reject(nil, resultOrError)
48
- end
49
- end
50
- )
51
- end
52
- local function __TS__Await(thing)
53
- return coroutine.yield(thing)
54
- end
@@ -1,6 +0,0 @@
1
- local function __TS__Class(self)
2
- local c = {prototype = {}}
3
- c.prototype.__index = c.prototype
4
- c.prototype.constructor = c
5
- return c
6
- end
@@ -1,24 +0,0 @@
1
- local function __TS__ClassExtends(target, base)
2
- target.____super = base
3
- local staticMetatable = setmetatable({__index = base}, base)
4
- setmetatable(target, staticMetatable)
5
- local baseMetatable = getmetatable(base)
6
- if baseMetatable then
7
- if type(baseMetatable.__index) == "function" then
8
- staticMetatable.__index = baseMetatable.__index
9
- end
10
- if type(baseMetatable.__newindex) == "function" then
11
- staticMetatable.__newindex = baseMetatable.__newindex
12
- end
13
- end
14
- setmetatable(target.prototype, base.prototype)
15
- if type(base.prototype.__index) == "function" then
16
- target.prototype.__index = base.prototype.__index
17
- end
18
- if type(base.prototype.__newindex) == "function" then
19
- target.prototype.__newindex = base.prototype.__newindex
20
- end
21
- if type(base.prototype.__tostring) == "function" then
22
- target.prototype.__tostring = base.prototype.__tostring
23
- end
24
- end
@@ -1,28 +0,0 @@
1
- local function __TS__CloneDescriptor(____bindingPattern0)
2
- local value
3
- local writable
4
- local set
5
- local get
6
- local configurable
7
- local enumerable
8
- enumerable = ____bindingPattern0.enumerable
9
- configurable = ____bindingPattern0.configurable
10
- get = ____bindingPattern0.get
11
- set = ____bindingPattern0.set
12
- writable = ____bindingPattern0.writable
13
- value = ____bindingPattern0.value
14
- local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
15
- local hasGetterOrSetter = get ~= nil or set ~= nil
16
- local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
17
- if hasGetterOrSetter and hasValueOrWritableAttribute then
18
- error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
19
- end
20
- if get or set then
21
- descriptor.get = get
22
- descriptor.set = set
23
- else
24
- descriptor.value = value
25
- descriptor.writable = writable == true
26
- end
27
- return descriptor
28
- end
@@ -1,36 +0,0 @@
1
- local function __TS__Decorate(decorators, target, key, desc)
2
- local result = target
3
- do
4
- local i = #decorators
5
- while i >= 0 do
6
- local decorator = decorators[i + 1]
7
- if decorator then
8
- local oldResult = result
9
- if key == nil then
10
- result = decorator(nil, result)
11
- elseif desc == true then
12
- local value = rawget(target, key)
13
- local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
14
- local desc = decorator(nil, target, key, descriptor) or descriptor
15
- local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
16
- if isSimpleValue then
17
- rawset(target, key, desc.value)
18
- else
19
- __TS__SetDescriptor(
20
- target,
21
- key,
22
- __TS__ObjectAssign({}, descriptor, desc)
23
- )
24
- end
25
- elseif desc == false then
26
- result = decorator(nil, target, key, desc)
27
- else
28
- result = decorator(nil, target, key)
29
- end
30
- result = result or oldResult
31
- end
32
- i = i - 1
33
- end
34
- end
35
- return result
36
- end
@@ -1,3 +0,0 @@
1
- local function __TS__DecorateParam(paramIndex, decorator)
2
- return function(____, target, key) return decorator(nil, target, key, paramIndex) end
3
- end
@@ -1,34 +0,0 @@
1
- local function __TS__DelegatedYield(iterable)
2
- if type(iterable) == "string" then
3
- for index = 0, #iterable - 1 do
4
- coroutine.yield(__TS__StringAccess(iterable, index))
5
- end
6
- elseif iterable.____coroutine ~= nil then
7
- local co = iterable.____coroutine
8
- while true do
9
- local status, value = coroutine.resume(co)
10
- if not status then
11
- error(value, 0)
12
- end
13
- if coroutine.status(co) == "dead" then
14
- return value
15
- else
16
- coroutine.yield(value)
17
- end
18
- end
19
- elseif iterable[Symbol.iterator] then
20
- local iterator = iterable[Symbol.iterator](iterable)
21
- while true do
22
- local result = iterator:next()
23
- if result.done then
24
- return result.value
25
- else
26
- coroutine.yield(result.value)
27
- end
28
- end
29
- else
30
- for ____, value in ipairs(iterable) do
31
- coroutine.yield(value)
32
- end
33
- end
34
- end
@@ -1,19 +0,0 @@
1
- local function __TS__Delete(target, key)
2
- local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
3
- local descriptor = descriptors[key]
4
- if descriptor then
5
- if not descriptor.configurable then
6
- error(
7
- __TS__New(
8
- TypeError,
9
- ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
10
- ),
11
- 0
12
- )
13
- end
14
- descriptors[key] = nil
15
- return true
16
- end
17
- target[key] = nil
18
- return true
19
- end
@@ -1,77 +0,0 @@
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
14
- end
15
- return debug.traceback(nil, level)
16
- end
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
26
- end
27
- end
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
- )
34
- end
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
50
- end
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
59
- end
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)
71
- end
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")
77
- end
@@ -1,11 +0,0 @@
1
- local function __TS__FunctionBind(fn, ...)
2
- local boundArgs = {...}
3
- return function(____, ...)
4
- local args = {...}
5
- __TS__ArrayUnshift(
6
- args,
7
- __TS__Unpack(boundArgs)
8
- )
9
- return fn(__TS__Unpack(args))
10
- end
11
- end
@@ -1,38 +0,0 @@
1
- local __TS__Generator
2
- do
3
- local function generatorIterator(self)
4
- return self
5
- end
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
15
- return {
16
- value = value,
17
- done = coroutine.status(co) == "dead"
18
- }
19
- end
20
- function __TS__Generator(fn)
21
- return function(...)
22
- local args = {...}
23
- local argsLength = select("#", ...)
24
- return {
25
- ____coroutine = coroutine.create(function()
26
- local ____fn_1 = fn
27
- local ____unpack_0 = unpack
28
- if ____unpack_0 == nil then
29
- ____unpack_0 = table.unpack
30
- end
31
- return ____fn_1(____unpack_0(args, 1, argsLength))
32
- end),
33
- [Symbol.iterator] = generatorIterator,
34
- next = generatorNext
35
- }
36
- end
37
- end
38
- end
@@ -1,18 +0,0 @@
1
- local function __TS__InstanceOf(obj, classTbl)
2
- if type(classTbl) ~= "table" then
3
- error("Right-hand side of 'instanceof' is not an object", 0)
4
- end
5
- if classTbl[Symbol.hasInstance] ~= nil then
6
- return not not classTbl[Symbol.hasInstance](classTbl, obj)
7
- end
8
- if type(obj) == "table" then
9
- local luaClass = obj.constructor
10
- while luaClass ~= nil do
11
- if luaClass == classTbl then
12
- return true
13
- end
14
- luaClass = luaClass.____super
15
- end
16
- end
17
- return false
18
- end
@@ -1,4 +0,0 @@
1
- local function __TS__InstanceOfObject(value)
2
- local valueType = type(value)
3
- return valueType == "table" or valueType == "function"
4
- end
@@ -1,40 +0,0 @@
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
13
- end
14
- local function iteratorIteratorStep(self)
15
- local result = self:next()
16
- if result.done then
17
- return
18
- end
19
- return true, result.value
20
- end
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)
27
- end
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
39
- end
40
- end
@@ -1,9 +0,0 @@
1
- local function __TS__LuaIteratorSpread(self, state, firstKey)
2
- local results = {}
3
- local key, value = self(state, firstKey)
4
- while key do
5
- results[#results + 1] = {key, value}
6
- key, value = self(state, key)
7
- end
8
- return __TS__Unpack(results)
9
- end
@@ -1,140 +0,0 @@
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
13
- end
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
30
- end
31
- end
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
61
- end
62
- self.items[key] = nil
63
- return contains
64
- end
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
69
- end
70
- function Map.prototype.get(self, key)
71
- return self.items[key]
72
- end
73
- function Map.prototype.has(self, key)
74
- return self.nextKey[key] ~= nil or self.lastKey == key
75
- end
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
80
- end
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
89
- end
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 items = self.items
97
- local nextKey = self.nextKey
98
- local key = self.firstKey
99
- return {
100
- [Symbol.iterator] = function(self)
101
- return self
102
- end,
103
- next = function(self)
104
- local result = {done = not key, value = {key, items[key]}}
105
- key = nextKey[key]
106
- return result
107
- end
108
- }
109
- end
110
- function Map.prototype.keys(self)
111
- local nextKey = self.nextKey
112
- local key = self.firstKey
113
- return {
114
- [Symbol.iterator] = function(self)
115
- return self
116
- end,
117
- next = function(self)
118
- local result = {done = not key, value = key}
119
- key = nextKey[key]
120
- return result
121
- end
122
- }
123
- end
124
- function Map.prototype.values(self)
125
- local items = self.items
126
- local nextKey = self.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
- end
@@ -1 +0,0 @@
1
- local __TS__MathAtan2 = math.atan2 or math.atan
@@ -1,8 +0,0 @@
1
- local function __TS__MathSign(val)
2
- if val > 0 then
3
- return 1
4
- elseif val < 0 then
5
- return -1
6
- end
7
- return 0
8
- end
@@ -1,5 +0,0 @@
1
- local function __TS__New(target, ...)
2
- local instance = setmetatable({}, target.prototype)
3
- instance:____constructor(...)
4
- return instance
5
- end