ai_old/goja_nodejs
Star 767d87ac3e update throw exception
add util.load and util.save
2024-09-24 13:34:32 +08:00
..
buffer update throw exception 2024-09-24 13:34:32 +08:00
console update throw exception 2024-09-24 13:34:32 +08:00
errors update throw exception 2024-09-24 13:34:32 +08:00
eventloop update throw exception 2024-09-24 13:34:32 +08:00
process update throw exception 2024-09-24 13:34:32 +08:00
require update throw exception 2024-09-24 13:34:32 +08:00
url update throw exception 2024-09-24 13:34:32 +08:00
util update throw exception 2024-09-24 13:34:32 +08:00
assert.js update throw exception 2024-09-24 13:34:32 +08:00
LICENSE update throw exception 2024-09-24 13:34:32 +08:00
README.md update throw exception 2024-09-24 13:34:32 +08:00
staticcheck.conf update throw exception 2024-09-24 13:34:32 +08:00

Nodejs compatibility library for Goja

This is a collection of Goja modules that provide nodejs compatibility.

Example:

package main

import (
    "apigo.cc/ai/ai/goja"
    "apigo.cc/ai/ai/goja_nodejs/require"
)

func main() {
    registry := new(require.Registry) // this can be shared by multiple runtimes

    runtime := goja.New()
    req := registry.Enable(runtime)

    runtime.RunString(`
    var m = require("./m.js");
    m.test();
    `)

    m, err := req.Require("./m.js")
    _, _ = m, err
}

More modules will be added. Contributions welcome too.