https://github.com/tx7do/go-js
https://github.com/tx7do/go-js
embedded golang javascript
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/tx7do/go-js
- Owner: tx7do
- License: mit
- Created: 2022-09-06T02:10:53.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-09T08:47:24.000Z (over 3 years ago)
- Last Synced: 2024-06-20T10:16:57.907Z (almost 2 years ago)
- Topics: embedded, golang, javascript
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-js
基于[goja](https://github.com/dop251/goja)封装的一个JavaScript脚本引擎。
最开始是基于[otto](https://github.com/robertkrimen/otto)封装的,可惜它对很多ES5的语法都不支持,用着实在是蛋疼无比。
后来改为[goja](https://github.com/dop251/goja),goja甚至支持一些ES6的语法。其实,goja是基于otto做的开发,可以说是青出于蓝,更甚于蓝。
## 基本交互
### 变量
变量有三种访问方式:
- 单向只写 - 将宿主的变量注入;
- 单向只读 - 读取脚本中的变量;
- 双向可读可写 - 将宿主的变量注入,脚本可操作宿主的变量并且反馈到宿主。
### 方法
- 宿主调用脚本中的方法;
- 脚本调用宿主中的方法。