Skip to content

Latest commit

 

History

History
82 lines (59 loc) · 1.4 KB

README.template.md

File metadata and controls

82 lines (59 loc) · 1.4 KB

js2lua

js2lua Writing LuaJIT with the expressiveness of JavaScript.

Install

npm install @xiangnanscu/js2lua

Usage

command

Concat one or more js files and transform them to one lua string:

js2lua [options] file1, file2, ...

where options are:

const defaultOptions = {
  tagArrayExpression: true,
  importStatementHoisting: true,
  transform$SymbolToDollar: true,
  transformToString: true,
  transformString: true,
  transformJSONStringify: true,
  transformJSONParse: true,
  transformParseFloat: true,
  transformParseInt: true,
  transformNumber: true,
  transformIsArray: true,
  transformConsoleLog: true,
  moduleExportsToReturn: true,
  index0To1: true,
  tryTranslateClass: true,
  disableUpdateExpressionCallback: true,
  renameCatchErrorIfNeeded: true,
  disableClassCall: true,
};

examples

Basic:

js2lua foo.js > foo.lua

To disable a feature --no-[option]:

js2lua --no-transformToString foo.js

To enable a feature --[option]:

js2lua --debug foo.js

api

import { js2lua } from "js2lua";
js2lua(`let a = 1`, { importStatementHoisting: true });

see also

Features

[CODE_TABLE]