typescript-to-lua 1.3.4 → 1.4.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/dist/CompilerOptions.d.ts +1 -1
- package/dist/CompilerOptions.js +0 -1
- package/dist/LuaLib.d.ts +13 -1
- package/dist/LuaLib.js +62 -65
- package/dist/LuaPrinter.js +13 -12
- 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/ArrayFrom.lua +32 -0
- 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 +1096 -932
- package/dist/lualib/lualib_module_info.json +628 -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/array.d.ts +1 -1
- package/dist/transformation/builtins/array.js +5 -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/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 +19 -1
- package/dist/transpilation/plugins.js +6 -2
- package/dist/transpilation/resolve.js +1 -0
- package/dist/transpilation/transpile.d.ts +1 -1
- package/dist/transpilation/transpile.js +13 -5
- package/dist/transpilation/transpiler.js +25 -11
- package/dist/transpilation/utils.d.ts +2 -0
- package/package.json +12 -11
- package/CHANGELOG.md +0 -703
package/dist/lualib/Await.lua
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function __TS__AsyncAwaiter(generator)
|
|
1
|
+
local function __TS__AsyncAwaiter(generator)
|
|
2
2
|
return __TS__New(
|
|
3
3
|
__TS__Promise,
|
|
4
4
|
function(____, resolve, reject)
|
|
@@ -15,9 +15,9 @@ function __TS__AsyncAwaiter(generator)
|
|
|
15
15
|
function fulfilled(self, value)
|
|
16
16
|
local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine, value)
|
|
17
17
|
if success then
|
|
18
|
-
step(
|
|
18
|
+
step(nil, resultOrError, errorOrErrorHandler)
|
|
19
19
|
else
|
|
20
|
-
reject(
|
|
20
|
+
reject(nil, errorOrErrorHandler)
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
function rejected(self, handler)
|
|
@@ -26,42 +26,42 @@ function __TS__AsyncAwaiter(generator)
|
|
|
26
26
|
local success, hasReturnedOrError, returnedValue = pcall(handler, value)
|
|
27
27
|
if success then
|
|
28
28
|
if hasReturnedOrError then
|
|
29
|
-
resolve(
|
|
29
|
+
resolve(nil, returnedValue)
|
|
30
30
|
else
|
|
31
|
-
step(
|
|
31
|
+
step(nil, hasReturnedOrError, handler)
|
|
32
32
|
end
|
|
33
33
|
else
|
|
34
|
-
reject(
|
|
34
|
+
reject(nil, hasReturnedOrError)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
else
|
|
38
38
|
return function(____, value)
|
|
39
|
-
reject(
|
|
39
|
+
reject(nil, value)
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
function step(self, result, errorHandler)
|
|
44
44
|
if coroutine.status(asyncCoroutine) == "dead" then
|
|
45
|
-
resolve(
|
|
45
|
+
resolve(nil, result)
|
|
46
46
|
else
|
|
47
|
-
local ____self_1 = adopt(
|
|
47
|
+
local ____self_1 = adopt(nil, result)
|
|
48
48
|
____self_1["then"](
|
|
49
49
|
____self_1,
|
|
50
50
|
fulfilled,
|
|
51
|
-
rejected(
|
|
51
|
+
rejected(nil, errorHandler)
|
|
52
52
|
)
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
asyncCoroutine = coroutine.create(generator)
|
|
56
56
|
local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine)
|
|
57
57
|
if success then
|
|
58
|
-
step(
|
|
58
|
+
step(nil, resultOrError, errorOrErrorHandler)
|
|
59
59
|
else
|
|
60
|
-
reject(
|
|
60
|
+
reject(nil, errorOrErrorHandler)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
)
|
|
64
64
|
end
|
|
65
|
-
function __TS__Await(errorHandler, thing)
|
|
65
|
+
local function __TS__Await(errorHandler, thing)
|
|
66
66
|
return coroutine.yield(errorHandler, thing)
|
|
67
67
|
end
|
package/dist/lualib/Class.lua
CHANGED
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
|