Skip to content

felixdrp/node-addon-example-function-call-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-addon-example-function-call-zig Zig Logo

Example of addon using Zig lang. This example will call a JavaScript function from a native add-on. This is the primary mechanism of calling back from the add-on's native code into JavaScript.
For the special case of calling into JavaScript after an async operation, see napi_make_callback [github].

Similar example in C

Other examples by @felixdrp

Node.js Native Module written in Zig

This project is an example Hello World for making a Node.js native module in Zig. To install Zig:

The entry point is src/lib.zig.

Run this project like this:

# 1. Git clone it
git clone https://github.com/felixdrp/node-addon-example-function-call-zig.git

# 2. Download Node.js header files
npm run postinstall

# 3. Compile the Zig module and produce `dist/lib.node`
npm run build

# 4. Run example. It will call the `foo()` function from Zig module.
npm run exec

# Bonus: Debug mode (build dev) 🐛
npm run bdev

License and acknowledgements

Many thanks to https://staltz.com for his example. [1]: https://staltz.com [2]: https://github.com/staltz/zig-nodejs-example

Learning Zig

Debug Zig

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published