slt-js
v0.2.0
Published
Reference SLT transpiler for localized JavaScript keywords (ES/FR/IT).
Maintainers
Readme
slt-js
Reference SLT transpiler for JavaScript.
This package implements a simple reference transpiler that recognizes a #!slt <lang> header at the top
of a JavaScript source file and replaces localized keywords with canonical JavaScript keywords.
Built-in languages: es (Spanish), fr (French), it (Italian).
Install (development)
# from the package root:
npm install
npm linkThis will make the slt-js command available in your PATH.
Usage
# transpile and print to stdout
slt-js example-esp.js
# write output to a file
slt-js example-esp.js -o example.js
# list built-in languages
slt-js --list-langs
# use a custom mapping
slt-js example-esp.js --map maps/es-map.json -o example.js
# strip the SLT header from output
slt-js example-esp.js --strip-header -o example.jsExamples
See examples/ for sample files in Spanish, French, and Italian:
examples/example-esp.jsexamples/example-fr.jsexamples/example-it.js
Tests
Run tests with:
npm testTests are implemented using a small Node.js test runner in test/run-tests.js.
Limitations
This is a reference tool and not a full JS-aware tokenizer. It attempts to avoid altering strings, comments, and template literals, but it is not perfect (especially around regex literals). For production use, integrate with a parser such as acorn or @babel/parser.
License
MIT
