Categorygithub.com/newdash/quickjs
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

github ci

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

  1. Free quickjs.Runtime and quickjs.Context once you are done using them.
  2. Free quickjs.Value's returned by Eval() and EvalFile(). All other values do not need to be freed, as they get garbage-collected.
  3. You may access the stacktrace of an error returned by Eval() or EvalFile() by casting it to a *quickjs.Error.
  4. Make new copies of arguments should you want to return them in functions you created.
  5. Make sure to call runtime.LockOSThread() to ensure that QuickJS always operates in the exact same thread.

Free

Free Safe Functions

  1. Value.Interface - inner references will be freed
  2. Value.InterfaceAndFree - current & inner reference will be freed
  3. Value.GetString(ByUint32) - new reference will be freed
  4. Value.GetInt64(ByUint32) - new reference will be freed
  5. Value.GetFloat64(ByUint32) - new reference will be freed
  6. Value.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.