Created
January 17, 2020 16:40
-
-
Save DoctorRyner/9e3f478c5b021e0fb86f14d96c333d6b to your computer and use it in GitHub Desktop.
main = log $ show 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ____modules = {} | |
local ____moduleCache = {} | |
local ____originalRequire = require | |
local function require(file) | |
if ____moduleCache[file] then | |
return ____moduleCache[file] | |
end | |
if ____modules[file] then | |
____moduleCache[file] = ____modules[file]() | |
return ____moduleCache[file] | |
else | |
if ____originalRequire then | |
return ____originalRequire(file) | |
else | |
error("module '" .. file .. "' not found") | |
end | |
end | |
end | |
____modules = { | |
["Main"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]] | |
require("lualib_bundle"); | |
local PS = {}; | |
(function(self, exports) | |
local ____ = "use strict" | |
exports.showIntImpl = function(self, n) | |
return tostring(n) | |
end | |
end)( | |
_G, | |
(function(o, i, v) | |
o[i] = v | |
return v | |
end)(PS, "Data.Show", PS["Data.Show"] or {}) | |
); | |
(function(self, _____24PS) | |
local ____ = "use strict" | |
_____24PS["Data.Show"] = _____24PS["Data.Show"] or {} | |
local exports = _____24PS["Data.Show"] | |
local _____24foreign = _____24PS["Data.Show"] | |
local Show | |
Show = function(self, show) | |
self.show = show | |
end | |
local showInt = __TS__New(Show, _____24foreign.showIntImpl) | |
local show | |
show = function(self, dict) | |
return dict.show | |
end | |
exports.show = show | |
exports.showInt = showInt | |
end)(_G, PS); | |
(function(self, exports) | |
local ____ = "use strict" | |
exports.log = function(self, s) | |
return function(self) | |
print(s) | |
return {} | |
end | |
end | |
end)( | |
_G, | |
(function(o, i, v) | |
o[i] = v | |
return v | |
end)(PS, "Effect.Console", PS["Effect.Console"] or {}) | |
); | |
(function(self, _____24PS) | |
local ____ = "use strict" | |
_____24PS["Effect.Console"] = _____24PS["Effect.Console"] or {} | |
local exports = _____24PS["Effect.Console"] | |
local _____24foreign = _____24PS["Effect.Console"] | |
exports.log = _____24foreign.log | |
end)(_G, PS); | |
(function(self, _____24PS) | |
local ____ = "use strict" | |
_____24PS.Main = _____24PS.Main or {} | |
local exports = _____24PS.Main | |
local Data_Show = _____24PS["Data.Show"] | |
local Effect_Console = _____24PS["Effect.Console"] | |
local main = Effect_Console:log( | |
Data_Show:show(Data_Show.showInt)(_G, 0) | |
) | |
exports.main = main | |
end)(_G, PS) | |
PS.Main:main() | |
end, | |
["lualib_bundle"] = function() function __TS__ArrayConcat(arr1, ...) | |
local args = ({...}) | |
local out = {} | |
for ____, val in ipairs(arr1) do | |
out[#out + 1] = val | |
end | |
for ____, arg in ipairs(args) do | |
if pcall( | |
function() return #arg end | |
) and type(arg) ~= "string" then | |
local argAsArray = arg | |
for ____, val in ipairs(argAsArray) do | |
out[#out + 1] = val | |
end | |
else | |
out[#out + 1] = arg | |
end | |
end | |
return out | |
end | |
function __TS__ArrayEvery(arr, callbackfn) | |
do | |
local i = 0 | |
while i < #arr do | |
if not callbackfn(_G, arr[i + 1], i, arr) then | |
return false | |
end | |
i = i + 1 | |
end | |
end | |
return true | |
end | |
function __TS__ArrayFilter(arr, callbackfn) | |
local result = {} | |
do | |
local i = 0 | |
while i < #arr do | |
if callbackfn(_G, arr[i + 1], i, arr) then | |
result[#result + 1] = arr[i + 1] | |
end | |
i = i + 1 | |
end | |
end | |
return result | |
end | |
function __TS__ArrayForEach(arr, callbackFn) | |
do | |
local i = 0 | |
while i < #arr do | |
callbackFn(_G, arr[i + 1], i, arr) | |
i = i + 1 | |
end | |
end | |
end | |
function __TS__ArrayFind(arr, predicate) | |
local len = #arr | |
local k = 0 | |
while k < len do | |
local elem = arr[k + 1] | |
if predicate(_G, elem, k, arr) then | |
return elem | |
end | |
k = k + 1 | |
end | |
return nil | |
end | |
function __TS__ArrayFindIndex(arr, callbackFn) | |
do | |
local i = 0 | |
local len = #arr | |
while i < len do | |
if callbackFn(_G, arr[i + 1], i, arr) then | |
return i | |
end | |
i = i + 1 | |
end | |
end | |
return -1 | |
end | |
function __TS__ArrayIndexOf(arr, searchElement, fromIndex) | |
local len = #arr | |
if len == 0 then | |
return -1 | |
end | |
local n = 0 | |
if fromIndex then | |
n = fromIndex | |
end | |
if n >= len then | |
return -1 | |
end | |
local k | |
if n >= 0 then | |
k = n | |
else | |
k = len + n | |
if k < 0 then | |
k = 0 | |
end | |
end | |
do | |
local i = k | |
while i < len do | |
if arr[i + 1] == searchElement then | |
return i | |
end | |
i = i + 1 | |
end | |
end | |
return -1 | |
end | |
function __TS__ArrayMap(arr, callbackfn) | |
local newArray = {} | |
do | |
local i = 0 | |
while i < #arr do | |
newArray[i + 1] = callbackfn(_G, arr[i + 1], i, arr) | |
i = i + 1 | |
end | |
end | |
return newArray | |
end | |
function __TS__ArrayPush(arr, ...) | |
local items = ({...}) | |
for ____, item in ipairs(items) do | |
arr[#arr + 1] = item | |
end | |
return #arr | |
end | |
function __TS__ArrayReduce(arr, callbackFn, ...) | |
local len = #arr | |
local k = 0 | |
local accumulator = nil | |
if select("#", ...) ~= 0 then | |
accumulator = select(1, ...) | |
elseif len > 0 then | |
accumulator = arr[1] | |
k = 1 | |
else | |
error("Reduce of empty array with no initial value", 0) | |
end | |
for i = k, len - 1 do | |
accumulator = callbackFn(_G, accumulator, arr[i + 1], i, arr) | |
end | |
return accumulator | |
end | |
function __TS__ArrayReduceRight(arr, callbackFn, ...) | |
local len = #arr | |
local k = len - 1 | |
local accumulator = nil | |
if select("#", ...) ~= 0 then | |
accumulator = select(1, ...) | |
elseif len > 0 then | |
accumulator = arr[k + 1] | |
k = k - 1 | |
else | |
error("Reduce of empty array with no initial value", 0) | |
end | |
for i = k, 0, -1 do | |
accumulator = callbackFn(_G, accumulator, arr[i + 1], i, arr) | |
end | |
return accumulator | |
end | |
function __TS__ArrayReverse(arr) | |
local i = 0 | |
local j = #arr - 1 | |
while i < j do | |
local temp = arr[j + 1] | |
arr[j + 1] = arr[i + 1] | |
arr[i + 1] = temp | |
i = i + 1 | |
j = j - 1 | |
end | |
return arr | |
end | |
function __TS__ArrayShift(arr) | |
return table.remove(arr, 1) | |
end | |
function __TS__ArrayUnshift(arr, ...) | |
local items = ({...}) | |
do | |
local i = #items - 1 | |
while i >= 0 do | |
table.insert(arr, 1, items[i + 1]) | |
i = i - 1 | |
end | |
end | |
return #arr | |
end | |
function __TS__ArraySort(arr, compareFn) | |
if compareFn ~= nil then | |
table.sort( | |
arr, | |
function(a, b) return compareFn(_G, a, b) < 0 end | |
) | |
else | |
table.sort(arr) | |
end | |
return arr | |
end | |
function __TS__ArraySlice(list, first, last) | |
local len = #list | |
local relativeStart = first or 0 | |
local k | |
if relativeStart < 0 then | |
k = math.max(len + relativeStart, 0) | |
else | |
k = math.min(relativeStart, len) | |
end | |
local relativeEnd = last | |
if last == nil then | |
relativeEnd = len | |
end | |
local final | |
if relativeEnd < 0 then | |
final = math.max(len + relativeEnd, 0) | |
else | |
final = math.min(relativeEnd, len) | |
end | |
local out = {} | |
local n = 0 | |
while k < final do | |
out[n + 1] = list[k + 1] | |
k = k + 1 | |
n = n + 1 | |
end | |
return out | |
end | |
function __TS__ArraySome(arr, callbackfn) | |
do | |
local i = 0 | |
while i < #arr do | |
if callbackfn(_G, arr[i + 1], i, arr) then | |
return true | |
end | |
i = i + 1 | |
end | |
end | |
return false | |
end | |
function __TS__ArraySplice(list, ...) | |
local len = #list | |
local actualArgumentCount = select("#", ...) | |
local start = select(1, ...) | |
local deleteCount = select(2, ...) | |
local actualStart | |
if start < 0 then | |
actualStart = math.max(len + start, 0) | |
else | |
actualStart = math.min(start, len) | |
end | |
local itemCount = math.max(actualArgumentCount - 2, 0) | |
local actualDeleteCount | |
if actualArgumentCount == 0 then | |
actualDeleteCount = 0 | |
elseif actualArgumentCount == 1 then | |
actualDeleteCount = len - actualStart | |
else | |
actualDeleteCount = math.min( | |
math.max(deleteCount or 0, 0), | |
len - actualStart | |
) | |
end | |
local out = {} | |
do | |
local k = 0 | |
while k < actualDeleteCount do | |
local from = actualStart + k | |
if list[from + 1] then | |
out[k + 1] = list[from + 1] | |
end | |
k = k + 1 | |
end | |
end | |
if itemCount < actualDeleteCount then | |
do | |
local k = actualStart | |
while k < len - actualDeleteCount do | |
local from = k + actualDeleteCount | |
local to = k + itemCount | |
if list[from + 1] then | |
list[to + 1] = list[from + 1] | |
else | |
list[to + 1] = nil | |
end | |
k = k + 1 | |
end | |
end | |
do | |
local k = len | |
while k > len - actualDeleteCount + itemCount do | |
list[k] = nil | |
k = k - 1 | |
end | |
end | |
elseif itemCount > actualDeleteCount then | |
do | |
local k = len - actualDeleteCount | |
while k > actualStart do | |
local from = k + actualDeleteCount - 1 | |
local to = k + itemCount - 1 | |
if list[from + 1] then | |
list[to + 1] = list[from + 1] | |
else | |
list[to + 1] = nil | |
end | |
k = k - 1 | |
end | |
end | |
end | |
local j = actualStart | |
for i = 3, actualArgumentCount do | |
list[j + 1] = select(i, ...) | |
j = j + 1 | |
end | |
do | |
local k = #list - 1 | |
while k >= len - actualDeleteCount + itemCount do | |
list[k + 1] = nil | |
k = k - 1 | |
end | |
end | |
return out | |
end | |
function __TS__ArrayToObject(array) | |
local object = {} | |
do | |
local i = 0 | |
while i < #array do | |
object[i] = array[i + 1] | |
i = i + 1 | |
end | |
end | |
return object | |
end | |
function __TS__ArrayFlat(array, depth) | |
if depth == nil then | |
depth = 1 | |
end | |
local result = {} | |
for ____, value in ipairs(array) do | |
if depth > 0 and type(value) == "table" and (value[1] ~= nil or next(value, nil) == nil) then | |
result = __TS__ArrayConcat( | |
result, | |
__TS__ArrayFlat(value, depth - 1) | |
) | |
else | |
result[#result + 1] = value | |
end | |
end | |
return result | |
end | |
function __TS__ArrayFlatMap(array, callback) | |
local result = {} | |
do | |
local i = 0 | |
while i < #array do | |
local value = callback(_G, array[i + 1], i, array) | |
if type(value) == "table" and (value[1] ~= nil or next(value, nil) == nil) then | |
result = __TS__ArrayConcat(result, value) | |
else | |
result[#result + 1] = value | |
end | |
i = i + 1 | |
end | |
end | |
return result | |
end | |
function __TS__ArraySetLength(arr, length) | |
if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then | |
error( | |
"invalid array length: " .. tostring(length), | |
0 | |
) | |
end | |
do | |
local i = #arr - 1 | |
while i >= length do | |
arr[i + 1] = nil | |
i = i - 1 | |
end | |
end | |
return length | |
end | |
function __TS__Class(self) | |
local c = {} | |
c.__index = c | |
c.prototype = {} | |
c.prototype.__index = c.prototype | |
c.prototype.constructor = c | |
return c | |
end | |
function __TS__ClassIndex(classTable, key) | |
while true do | |
local getters = rawget(classTable, "____getters") | |
if getters then | |
local getter | |
getter = getters[key] | |
if getter then | |
return getter(classTable) | |
end | |
end | |
classTable = rawget(classTable, "____super") | |
if not classTable then | |
break | |
end | |
local val = rawget(classTable, key) | |
if val ~= nil then | |
return val | |
end | |
end | |
end | |
function __TS__ClassNewIndex(classTable, key, val) | |
local tbl = classTable | |
repeat | |
do | |
local setters = rawget(tbl, "____setters") | |
if setters then | |
local setter | |
setter = setters[key] | |
if setter then | |
setter(tbl, val) | |
return | |
end | |
end | |
tbl = rawget(tbl, "____super") | |
end | |
until not tbl | |
rawset(classTable, key, val) | |
end | |
function __TS__Decorate(decorators, target, key, desc) | |
local result = target | |
do | |
local i = #decorators | |
while i >= 0 do | |
local decorator = decorators[i + 1] | |
if decorator then | |
local oldResult = result | |
if key == nil then | |
result = decorator(_G, result) | |
elseif desc ~= nil then | |
result = decorator(_G, target, key, result) | |
else | |
result = decorator(_G, target, key) | |
end | |
result = result or oldResult | |
end | |
i = i - 1 | |
end | |
end | |
return result | |
end | |
function __TS__New(target, ...) | |
local instance = setmetatable({}, target.prototype) | |
instance:____constructor(...) | |
return instance | |
end | |
function __TS__FunctionCall(fn, thisArg, ...) | |
local args = ({...}) | |
return fn( | |
thisArg, | |
(unpack or table.unpack)(args) | |
) | |
end | |
function __TS__GetErrorStack(self, constructor) | |
local level = 1 | |
while true do | |
local info = debug.getinfo(level, "f") | |
level = level + 1 | |
if not info then | |
level = 1 | |
break | |
elseif info.func == constructor then | |
break | |
end | |
end | |
return debug.traceback(nil, level) | |
end | |
function __TS__WrapErrorToString(self, getDescription) | |
return function(self) | |
local description = __TS__FunctionCall(getDescription, self) | |
local caller = debug.getinfo(3, "f") | |
if _VERSION == "Lua 5.1" or (caller and caller.func ~= error) then | |
return description | |
else | |
return tostring(description) .. "\n" .. tostring(self.stack) | |
end | |
end | |
end | |
function __TS__InitErrorClass(self, Type, name) | |
Type.name = name | |
return setmetatable( | |
Type, | |
{ | |
__call = function(____, _self, message) return __TS__New(Type, message) end | |
} | |
) | |
end | |
Error = __TS__InitErrorClass( | |
_G, | |
(function() | |
local ____ = __TS__Class() | |
____.name = "____" | |
function ____.prototype.____constructor(self, message) | |
if message == nil then | |
message = "" | |
end | |
self.message = message | |
self.name = "Error" | |
self.stack = __TS__GetErrorStack(_G, self.constructor.new) | |
local metatable = getmetatable(self) | |
if not metatable.__errorToStringPatched then | |
metatable.__errorToStringPatched = true | |
metatable.__tostring = __TS__WrapErrorToString(_G, metatable.__tostring) | |
end | |
end | |
function ____.prototype.__tostring(self) | |
return ((self.message ~= "") and function() return tostring(self.name) .. ": " .. tostring(self.message) end or function() return self.name end)() | |
end | |
return ____ | |
end)(), | |
"Error" | |
) | |
for ____, errorName in ipairs({"RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError"}) do | |
_G[errorName] = __TS__InitErrorClass( | |
_G, | |
(function() | |
local ____ = __TS__Class() | |
____.name = "____" | |
____.____super = Error | |
setmetatable(____, ____.____super) | |
setmetatable(____.prototype, ____.____super.prototype) | |
function ____.prototype.____constructor(self, ...) | |
Error.prototype.____constructor(self, ...) | |
self.name = errorName | |
end | |
return ____ | |
end)(), | |
errorName | |
) | |
end | |
function __TS__FunctionApply(fn, thisArg, args) | |
if args then | |
return fn( | |
thisArg, | |
(unpack or table.unpack)(args) | |
) | |
else | |
return fn(thisArg) | |
end | |
end | |
function __TS__FunctionBind(fn, thisArg, ...) | |
local boundArgs = ({...}) | |
return function(____, ...) | |
local args = ({...}) | |
do | |
local i = 0 | |
while i < #boundArgs do | |
table.insert(args, i + 1, boundArgs[i + 1]) | |
i = i + 1 | |
end | |
end | |
return fn( | |
thisArg, | |
(unpack or table.unpack)(args) | |
) | |
end | |
end | |
function __TS__Index(classProto) | |
return function(tbl, key) | |
local proto = classProto | |
while true do | |
local val = rawget(proto, key) | |
if val ~= nil then | |
return val | |
end | |
local getters = rawget(proto, "____getters") | |
if getters then | |
local getter | |
getter = getters[key] | |
if getter then | |
return getter(tbl) | |
end | |
end | |
local base = rawget( | |
rawget(proto, "constructor"), | |
"____super" | |
) | |
if not base then | |
break | |
end | |
proto = rawget(base, "prototype") | |
end | |
end | |
end | |
local ____symbolMetatable = { | |
__tostring = function(self) | |
if self.description == nil then | |
return "Symbol()" | |
else | |
return "Symbol(" .. tostring(self.description) .. ")" | |
end | |
end | |
} | |
function __TS__Symbol(description) | |
return setmetatable({description = description}, ____symbolMetatable) | |
end | |
Symbol = { | |
iterator = __TS__Symbol("Symbol.iterator"), | |
hasInstance = __TS__Symbol("Symbol.hasInstance"), | |
species = __TS__Symbol("Symbol.species"), | |
toStringTag = __TS__Symbol("Symbol.toStringTag") | |
} | |
function __TS__InstanceOf(obj, classTbl) | |
if type(classTbl) ~= "table" then | |
error("Right-hand side of 'instanceof' is not an object", 0) | |
end | |
if classTbl[Symbol.hasInstance] ~= nil then | |
return not not classTbl[Symbol.hasInstance](classTbl, obj) | |
end | |
if obj ~= nil then | |
local luaClass = obj.constructor | |
while luaClass ~= nil do | |
if luaClass == classTbl then | |
return true | |
end | |
luaClass = luaClass.____super | |
end | |
end | |
return false | |
end | |
function __TS__InstanceOfObject(value) | |
local valueType = type(value) | |
return valueType == "table" or valueType == "function" | |
end | |
function __TS__Iterator(iterable) | |
if iterable[Symbol.iterator] then | |
local iterator = iterable[Symbol.iterator](iterable) | |
return function() | |
local result = iterator:next() | |
if not result.done then | |
return result.value | |
else | |
return nil | |
end | |
end | |
else | |
local i = 0 | |
return function() | |
i = i + 1 | |
return iterable[i] | |
end | |
end | |
end | |
Map = (function() | |
local Map = __TS__Class() | |
Map.name = "Map" | |
function Map.prototype.____constructor(self, entries) | |
self[Symbol.toStringTag] = "Map" | |
self.items = {} | |
self.size = 0 | |
self.nextKey = {} | |
self.previousKey = {} | |
if entries == nil then | |
return | |
end | |
local iterable = entries | |
if iterable[Symbol.iterator] then | |
local iterator = iterable[Symbol.iterator](iterable) | |
while true do | |
local result = iterator:next() | |
if result.done then | |
break | |
end | |
local value = result.value | |
self:set(value[1], value[2]) | |
end | |
else | |
local array = entries | |
for ____, kvp in ipairs(array) do | |
self:set(kvp[1], kvp[2]) | |
end | |
end | |
end | |
function Map.prototype.clear(self) | |
self.items = {} | |
self.nextKey = {} | |
self.previousKey = {} | |
self.firstKey = nil | |
self.lastKey = nil | |
self.size = 0 | |
return | |
end | |
function Map.prototype.delete(self, key) | |
local contains = self:has(key) | |
if contains then | |
self.size = self.size - 1 | |
local next = self.nextKey[key] | |
local previous = self.previousKey[key] | |
if next and previous then | |
self.nextKey[previous] = next | |
self.previousKey[next] = previous | |
elseif next then | |
self.firstKey = next | |
self.previousKey[next] = nil | |
elseif previous then | |
self.lastKey = previous | |
self.nextKey[previous] = nil | |
else | |
self.firstKey = nil | |
self.lastKey = nil | |
end | |
self.nextKey[key] = nil | |
self.previousKey[key] = nil | |
end | |
self.items[key] = nil | |
return contains | |
end | |
function Map.prototype.forEach(self, callback) | |
for key in __TS__Iterator( | |
self:keys() | |
) do | |
callback(_G, self.items[key], key, self) | |
end | |
return | |
end | |
function Map.prototype.get(self, key) | |
return self.items[key] | |
end | |
function Map.prototype.has(self, key) | |
return self.nextKey[key] ~= nil or self.lastKey == key | |
end | |
function Map.prototype.set(self, key, value) | |
local isNewValue = not self:has(key) | |
if isNewValue then | |
self.size = self.size + 1 | |
end | |
self.items[key] = value | |
if self.firstKey == nil then | |
self.firstKey = key | |
self.lastKey = key | |
elseif isNewValue then | |
self.nextKey[self.lastKey] = key | |
self.previousKey[key] = self.lastKey | |
self.lastKey = key | |
end | |
return self | |
end | |
Map.prototype[Symbol.iterator] = function(self) | |
return self:entries() | |
end | |
function Map.prototype.entries(self) | |
local items = self.items | |
local nextKey = self.nextKey | |
local key = self.firstKey | |
return { | |
[Symbol.iterator] = function(self) | |
return self | |
end, | |
next = function(self) | |
local result = {done = not key, value = {key, items[key]}} | |
key = nextKey[key] | |
return result | |
end | |
} | |
end | |
function Map.prototype.keys(self) | |
local nextKey = self.nextKey | |
local key = self.firstKey | |
return { | |
[Symbol.iterator] = function(self) | |
return self | |
end, | |
next = function(self) | |
local result = {done = not key, value = key} | |
key = nextKey[key] | |
return result | |
end | |
} | |
end | |
function Map.prototype.values(self) | |
local items = self.items | |
local nextKey = self.nextKey | |
local key = self.firstKey | |
return { | |
[Symbol.iterator] = function(self) | |
return self | |
end, | |
next = function(self) | |
local result = {done = not key, value = items[key]} | |
key = nextKey[key] | |
return result | |
end | |
} | |
end | |
Map[Symbol.species] = Map | |
return Map | |
end)() | |
function __TS__NewIndex(classProto) | |
return function(tbl, key, val) | |
local proto = classProto | |
while true do | |
local setters = rawget(proto, "____setters") | |
if setters then | |
local setter | |
setter = setters[key] | |
if setter then | |
setter(tbl, val) | |
return | |
end | |
end | |
local base = rawget( | |
rawget(proto, "constructor"), | |
"____super" | |
) | |
if not base then | |
break | |
end | |
proto = rawget(base, "prototype") | |
end | |
rawset(tbl, key, val) | |
end | |
end | |
function __TS__Number(value) | |
local valueType = type(value) | |
if valueType == "number" then | |
return value | |
elseif valueType == "string" then | |
local numberValue = tonumber(value) | |
if numberValue then | |
return numberValue | |
end | |
if value == "Infinity" then | |
return math.huge | |
end | |
if value == "-Infinity" then | |
return -math.huge | |
end | |
local stringWithoutSpaces = string.gsub(value, "%s", "") | |
if stringWithoutSpaces == "" then | |
return 0 | |
end | |
return (0 / 0) | |
elseif valueType == "boolean" then | |
return value and 1 or 0 | |
else | |
return (0 / 0) | |
end | |
end | |
function __TS__NumberIsFinite(value) | |
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge | |
end | |
function __TS__NumberIsNaN(value) | |
return value ~= value | |
end | |
local ____radixChars = "0123456789abcdefghijklmnopqrstuvwxyz" | |
function __TS__NumberToString(self, radix) | |
if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then | |
return tostring(self) | |
end | |
radix = math.floor(radix) | |
if radix < 2 or radix > 36 then | |
error("toString() radix argument must be between 2 and 36", 0) | |
end | |
local integer, fraction = math.modf( | |
math.abs(self) | |
) | |
local result = "" | |
if radix == 8 then | |
result = string.format("%o", integer) | |
elseif radix == 16 then | |
result = string.format("%x", integer) | |
else | |
repeat | |
do | |
result = tostring( | |
string.sub(____radixChars, (integer % radix) + 1, (integer % radix) + 1) | |
) .. tostring(result) | |
integer = math.floor(integer / radix) | |
end | |
until not (integer ~= 0) | |
end | |
if fraction ~= 0 then | |
result = tostring(result) .. "." | |
local delta = 1e-16 | |
repeat | |
do | |
fraction = fraction * radix | |
delta = delta * radix | |
local digit = math.floor(fraction) | |
result = tostring(result) .. tostring( | |
string.sub(____radixChars, digit + 1, digit + 1) | |
) | |
fraction = fraction - digit | |
end | |
until not (fraction >= delta) | |
end | |
if self < 0 then | |
result = "-" .. tostring(result) | |
end | |
return result | |
end | |
function __TS__ObjectAssign(to, ...) | |
local sources = ({...}) | |
if to == nil then | |
return to | |
end | |
for ____, source in ipairs(sources) do | |
for key in pairs(source) do | |
to[key] = source[key] | |
end | |
end | |
return to | |
end | |
function __TS__ObjectEntries(obj) | |
local result = {} | |
for key in pairs(obj) do | |
result[#result + 1] = {key, obj[key]} | |
end | |
return result | |
end | |
function __TS__ObjectFromEntries(entries) | |
local obj = {} | |
local iterable = entries | |
if iterable[Symbol.iterator] then | |
local iterator = iterable[Symbol.iterator](iterable) | |
while true do | |
local result = iterator:next() | |
if result.done then | |
break | |
end | |
local value = result.value | |
obj[value[1]] = value[2] | |
end | |
else | |
for ____, entry in ipairs(entries) do | |
obj[entry[1]] = entry[2] | |
end | |
end | |
return obj | |
end | |
function __TS__ObjectKeys(obj) | |
local result = {} | |
for key in pairs(obj) do | |
result[#result + 1] = key | |
end | |
return result | |
end | |
function __TS__ObjectRest(target, usedProperties) | |
local result = {} | |
for property in pairs(target) do | |
if not usedProperties[property] then | |
result[property] = target[property] | |
end | |
end | |
return result | |
end | |
function __TS__ObjectValues(obj) | |
local result = {} | |
for key in pairs(obj) do | |
result[#result + 1] = obj[key] | |
end | |
return result | |
end | |
Set = (function() | |
local Set = __TS__Class() | |
Set.name = "Set" | |
function Set.prototype.____constructor(self, values) | |
self[Symbol.toStringTag] = "Set" | |
self.size = 0 | |
self.nextKey = {} | |
self.previousKey = {} | |
if values == nil then | |
return | |
end | |
local iterable = values | |
if iterable[Symbol.iterator] then | |
local iterator = iterable[Symbol.iterator](iterable) | |
while true do | |
local result = iterator:next() | |
if result.done then | |
break | |
end | |
self:add(result.value) | |
end | |
else | |
local array = values | |
for ____, value in ipairs(array) do | |
self:add(value) | |
end | |
end | |
end | |
function Set.prototype.add(self, value) | |
local isNewValue = not self:has(value) | |
if isNewValue then | |
self.size = self.size + 1 | |
end | |
if self.firstKey == nil then | |
self.firstKey = value | |
self.lastKey = value | |
elseif isNewValue then | |
self.nextKey[self.lastKey] = value | |
self.previousKey[value] = self.lastKey | |
self.lastKey = value | |
end | |
return self | |
end | |
function Set.prototype.clear(self) | |
self.nextKey = {} | |
self.previousKey = {} | |
self.firstKey = nil | |
self.lastKey = nil | |
self.size = 0 | |
return | |
end | |
function Set.prototype.delete(self, value) | |
local contains = self:has(value) | |
if contains then | |
self.size = self.size - 1 | |
local next = self.nextKey[value] | |
local previous = self.previousKey[value] | |
if next and previous then | |
self.nextKey[previous] = next | |
self.previousKey[next] = previous | |
elseif next then | |
self.firstKey = next | |
self.previousKey[next] = nil | |
elseif previous then | |
self.lastKey = previous | |
self.nextKey[previous] = nil | |
else | |
self.firstKey = nil | |
self.lastKey = nil | |
end | |
self.nextKey[value] = nil | |
self.previousKey[value] = nil | |
end | |
return contains | |
end | |
function Set.prototype.forEach(self, callback) | |
for key in __TS__Iterator( | |
self:keys() | |
) do | |
callback(_G, key, key, self) | |
end | |
end | |
function Set.prototype.has(self, value) | |
return self.nextKey[value] ~= nil or self.lastKey == value | |
end | |
Set.prototype[Symbol.iterator] = function(self) | |
return self:values() | |
end | |
function Set.prototype.entries(self) | |
local nextKey = self.nextKey | |
local key = self.firstKey | |
return { | |
[Symbol.iterator] = function(self) | |
return self | |
end, | |
next = function(self) | |
local result = {done = not key, value = {key, key}} | |
key = nextKey[key] | |
return result | |
end | |
} | |
end | |
function Set.prototype.keys(self) | |
local nextKey = self.nextKey | |
local key = self.firstKey | |
return { | |
[Symbol.iterator] = function(self) | |
return self | |
end, | |
next = function(self) | |
local result = {done = not key, value = key} | |
key = nextKey[key] | |
return result | |
end | |
} | |
end | |
function Set.prototype.values(self) | |
local nextKey = self.nextKey | |
local key = self.firstKey | |
return { | |
[Symbol.iterator] = function(self) | |
return self | |
end, | |
next = function(self) | |
local result = {done = not key, value = key} | |
key = nextKey[key] | |
return result | |
end | |
} | |
end | |
Set[Symbol.species] = Set | |
return Set | |
end)() | |
WeakMap = (function() | |
local WeakMap = __TS__Class() | |
WeakMap.name = "WeakMap" | |
function WeakMap.prototype.____constructor(self, entries) | |
self[Symbol.toStringTag] = "WeakMap" | |
self.items = {} | |
setmetatable(self.items, {__mode = "k"}) | |
if entries == nil then | |
return | |
end | |
local iterable = entries | |
if iterable[Symbol.iterator] then | |
local iterator = iterable[Symbol.iterator](iterable) | |
while true do | |
local result = iterator:next() | |
if result.done then | |
break | |
end | |
local value = result.value | |
self.items[value[1]] = value[2] | |
end | |
else | |
for ____, kvp in ipairs(entries) do | |
self.items[kvp[1]] = kvp[2] | |
end | |
end | |
end | |
function WeakMap.prototype.delete(self, key) | |
local contains = self:has(key) | |
self.items[key] = nil | |
return contains | |
end | |
function WeakMap.prototype.get(self, key) | |
return self.items[key] | |
end | |
function WeakMap.prototype.has(self, key) | |
return self.items[key] ~= nil | |
end | |
function WeakMap.prototype.set(self, key, value) | |
self.items[key] = value | |
return self | |
end | |
WeakMap[Symbol.species] = WeakMap | |
return WeakMap | |
end)() | |
WeakSet = (function() | |
local WeakSet = __TS__Class() | |
WeakSet.name = "WeakSet" | |
function WeakSet.prototype.____constructor(self, values) | |
self[Symbol.toStringTag] = "WeakSet" | |
self.items = {} | |
setmetatable(self.items, {__mode = "k"}) | |
if values == nil then | |
return | |
end | |
local iterable = values | |
if iterable[Symbol.iterator] then | |
local iterator = iterable[Symbol.iterator](iterable) | |
while true do | |
local result = iterator:next() | |
if result.done then | |
break | |
end | |
self.items[result.value] = true | |
end | |
else | |
for ____, value in ipairs(values) do | |
self.items[value] = true | |
end | |
end | |
end | |
function WeakSet.prototype.add(self, value) | |
self.items[value] = true | |
return self | |
end | |
function WeakSet.prototype.delete(self, value) | |
local contains = self:has(value) | |
self.items[value] = nil | |
return contains | |
end | |
function WeakSet.prototype.has(self, value) | |
return self.items[value] == true | |
end | |
WeakSet[Symbol.species] = WeakSet | |
return WeakSet | |
end)() | |
function __TS__SourceMapTraceBack(fileName, sourceMap) | |
_G.__TS__sourcemap = _G.__TS__sourcemap or {} | |
_G.__TS__sourcemap[fileName] = sourceMap | |
if _G.__TS__originalTraceback == nil then | |
_G.__TS__originalTraceback = debug.traceback | |
debug.traceback = function(thread, message, level) | |
local trace = _G.__TS__originalTraceback(thread, message, level) | |
if type(trace) ~= "string" then | |
return trace | |
end | |
local result = string.gsub( | |
trace, | |
"(%S+).lua:(%d+)", | |
function(file, line) | |
local fileSourceMap = _G.__TS__sourcemap[tostring(file) .. ".lua"] | |
if fileSourceMap and fileSourceMap[line] then | |
return tostring(file) .. ".ts:" .. tostring(fileSourceMap[line]) | |
end | |
return tostring(file) .. ".lua:" .. tostring(line) | |
end | |
) | |
return result | |
end | |
end | |
end | |
function __TS__Spread(iterable) | |
local arr = {} | |
if type(iterable) == "string" then | |
do | |
local i = 0 | |
while i < #iterable do | |
arr[#arr + 1] = string.sub(iterable, i + 1, i + 1) | |
i = i + 1 | |
end | |
end | |
else | |
for item in __TS__Iterator(iterable) do | |
arr[#arr + 1] = item | |
end | |
end | |
return (table.unpack or unpack)(arr) | |
end | |
function __TS__StringConcat(str1, ...) | |
local args = ({...}) | |
local out = str1 | |
for ____, arg in ipairs(args) do | |
out = tostring(out) .. tostring(arg) | |
end | |
return out | |
end | |
function __TS__StringEndsWith(self, searchString, endPosition) | |
if endPosition == nil or endPosition > #self then | |
endPosition = #self | |
end | |
return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString | |
end | |
function __TS__StringPadEnd(self, maxLength, fillString) | |
if fillString == nil then | |
fillString = " " | |
end | |
if maxLength ~= maxLength then | |
maxLength = 0 | |
end | |
if maxLength == -math.huge or maxLength == math.huge then | |
error("Invalid string length", 0) | |
end | |
if #self >= maxLength or #fillString == 0 then | |
return self | |
end | |
maxLength = maxLength - #self | |
if maxLength > #fillString then | |
fillString = tostring(fillString) .. tostring( | |
string.rep( | |
fillString, | |
math.floor(maxLength / #fillString) | |
) | |
) | |
end | |
return tostring(self) .. tostring( | |
string.sub( | |
fillString, | |
1, | |
math.floor(maxLength) | |
) | |
) | |
end | |
function __TS__StringPadStart(self, maxLength, fillString) | |
if fillString == nil then | |
fillString = " " | |
end | |
if maxLength ~= maxLength then | |
maxLength = 0 | |
end | |
if maxLength == -math.huge or maxLength == math.huge then | |
error("Invalid string length", 0) | |
end | |
if #self >= maxLength or #fillString == 0 then | |
return self | |
end | |
maxLength = maxLength - #self | |
if maxLength > #fillString then | |
fillString = tostring(fillString) .. tostring( | |
string.rep( | |
fillString, | |
math.floor(maxLength / #fillString) | |
) | |
) | |
end | |
return tostring( | |
string.sub( | |
fillString, | |
1, | |
math.floor(maxLength) | |
) | |
) .. tostring(self) | |
end | |
function __TS__StringReplace(source, searchValue, replaceValue) | |
searchValue = string.gsub(searchValue, "[%%%(%)%.%+%-%*%?%[%^%$]", "%%%1") | |
if type(replaceValue) == "string" then | |
replaceValue = string.gsub(replaceValue, "[%%%(%)%.%+%-%*%?%[%^%$]", "%%%1") | |
local result = string.gsub(source, searchValue, replaceValue, 1) | |
return result | |
else | |
local result = string.gsub( | |
source, | |
searchValue, | |
function(match) return replaceValue(_G, match) end, | |
1 | |
) | |
return result | |
end | |
end | |
function __TS__StringSplit(source, separator, limit) | |
if limit == nil then | |
limit = 4294967295 | |
end | |
if limit == 0 then | |
return {} | |
end | |
local out = {} | |
local index = 0 | |
local count = 0 | |
if separator == nil or separator == "" then | |
while index < #source - 1 and count < limit do | |
out[count + 1] = string.sub(source, index + 1, index + 1) | |
count = count + 1 | |
index = index + 1 | |
end | |
else | |
local separatorLength = #separator | |
local nextIndex = ((string.find(source, separator, nil, true) or 0) - 1) | |
while nextIndex >= 0 and count < limit do | |
out[count + 1] = string.sub(source, index + 1, nextIndex) | |
count = count + 1 | |
index = nextIndex + separatorLength | |
nextIndex = ((string.find(source, separator, index + 1, true) or 0) - 1) | |
end | |
end | |
if count < limit then | |
out[count + 1] = string.sub(source, index + 1) | |
end | |
return out | |
end | |
function __TS__StringStartsWith(self, searchString, position) | |
if position == nil or position < 0 then | |
position = 0 | |
end | |
return string.sub(self, position + 1, #searchString + position) == searchString | |
end | |
function __TS__StringTrim(self) | |
local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1") | |
return result | |
end | |
function __TS__StringTrimEnd(self) | |
local result = string.gsub(self, "[%s ]*$", "") | |
return result | |
end | |
function __TS__StringTrimStart(self) | |
local result = string.gsub(self, "^[%s ]*", "") | |
return result | |
end | |
local ____symbolRegistry = {} | |
function __TS__SymbolRegistryFor(key) | |
if not ____symbolRegistry[key] then | |
____symbolRegistry[key] = __TS__Symbol(key) | |
end | |
return ____symbolRegistry[key] | |
end | |
function __TS__SymbolRegistryKeyFor(sym) | |
for key in pairs(____symbolRegistry) do | |
if ____symbolRegistry[key] == sym then | |
return key | |
end | |
end | |
end | |
function __TS__TypeOf(value) | |
local luaType = type(value) | |
if luaType == "table" then | |
return "object" | |
elseif luaType == "nil" then | |
return "undefined" | |
else | |
return luaType | |
end | |
end | |
end, | |
} | |
return require("Main") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment