typescript-to-lua 1.19.2 → 1.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/LuaLib.d.ts CHANGED
@@ -60,6 +60,8 @@ export declare enum LuaLibFeature {
60
60
  Number = "Number",
61
61
  NumberIsFinite = "NumberIsFinite",
62
62
  NumberIsNaN = "NumberIsNaN",
63
+ NumberParseInt = "ParseInt",
64
+ NumberParseFloat = "ParseFloat",
63
65
  NumberToString = "NumberToString",
64
66
  NumberToFixed = "NumberToFixed",
65
67
  ObjectAssign = "ObjectAssign",
package/dist/LuaLib.js CHANGED
@@ -65,6 +65,8 @@ var LuaLibFeature;
65
65
  LuaLibFeature["Number"] = "Number";
66
66
  LuaLibFeature["NumberIsFinite"] = "NumberIsFinite";
67
67
  LuaLibFeature["NumberIsNaN"] = "NumberIsNaN";
68
+ LuaLibFeature["NumberParseInt"] = "ParseInt";
69
+ LuaLibFeature["NumberParseFloat"] = "ParseFloat";
68
70
  LuaLibFeature["NumberToString"] = "NumberToString";
69
71
  LuaLibFeature["NumberToFixed"] = "NumberToFixed";
70
72
  LuaLibFeature["ObjectAssign"] = "ObjectAssign";
@@ -1,6 +1,9 @@
1
1
  local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
2
2
  do
3
3
  local function getErrorStack(self, constructor)
4
+ if debug == nil then
5
+ return nil
6
+ end
4
7
  local level = 1
5
8
  while true do
6
9
  local info = debug.getinfo(level, "f")
@@ -1071,6 +1071,9 @@ end
1071
1071
  local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
1072
1072
  do
1073
1073
  local function getErrorStack(self, constructor)
1074
+ if debug == nil then
1075
+ return nil
1076
+ end
1074
1077
  local level = 1
1075
1078
  while true do
1076
1079
  local info = debug.getinfo(level, "f")
@@ -1508,6 +1511,68 @@ local function __TS__NumberIsNaN(value)
1508
1511
  return value ~= value
1509
1512
  end
1510
1513
 
1514
+ local function __TS__StringSubstring(self, start, ____end)
1515
+ if ____end ~= ____end then
1516
+ ____end = 0
1517
+ end
1518
+ if ____end ~= nil and start > ____end then
1519
+ start, ____end = ____end, start
1520
+ end
1521
+ if start >= 0 then
1522
+ start = start + 1
1523
+ else
1524
+ start = 1
1525
+ end
1526
+ if ____end ~= nil and ____end < 0 then
1527
+ ____end = 0
1528
+ end
1529
+ return string.sub(self, start, ____end)
1530
+ end
1531
+
1532
+ local __TS__ParseInt
1533
+ do
1534
+ local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
1535
+ function __TS__ParseInt(numberString, base)
1536
+ if base == nil then
1537
+ base = 10
1538
+ local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
1539
+ if hexMatch ~= nil then
1540
+ base = 16
1541
+ numberString = (__TS__Match(hexMatch, "-")) and "-" .. __TS__StringSubstring(
1542
+ numberString,
1543
+ string.len(hexMatch)
1544
+ ) or __TS__StringSubstring(
1545
+ numberString,
1546
+ string.len(hexMatch)
1547
+ )
1548
+ end
1549
+ end
1550
+ if base < 2 or base > 36 then
1551
+ return 0 / 0
1552
+ end
1553
+ local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1554
+ local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1555
+ local number = tonumber((__TS__Match(numberString, pattern)), base)
1556
+ if number == nil then
1557
+ return 0 / 0
1558
+ end
1559
+ if number >= 0 then
1560
+ return math.floor(number)
1561
+ else
1562
+ return math.ceil(number)
1563
+ end
1564
+ end
1565
+ end
1566
+
1567
+ local function __TS__ParseFloat(numberString)
1568
+ local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
1569
+ if infinityMatch ~= nil then
1570
+ return __TS__StringAccess(infinityMatch, 0) == "-" and -(1 / 0) or 1 / 0
1571
+ end
1572
+ local number = tonumber((__TS__Match(numberString, "^%s*(-?%d+%.?%d*)")))
1573
+ return number or 0 / 0
1574
+ end
1575
+
1511
1576
  local __TS__NumberToString
1512
1577
  do
1513
1578
  local radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
@@ -1685,68 +1750,6 @@ local function __TS__ObjectValues(obj)
1685
1750
  return result
1686
1751
  end
1687
1752
 
1688
- local function __TS__ParseFloat(numberString)
1689
- local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
1690
- if infinityMatch ~= nil then
1691
- return __TS__StringAccess(infinityMatch, 0) == "-" and -(1 / 0) or 1 / 0
1692
- end
1693
- local number = tonumber((__TS__Match(numberString, "^%s*(-?%d+%.?%d*)")))
1694
- return number or 0 / 0
1695
- end
1696
-
1697
- local function __TS__StringSubstring(self, start, ____end)
1698
- if ____end ~= ____end then
1699
- ____end = 0
1700
- end
1701
- if ____end ~= nil and start > ____end then
1702
- start, ____end = ____end, start
1703
- end
1704
- if start >= 0 then
1705
- start = start + 1
1706
- else
1707
- start = 1
1708
- end
1709
- if ____end ~= nil and ____end < 0 then
1710
- ____end = 0
1711
- end
1712
- return string.sub(self, start, ____end)
1713
- end
1714
-
1715
- local __TS__ParseInt
1716
- do
1717
- local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
1718
- function __TS__ParseInt(numberString, base)
1719
- if base == nil then
1720
- base = 10
1721
- local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
1722
- if hexMatch ~= nil then
1723
- base = 16
1724
- numberString = (__TS__Match(hexMatch, "-")) and "-" .. __TS__StringSubstring(
1725
- numberString,
1726
- string.len(hexMatch)
1727
- ) or __TS__StringSubstring(
1728
- numberString,
1729
- string.len(hexMatch)
1730
- )
1731
- end
1732
- end
1733
- if base < 2 or base > 36 then
1734
- return 0 / 0
1735
- end
1736
- local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1737
- local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1738
- local number = tonumber((__TS__Match(numberString, pattern)), base)
1739
- if number == nil then
1740
- return 0 / 0
1741
- end
1742
- if number >= 0 then
1743
- return math.floor(number)
1744
- else
1745
- return math.ceil(number)
1746
- end
1747
- end
1748
- end
1749
-
1750
1753
  local function __TS__PromiseAll(iterable)
1751
1754
  local results = {}
1752
1755
  local toResolve = {}
@@ -2605,6 +2608,8 @@ return {
2605
2608
  __TS__Number = __TS__Number,
2606
2609
  __TS__NumberIsFinite = __TS__NumberIsFinite,
2607
2610
  __TS__NumberIsNaN = __TS__NumberIsNaN,
2611
+ __TS__ParseInt = __TS__ParseInt,
2612
+ __TS__ParseFloat = __TS__ParseFloat,
2608
2613
  __TS__NumberToString = __TS__NumberToString,
2609
2614
  __TS__NumberToFixed = __TS__NumberToFixed,
2610
2615
  __TS__ObjectAssign = __TS__ObjectAssign,
@@ -381,6 +381,24 @@
381
381
  "__TS__NumberIsNaN"
382
382
  ]
383
383
  },
