repositorypackage
0.0.0-20201109020232-7d29a43a366e
Repository: https://github.com/newdash/quickjs.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
quickjs
Go bindings to QuickJS: a fast, small, and embeddable ES2020 JavaScript interpreter.
These bindings are a WIP and do not match full parity with QuickJS' API, though expose just enough features to be usable. The version of QuickJS that these bindings bind to may be located here.
NOTICE
QuickJS is not works well with Golang's goroutine
, please DO NOT share a quickjs.Runtime
cross different goroutines
.
Usage
$ go get github.com/newdash/quickjs
Guidelines
- Free
quickjs.Runtime
andquickjs.Context
once you are done using them. - Free
quickjs.Value
's returned byEval()
andEvalFile()
. All other values do not need to be freed, as they get garbage-collected. - You may access the stacktrace of an error returned by
Eval()
orEvalFile()
by casting it to a*quickjs.Error
. - Make new copies of arguments should you want to return them in functions you created.
- Make sure to call
runtime.LockOSThread()
to ensure that QuickJS always operates in the exact same thread.
Free
Free Safe Functions
Value.Interface
- inner references will be freedValue.InterfaceAndFree
- current & inner reference will be freedValue.GetString(ByUint32)
- new reference will be freedValue.GetInt64(ByUint32)
- new reference will be freedValue.GetFloat64(ByUint32)
- new reference will be freedValue.DynamicCall(WithContext)
- args references will freed
License
QuickJS
is released under the MIT license.
QuickJS bindings
are copyright Kenta Iwasaki
, with code copyright Fabrice Bellard
and Charlie Gordon
.