Example of addon using Zig lang. How to access Buffers in Zig.
For more info about C/C++ addons with Node-API
, see C/C++ addons with Node-API [github].
This example is based on:
- https://blog.risingstack.com/using-buffers-node-js-c-plus-plus/
- https://github.com/freezer333/nodecpp-demo/blob/master/buffers/basic/buffer_example.cpp
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-buffer-zig.git
# 2. Download Node.js header files
npm install
# 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
Many thanks to @staltz for his example. [1]: https://staltz.com [2]: https://github.com/staltz/zig-nodejs-example
Many thanks to RisingStack Engineering
. [1]:(https://blog.risingstack.com)