384
+ "ParseInt": {
385
+ "exports": [
386
+ "__TS__ParseInt"
387
+ ],
388
+ "dependencies": [
389
+ "StringSubstring",
390
+ "Match"
391
+ ]
392
+ },
393
+ "ParseFloat": {
394
+ "exports": [
395
+ "__TS__ParseFloat"
396
+ ],
397
+ "dependencies": [
398
+ "StringAccess",
399
+ "Match"
400
+ ]
401
+ },
384
402
  "NumberToString": {
385
403
  "exports": [
386
404
  "__TS__NumberToString"
@@ -446,24 +464,6 @@
446
464
  "__TS__ObjectValues"
447
465
  ]
448
466
  },
449
- "ParseFloat": {
450
- "exports": [
451
- "__TS__ParseFloat"
452
- ],
453
- "dependencies": [
454
- "StringAccess",
455
- "Match"
456
- ]
457
- },
458
- "ParseInt": {
459
- "exports": [
460
- "__TS__ParseInt"
461
- ],
462
- "dependencies": [
463
- "StringSubstring",
464
- "Match"
465
- ]
466
- },
467
467
  "Promise": {
468
468
  "exports": [
469
469
  "__TS__Promise"
@@ -1,6 +1,9 @@
1
1
  local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
2
2
  do
3
3
  local function getErrorStack(self, constructor)
4
+ if debug == nil then
5
+ return nil
6
+ end
4
7
  local level = 1
5
8
  while true do
6
9
  local info = debug.getinfo(level, "f")
@@ -1067,6 +1067,9 @@ end
1067
1067
  local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
1068
1068
  do
1069
1069
  local function getErrorStack(self, constructor)
1070
+ if debug == nil then
1071
+ return nil
1072
+ end
1070
1073
  local level = 1
1071
1074
  while true do
1072
1075
  local info = debug.getinfo(level, "f")
@@ -1448,6 +1451,62 @@ local function __TS__NumberIsNaN(value)
1448
1451
  return value ~= value
1449
1452
  end
1450
1453
 
1454
+ local function __TS__StringSubstring(self, start, ____end)
1455
+ if ____end ~= ____end then
1456
+ ____end = 0
1457
+ end
1458
+ if ____end ~= nil and start > ____end then
1459
+ start, ____end = ____end, start
1460
+ end
1461
+ if start >= 0 then
1462
+ start = start + 1
1463
+ else
1464
+ start = 1
1465
+ end
1466
+ if ____end ~= nil and ____end < 0 then
1467
+ ____end = 0
1468
+ end
1469
+ return string.sub(self, start, ____end)
1470
+ end
1471
+
1472
+ local __TS__ParseInt
1473
+ do
1474
+ local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
1475
+ function __TS__ParseInt(numberString, base)
1476
+ if base == nil then
1477
+ base = 10
1478
+ local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
1479
+ if hexMatch ~= nil then
1480
+ base = 16
1481
+ numberString = (__TS__Match(hexMatch, "-")) and "-" .. __TS__StringSubstring(numberString, #hexMatch) or __TS__StringSubstring(numberString, #hexMatch)
1482
+ end
1483
+ end
1484
+ if base < 2 or base > 36 then
1485
+ return 0 / 0
1486
+ end
1487
+ local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1488
+ local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1489
+ local number = tonumber((__TS__Match(numberString, pattern)), base)
1490
+ if number == nil then
1491
+ return 0 / 0
1492
+ end
1493
+ if number >= 0 then
1494
+ return math.floor(number)
1495
+ else
1496
+ return math.ceil(number)
1497
+ end
1498
+ end
1499
+ end
1500
+
1501
+ local function __TS__ParseFloat(numberString)
1502
+ local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
1503
+ if infinityMatch ~= nil then
1504
+ return __TS__StringAccess(infinityMatch, 0) == "-" and -math.huge or math.huge
1505
+ end
1506
+ local number = tonumber((__TS__Match(numberString, "^%s*(-?%d+%.?%d*)")))
1507
+ return number or 0 / 0
1508
+ end
1509
+
1451
1510
  local __TS__NumberToString
1452
1511
  do
1453
1512
  local radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
@@ -1622,62 +1681,6 @@ local function __TS__ObjectValues(obj)
1622
1681
  return result
1623
1682
  end
1624
1683
 
1625
- local function __TS__ParseFloat(numberString)
1626
- local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
1627
- if infinityMatch ~= nil then
1628
- return __TS__StringAccess(infinityMatch, 0) == "-" and -math.huge or math.huge
1629
- end
1630
- local number = tonumber((__TS__Match(numberString, "^%s*(-?%d+%.?%d*)")))
1631
- return number or 0 / 0
1632
- end
1633
-
1634
- local function __TS__StringSubstring(self, start, ____end)
1635
- if ____end ~= ____end then
1636
- ____end = 0
1637
- end
1638
- if ____end ~= nil and start > ____end then
1639
- start, ____end = ____end, start
1640
- end
1641
- if start >= 0 then
1642
- start = start + 1
1643
- else
1644
- start = 1
1645
- end
1646
- if ____end ~= nil and ____end < 0 then
1647
- ____end = 0
1648
- end
1649
- return string.sub(self, start, ____end)
1650
- end
1651
-
1652
- local __TS__ParseInt
1653
- do
1654
- local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
1655
- function __TS__ParseInt(numberString, base)
1656
- if base == nil then
1657
- base = 10
1658
- local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
1659
- if hexMatch ~= nil then
1660
- base = 16
1661
- numberString = (__TS__Match(hexMatch, "-")) and "-" .. __TS__StringSubstring(numberString, #hexMatch) or __TS__StringSubstring(numberString, #hexMatch)
1662
- end
1663
- end
1664
- if base < 2 or base > 36 then
1665
- return 0 / 0
1666
- end
1667
- local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1668
- local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1669
- local number = tonumber((__TS__Match(numberString, pattern)), base)
1670
- if number == nil then
1671
- return 0 / 0
1672
- end
1673
- if number >= 0 then
1674
- return math.floor(number)
1675
- else
1676
- return math.ceil(number)
1677
- end
1678
- end
1679
- end
1680
-
1681
1684
  local function __TS__PromiseAll(iterable)
1682
1685
  local results = {}
1683
1686
  local toResolve = {}
@@ -2545,6 +2548,8 @@ return {
2545
2548
  __TS__Number = __TS__Number,
2546
2549
  __TS__NumberIsFinite = __TS__NumberIsFinite,
2547
2550
  __TS__NumberIsNaN = __TS__NumberIsNaN,
2551
+ __TS__ParseInt = __TS__ParseInt,
2552
+ __TS__ParseFloat = __TS__ParseFloat,
2548
2553
  __TS__NumberToString = __TS__NumberToString,
2549
2554
  __TS__NumberToFixed = __TS__NumberToFixed,
2550
2555
  __TS__ObjectAssign = __TS__ObjectAssign,
@@ -387,6 +387,24 @@
387
387
  "__TS__NumberIsNaN"
388
388
  ]
389
389
  },
390
+ "ParseInt": {
391
+ "exports": [
392
+ "__TS__ParseInt"
393
+ ],
394
+ "dependencies": [
395
+ "StringSubstring",
396
+ "Match"
397
+ ]
398
+ },
399
+ "ParseFloat": {
400
+ "exports": [
401
+ "__TS__ParseFloat"
402
+ ],
403
+ "dependencies": [
404
+ "StringAccess",
405
+ "Match"
406
+ ]
407
+ },
390
408
  "NumberToString": {
391
409
  "exports": [
392
410
  "__TS__NumberToString"
@@ -452,24 +470,6 @@
452
470
  "__TS__ObjectValues"
453
471
  ]
454
472
  },
455
- "ParseFloat": {
456
- "exports": [
457
- "__TS__ParseFloat"
458
- ],
459
- "dependencies": [
460
- "StringAccess",
461
- "Match"
462
- ]
463
- },
464
- "ParseInt": {
465
- "exports": [
466
- "__TS__ParseInt"
467
- ],
468
- "dependencies": [
469
- "StringSubstring",
470
- "Match"
471
- ]
472
- },
473
473
  "Promise": {
474
474
  "exports": [
475
475
  "__TS__Promise"
@@ -30,6 +30,10 @@ function transformNumberConstructorCall(context, node, calledMethod) {
30
30
  return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.NumberIsNaN, node, ...parameters);
31
31
  case "isFinite":
32
32
  return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.NumberIsFinite, node, ...parameters);
33
+ case "parseInt":
34
+ return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.NumberParseInt, node, ...parameters);
35
+ case "parseFloat":
36
+ return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.NumberParseFloat, node, ...parameters);
33
37
  default:
34
38
  context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(calledMethod.name, "Number", methodName));
35
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-to-lua",
3
- "version": "1.19.2",
3
+ "version": "1.19.3",
4
4
  "description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",
5
5
  "repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
6
6
  "homepage": "https://typescripttolua.github.io/",