Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 = {
- ["printer"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
- require("lualib_bundle");
- local ____exports = {}
- ____exports.default = __TS__Class()
- local Printer = ____exports.default
- Printer.name = "Printer"
- function Printer.prototype.____constructor(self)
- end
- function Printer.print(text, color)
- if color == nil then
- color = colours.white
- end
- if ____exports.default.monitor == nil then
- ____exports.default.monitor = peripheral.find("monitor")
- end
- if ____exports.default.monitor ~= nil then
- ____exports.default.monitor.setCursorPos(1, ____exports.default.line)
- ____exports.default.monitor.setTextColour(color)
- ____exports.default.monitor.write(text)
- ____exports.default.line = ____exports.default.line + 1
- else
- print(text)
- end
- end
- Printer.line = 1
- return ____exports
- end,
- ["testApi.Operatrs"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
- require("lualib_bundle");
- local ____exports = {}
- ____exports.default = __TS__Class()
- local Operators = ____exports.default
- Operators.name = "Operators"
- function Operators.prototype.____constructor(self, parent, data)
- self.text = ""
- self.notFlag = false
- self.parent = parent
- self.data = data
- end
- __TS__SetDescriptor(
- Operators.prototype,
- "to",
- {
- get = function(self)
- self.text = tostring(self.text) .. " be"
- return self
- end
- }
- )
- __TS__SetDescriptor(
- Operators.prototype,
- "be",
- {
- get = function(self)
- self.text = tostring(self.text) .. " be"
- return self
- end
- }
- )
- __TS__SetDescriptor(
- Operators.prototype,
- "am",
- {
- get = function(self)
- self.text = tostring(self.text) .. " am"
- return self
- end
- }
- )
- __TS__SetDescriptor(
- Operators.prototype,
- "is",
- {
- get = function(self)
- self.text = tostring(self.text) .. " is"
- return self
- end
- }
- )
- __TS__SetDescriptor(
- Operators.prototype,
- "are",
- {
- get = function(self)
- self.text = tostring(self.text) .. " are"
- return self
- end
- }
- )
- __TS__SetDescriptor(
- Operators.prototype,
- "not",
- {
- get = function(self)
- self.text = tostring(self.text) .. " not"
- self.notFlag = not self.notFlag
- return self
- end
- }
- )
- __TS__SetDescriptor(
- Operators.prototype,
- "null",
- {
- get = function(self)
- local result
- self.text = tostring(self.text) .. " nil"
- if self.notFlag == true then
- result = self.data ~= nil
- else
- result = self.data == nil
- end
- if result == false then
- self.parent.testResult = false
- end
- return "any"
- end
- }
- )
- function Operators.prototype.equal(self, value)
- local result
- self.text = tostring(self.text) .. " equal"
- if self.notFlag == true then
- result = self.data ~= value
- else
- result = self.data == value
- end
- if result == false then
- self.parent.testResult = false
- end
- end
- function Operators.prototype.equals(self, value)
- local result
- self.text = tostring(self.text) .. " equals"
- if self.notFlag == true then
- result = self.data ~= value
- else
- result = self.data == value
- end
- if result == false then
- self.parent.testResult = false
- end
- end
- return ____exports
- end,
- ["testApi.testApi"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
- require("lualib_bundle");
- local ____exports = {}
- local ____printer = require("printer")
- local Printer = ____printer.default
- local ____Operatrs = require("testApi.Operatrs")
- local Operators = ____Operatrs.default
- local Expect
- local Component = __TS__Class()
- Component.name = "Component"
- function Component.prototype.____constructor(self, title)
- self.deepLevel = 0
- self.title = title
- end
- function Component.prototype.setParent(self, parent)
- self.parent = parent
- self.deepLevel = self.parent.deepLevel + 1
- end
- function Component.prototype.isRoot(self)
- return self.parent == nil
- end
- function Component.prototype.generateSpacesByDeepLevel(self)
- local spaces = ""
- do
- local i = 0
- while i < self.deepLevel do
- spaces = tostring(spaces) .. " "
- i = i + 1
- end
- end
- return spaces
- end
- function Component.prototype.draw(self)
- Printer.print(
- tostring(
- self:generateSpacesByDeepLevel()
- ) .. tostring(self.title)
- )
- end
- local Describe = __TS__Class()
- Describe.name = "Describe"
- __TS__ClassExtends(Describe, Component)
- function Describe.prototype.____constructor(self, title, children)
- Component.prototype.____constructor(self, title)
- print(
- "Component Describe: " .. tostring(self.deepLevel)
- )
- self.children = children
- self:setAllChildrenParent()
- self:startTesting()
- end
- function Describe.prototype.setAllChildrenParent(self)
- __TS__ArrayForEach(
- self.children,
- function(____, child)
- child:setParent(self)
- end
- )
- end
- function Describe.prototype.startTesting(self)
- if self:isRoot() then
- self:draw()
- end
- end
- function Describe.prototype.draw(self)
- Component.prototype.draw(self)
- __TS__ArrayForEach(
- self.children,
- function(____, child) return child:draw() end
- )
- end
- ____exports.It = __TS__Class()
- local It = ____exports.It
- It.name = "It"
- __TS__ClassExtends(It, Component)
- function It.prototype.____constructor(self, title, testFunction)
- Component.prototype.____constructor(self, title)
- self.testResult = true
- print(
- "Component it: " .. tostring(self.deepLevel)
- )
- testFunction(
- nil,
- function(____, data)
- return __TS__New(Expect, self, data)
- end
- )
- end
- Expect = __TS__Class()
- Expect.name = "Expect"
- __TS__ClassExtends(Expect, Operators)
- function Expect.prototype.____constructor(self, parent, data)
- Operators.prototype.____constructor(self, parent, data)
- end
- function ____exports.describe(self, title, children)
- return __TS__New(Describe, title, children)
- end
- function ____exports.it(self, title, testFunction)
- return __TS__New(____exports.It, title, testFunction)
- end
- return ____exports
- end,
- ["main"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
- local ____exports = {}
- local ____testApi = require("testApi.testApi")
- local describe = ____testApi.describe
- local it = ____testApi.it
- describe(
- nil,
- "Test",
- {
- describe(
- nil,
- "Test 2",
- {
- it(
- nil,
- "should be zero",
- function(____, expect)
- expect(nil, 1).is:equal(0)
- end
- ),
- it(
- nil,
- "should be zero",
- function(____, expect)
- expect(nil, 1).is:equal(0)
- end
- ),
- it(
- nil,
- "should be zero",
- function(____, expect)
- expect(nil, 1).is:equal(0)
- end
- ),
- it(
- nil,
- "should be zero",
- function(____, expect)
- expect(nil, 1).is:equal(0)
- expect(nil, 2).is:equal(0)
- expect(nil, 3).is:equal(0)
- expect(nil, 4).is:equal(0)
- end
- ),
- it(
- nil,
- "should be zero",
- function(____, expect)
- expect(nil, 2).is:equal(2)
- expect(nil, 1).is:equal(0)
- end
- )
- }
- )
- }
- )
- return ____exports
- 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__ArrayIncludes(self, searchElement, fromIndex)
- if fromIndex == nil then
- fromIndex = 0
- end
- local len = #self
- local k = fromIndex
- if fromIndex < 0 then
- k = len + fromIndex
- end
- if k < 0 then
- k = 0
- end
- for i = k, len do
- if self[i + 1] == searchElement then
- return true
- end
- end
- return false
- 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 = {prototype = {}}
- c.prototype.__index = c.prototype
- c.prototype.constructor = c
- return c
- end
- function __TS__ClassExtends(target, base)
- target.____super = base
- local staticMetatable = setmetatable({__index = base}, base)
- setmetatable(target, staticMetatable)
- local baseMetatable = getmetatable(base)
- if baseMetatable then
- if type(baseMetatable.__index) == "function" then
- staticMetatable.__index = baseMetatable.__index
- end
- if type(baseMetatable.__newindex) == "function" then
- staticMetatable.__newindex = baseMetatable.__newindex
- end
- end
- setmetatable(target.prototype, base.prototype)
- if type(base.prototype.__index) == "function" then
- target.prototype.__index = base.prototype.__index
- end
- if type(base.prototype.__newindex) == "function" then
- target.prototype.__newindex = base.prototype.__newindex
- end
- 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 ____descriptorIndex(self, key)
- local value = rawget(self, key)
- if value ~= nil then
- return value
- end
- local metatable = getmetatable(self)
- while metatable do
- local rawResult = rawget(metatable, key)
- if rawResult ~= nil then
- return rawResult
- end
- local descriptors = rawget(metatable, "_descriptors")
- if descriptors then
- local descriptor = descriptors[key]
- if descriptor then
- if descriptor.get then
- return __TS__FunctionCall(descriptor.get, self)
- end
- return
- end
- end
- metatable = getmetatable(metatable)
- end
- end
- function ____descriptorNewindex(self, key, value)
- local metatable = getmetatable(self)
- while metatable do
- local descriptors = rawget(metatable, "_descriptors")
- if descriptors then
- local descriptor = descriptors[key]
- if descriptor then
- if descriptor.set then
- __TS__FunctionCall(descriptor.set, self, value)
- end
- return
- end
- end
- metatable = getmetatable(metatable)
- end
- rawset(self, key, value)
- end
- function __TS__SetDescriptor(metatable, prop, descriptor)
- if not metatable._descriptors then
- metatable._descriptors = {}
- end
- metatable._descriptors[prop] = descriptor
- if descriptor.get then
- metatable.__index = ____descriptorIndex
- end
- if descriptor.set then
- metatable.__newindex = ____descriptorNewindex
- end
- end
- function __TS__ObjectDefineProperty(object, prop, descriptor)
- local metatable = getmetatable(object)
- if not metatable then
- metatable = {}
- setmetatable(object, metatable)
- end
- __TS__SetDescriptor(metatable, prop, descriptor)
- return object
- 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 = "____"
- __TS__ClassExtends(____, Error)
- 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
- ____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 type(obj) == "table" 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__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
- ____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
- if ((thread == nil) and (message == nil)) and (level == nil) then
- trace = _G.__TS__originalTraceback()
- else
- trace = _G.__TS__originalTraceback(thread, message, level)
- end
- 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
- ____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")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement