Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

github.com/chumaumenze/gjs

Package Overview
Dependencies
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/chumaumenze/gjs

Source
Go Modules
Version
v0.1.0
Version published
Created
Source

✨ GJS ✨

Comprehensive API for Webassembly environment

Create a fork Github Actions made-with-Go GoReportCard Go.mod version LICENCE Latest release

About

GJS provides a comprehensive API to access the WebAssembly host environment when using the js/wasm architecture. Its API is based on JavaScript semantics and provides WebAssembly interop between Go and JS values. Its current scope is to provide a comprehensive and well-tested API.

Install

GOOS=js GOARCH=wasm go get github.com/chumaumenze/gjs

Usage

package main

import "github.com/chumaumenze/gjs"

type Data struct {
    Code    int
	Message string `json:"message"`
    inner   any
}

func main() {
    data := Data{
        Code: 200,
		Message: "Hello World!",
        inner: "I am ignored",
	}
	v := gjs.ValueOf(data) // e.g. {Code: 200, "message": "Hello World!"}
}

Motivations

The Go standard library's syscall/js package offers limited compatibility between Go and JavaScript values.

  • The js.Value type lacks support for interfaces or assignment methods for complex Go values.
  • The js.ValueOf function cannot handle complex types like structs, leading to a panic with the error message ValueOf: invalid value.

To overcome these limitations, gjs builds upon and extends the functionality of syscall/js.

FAQs

Package last updated on 07 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts