buke / quickjs-go Goto Github PK
View Code? Open in Web Editor NEWGo bindings to QuickJS
License: MIT License
Go bindings to QuickJS
License: MIT License
// hello.js
function hello() {
return 'hello'
}
export default hello
//mian.go
package main
import (
"fmt"
"time"
"github.com/buke/quickjs-go"
polyfill "github.com/buke/quickjs-go-polyfill"
)
func main() {
// Create a new runtime
rt := quickjs.NewRuntime()
defer rt.Close()
// Create a new context
ctx := rt.NewContext()
defer ctx.Close()
// Inject polyfills to the context
polyfill.InjectAll(ctx)
ret, err := ctx.Eval(console.log("aaaa"); import {hello} from './hello'; console.log("22222"+hello())
)
defer ret.Free()
fmt.Println("error:", ret, err)
// Wait for the timeout to finish
time.Sleep(time.Millisecond * 100)
rt.ExecuteAllPendingJobs()
// Output:
// error: SyntaxError: expecting '('
}
感谢作者的努力,这是一个非常好的项目,但是实际使用下来发现少了一些针对js集合相关的操作,我在fork的基础上简单实现了下,已经通过了大部分的测试,请问作者是否需要这部分代码?如果可以的话,我将会提一个PR
Can we have support for JS_SetInterruptHandler
? I would like to use it to enforce a timeout.
Need support for setTimeout
想要实现 fetch 的 arrayBuffer 和 blob , 发现没有进行绑定,是否有计划实现,或者是否接受 pr
速度怎么样?
如果需要支持debug,原始的quickjs源码并不支持,找了下 https://github.com/koush/quickjs 这个是支持的,但是或许需要更改构建目标?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.