typescript-to-lua 1.19.1 → 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 +3 -0
- package/dist/LuaLib.js +3 -0
- package/dist/lualib/5.0/ArrayAt.lua +7 -0
- package/dist/lualib/5.0/Error.lua +3 -0
- package/dist/lualib/5.0/lualib_bundle.lua +76 -62
- package/dist/lualib/5.0/lualib_module_info.json +23 -18
- package/dist/lualib/universal/ArrayAt.lua +7 -0
- package/dist/lualib/universal/Error.lua +3 -0
- package/dist/lualib/universal/lualib_bundle.lua +70 -56
- package/dist/lualib/universal/lualib_module_info.json +23 -18
- package/dist/transformation/builtins/array.js +2 -0
- package/dist/transformation/builtins/number.js +4 -0
- package/package.json +1 -1
package/dist/LuaLib.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { EmitHost } from "./transpilation";
|
|
|
2
2
|
import * as lua from "./LuaAST";
|
|
3
3
|
import { LuaTarget } from "./CompilerOptions";
|
|
4
4
|
export declare enum LuaLibFeature {
|
|
5
|
+
ArrayAt = "ArrayAt",
|
|
5
6
|
ArrayConcat = "ArrayConcat",
|
|
6
7
|
ArrayEntries = "ArrayEntries",
|
|
7
8
|
ArrayEvery = "ArrayEvery",
|
|
@@ -59,6 +60,8 @@ export declare enum LuaLibFeature {
|
|
|
59
60
|
Number = "Number",
|
|
60
61
|
NumberIsFinite = "NumberIsFinite",
|
|
61
62
|
NumberIsNaN = "NumberIsNaN",
|
|
63
|
+
NumberParseInt = "ParseInt",
|
|
64
|
+
NumberParseFloat = "ParseFloat",
|
|
62
65
|
NumberToString = "NumberToString",
|
|
63
66
|
NumberToFixed = "NumberToFixed",
|
|
64
67
|
ObjectAssign = "ObjectAssign",
|
package/dist/LuaLib.js
CHANGED
|
@@ -7,6 +7,7 @@ const CompilerOptions_1 = require("./CompilerOptions");
|
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
8
|
var LuaLibFeature;
|
|
9
9
|
(function (LuaLibFeature) {
|
|
10
|
+
LuaLibFeature["ArrayAt"] = "ArrayAt";
|
|
10
11
|
LuaLibFeature["ArrayConcat"] = "ArrayConcat";
|
|
11
12
|
LuaLibFeature["ArrayEntries"] = "ArrayEntries";
|
|
12
13
|
LuaLibFeature["ArrayEvery"] = "ArrayEvery";
|
|
@@ -64,6 +65,8 @@ var LuaLibFeature;
|
|
|
64
65
|
LuaLibFeature["Number"] = "Number";
|
|
65
66
|
LuaLibFeature["NumberIsFinite"] = "NumberIsFinite";
|
|
66
67
|
LuaLibFeature["NumberIsNaN"] = "NumberIsNaN";
|
|
68
|
+
LuaLibFeature["NumberParseInt"] = "ParseInt";
|
|
69
|
+
LuaLibFeature["NumberParseFloat"] = "ParseFloat";
|
|
67
70
|
LuaLibFeature["NumberToString"] = "NumberToString";
|
|
68
71
|
LuaLibFeature["NumberToFixed"] = "NumberToFixed";
|
|
69
72
|
LuaLibFeature["ObjectAssign"] = "ObjectAssign";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
local function __TS__ArrayAt(self, relativeIndex)
|
|
2
|
+
local absoluteIndex = relativeIndex < 0 and table.getn(self) + relativeIndex or relativeIndex
|
|
3
|
+
if absoluteIndex >= 0 and absoluteIndex < table.getn(self) then
|
|
4
|
+
return self[absoluteIndex + 1]
|
|
5
|
+
end
|
|
6
|
+
return nil
|
|
7
|
+
end
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
local function __TS__ArrayAt(self, relativeIndex)
|
|
2
|
+
local absoluteIndex = relativeIndex < 0 and table.getn(self) + relativeIndex or relativeIndex
|
|
3
|
+
if absoluteIndex >= 0 and absoluteIndex < table.getn(self) then
|
|
4
|
+
return self[absoluteIndex + 1]
|
|
5
|
+
end
|
|
6
|
+
return nil
|
|
7
|
+
end
|
|
8
|
+
|
|
1
9
|
local function __TS__ArrayIsArray(value)
|
|
2
10
|
return type(value) == "table" and (value[1] ~= nil or next(value) == nil)
|
|
3
11
|
end
|
|
@@ -1063,6 +1071,9 @@ end
|
|
|
1063
1071
|
local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
|
|
1064
1072
|
do
|
|
1065
1073
|
local function getErrorStack(self, constructor)
|
|
1074
|
+
if debug == nil then
|
|
1075
|
+
return nil
|
|
1076
|
+
end
|
|
1066
1077
|
local level = 1
|
|
1067
1078
|
while true do
|
|
1068
1079
|
local info = debug.getinfo(level, "f")
|
|
@@ -1500,6 +1511,68 @@ local function __TS__NumberIsNaN(value)
|
|
|
1500
1511
|
return value ~= value
|
|
1501
1512
|
end
|
|
1502
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
|
+
|
|
1503
1576
|
local __TS__NumberToString
|
|
1504
1577
|
do
|
|
1505
1578
|
local radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
|
|
@@ -1677,68 +1750,6 @@ local function __TS__ObjectValues(obj)
|
|
|
1677
1750
|
return result
|
|
1678
1751
|
end
|
|
1679
1752
|
|
|
1680
|
-
local function __TS__ParseFloat(numberString)
|
|
1681
|
-
local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
|
|
1682
|
-
if infinityMatch ~= nil then
|
|
1683
|
-
return __TS__StringAccess(infinityMatch, 0) == "-" and -(1 / 0) or 1 / 0
|
|
1684
|
-
end
|
|
1685
|
-
local number = tonumber((__TS__Match(numberString, "^%s*(-?%d+%.?%d*)")))
|
|
1686
|
-
return number or 0 / 0
|
|
1687
|
-
end
|
|
1688
|
-
|
|
1689
|
-
local function __TS__StringSubstring(self, start, ____end)
|
|
1690
|
-
if ____end ~= ____end then
|
|
1691
|
-
____end = 0
|
|
1692
|
-
end
|
|
1693
|
-
if ____end ~= nil and start > ____end then
|
|
1694
|
-
start, ____end = ____end, start
|
|
1695
|
-
end
|
|
1696
|
-
if start >= 0 then
|
|
1697
|
-
start = start + 1
|
|
1698
|
-
else
|
|
1699
|
-
start = 1
|
|
1700
|
-
end
|
|
1701
|
-
if ____end ~= nil and ____end < 0 then
|
|
1702
|
-
____end = 0
|
|
1703
|
-
end
|
|
1704
|
-
return string.sub(self, start, ____end)
|
|
1705
|
-
end
|
|
1706
|
-
|
|
1707
|
-
local __TS__ParseInt
|
|
1708
|
-
do
|
|
1709
|
-
local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
|
|
1710
|
-
function __TS__ParseInt(numberString, base)
|
|
1711
|
-
if base == nil then
|
|
1712
|
-
base = 10
|
|
1713
|
-
local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
|
|
1714
|
-
if hexMatch ~= nil then
|
|
1715
|
-
base = 16
|
|
1716
|
-
numberString = (__TS__Match(hexMatch, "-")) and "-" .. __TS__StringSubstring(
|
|
1717
|
-
numberString,
|
|
1718
|
-
string.len(hexMatch)
|
|
1719
|
-
) or __TS__StringSubstring(
|
|
1720
|
-
numberString,
|
|
1721
|
-
string.len(hexMatch)
|
|
1722
|
-
)
|
|
1723
|
-
end
|
|
1724
|
-
end
|
|
1725
|
-
if base < 2 or base > 36 then
|
|
1726
|
-
return 0 / 0
|
|
1727
|
-
end
|
|
1728
|
-
local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
|
|
1729
|
-
local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
|
|
1730
|
-
local number = tonumber((__TS__Match(numberString, pattern)), base)
|
|
1731
|
-
if number == nil then
|
|
1732
|
-
return 0 / 0
|
|
1733
|
-
end
|
|
1734
|
-
if number >= 0 then
|
|
1735
|
-
return math.floor(number)
|
|
1736
|
-
else
|
|
1737
|
-
return math.ceil(number)
|
|
1738
|
-
end
|
|
1739
|
-
end
|
|
1740
|
-
end
|
|
1741
|
-
|
|
1742
1753
|
local function __TS__PromiseAll(iterable)
|
|
1743
1754
|
local results = {}
|
|
1744
1755
|
local toResolve = {}
|
|
@@ -2533,6 +2544,7 @@ local function __TS__UsingAsync(self, cb, ...)
|
|
|
2533
2544
|
end
|
|
2534
2545
|
|
|
2535
2546
|
return {
|
|
2547
|
+
__TS__ArrayAt = __TS__ArrayAt,
|
|
2536
2548
|
__TS__ArrayConcat = __TS__ArrayConcat,
|
|
2537
2549
|
__TS__ArrayEntries = __TS__ArrayEntries,
|
|
2538
2550
|
__TS__ArrayEvery = __TS__ArrayEvery,
|
|
@@ -2596,6 +2608,8 @@ return {
|
|
|
2596
2608
|
__TS__Number = __TS__Number,
|
|
2597
2609
|
__TS__NumberIsFinite = __TS__NumberIsFinite,
|
|
2598
2610
|
__TS__NumberIsNaN = __TS__NumberIsNaN,
|
|
2611
|
+
__TS__ParseInt = __TS__ParseInt,
|
|
2612
|
+
__TS__ParseFloat = __TS__ParseFloat,
|
|
2599
2613
|
__TS__NumberToString = __TS__NumberToString,
|
|
2600
2614
|
__TS__NumberToFixed = __TS__NumberToFixed,
|
|
2601
2615
|
__TS__ObjectAssign = __TS__ObjectAssign,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
+
"ArrayAt": {
|
|
3
|
+
"exports": [
|
|
4
|
+
"__TS__ArrayAt"
|
|
5
|
+
]
|
|
6
|
+
},
|
|
2
7
|
"ArrayConcat": {
|
|
3
8
|
"exports": [
|
|
4
9
|
"__TS__ArrayConcat"
|
|
@@ -376,6 +381,24 @@
|
|
|
376
381
|
"__TS__NumberIsNaN"
|
|
377
382
|
]
|
|
378
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
|
+
},
|
|
379
402
|
"NumberToString": {
|
|
380
403
|
"exports": [
|
|
381
404
|
"__TS__NumberToString"
|
|
@@ -441,24 +464,6 @@
|
|
|
441
464
|
"__TS__ObjectValues"
|
|
442
465
|
]
|
|
443
466
|
},
|
|
444
|
-
"ParseFloat": {
|
|
445
|
-
"exports": [
|
|
446
|
-
"__TS__ParseFloat"
|
|
447
|
-
],
|
|
448
|
-
"dependencies": [
|
|
449
|
-
"StringAccess",
|
|
450
|
-
"Match"
|
|
451
|
-
]
|
|
452
|
-
},
|
|
453
|
-
"ParseInt": {
|
|
454
|
-
"exports": [
|
|
455
|
-
"__TS__ParseInt"
|
|
456
|
-
],
|
|
457
|
-
"dependencies": [
|
|
458
|
-
"StringSubstring",
|
|
459
|
-
"Match"
|
|
460
|
-
]
|
|
461
|
-
},
|
|
462
467
|
"Promise": {
|
|
463
468
|
"exports": [
|
|
464
469
|
"__TS__Promise"
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
local function __TS__ArrayAt(self, relativeIndex)
|
|
2
|
+
local absoluteIndex = relativeIndex < 0 and #self + relativeIndex or relativeIndex
|
|
3
|
+
if absoluteIndex >= 0 and absoluteIndex < #self then
|
|
4
|
+
return self[absoluteIndex + 1]
|
|
5
|
+
end
|
|
6
|
+
return nil
|
|
7
|
+
end
|
|
8
|
+
|
|
1
9
|
local function __TS__ArrayIsArray(value)
|
|
2
10
|
return type(value) == "table" and (value[1] ~= nil or next(value) == nil)
|
|
3
11
|
end
|
|
@@ -1059,6 +1067,9 @@ end
|
|
|
1059
1067
|
local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
|
|
1060
1068
|
do
|
|
1061
1069
|
local function getErrorStack(self, constructor)
|
|
1070
|
+
if debug == nil then
|
|
1071
|
+
return nil
|
|
1072
|
+
end
|
|
1062
1073
|
local level = 1
|
|
1063
1074
|
while true do
|
|
1064
1075
|
local info = debug.getinfo(level, "f")
|
|
@@ -1440,6 +1451,62 @@ local function __TS__NumberIsNaN(value)
|
|
|
1440
1451
|
return value ~= value
|
|
1441
1452
|
end
|
|
1442
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
|
+
|
|
1443
1510
|
local __TS__NumberToString
|
|
1444
1511
|
do
|
|
1445
1512
|
local radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
|
|
@@ -1614,62 +1681,6 @@ local function __TS__ObjectValues(obj)
|
|
|
1614
1681
|
return result
|
|
1615
1682
|
end
|
|
1616
1683
|
|
|
1617
|
-
local function __TS__ParseFloat(numberString)
|
|
1618
|
-
local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
|
|
1619
|
-
if infinityMatch ~= nil then
|
|
1620
|
-
return __TS__StringAccess(infinityMatch, 0) == "-" and -math.huge or math.huge
|
|
1621
|
-
end
|
|
1622
|
-
local number = tonumber((__TS__Match(numberString, "^%s*(-?%d+%.?%d*)")))
|
|
1623
|
-
return number or 0 / 0
|
|
1624
|
-
end
|
|
1625
|
-
|
|
1626
|
-
local function __TS__StringSubstring(self, start, ____end)
|
|
1627
|
-
if ____end ~= ____end then
|
|
1628
|
-
____end = 0
|
|
1629
|
-
end
|
|
1630
|
-
if ____end ~= nil and start > ____end then
|
|
1631
|
-
start, ____end = ____end, start
|
|
1632
|
-
end
|
|
1633
|
-
if start >= 0 then
|
|
1634
|
-
start = start + 1
|
|
1635
|
-
else
|
|
1636
|
-
start = 1
|
|
1637
|
-
end
|
|
1638
|
-
if ____end ~= nil and ____end < 0 then
|
|
1639
|
-
____end = 0
|
|
1640
|
-
end
|
|
1641
|
-
return string.sub(self, start, ____end)
|
|
1642
|
-
end
|
|
1643
|
-
|
|
1644
|
-
local __TS__ParseInt
|
|
1645
|
-
do
|
|
1646
|
-
local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
|
|
1647
|
-
function __TS__ParseInt(numberString, base)
|
|
1648
|
-
if base == nil then
|
|
1649
|
-
base = 10
|
|
1650
|
-
local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
|
|
1651
|
-
if hexMatch ~= nil then
|
|
1652
|
-
base = 16
|
|
1653
|
-
numberString = (__TS__Match(hexMatch, "-")) and "-" .. __TS__StringSubstring(numberString, #hexMatch) or __TS__StringSubstring(numberString, #hexMatch)
|
|
1654
|
-
end
|
|
1655
|
-
end
|
|
1656
|
-
if base < 2 or base > 36 then
|
|
1657
|
-
return 0 / 0
|
|
1658
|
-
end
|
|
1659
|
-
local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
|
|
1660
|
-
local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
|
|
1661
|
-
local number = tonumber((__TS__Match(numberString, pattern)), base)
|
|
1662
|
-
if number == nil then
|
|
1663
|
-
return 0 / 0
|
|
1664
|
-
end
|
|
1665
|
-
if number >= 0 then
|
|
1666
|
-
return math.floor(number)
|
|
1667
|
-
else
|
|
1668
|
-
return math.ceil(number)
|
|
1669
|
-
end
|
|
1670
|
-
end
|
|
1671
|
-
end
|
|
1672
|
-
|
|
1673
1684
|
local function __TS__PromiseAll(iterable)
|
|
1674
1685
|
local results = {}
|
|
1675
1686
|
local toResolve = {}
|
|
@@ -2473,6 +2484,7 @@ local function __TS__UsingAsync(self, cb, ...)
|
|
|
2473
2484
|
end
|
|
2474
2485
|
|
|
2475
2486
|
return {
|
|
2487
|
+
__TS__ArrayAt = __TS__ArrayAt,
|
|
2476
2488
|
__TS__ArrayConcat = __TS__ArrayConcat,
|
|
2477
2489
|
__TS__ArrayEntries = __TS__ArrayEntries,
|
|
2478
2490
|
__TS__ArrayEvery = __TS__ArrayEvery,
|
|
@@ -2536,6 +2548,8 @@ return {
|
|
|
2536
2548
|
__TS__Number = __TS__Number,
|
|
2537
2549
|
__TS__NumberIsFinite = __TS__NumberIsFinite,
|
|
2538
2550
|
__TS__NumberIsNaN = __TS__NumberIsNaN,
|
|
2551
|
+
__TS__ParseInt = __TS__ParseInt,
|
|
2552
|
+
__TS__ParseFloat = __TS__ParseFloat,
|
|
2539
2553
|
__TS__NumberToString = __TS__NumberToString,
|
|
2540
2554
|
__TS__NumberToFixed = __TS__NumberToFixed,
|
|
2541
2555
|
__TS__ObjectAssign = __TS__ObjectAssign,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
+
"ArrayAt": {
|
|
3
|
+
"exports": [
|
|
4
|
+
"__TS__ArrayAt"
|
|
5
|
+
]
|
|
6
|
+
},
|
|
2
7
|
"ArrayConcat": {
|
|
3
8
|
"exports": [
|
|
4
9
|
"__TS__ArrayConcat"
|
|
@@ -382,6 +387,24 @@
|
|
|
382
387
|
"__TS__NumberIsNaN"
|
|
383
388
|
]
|
|
384
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
|
+
},
|
|
385
408
|
"NumberToString": {
|
|
386
409
|
"exports": [
|
|
387
410
|
"__TS__NumberToString"
|
|
@@ -447,24 +470,6 @@
|
|
|
447
470
|
"__TS__ObjectValues"
|
|
448
471
|
]
|
|
449
472
|
},
|
|
450
|
-
"ParseFloat": {
|
|
451
|
-
"exports": [
|
|
452
|
-
"__TS__ParseFloat"
|
|
453
|
-
],
|
|
454
|
-
"dependencies": [
|
|
455
|
-
"StringAccess",
|
|
456
|
-
"Match"
|
|
457
|
-
]
|
|
458
|
-
},
|
|
459
|
-
"ParseInt": {
|
|
460
|
-
"exports": [
|
|
461
|
-
"__TS__ParseInt"
|
|
462
|
-
],
|
|
463
|
-
"dependencies": [
|
|
464
|
-
"StringSubstring",
|
|
465
|
-
"Match"
|
|
466
|
-
]
|
|
467
|
-
},
|
|
468
473
|
"Promise": {
|
|
469
474
|
"exports": [
|
|
470
475
|
"__TS__Promise"
|
|
@@ -60,6 +60,8 @@ function transformArrayPrototypeCall(context, node, calledMethod) {
|
|
|
60
60
|
const [caller, params] = (0, call_1.transformCallAndArguments)(context, calledMethod.expression, node.arguments, signature);
|
|
61
61
|
const expressionName = calledMethod.name.text;
|
|
62
62
|
switch (expressionName) {
|
|
63
|
+
case "at":
|
|
64
|
+
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayAt, node, caller, ...params);
|
|
63
65
|
case "concat":
|
|
64
66
|
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayConcat, node, caller, ...params);
|
|
65
67
|
case "entries":
|
|
@@ -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.
|
|
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/",
|