Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ldarren/quickjs
QuickJS is a small and embeddable Javascript engine. QuickJS sources are copyright Fabrice Bellard and Charlie Gordon.
https://github.com/ldarren/quickjs
Last synced: 2 days ago
JSON representation
QuickJS is a small and embeddable Javascript engine. QuickJS sources are copyright Fabrice Bellard and Charlie Gordon.
- Host: GitHub
- URL: https://github.com/ldarren/quickjs
- Owner: ldarren
- License: mit
- Created: 2019-07-12T05:24:19.000Z (over 5 years ago)
- Default Branch: mod
- Last Pushed: 2023-10-29T19:34:38.000Z (about 1 year ago)
- Last Synced: 2025-01-18T22:41:01.939Z (9 days ago)
- Language: C
- Size: 2.14 MB
- Stars: 572
- Watchers: 11
- Forks: 24
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog
- License: LICENSE
Awesome Lists containing this project
README
Original code is located at `master` branch
# Installation
## Ubuntu
- `sudo apt-get install -y build-essential gcc-multilib`
- `cd {/YOUR/PATH/TO/}QuickJS`
- `make`
- `sudo make install` # to use qjs and qjsc outside of repo folder## Mac
- `mod` branch contained mac fixes for undefined `environ` in `./quickjs-libc.c`
- update xcode
- `make`
- `sudo make install` # to use qjs and qjsc outside of repo folder# Getting Started
## compile js to binary
create a hello\_world1.js javascript file
```javascript
console.log('Hello World')
```
goto command line and type
```bash
> ./qjsc -o hello_world1 ./hello_world1.js
> ./hello_world1
> Hello World
```## compile js with module to binary
create a hello\_world2.js javascript file
```javascript
import * as std from 'std'
console.log(std.getenv('msg'))
```
goto command line and type
```bash
> ./qjsc -o hello_world2 ./hello_world2.js
> SyntaxError: unsupported keyword: import
> ./qjsc -m -o hello_world2 ./hello_world2.js
> msg="Hello World w Import" ./hello_world2
> Hello World w Import
```# known issues
- doesn't support Blob
- doesn't support WebWorker
- exceptions in promise are silent. use `./qjs --unhandled-rejection {script.js}` to display exceptions
- doesn't handle `Maximum call stack size exceeded` for recursive async function correctly. it crashes with segmentation error# fun facts
- compiled executable of `qjsc` does not has speed advantage compared with interpreting script with `qjs`test it yourself
```
# run benchmark with interpretor
./qjs tests/microbench.js
# run benchmark with compiler
./qjsc -o microbench tests/microbench.js
./microbench
```