GiavaScript is an open-source, cross-platform JavaScript runtime implemented in Crystal.
It intentionally does not aim for full ECMAScript compliance. Check the reference docs before relying on specific language features.
- Crystal 1.19.1 or later
git clone https://github.com/memburg/GiavaScript.git
cd GiavaScript
crystal run src/giavascript_cli.cr -- install.jsThis installs the giavascript binary and a gs shortcut (symlink) to /usr/local/bin by default. Both commands work interchangeably.
Install to a user-local path instead of /usr/local/bin:
INSTALL_DIR="$HOME/.local/bin" crystal run src/giavascript_cli.cr -- install.jsMake sure your install directory is on PATH.
gsREPL commands:
:quitexits the REPL.
gs path/to/program.jsBehavior to expect:
- Empty files return an error.
- If a runtime error occurs, messages are written to standard error.
- Process exit code is
1when anyError:message is produced; otherwise0.
crystal run src/giavascript_cli.cr -- examples/templateLiterals.jsRun the tests:
crystal specSample programs are in examples/:
examples/templateLiterals.js- string interpolation and expression formattingexamples/arrayFlatFlatMapSplice.js- array manipulation methodsexamples/dateBasics.js- Date object usageexamples/functionExpressionsAndOperators.js- function expressions and operatorsexamples/multilineMethodChaining.js- method chaining patternsexamples/objectKeysValuesEntries.js- Object.keys, values, entriesexamples/random.js- random number generationexamples/tryCatchFinally.js- error handling with try/catch/finally
Run any example with:
gs examples/templateLiterals.jsSee CONTRIBUTING.md for setup, test, and documentation update guidelines.