File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,33 @@ const example = require("./example.node");
5050example .myHandler ();
5151```
5252
53+ ### JS Helpers
54+
55+ In addition to the Node-API exposed via package ` napi ` , the ` napi-go/js `
56+ package provides functions similar to the ` syscall/js ` standard library.
57+
58+ ``` go
59+ package main
60+
61+ import (
62+ " github.com/akshayganeshen/napi-go/entry"
63+ " github.com/akshayganeshen/napi-go/js"
64+ )
65+
66+ func init () {
67+ entry.Export (" myCallback" , js.AsCallback (MyCallback))
68+ }
69+
70+ func MyCallback (env js .Env , this js .Value , args []js .Value ) any {
71+ return map [string ]any{
72+ " message" : " hello world" ,
73+ " args" : args,
74+ }
75+ }
76+
77+ func main () {}
78+ ```
79+
5380## Examples
5481
5582Check out the example addons in [ ` docs/examples ` ] ( docs/examples ) .
You can’t perform that action at this time.
0 commit comments