typescript-to-lua 1.19.0 → 1.19.2

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
@@ -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",
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";
@@ -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
@@ -2533,6 +2541,7 @@ local function __TS__UsingAsync(self, cb, ...)
2533
2541
  end
2534
2542
 
2535
2543
  return {
2544
+ __TS__ArrayAt = __TS__ArrayAt,
2536
2545
  __TS__ArrayConcat = __TS__ArrayConcat,
2537
2546
  __TS__ArrayEntries = __TS__ArrayEntries,
2538
2547
  __TS__ArrayEvery = __TS__ArrayEvery,
@@ -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"
@@ -0,0 +1,7 @@
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
@@ -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
@@ -2473,6 +2481,7 @@ local function __TS__UsingAsync(self, cb, ...)
2473
2481
  end
2474
2482
 
2475
2483
  return {
2484
+ __TS__ArrayAt = __TS__ArrayAt,
2476
2485
  __TS__ArrayConcat = __TS__ArrayConcat,
2477
2486
  __TS__ArrayEntries = __TS__ArrayEntries,
2478
2487
  __TS__ArrayEvery = __TS__ArrayEvery,
@@ -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"
@@ -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":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-to-lua",
3
- "version": "1.19.0",
3
+ "version": "1.19.2",
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/",
@@ -45,7 +45,7 @@
45
45
  "typescript": "5.2.2"
46
46
  },
47
47
  "dependencies": {
48
- "@typescript-to-lua/language-extensions": "1.0.0",
48
+ "@typescript-to-lua/language-extensions": "1.19.0",
49
49
  "enhanced-resolve": "^5.8.2",
50
50
  "picomatch": "^2.3.1",
51
51
  "resolve": "^1.15.1",