Advertisement
AMONUWNA

Please, work correctly

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