txiki.js

微型 JavaScript 运行时。「A tiny JavaScript runtime」

Github星跟踪图

txiki.js — The tiny JavaScript runtime

Overview

txikia (basque): small, tiny.

txiki.js is a small and powerful JavaScript runtime. It's built on the shoulders of
giants: it uses QuickJS as its JavaScript engine, libuv as the platform layer,
wasm3 as the WebAssembly engine and curl as the HTTP / WebSocket client.

It targets ECMAScript 2020 and implements many web platform features.

See it in action here:

Getting started

First head over to building and build the runtime.

$ ./build/tjs eval "console.log('hello world')"
hello world
$

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

$ ./build/tjs run examples/hello_world.js
hello world
$

Explore all the options:

$ ./build/tjs --help

Features

Support for the ES2020 specification plus some ES2020+ features like top level await.

Web Platform APIs

(1): All of them are async.

(2): No subtle support.

(3): No tables, globals or memory support.

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
  • BigFloat and BigDecimal extensions
  • Builtin test runner

Standard library

The following modules compose the standard library:

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 (libffi, libuv and wasm3).
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):

# On Debian / Ubuntu
sudo apt install libcurl4-openssl-dev build-essential cmake

macOS

Install dependencies (cmake, autoconf):

brew install cmake autoconf

Unix systems

# Get the code
git clone --recursive https://github.com/saghul/txiki.js --shallow-submodules && cd txiki.js
# Compile it!
make
# Run the REPL
./build/tjs

Windows (beta)

Building has only been tested in 64bit Windows.

Prerequisites

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

Then install the required dependencies:

pacman -S git make pactoys
pacboy -S curl-winssl:p toolchain:p cmake:p ninja:p

Build

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

make

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).

make test

Versioning

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

主要指标

概览
名称与所有者saghul/txiki.js
主编程语言C
编程语言CMake (语言数: 7)
平台
许可证MIT License
所有者活动
创建于2019-07-21 19:39:26
推送于2025-05-01 22:28:02
最后一次提交2025-05-02 00:02:22
发布数12
最新版本名称v24.12.0 (发布于 )
第一版名称v22.2.0 (发布于 )
用户参与
星数2.7k
关注者数46
派生数180
提交数1k
已启用问题?
问题数195
打开的问题数31
拉请求数458
打开的拉请求数12
关闭的拉请求数30
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?