项目
在 GitHub 查看
ldarren/QuickJS
关于
QuickJS 是一个小巧且可嵌入的 JavaScript 引擎。QuickJS 源代码版权归 Fabrice Bellard 和 Charlie Gordon 所有。
其他项目实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Original code is located at master branch
Installation
Ubuntu
sudo apt-get install -y build-essential gcc-multilibcd {/YOUR/PATH/TO/}QuickJSmakesudo make install# to use qjs and qjsc outside of repo folder
Mac
modbranch contained mac fixes for undefinedenvironin./quickjs-libc.c- update xcode
makesudo make install# to use qjs and qjsc outside of repo folder
Getting Started
compile js to binary
create a hello_world1.js javascript file
console.log('Hello World')
goto command line and type
> ./qjsc -o hello_world1 ./hello_world1.js
> ./hello_world1
> Hello World
compile js with module to binary
create a hello_world2.js javascript file
import * as std from 'std'
console.log(std.getenv('msg'))
goto command line and type
> ./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 exceededfor recursive async function correctly. it crashes with segmentation error
fun facts
- compiled executable of
qjscdoes not has speed advantage compared with interpreting script withqjs
test it yourself
# run benchmark with interpretor
./qjs tests/microbench.js
# run benchmark with compiler
./qjsc -o microbench tests/microbench.js
./microbench
探索相关项目
加载中…