Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ajihyf/node-addon-api-helper
A more convenient, type-safe and boilerplate-less way to write Node.js C++ addons.
https://github.com/ajihyf/node-addon-api-helper
cpp n-api napi node-addon-api
Last synced: about 1 month ago
JSON representation
A more convenient, type-safe and boilerplate-less way to write Node.js C++ addons.
- Host: GitHub
- URL: https://github.com/ajihyf/node-addon-api-helper
- Owner: ajihyf
- License: mit
- Created: 2022-04-13T11:43:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-26T11:10:59.000Z (8 months ago)
- Last Synced: 2024-04-26T10:05:02.150Z (7 months ago)
- Topics: cpp, n-api, napi, node-addon-api
- Language: C++
- Homepage:
- Size: 154 KB
- Stars: 13
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-addon-api-helper
[![NPM](https://img.shields.io/npm/v/node-addon-api-helper)](https://www.npmjs.com/package/node-addon-api-helper)
[![CI](https://github.com/ajihyf/node-addon-api-helper/workflows/ci/badge.svg)](https://github.com/ajihyf/node-addon-api-helper/actions/workflows/ci.yml)
[![lint](https://github.com/ajihyf/node-addon-api-helper/workflows/lint/badge.svg)](https://github.com/ajihyf/node-addon-api-helper/actions/workflows/lint.yml)
![C++17](https://img.shields.io/badge/C%2B%2B-17-blue.svg)
[![LICENSE](https://img.shields.io/github/license/ajihyf/node-addon-api-helper)](https://github.com/ajihyf/node-addon-api-helper/blob/main/LICENSE)![Windows Support](https://img.shields.io/static/v1?label=Windows&logo=windows&logoColor=white&message=support&color=success)
![Linux Support](https://img.shields.io/static/v1?label=Linux&logo=linux&logoColor=white&message=support&color=success)
![Mac Support](https://img.shields.io/static/v1?label=macOS&logo=apple&logoColor=white&message=support&color=success)Based on [node-addon-api](https://github.com/nodejs/node-addon-api), **node-addon-api-helper(naah)** provides a more convenient, type-safe and boilerplate-less way to write Node.js C++ addons.
Features:
- Automatically transform values between JavaScript and C++
- Automatically register exports
- Class binding (with inheritance)
- Custom object type
- Thread safe function
- Create async work and return promise
- Can be used together with original node-addon-api, no need to rewrite all
- Pure header, can be easily integrated## QuickStart
```bash
npm install node-addon-api node-addon-api-helper
```Add following content to your GYP file.
```gyp
{
'include_dirs': [
"uint32_t add(uint32_t a, uint32_t b) {
return a + b;
}NAAH_REGISTRATION {
naah::Registration::Function("add");
}NAAH_EXPORT
```## Documentation
- [Exports](./doc/exports.md)
- [Function](./doc/function.md)
- [Object](./doc/object.md)
- [Class](./doc/class.md)
- [Mix with node-addon-api](./doc/mix_with_napi.md)
- [Thread Safe Function](./doc/thread_safe_function.md)
- [Async Work](./doc/async_work.md)
- [Error Handling](./doc/error_handling.md)## Examples
See `naah` directories in the [fork of node-addon-examples](https://github.com/ajihyf/node-addon-examples) for examples.
## Thanks
- Based on [node-addon-api](https://github.com/nodejs/node-addon-api).
- Inspired by [napi-rs](https://napi.rs), [emscripten](https://emscripten.org/) and [nbind](https://github.com/charto/nbind).