New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-addon-api-helper

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-addon-api-helper

Simplify node-addon-api native binding development with C++ meta programming

latest
Source
npmnpm
Version
2.2.0
Version published
Maintainers
1
Created
Source

node-addon-api-helper

NPM CI lint C++17 LICENSE

Windows Support Linux Support Mac Support

Based on 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

npm install node-addon-api node-addon-api-helper

Add following content to your GYP file.

{
  'include_dirs': [
    "<!(node -p \"require('node-addon-api').include_dir\")",
    "<!(node -p \"require('node-addon-api-helper').include_dir\")",
  ]
}

naah heavily depends on C++17, if you haven't configured your project on C++17, have a look at naah.gypi as an example.

A hello world example :

#include <naah.h>

uint32_t add(uint32_t a, uint32_t b) {
  return a + b;
}

NAAH_REGISTRATION {
  naah::Registration::Function<add>("add");
}

NAAH_EXPORT

Documentation

Examples

See naah directories in the fork of node-addon-examples for examples.

Thanks

Keywords

n-api

FAQs

Package last updated on 26 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts