Advertisement
AMONUWNA

Untitled

Mar 28th, 2020
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.41 KB | None | 0 0
  1.  
  2. local ____modules = {}
  3. local ____moduleCache = {}
  4. local ____originalRequire = require
  5. local function require(file)
  6. if ____moduleCache[file] then
  7. return ____moduleCache[file]
  8. end
  9. if ____modules[file] then
  10. ____moduleCache[file] = ____modules[file]()
  11. return ____moduleCache[file]
  12. else
  13. if ____originalRequire then
  14. return ____originalRequire(file)
  15. else
  16. error("module '" .. file .. "' not found")
  17. end
  18. end
  19. end
  20. ____modules = {
  21. ["printer"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
  22. require("lualib_bundle");
  23. local ____exports = {}
  24. ____exports.default = __TS__Class()
  25. local Printer = ____exports.default
  26. Printer.name = "Printer"
  27. function Printer.prototype.____constructor(self)
  28. end
  29. function Printer.print(text, color)
  30. if color == nil then
  31. color = colours.white
  32. end
  33. if ____exports.default.monitor == nil then
  34. ____exports.default.monitor = peripheral.find("monitor")
  35. end
  36. if ____exports.default.monitor ~= nil then
  37. ____exports.default.monitor.setCursorPos(1, ____exports.default.line)
  38. ____exports.default.monitor.setTextColour(color)
  39. ____exports.default.monitor.write(text)
  40. ____exports.default.line = ____exports.default.line + 1
  41. else
  42. print(text)
  43. end
  44. end
  45. Printer.line = 1
  46. return ____exports
  47. end,
  48. ["testApi.Operatrs"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
  49. require("lualib_bundle");
  50. local ____exports = {}
  51. ____exports.default = __TS__Class()
  52. local Operators = ____exports.default
  53. Operators.name = "Operators"
  54. function Operators.prototype.____constructor(self, parent, data)
  55. self.text = ""
  56. self.notFlag = false
  57. self.parent = parent
  58. self.data = data
  59. end
  60. __TS__SetDescriptor(
  61. Operators.prototype,
  62. "to",
  63. {
  64. get = function(self)
  65. self.text = tostring(self.text) .. " be"
  66. return self
  67. end
  68. }
  69. )
  70. __TS__SetDescriptor(
  71. Operators.prototype,
  72. "be",
  73. {
  74. get = function(self)
  75. self.text = tostring(self.text) .. " be"
  76. return self
  77. end
  78. }
  79. )
  80. __TS__SetDescriptor(
  81. Operators.prototype,
  82. "am",
  83. {
  84. get = function(self)
  85. self.text = tostring(self.text) .. " am"
  86. return self
  87. end
  88. }
  89. )
  90. __TS__SetDescriptor(
  91. Operators.prototype,
  92. "is",
  93. {
  94. get = function(self)
  95. self.text = tostring(self.text) .. " is"
  96. return self
  97. end
  98. }
  99. )
  100. __TS__SetDescriptor(
  101. Operators.prototype,
  102. "are",
  103. {
  104. get = function(self)
  105. self.text = tostring(self.text) .. " are"
  106. return self
  107. end
  108. }
  109. )
  110. __TS__SetDescriptor(
  111. Operators.prototype,
  112. "not",
  113. {
  114. get = function(self)
  115. self.text = tostring(self.text) .. " not"
  116. self.notFlag = not self.notFlag
  117. return self
  118. end
  119. }
  120. )
  121. __TS__SetDescriptor(
  122. Operators.prototype,
  123. "null",
  124. {
  125. get = function(self)
  126. local result
  127. self.text = tostring(self.text) .. " nil"
  128. if self.notFlag == true then
  129. result = self.data ~= nil
  130. else
  131. result = self.data == nil
  132. end
  133. if result == false then
  134. self.parent.testResult = false
  135. end
  136. return "any"
  137. end
  138. }
  139. )
  140. function Operators.prototype.equal(self, value)
  141. local result
  142. self.text = tostring(self.text) .. " equal"
  143. if self.notFlag == true then
  144. result = self.data ~= value
  145. else
  146. result = self.data == value
  147. end
  148. if result == false then
  149. self.parent.testResult = false
  150. end
  151. end
  152. function Operators.prototype.equals(self, value)
  153. local result
  154. self.text = tostring(self.text) .. " equals"
  155. if self.notFlag == true then
  156. result = self.data ~= value
  157. else
  158. result = self.data == value
  159. end
  160. if result == false then
  161. self.parent.testResult = false
  162. end
  163. end
  164. return ____exports
  165. end,
  166. ["testApi.testApi"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
  167. require("lualib_bundle");
  168. local ____exports = {}
  169. local ____printer = require("printer")
  170. local Printer = ____printer.default
  171. local ____Operatrs = require("testApi.Operatrs")
  172. local Operators = ____Operatrs.default
  173. local Expect
  174. local Component = __TS__Class()
  175. Component.name = "Component"
  176. function Component.prototype.____constructor(self, title)
  177. self.deepLevel = 0
  178. self.title = title
  179. end
  180. function Component.prototype.setParent(self, parent)
  181. self.parent = parent
  182. self.deepLevel = self.parent.deepLevel + 1
  183. end
  184. function Component.prototype.isRoot(self)
  185. return self.parent == nil
  186. end
  187. function Component.prototype.generateSpacesByDeepLevel(self)
  188. local spaces = ""
  189. do
  190. local i = 0
  191. while i < self.deepLevel do
  192. spaces = tostring(spaces) .. " "
  193. i = i + 1
  194. end
  195. end
  196. return spaces
  197. end
  198. function Component.prototype.draw(self)
  199. Printer.print(
  200. tostring(
  201. self:generateSpacesByDeepLevel()
  202. ) .. tostring(self.title)
  203. )
  204. end
  205. local Describe = __TS__Class()
  206. Describe.name = "Describe"
  207. __TS__ClassExtends(Describe, Component)
  208. function Describe.prototype.____constructor(self, title, children)
  209. Component.prototype.____constructor(self, title)
  210. print(
  211. "Component Describe: " .. tostring(self.deepLevel)
  212. )
  213. self.children = children
  214. self:setAllChildrenParent()
  215. self:startTesting()
  216. end
  217. function Describe.prototype.setAllChildrenParent(self)
  218. __TS__ArrayForEach(
  219. self.children,
  220. function(____, child)
  221. child:setParent(self)
  222. end
  223. )
  224. end
  225. function Describe.prototype.startTesting(self)
  226. if self:isRoot() then
  227. self:draw()
  228. end
  229. end
  230. function Describe.prototype.draw(self)
  231. Component.prototype.draw(self)
  232. __TS__ArrayForEach(
  233. self.children,
  234. function(____, child) return child:draw() end
  235. )
  236. end
  237. ____exports.It = __TS__Class()
  238. local It = ____exports.It
  239. It.name = "It"
  240. __TS__ClassExtends(It, Component)
  241. function It.prototype.____constructor(self, title, testFunction)
  242. Component.prototype.____constructor(self, title)
  243. self.testResult = true
  244. print(
  245. "Component it: " .. tostring(self.deepLevel)
  246. )
  247. testFunction(
  248. nil,
  249. function(____, data)
  250. return __TS__New(Expect, self, data)
  251. end
  252. )
  253. end
  254. Expect = __TS__Class()
  255. Expect.name = "Expect"
  256. __TS__ClassExtends(Expect, Operators)
  257. function Expect.prototype.____constructor(self, parent, data)
  258. Operators.prototype.____constructor(self, parent, data)
  259. end
  260. function ____exports.describe(self, title, children)
  261. return __TS__New(Describe, title, children)
  262. end
  263. function ____exports.it(self, title, testFunction)
  264. return __TS__New(____exports.It, title, testFunction)
  265. end
  266. return ____exports
  267. end,
  268. ["main"] = function() --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
  269. local ____exports = {}
  270. local ____testApi = require("testApi.testApi")
  271. local describe = ____testApi.describe
  272. local it = ____testApi.it
  273. describe(
  274. nil,
  275. "Test",
  276. {
  277. describe(
  278. nil,
  279. "Test 2",
  280. {
  281. it(
  282. nil,
  283. "should be zero",
  284. function(____, expect)
  285. expect(nil, 1).is:equal(0)
  286. end
  287. ),
  288. it(
  289. nil,
  290. "should be zero",
  291. function(____, expect)
  292. expect(nil, 1).is:equal(0)
  293. end
  294. ),
  295. it(
  296. nil,
  297. "should be zero",
  298. function(____, expect)
  299. expect(nil, 1).is:equal(0)
  300. end
  301. ),
  302. it(
  303. nil,
  304. "should be zero",
  305. function(____, expect)
  306. expect(nil, 1).is:equal(0)
  307. expect(nil, 2).is:equal(0)
  308. expect(nil, 3).is:equal(0)
  309. expect(nil, 4).is:equal(0)
  310. end
  311. ),
  312. it(
  313. nil,
  314. "should be zero",
  315. function(____, expect)
  316. expect(nil, 2).is:equal(2)
  317. expect(nil, 1).is:equal(0)
  318. end
  319. )
  320. }
  321. )
  322. }
  323. )
  324. return ____exports
  325. end,
  326. ["lualib_bundle"] = function() function __TS__ArrayConcat(arr1, ...)
  327. local args = {...}
  328. local out = {}
  329. for ____, val in ipairs(arr1) do
  330. out[#out + 1] = val
  331. end
  332. for ____, arg in ipairs(args) do
  333. if pcall(
  334. function() return #arg end
  335. ) and (type(arg) ~= "string") then
  336. local argAsArray = arg
  337. for ____, val in ipairs(argAsArray) do
  338. out[#out + 1] = val
  339. end
  340. else
  341. out[#out + 1] = arg
  342. end
  343. end
  344. return out
  345. end
  346.  
  347. function __TS__ArrayEvery(arr, callbackfn)
  348. do
  349. local i = 0
  350. while i < #arr do
  351. if not callbackfn(_G, arr[i + 1], i, arr) then
  352. return false
  353. end
  354. i = i + 1
  355. end
  356. end
  357. return true
  358. end
  359.  
  360. function __TS__ArrayFilter(arr, callbackfn)
  361. local result = {}
  362. do
  363. local i = 0
  364. while i < #arr do
  365. if callbackfn(_G, arr[i + 1], i, arr) then
  366. result[#result + 1] = arr[i + 1]
  367. end
  368. i = i + 1
  369. end
  370. end
  371. return result
  372. end
  373.  
  374. function __TS__ArrayForEach(arr, callbackFn)
  375. do
  376. local i = 0
  377. while i < #arr do
  378. callbackFn(_G, arr[i + 1], i, arr)
  379. i = i + 1
  380. end
  381. end
  382. end
  383.  
  384. function __TS__ArrayFind(arr, predicate)
  385. local len = #arr
  386. local k = 0
  387. while k < len do
  388. local elem = arr[k + 1]
  389. if predicate(_G, elem, k, arr) then
  390. return elem
  391. end
  392. k = k + 1
  393. end
  394. return nil
  395. end
  396.  
  397. function __TS__ArrayFindIndex(arr, callbackFn)
  398. do
  399. local i = 0
  400. local len = #arr
  401. while i < len do
  402. if callbackFn(_G, arr[i + 1], i, arr) then
  403. return i
  404. end
  405. i = i + 1
  406. end
  407. end
  408. return -1
  409. end
  410.  
  411. function __TS__ArrayIncludes(self, searchElement, fromIndex)
  412. if fromIndex == nil then
  413. fromIndex = 0
  414. end
  415. local len = #self
  416. local k = fromIndex
  417. if fromIndex < 0 then
  418. k = len + fromIndex
  419. end
  420. if k < 0 then
  421. k = 0
  422. end
  423. for i = k, len do
  424. if self[i + 1] == searchElement then
  425. return true
  426. end
  427. end
  428. return false
  429. end
  430.  
  431. function __TS__ArrayIndexOf(arr, searchElement, fromIndex)
  432. local len = #arr
  433. if len == 0 then
  434. return -1
  435. end
  436. local n = 0
  437. if fromIndex then
  438. n = fromIndex
  439. end
  440. if n >= len then
  441. return -1
  442. end
  443. local k
  444. if n >= 0 then
  445. k = n
  446. else
  447. k = len + n
  448. if k < 0 then
  449. k = 0
  450. end
  451. end
  452. do
  453. local i = k
  454. while i < len do
  455. if arr[i + 1] == searchElement then
  456. return i
  457. end
  458. i = i + 1
  459. end
  460. end
  461. return -1
  462. end
  463.  
  464. function __TS__ArrayMap(arr, callbackfn)
  465. local newArray = {}
  466. do
  467. local i = 0
  468. while i < #arr do
  469. newArray[i + 1] = callbackfn(_G, arr[i + 1], i, arr)
  470. i = i + 1
  471. end
  472. end
  473. return newArray
  474. end
  475.  
  476. function __TS__ArrayPush(arr, ...)
  477. local items = {...}
  478. for ____, item in ipairs(items) do
  479. arr[#arr + 1] = item
  480. end
  481. return #arr
  482. end
  483.  
  484. function __TS__ArrayReduce(arr, callbackFn, ...)
  485. local len = #arr
  486. local k = 0
  487. local accumulator = nil
  488. if select("#", ...) ~= 0 then
  489. accumulator = select(1, ...)
  490. elseif len > 0 then
  491. accumulator = arr[1]
  492. k = 1
  493. else
  494. error("Reduce of empty array with no initial value", 0)
  495. end
  496. for i = k, len - 1 do
  497. accumulator = callbackFn(_G, accumulator, arr[i + 1], i, arr)
  498. end
  499. return accumulator
  500. end
  501.  
  502. function __TS__ArrayReduceRight(arr, callbackFn, ...)
  503. local len = #arr
  504. local k = len - 1
  505. local accumulator = nil
  506. if select("#", ...) ~= 0 then
  507. accumulator = select(1, ...)
  508. elseif len > 0 then
  509. accumulator = arr[k + 1]
  510. k = k - 1
  511. else
  512. error("Reduce of empty array with no initial value", 0)
  513. end
  514. for i = k, 0, -1 do
  515. accumulator = callbackFn(_G, accumulator, arr[i + 1], i, arr)
  516. end
  517. return accumulator
  518. end
  519.  
  520. function __TS__ArrayReverse(arr)
  521. local i = 0
  522. local j = #arr - 1
  523. while i < j do
  524. local temp = arr[j + 1]
  525. arr[j + 1] = arr[i + 1]
  526. arr[i + 1] = temp
  527. i = i + 1
  528. j = j - 1
  529. end
  530. return arr
  531. end
  532.  
  533. function __TS__ArrayShift(arr)
  534. return table.remove(arr, 1)
  535. end
  536.  
  537. function __TS__ArrayUnshift(arr, ...)
  538. local items = {...}
  539. do
  540. local i = #items - 1
  541. while i >= 0 do
  542. table.insert(arr, 1, items[i + 1])
  543. i = i - 1
  544. end
  545. end
  546. return #arr
  547. end
  548.  
  549. function __TS__ArraySort(arr, compareFn)
  550. if compareFn ~= nil then
  551. table.sort(
  552. arr,
  553. function(a, b) return compareFn(_G, a, b) < 0 end
  554. )
  555. else
  556. table.sort(arr)
  557. end
  558. return arr
  559. end
  560.  
  561. function __TS__ArraySlice(list, first, last)
  562. local len = #list
  563. local relativeStart = first or 0
  564. local k
  565. if relativeStart < 0 then
  566. k = math.max(len + relativeStart, 0)
  567. else
  568. k = math.min(relativeStart, len)
  569. end
  570. local relativeEnd = last
  571. if last == nil then
  572. relativeEnd = len
  573. end
  574. local final
  575. if relativeEnd < 0 then
  576. final = math.max(len + relativeEnd, 0)
  577. else
  578. final = math.min(relativeEnd, len)
  579. end
  580. local out = {}
  581. local n = 0
  582. while k < final do
  583. out[n + 1] = list[k + 1]
  584. k = k + 1
  585. n = n + 1
  586. end
  587. return out
  588. end
  589.  
  590. function __TS__ArraySome(arr, callbackfn)
  591. do
  592. local i = 0
  593. while i < #arr do
  594. if callbackfn(_G, arr[i + 1], i, arr) then
  595. return true
  596. end
  597. i = i + 1
  598. end
  599. end
  600. return false
  601. end
  602.  
  603. function __TS__ArraySplice(list, ...)
  604. local len = #list
  605. local actualArgumentCount = select("#", ...)
  606. local start = select(1, ...)
  607. local deleteCount = select(2, ...)
  608. local actualStart
  609. if start < 0 then
  610. actualStart = math.max(len + start, 0)
  611. else
  612. actualStart = math.min(start, len)
  613. end
  614. local itemCount = math.max(actualArgumentCount - 2, 0)
  615. local actualDeleteCount
  616. if actualArgumentCount == 0 then
  617. actualDeleteCount = 0
  618. elseif actualArgumentCount == 1 then
  619. actualDeleteCount = len - actualStart
  620. else
  621. actualDeleteCount = math.min(
  622. math.max(deleteCount or 0, 0),
  623. len - actualStart
  624. )
  625. end
  626. local out = {}
  627. do
  628. local k = 0
  629. while k < actualDeleteCount do
  630. local from = actualStart + k
  631. if list[from + 1] then
  632. out[k + 1] = list[from + 1]
  633. end
  634. k = k + 1
  635. end
  636. end
  637. if itemCount < actualDeleteCount then
  638. do
  639. local k = actualStart
  640. while k < (len - actualDeleteCount) do
  641. local from = k + actualDeleteCount
  642. local to = k + itemCount
  643. if list[from + 1] then
  644. list[to + 1] = list[from + 1]
  645. else
  646. list[to + 1] = nil
  647. end
  648. k = k + 1
  649. end
  650. end
  651. do
  652. local k = len
  653. while k > ((len - actualDeleteCount) + itemCount) do
  654. list[k] = nil
  655. k = k - 1
  656. end
  657. end
  658. elseif itemCount > actualDeleteCount then
  659. do
  660. local k = len - actualDeleteCount
  661. while k > actualStart do
  662. local from = (k + actualDeleteCount) - 1
  663. local to = (k + itemCount) - 1
  664. if list[from + 1] then
  665. list[to + 1] = list[from + 1]
  666. else
  667. list[to + 1] = nil
  668. end
  669. k = k - 1
  670. end
  671. end
  672. end
  673. local j = actualStart
  674. for i = 3, actualArgumentCount do
  675. list[j + 1] = select(i, ...)
  676. j = j + 1
  677. end
  678. do
  679. local k = #list - 1
  680. while k >= ((len - actualDeleteCount) + itemCount) do
  681. list[k + 1] = nil
  682. k = k - 1
  683. end
  684. end
  685. return out
  686. end
  687.  
  688. function __TS__ArrayToObject(array)
  689. local object = {}
  690. do
  691. local i = 0
  692. while i < #array do
  693. object[i] = array[i + 1]
  694. i = i + 1
  695. end
  696. end
  697. return object
  698. end
  699.  
  700. function __TS__ArrayFlat(array, depth)
  701. if depth == nil then
  702. depth = 1
  703. end
  704. local result = {}
  705. for ____, value in ipairs(array) do
  706. if ((depth > 0) and (type(value) == "table")) and ((value[1] ~= nil) or (next(value, nil) == nil)) then
  707. result = __TS__ArrayConcat(
  708. result,
  709. __TS__ArrayFlat(value, depth - 1)
  710. )
  711. else
  712. result[#result + 1] = value
  713. end
  714. end
  715. return result
  716. end
  717.  
  718. function __TS__ArrayFlatMap(array, callback)
  719. local result = {}
  720. do
  721. local i = 0
  722. while i < #array do
  723. local value = callback(_G, array[i + 1], i, array)
  724. if (type(value) == "table") and ((value[1] ~= nil) or (next(value, nil) == nil)) then
  725. result = __TS__ArrayConcat(result, value)
  726. else
  727. result[#result + 1] = value
  728. end
  729. i = i + 1
  730. end
  731. end
  732. return result
  733. end
  734.  
  735. function __TS__ArraySetLength(arr, length)
  736. if (((length < 0) or (length ~= length)) or (length == math.huge)) or (math.floor(length) ~= length) then
  737. error(
  738. "invalid array length: " .. tostring(length),
  739. 0
  740. )
  741. end
  742. do
  743. local i = #arr - 1
  744. while i >= length do
  745. arr[i + 1] = nil
  746. i = i - 1
  747. end
  748. end
  749. return length
  750. end
  751.  
  752. function __TS__Class(self)
  753. local c = {prototype = {}}
  754. c.prototype.__index = c.prototype
  755. c.prototype.constructor = c
  756. return c
  757. end
  758.  
  759. function __TS__ClassExtends(target, base)
  760. target.____super = base
  761. local staticMetatable = setmetatable({__index = base}, base)
  762. setmetatable(target, staticMetatable)
  763. local baseMetatable = getmetatable(base)
  764. if baseMetatable then
  765. if type(baseMetatable.__index) == "function" then
  766. staticMetatable.__index = baseMetatable.__index
  767. end
  768. if type(baseMetatable.__newindex) == "function" then
  769. staticMetatable.__newindex = baseMetatable.__newindex
  770. end
  771. end
  772. setmetatable(target.prototype, base.prototype)
  773. if type(base.prototype.__index) == "function" then
  774. target.prototype.__index = base.prototype.__index
  775. end
  776. if type(base.prototype.__newindex) == "function" then
  777. target.prototype.__newindex = base.prototype.__newindex
  778. end
  779. end
  780.  
  781. function __TS__Decorate(decorators, target, key, desc)
  782. local result = target
  783. do
  784. local i = #decorators
  785. while i >= 0 do
  786. local decorator = decorators[i + 1]
  787. if decorator then
  788. local oldResult = result
  789. if key == nil then
  790. result = decorator(_G, result)
  791. elseif desc ~= nil then
  792. result = decorator(_G, target, key, result)
  793. else
  794. result = decorator(_G, target, key)
  795. end
  796. result = result or oldResult
  797. end
  798. i = i - 1
  799. end
  800. end
  801. return result
  802. end
  803.  
  804. function ____descriptorIndex(self, key)
  805. local value = rawget(self, key)
  806. if value ~= nil then
  807. return value
  808. end
  809. local metatable = getmetatable(self)
  810. while metatable do
  811. local rawResult = rawget(metatable, key)
  812. if rawResult ~= nil then
  813. return rawResult
  814. end
  815. local descriptors = rawget(metatable, "_descriptors")
  816. if descriptors then
  817. local descriptor = descriptors[key]
  818. if descriptor then
  819. if descriptor.get then
  820. return __TS__FunctionCall(descriptor.get, self)
  821. end
  822. return
  823. end
  824. end
  825. metatable = getmetatable(metatable)
  826. end
  827. end
  828. function ____descriptorNewindex(self, key, value)
  829. local metatable = getmetatable(self)
  830. while metatable do
  831. local descriptors = rawget(metatable, "_descriptors")
  832. if descriptors then
  833. local descriptor = descriptors[key]
  834. if descriptor then
  835. if descriptor.set then
  836. __TS__FunctionCall(descriptor.set, self, value)
  837. end
  838. return
  839. end
  840. end
  841. metatable = getmetatable(metatable)
  842. end
  843. rawset(self, key, value)
  844. end
  845. function __TS__SetDescriptor(metatable, prop, descriptor)
  846. if not metatable._descriptors then
  847. metatable._descriptors = {}
  848. end
  849. metatable._descriptors[prop] = descriptor
  850. if descriptor.get then
  851. metatable.__index = ____descriptorIndex
  852. end
  853. if descriptor.set then
  854. metatable.__newindex = ____descriptorNewindex
  855. end
  856. end
  857. function __TS__ObjectDefineProperty(object, prop, descriptor)
  858. local metatable = getmetatable(object)
  859. if not metatable then
  860. metatable = {}
  861. setmetatable(object, metatable)
  862. end
  863. __TS__SetDescriptor(metatable, prop, descriptor)
  864. return object
  865. end
  866.  
  867. function __TS__New(target, ...)
  868. local instance = setmetatable({}, target.prototype)
  869. instance:____constructor(...)
  870. return instance
  871. end
  872.  
  873. function __TS__FunctionCall(fn, thisArg, ...)
  874. local args = {...}
  875. return fn(
  876. thisArg,
  877. (unpack or table.unpack)(args)
  878. )
  879. end
  880.  
  881. function __TS__GetErrorStack(self, constructor)
  882. local level = 1
  883. while true do
  884. local info = debug.getinfo(level, "f")
  885. level = level + 1
  886. if not info then
  887. level = 1
  888. break
  889. elseif info.func == constructor then
  890. break
  891. end
  892. end
  893. return debug.traceback(nil, level)
  894. end
  895. function __TS__WrapErrorToString(self, getDescription)
  896. return function(self)
  897. local description = __TS__FunctionCall(getDescription, self)
  898. local caller = debug.getinfo(3, "f")
  899. if (_VERSION == "Lua 5.1") or (caller and (caller.func ~= error)) then
  900. return description
  901. else
  902. return (tostring(description) .. "\n") .. tostring(self.stack)
  903. end
  904. end
  905. end
  906. function __TS__InitErrorClass(self, Type, name)
  907. Type.name = name
  908. return setmetatable(
  909. Type,
  910. {
  911. __call = function(____, _self, message) return __TS__New(Type, message) end
  912. }
  913. )
  914. end
  915. Error = __TS__InitErrorClass(
  916. _G,
  917. (function()
  918. local ____ = __TS__Class()
  919. ____.name = "____"
  920. function ____.prototype.____constructor(self, message)
  921. if message == nil then
  922. message = ""
  923. end
  924. self.message = message
  925. self.name = "Error"
  926. self.stack = __TS__GetErrorStack(_G, self.constructor.new)
  927. local metatable = getmetatable(self)
  928. if not metatable.__errorToStringPatched then
  929. metatable.__errorToStringPatched = true
  930. metatable.__tostring = __TS__WrapErrorToString(_G, metatable.__tostring)
  931. end
  932. end
  933. function ____.prototype.__tostring(self)
  934. return (((self.message ~= "") and (function() return (tostring(self.name) .. ": ") .. tostring(self.message) end)) or (function() return self.name end))()
  935. end
  936. return ____
  937. end)(),
  938. "Error"
  939. )
  940. for ____, errorName in ipairs({"RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError"}) do
  941. _G[errorName] = __TS__InitErrorClass(
  942. _G,
  943. (function()
  944. local ____ = __TS__Class()
  945. ____.name = "____"
  946. __TS__ClassExtends(____, Error)
  947. function ____.prototype.____constructor(self, ...)
  948. Error.prototype.____constructor(self, ...)
  949. self.name = errorName
  950. end
  951. return ____
  952. end)(),
  953. errorName
  954. )
  955. end
  956.  
  957. function __TS__FunctionApply(fn, thisArg, args)
  958. if args then
  959. return fn(
  960. thisArg,
  961. (unpack or table.unpack)(args)
  962. )
  963. else
  964. return fn(thisArg)
  965. end
  966. end
  967.  
  968. function __TS__FunctionBind(fn, thisArg, ...)
  969. local boundArgs = {...}
  970. return function(____, ...)
  971. local args = {...}
  972. do
  973. local i = 0
  974. while i < #boundArgs do
  975. table.insert(args, i + 1, boundArgs[i + 1])
  976. i = i + 1
  977. end
  978. end
  979. return fn(
  980. thisArg,
  981. (unpack or table.unpack)(args)
  982. )
  983. end
  984. end
  985.  
  986. ____symbolMetatable = {
  987. __tostring = function(self)
  988. if self.description == nil then
  989. return "Symbol()"
  990. else
  991. return ("Symbol(" .. tostring(self.description)) .. ")"
  992. end
  993. end
  994. }
  995. function __TS__Symbol(description)
  996. return setmetatable({description = description}, ____symbolMetatable)
  997. end
  998. Symbol = {
  999. iterator = __TS__Symbol("Symbol.iterator"),
  1000. hasInstance = __TS__Symbol("Symbol.hasInstance"),
  1001. species = __TS__Symbol("Symbol.species"),
  1002. toStringTag = __TS__Symbol("Symbol.toStringTag")
  1003. }
  1004.  
  1005. function __TS__InstanceOf(obj, classTbl)
  1006. if type(classTbl) ~= "table" then
  1007. error("Right-hand side of 'instanceof' is not an object", 0)
  1008. end
  1009. if classTbl[Symbol.hasInstance] ~= nil then
  1010. return not (not classTbl[Symbol.hasInstance](classTbl, obj))
  1011. end
  1012. if type(obj) == "table" then
  1013. local luaClass = obj.constructor
  1014. while luaClass ~= nil do
  1015. if luaClass == classTbl then
  1016. return true
  1017. end
  1018. luaClass = luaClass.____super
  1019. end
  1020. end
  1021. return false
  1022. end
  1023.  
  1024. function __TS__InstanceOfObject(value)
  1025. local valueType = type(value)
  1026. return (valueType == "table") or (valueType == "function")
  1027. end
  1028.  
  1029. function __TS__Iterator(iterable)
  1030. if iterable[Symbol.iterator] then
  1031. local iterator = iterable[Symbol.iterator](iterable)
  1032. return function()
  1033. local result = iterator:next()
  1034. if not result.done then
  1035. return result.value
  1036. else
  1037. return nil
  1038. end
  1039. end
  1040. else
  1041. local i = 0
  1042. return function()
  1043. i = i + 1
  1044. return iterable[i]
  1045. end
  1046. end
  1047. end
  1048.  
  1049. Map = (function()
  1050. local Map = __TS__Class()
  1051. Map.name = "Map"
  1052. function Map.prototype.____constructor(self, entries)
  1053. self[Symbol.toStringTag] = "Map"
  1054. self.items = {}
  1055. self.size = 0
  1056. self.nextKey = {}
  1057. self.previousKey = {}
  1058. if entries == nil then
  1059. return
  1060. end
  1061. local iterable = entries
  1062. if iterable[Symbol.iterator] then
  1063. local iterator = iterable[Symbol.iterator](iterable)
  1064. while true do
  1065. local result = iterator:next()
  1066. if result.done then
  1067. break
  1068. end
  1069. local value = result.value
  1070. self:set(value[1], value[2])
  1071. end
  1072. else
  1073. local array = entries
  1074. for ____, kvp in ipairs(array) do
  1075. self:set(kvp[1], kvp[2])
  1076. end
  1077. end
  1078. end
  1079. function Map.prototype.clear(self)
  1080. self.items = {}
  1081. self.nextKey = {}
  1082. self.previousKey = {}
  1083. self.firstKey = nil
  1084. self.lastKey = nil
  1085. self.size = 0
  1086. return
  1087. end
  1088. function Map.prototype.delete(self, key)
  1089. local contains = self:has(key)
  1090. if contains then
  1091. self.size = self.size - 1
  1092. local next = self.nextKey[key]
  1093. local previous = self.previousKey[key]
  1094. if next and previous then
  1095. self.nextKey[previous] = next
  1096. self.previousKey[next] = previous
  1097. elseif next then
  1098. self.firstKey = next
  1099. self.previousKey[next] = nil
  1100. elseif previous then
  1101. self.lastKey = previous
  1102. self.nextKey[previous] = nil
  1103. else
  1104. self.firstKey = nil
  1105. self.lastKey = nil
  1106. end
  1107. self.nextKey[key] = nil
  1108. self.previousKey[key] = nil
  1109. end
  1110. self.items[key] = nil
  1111. return contains
  1112. end
  1113. function Map.prototype.forEach(self, callback)
  1114. for key in __TS__Iterator(
  1115. self:keys()
  1116. ) do
  1117. callback(_G, self.items[key], key, self)
  1118. end
  1119. return
  1120. end
  1121. function Map.prototype.get(self, key)
  1122. return self.items[key]
  1123. end
  1124. function Map.prototype.has(self, key)
  1125. return (self.nextKey[key] ~= nil) or (self.lastKey == key)
  1126. end
  1127. function Map.prototype.set(self, key, value)
  1128. local isNewValue = not self:has(key)
  1129. if isNewValue then
  1130. self.size = self.size + 1
  1131. end
  1132. self.items[key] = value
  1133. if self.firstKey == nil then
  1134. self.firstKey = key
  1135. self.lastKey = key
  1136. elseif isNewValue then
  1137. self.nextKey[self.lastKey] = key
  1138. self.previousKey[key] = self.lastKey
  1139. self.lastKey = key
  1140. end
  1141. return self
  1142. end
  1143. Map.prototype[Symbol.iterator] = function(self)
  1144. return self:entries()
  1145. end
  1146. function Map.prototype.entries(self)
  1147. local items = self.items
  1148. local nextKey = self.nextKey
  1149. local key = self.firstKey
  1150. return {
  1151. [Symbol.iterator] = function(self)
  1152. return self
  1153. end,
  1154. next = function(self)
  1155. local result = {done = not key, value = {key, items[key]}}
  1156. key = nextKey[key]
  1157. return result
  1158. end
  1159. }
  1160. end
  1161. function Map.prototype.keys(self)
  1162. local nextKey = self.nextKey
  1163. local key = self.firstKey
  1164. return {
  1165. [Symbol.iterator] = function(self)
  1166. return self
  1167. end,
  1168. next = function(self)
  1169. local result = {done = not key, value = key}
  1170. key = nextKey[key]
  1171. return result
  1172. end
  1173. }
  1174. end
  1175. function Map.prototype.values(self)
  1176. local items = self.items
  1177. local nextKey = self.nextKey
  1178. local key = self.firstKey
  1179. return {
  1180. [Symbol.iterator] = function(self)
  1181. return self
  1182. end,
  1183. next = function(self)
  1184. local result = {done = not key, value = items[key]}
  1185. key = nextKey[key]
  1186. return result
  1187. end
  1188. }
  1189. end
  1190. Map[Symbol.species] = Map
  1191. return Map
  1192. end)()
  1193.  
  1194. function __TS__Number(value)
  1195. local valueType = type(value)
  1196. if valueType == "number" then
  1197. return value
  1198. elseif valueType == "string" then
  1199. local numberValue = tonumber(value)
  1200. if numberValue then
  1201. return numberValue
  1202. end
  1203. if value == "Infinity" then
  1204. return math.huge
  1205. end
  1206. if value == "-Infinity" then
  1207. return -math.huge
  1208. end
  1209. local stringWithoutSpaces = string.gsub(value, "%s", "")
  1210. if stringWithoutSpaces == "" then
  1211. return 0
  1212. end
  1213. return 0 / 0
  1214. elseif valueType == "boolean" then
  1215. return (value and 1) or 0
  1216. else
  1217. return 0 / 0
  1218. end
  1219. end
  1220.  
  1221. function __TS__NumberIsFinite(value)
  1222. return (((type(value) == "number") and (value == value)) and (value ~= math.huge)) and (value ~= -math.huge)
  1223. end
  1224.  
  1225. function __TS__NumberIsNaN(value)
  1226. return value ~= value
  1227. end
  1228.  
  1229. ____radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
  1230. function __TS__NumberToString(self, radix)
  1231. if ((((radix == nil) or (radix == 10)) or (self == math.huge)) or (self == -math.huge)) or (self ~= self) then
  1232. return tostring(self)
  1233. end
  1234. radix = math.floor(radix)
  1235. if (radix < 2) or (radix > 36) then
  1236. error("toString() radix argument must be between 2 and 36", 0)
  1237. end
  1238. local integer, fraction = math.modf(
  1239. math.abs(self)
  1240. )
  1241. local result = ""
  1242. if radix == 8 then
  1243. result = string.format("%o", integer)
  1244. elseif radix == 16 then
  1245. result = string.format("%x", integer)
  1246. else
  1247. repeat
  1248. do
  1249. result = tostring(
  1250. string.sub(____radixChars, (integer % radix) + 1, (integer % radix) + 1)
  1251. ) .. tostring(result)
  1252. integer = math.floor(integer / radix)
  1253. end
  1254. until not (integer ~= 0)
  1255. end
  1256. if fraction ~= 0 then
  1257. result = tostring(result) .. "."
  1258. local delta = 1e-16
  1259. repeat
  1260. do
  1261. fraction = fraction * radix
  1262. delta = delta * radix
  1263. local digit = math.floor(fraction)
  1264. result = tostring(result) .. tostring(
  1265. string.sub(____radixChars, digit + 1, digit + 1)
  1266. )
  1267. fraction = fraction - digit
  1268. end
  1269. until not (fraction >= delta)
  1270. end
  1271. if self < 0 then
  1272. result = "-" .. tostring(result)
  1273. end
  1274. return result
  1275. end
  1276.  
  1277. function __TS__ObjectAssign(to, ...)
  1278. local sources = {...}
  1279. if to == nil then
  1280. return to
  1281. end
  1282. for ____, source in ipairs(sources) do
  1283. for key in pairs(source) do
  1284. to[key] = source[key]
  1285. end
  1286. end
  1287. return to
  1288. end
  1289.  
  1290. function __TS__ObjectEntries(obj)
  1291. local result = {}
  1292. for key in pairs(obj) do
  1293. result[#result + 1] = {key, obj[key]}
  1294. end
  1295. return result
  1296. end
  1297.  
  1298. function __TS__ObjectFromEntries(entries)
  1299. local obj = {}
  1300. local iterable = entries
  1301. if iterable[Symbol.iterator] then
  1302. local iterator = iterable[Symbol.iterator](iterable)
  1303. while true do
  1304. local result = iterator:next()
  1305. if result.done then
  1306. break
  1307. end
  1308. local value = result.value
  1309. obj[value[1]] = value[2]
  1310. end
  1311. else
  1312. for ____, entry in ipairs(entries) do
  1313. obj[entry[1]] = entry[2]
  1314. end
  1315. end
  1316. return obj
  1317. end
  1318.  
  1319. function __TS__ObjectKeys(obj)
  1320. local result = {}
  1321. for key in pairs(obj) do
  1322. result[#result + 1] = key
  1323. end
  1324. return result
  1325. end
  1326.  
  1327. function __TS__ObjectRest(target, usedProperties)
  1328. local result = {}
  1329. for property in pairs(target) do
  1330. if not usedProperties[property] then
  1331. result[property] = target[property]
  1332. end
  1333. end
  1334. return result
  1335. end
  1336.  
  1337. function __TS__ObjectValues(obj)
  1338. local result = {}
  1339. for key in pairs(obj) do
  1340. result[#result + 1] = obj[key]
  1341. end
  1342. return result
  1343. end
  1344.  
  1345. Set = (function()
  1346. local Set = __TS__Class()
  1347. Set.name = "Set"
  1348. function Set.prototype.____constructor(self, values)
  1349. self[Symbol.toStringTag] = "Set"
  1350. self.size = 0
  1351. self.nextKey = {}
  1352. self.previousKey = {}
  1353. if values == nil then
  1354. return
  1355. end
  1356. local iterable = values
  1357. if iterable[Symbol.iterator] then
  1358. local iterator = iterable[Symbol.iterator](iterable)
  1359. while true do
  1360. local result = iterator:next()
  1361. if result.done then
  1362. break
  1363. end
  1364. self:add(result.value)
  1365. end
  1366. else
  1367. local array = values
  1368. for ____, value in ipairs(array) do
  1369. self:add(value)
  1370. end
  1371. end
  1372. end
  1373. function Set.prototype.add(self, value)
  1374. local isNewValue = not self:has(value)
  1375. if isNewValue then
  1376. self.size = self.size + 1
  1377. end
  1378. if self.firstKey == nil then
  1379. self.firstKey = value
  1380. self.lastKey = value
  1381. elseif isNewValue then
  1382. self.nextKey[self.lastKey] = value
  1383. self.previousKey[value] = self.lastKey
  1384. self.lastKey = value
  1385. end
  1386. return self
  1387. end
  1388. function Set.prototype.clear(self)
  1389. self.nextKey = {}
  1390. self.previousKey = {}
  1391. self.firstKey = nil
  1392. self.lastKey = nil
  1393. self.size = 0
  1394. return
  1395. end
  1396. function Set.prototype.delete(self, value)
  1397. local contains = self:has(value)
  1398. if contains then
  1399. self.size = self.size - 1
  1400. local next = self.nextKey[value]
  1401. local previous = self.previousKey[value]
  1402. if next and previous then
  1403. self.nextKey[previous] = next
  1404. self.previousKey[next] = previous
  1405. elseif next then
  1406. self.firstKey = next
  1407. self.previousKey[next] = nil
  1408. elseif previous then
  1409. self.lastKey = previous
  1410. self.nextKey[previous] = nil
  1411. else
  1412. self.firstKey = nil
  1413. self.lastKey = nil
  1414. end
  1415. self.nextKey[value] = nil
  1416. self.previousKey[value] = nil
  1417. end
  1418. return contains
  1419. end
  1420. function Set.prototype.forEach(self, callback)
  1421. for key in __TS__Iterator(
  1422. self:keys()
  1423. ) do
  1424. callback(_G, key, key, self)
  1425. end
  1426. end
  1427. function Set.prototype.has(self, value)
  1428. return (self.nextKey[value] ~= nil) or (self.lastKey == value)
  1429. end
  1430. Set.prototype[Symbol.iterator] = function(self)
  1431. return self:values()
  1432. end
  1433. function Set.prototype.entries(self)
  1434. local nextKey = self.nextKey
  1435. local key = self.firstKey
  1436. return {
  1437. [Symbol.iterator] = function(self)
  1438. return self
  1439. end,
  1440. next = function(self)
  1441. local result = {done = not key, value = {key, key}}
  1442. key = nextKey[key]
  1443. return result
  1444. end
  1445. }
  1446. end
  1447. function Set.prototype.keys(self)
  1448. local nextKey = self.nextKey
  1449. local key = self.firstKey
  1450. return {
  1451. [Symbol.iterator] = function(self)
  1452. return self
  1453. end,
  1454. next = function(self)
  1455. local result = {done = not key, value = key}
  1456. key = nextKey[key]
  1457. return result
  1458. end
  1459. }
  1460. end
  1461. function Set.prototype.values(self)
  1462. local nextKey = self.nextKey
  1463. local key = self.firstKey
  1464. return {
  1465. [Symbol.iterator] = function(self)
  1466. return self
  1467. end,
  1468. next = function(self)
  1469. local result = {done = not key, value = key}
  1470. key = nextKey[key]
  1471. return result
  1472. end
  1473. }
  1474. end
  1475. Set[Symbol.species] = Set
  1476. return Set
  1477. end)()
  1478.  
  1479. WeakMap = (function()
  1480. local WeakMap = __TS__Class()
  1481. WeakMap.name = "WeakMap"
  1482. function WeakMap.prototype.____constructor(self, entries)
  1483. self[Symbol.toStringTag] = "WeakMap"
  1484. self.items = {}
  1485. setmetatable(self.items, {__mode = "k"})
  1486. if entries == nil then
  1487. return
  1488. end
  1489. local iterable = entries
  1490. if iterable[Symbol.iterator] then
  1491. local iterator = iterable[Symbol.iterator](iterable)
  1492. while true do
  1493. local result = iterator:next()
  1494. if result.done then
  1495. break
  1496. end
  1497. local value = result.value
  1498. self.items[value[1]] = value[2]
  1499. end
  1500. else
  1501. for ____, kvp in ipairs(entries) do
  1502. self.items[kvp[1]] = kvp[2]
  1503. end
  1504. end
  1505. end
  1506. function WeakMap.prototype.delete(self, key)
  1507. local contains = self:has(key)
  1508. self.items[key] = nil
  1509. return contains
  1510. end
  1511. function WeakMap.prototype.get(self, key)
  1512. return self.items[key]
  1513. end
  1514. function WeakMap.prototype.has(self, key)
  1515. return self.items[key] ~= nil
  1516. end
  1517. function WeakMap.prototype.set(self, key, value)
  1518. self.items[key] = value
  1519. return self
  1520. end
  1521. WeakMap[Symbol.species] = WeakMap
  1522. return WeakMap
  1523. end)()
  1524.  
  1525. WeakSet = (function()
  1526. local WeakSet = __TS__Class()
  1527. WeakSet.name = "WeakSet"
  1528. function WeakSet.prototype.____constructor(self, values)
  1529. self[Symbol.toStringTag] = "WeakSet"
  1530. self.items = {}
  1531. setmetatable(self.items, {__mode = "k"})
  1532. if values == nil then
  1533. return
  1534. end
  1535. local iterable = values
  1536. if iterable[Symbol.iterator] then
  1537. local iterator = iterable[Symbol.iterator](iterable)
  1538. while true do
  1539. local result = iterator:next()
  1540. if result.done then
  1541. break
  1542. end
  1543. self.items[result.value] = true
  1544. end
  1545. else
  1546. for ____, value in ipairs(values) do
  1547. self.items[value] = true
  1548. end
  1549. end
  1550. end
  1551. function WeakSet.prototype.add(self, value)
  1552. self.items[value] = true
  1553. return self
  1554. end
  1555. function WeakSet.prototype.delete(self, value)
  1556. local contains = self:has(value)
  1557. self.items[value] = nil
  1558. return contains
  1559. end
  1560. function WeakSet.prototype.has(self, value)
  1561. return self.items[value] == true
  1562. end
  1563. WeakSet[Symbol.species] = WeakSet
  1564. return WeakSet
  1565. end)()
  1566.  
  1567. function __TS__SourceMapTraceBack(fileName, sourceMap)
  1568. _G.__TS__sourcemap = _G.__TS__sourcemap or ({})
  1569. _G.__TS__sourcemap[fileName] = sourceMap
  1570. if _G.__TS__originalTraceback == nil then
  1571. _G.__TS__originalTraceback = debug.traceback
  1572. debug.traceback = function(thread, message, level)
  1573. local trace
  1574. if ((thread == nil) and (message == nil)) and (level == nil) then
  1575. trace = _G.__TS__originalTraceback()
  1576. else
  1577. trace = _G.__TS__originalTraceback(thread, message, level)
  1578. end
  1579. if type(trace) ~= "string" then
  1580. return trace
  1581. end
  1582. local result = string.gsub(
  1583. trace,
  1584. "(%S+).lua:(%d+)",
  1585. function(file, line)
  1586. local fileSourceMap = _G.__TS__sourcemap[tostring(file) .. ".lua"]
  1587. if fileSourceMap and fileSourceMap[line] then
  1588. return (tostring(file) .. ".ts:") .. tostring(fileSourceMap[line])
  1589. end
  1590. return (tostring(file) .. ".lua:") .. tostring(line)
  1591. end
  1592. )
  1593. return result
  1594. end
  1595. end
  1596. end
  1597.  
  1598. function __TS__Spread(iterable)
  1599. local arr = {}
  1600. if type(iterable) == "string" then
  1601. do
  1602. local i = 0
  1603. while i < #iterable do
  1604. arr[#arr + 1] = string.sub(iterable, i + 1, i + 1)
  1605. i = i + 1
  1606. end
  1607. end
  1608. else
  1609. for item in __TS__Iterator(iterable) do
  1610. arr[#arr + 1] = item
  1611. end
  1612. end
  1613. return (table.unpack or unpack)(arr)
  1614. end
  1615.  
  1616. function __TS__StringConcat(str1, ...)
  1617. local args = {...}
  1618. local out = str1
  1619. for ____, arg in ipairs(args) do
  1620. out = tostring(out) .. tostring(arg)
  1621. end
  1622. return out
  1623. end
  1624.  
  1625. function __TS__StringEndsWith(self, searchString, endPosition)
  1626. if (endPosition == nil) or (endPosition > #self) then
  1627. endPosition = #self
  1628. end
  1629. return string.sub(self, (endPosition - #searchString) + 1, endPosition) == searchString
  1630. end
  1631.  
  1632. function __TS__StringPadEnd(self, maxLength, fillString)
  1633. if fillString == nil then
  1634. fillString = " "
  1635. end
  1636. if maxLength ~= maxLength then
  1637. maxLength = 0
  1638. end
  1639. if (maxLength == -math.huge) or (maxLength == math.huge) then
  1640. error("Invalid string length", 0)
  1641. end
  1642. if (#self >= maxLength) or (#fillString == 0) then
  1643. return self
  1644. end
  1645. maxLength = maxLength - #self
  1646. if maxLength > #fillString then
  1647. fillString = tostring(fillString) .. tostring(
  1648. string.rep(
  1649. fillString,
  1650. math.floor(maxLength / #fillString)
  1651. )
  1652. )
  1653. end
  1654. return tostring(self) .. tostring(
  1655. string.sub(
  1656. fillString,
  1657. 1,
  1658. math.floor(maxLength)
  1659. )
  1660. )
  1661. end
  1662.  
  1663. function __TS__StringPadStart(self, maxLength, fillString)
  1664. if fillString == nil then
  1665. fillString = " "
  1666. end
  1667. if maxLength ~= maxLength then
  1668. maxLength = 0
  1669. end
  1670. if (maxLength == -math.huge) or (maxLength == math.huge) then
  1671. error("Invalid string length", 0)
  1672. end
  1673. if (#self >= maxLength) or (#fillString == 0) then
  1674. return self
  1675. end
  1676. maxLength = maxLength - #self
  1677. if maxLength > #fillString then
  1678. fillString = tostring(fillString) .. tostring(
  1679. string.rep(
  1680. fillString,
  1681. math.floor(maxLength / #fillString)
  1682. )
  1683. )
  1684. end
  1685. return tostring(
  1686. string.sub(
  1687. fillString,
  1688. 1,
  1689. math.floor(maxLength)
  1690. )
  1691. ) .. tostring(self)
  1692. end
  1693.  
  1694. function __TS__StringReplace(source, searchValue, replaceValue)
  1695. searchValue = string.gsub(searchValue, "[%%%(%)%.%+%-%*%?%[%^%$]", "%%%1")
  1696. if type(replaceValue) == "string" then
  1697. replaceValue = string.gsub(replaceValue, "[%%%(%)%.%+%-%*%?%[%^%$]", "%%%1")
  1698. local result = string.gsub(source, searchValue, replaceValue, 1)
  1699. return result
  1700. else
  1701. local result = string.gsub(
  1702. source,
  1703. searchValue,
  1704. function(match) return replaceValue(_G, match) end,
  1705. 1
  1706. )
  1707. return result
  1708. end
  1709. end
  1710.  
  1711. function __TS__StringSplit(source, separator, limit)
  1712. if limit == nil then
  1713. limit = 4294967295
  1714. end
  1715. if limit == 0 then
  1716. return {}
  1717. end
  1718. local out = {}
  1719. local index = 0
  1720. local count = 0
  1721. if (separator == nil) or (separator == "") then
  1722. while (index < (#source - 1)) and (count < limit) do
  1723. out[count + 1] = string.sub(source, index + 1, index + 1)
  1724. count = count + 1
  1725. index = index + 1
  1726. end
  1727. else
  1728. local separatorLength = #separator
  1729. local nextIndex = (string.find(source, separator, nil, true) or 0) - 1
  1730. while (nextIndex >= 0) and (count < limit) do
  1731. out[count + 1] = string.sub(source, index + 1, nextIndex)
  1732. count = count + 1
  1733. index = nextIndex + separatorLength
  1734. nextIndex = (string.find(source, separator, index + 1, true) or 0) - 1
  1735. end
  1736. end
  1737. if count < limit then
  1738. out[count + 1] = string.sub(source, index + 1)
  1739. end
  1740. return out
  1741. end
  1742.  
  1743. function __TS__StringStartsWith(self, searchString, position)
  1744. if (position == nil) or (position < 0) then
  1745. position = 0
  1746. end
  1747. return string.sub(self, position + 1, #searchString + position) == searchString
  1748. end
  1749.  
  1750. function __TS__StringTrim(self)
  1751. local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1")
  1752. return result
  1753. end
  1754.  
  1755. function __TS__StringTrimEnd(self)
  1756. local result = string.gsub(self, "[%s ]*$", "")
  1757. return result
  1758. end
  1759.  
  1760. function __TS__StringTrimStart(self)
  1761. local result = string.gsub(self, "^[%s ]*", "")
  1762. return result
  1763. end
  1764.  
  1765. ____symbolRegistry = {}
  1766. function __TS__SymbolRegistryFor(key)
  1767. if not ____symbolRegistry[key] then
  1768. ____symbolRegistry[key] = __TS__Symbol(key)
  1769. end
  1770. return ____symbolRegistry[key]
  1771. end
  1772. function __TS__SymbolRegistryKeyFor(sym)
  1773. for key in pairs(____symbolRegistry) do
  1774. if ____symbolRegistry[key] == sym then
  1775. return key
  1776. end
  1777. end
  1778. end
  1779.  
  1780. function __TS__TypeOf(value)
  1781. local luaType = type(value)
  1782. if luaType == "table" then
  1783. return "object"
  1784. elseif luaType == "nil" then
  1785. return "undefined"
  1786. else
  1787. return luaType
  1788. end
  1789. end
  1790.  
  1791. end,
  1792. }
  1793. return require("main")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement