txiki.js

A tiny JavaScript runtime

README


txiki.js — The tiny JavaScript runtime


Overview


txikia (basque): small, tiny.


txiki.js is a small and powerful JavaScript runtime.  It targets state-of-the-art ECMAScript
and aims to be WinterCG compliant.

It's built on the shoulders of giants: it uses QuickJS-ng as its JavaScript engine and libuv as the platform layer.

Getting started


First head over to building and build the runtime.

  1. ```bash
  2. $ ./build/tjs eval "console.log('hello world')"
  3. hello world
  4. $
  5. ```

If you want to run a script you can use tjs run:

  1. ```bash
  2. $ ./build/tjs run examples/hello_world.js
  3. hello world
  4. $
  5. ```

Explore all the options:

  1. ```bash
  2. $ ./build/tjs --help
  3. ```

For TS support see @txikijs/types.

Features


Support for the ES2023 specification (almost complete).

WinterCG


txiki.js aims to be WinterCG compliant, you can track the progress here.

Runtime features


- TCP and UDP sockets
- Unix sockets / named pipes
- Signal handling
- File operations
- Child processes
- DNS (getaddrinfo)
- WASI
- Miscellaneous utility functions

See the full API documentation.

Other extras:

- Import directly from HTTP(S) URLs
- Import JSON files
- Builtin test runner

Standard library


The following modules compose the standard library:

- [tjs:assert](https://bettercallsaghul.com/txiki.js/api/modules/tjs_assert.html)
- [tjs:ffi](https://bettercallsaghul.com/txiki.js/api/modules/tjs_ffi.html)
- [tjs:getopts](https://bettercallsaghul.com/txiki.js/api/modules/tjs_getopts.html)
- [tjs:hashing](https://bettercallsaghul.com/txiki.js/api/modules/tjs_hashing.html)
- [tjs:ipaddr](https://bettercallsaghul.com/txiki.js/api/modules/tjs_ipaddr.html)
- [tjs:path](https://bettercallsaghul.com/txiki.js/api/modules/tjs_path.html)
- [tjs:sqlite](https://bettercallsaghul.com/txiki.js/api/modules/tjs_sqlite.html)
- [tjs:uuid](https://bettercallsaghul.com/txiki.js/api/modules/tjs_uuid.html)

Supported platforms


GNU/Linux
macOS
Windows (beta)
Other Unixes (please test!)

Building


CMake is necessary.

NOTE: The txiki.js build depends on a number of git submodules.
If you didn't already clone this repository recursively, make sure you initialize these
submodules with git submodule update --init before proceeding to the build.

GNU/Linux


Install dependencies (libcurl, build-essential, cmake, makeinfo, autoreconf, libtool):

  1. ```bash
  2. # On Debian / Ubuntu
  3. sudo apt install libcurl4-openssl-dev build-essential cmake autoconf texinfo libtool
  4. ```

macOS


Install dependencies (cmake, autoconf):

  1. ```bash
  2. brew install cmake autoconf automake libtool texinfo
  3. ```

Unix systems


  1. ```bash
  2. # Get the code
  3. git clone --recursive https://github.com/saghul/txiki.js --shallow-submodules && cd txiki.js
  4. # Compile it!
  5. make
  6. # Run the REPL
  7. ./build/tjs
  8. ```

Windows (beta)


Windows support it's currently considered beta. Tests do pass, but building it is not as easy as it should be.

Building has only been tested in 64bit Windows.

Prerequisites


First make sure you have MSYS2 installed. Themingw64 and clang64 environments are currently tested.

Then install the required dependencies:

  1. ```bash
  2. pacman -S git make pactoys
  3. pacboy -S curl-winssl:p toolchain:p cmake:p ninja:p
  4. ```

Build


These commands must be run in a MinGW64 or clang64 shell.

  1. ```bash
  2. make
  3. ```

This will build the executable just like on Unix. Note that at this point there are a number of dynamically linked libraries, so if you want to use the executable on a different system you'll need to copy those too. Check the list with ldd build/tjs.exe.

Running the tests


Make sure these commands are run from Windows Terminal (mintty, what MSYS2 provides is not supported).

  1. ```bash
  2. make test
  3. ```

Versioning


At this time txiki.js uses calendar versioning with the form YY.MM.MICRO.



Built with ❤️ by saghul and these awesome contributors.