Nodejs Native C/C++ add on example with v8 and N-API.
Switch branches/tags
Nothing to show
Clone or download
Latest commit c42f4c8 Nov 26, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build_native_addon fixed typo Nov 26, 2017
build_native_addon_with_napi fixed file extention Nov 26, 2017
prime_number init commit Nov 20, 2017
Readme.md init commit Nov 20, 2017

Readme.md

NodeJs-Addon-Example

Nodejs Addon with Native C/C++ example.

In both cases we use node-gyp to build from C/C++ code.

In this example, We build a C++ code that determines a very simple prime as an add-on to node.js.

Confirm the C code

clang main.cpp prime_number.cpp -o prime_number

./prime_number
Enters number: 4
Is not prime number%

./prime_number
Enters number: 5
Is prime number%

C/C++ Addon with V8

Buildding nodejs native addon C/C++ code. Compile C/C++ code with node-gyp.

npm i
#  node-gyp configure
npm run configure
# node-gyp build
npm run build
# test build addon
npt test
# if prime number stdot `true` eles `false`

C/C++ Addon with N-API

N-APIis an ABI stable intermediate layer of the NodeJS API. Using N-API eliminates the need to build native add on dependent on V8 for each platform or architecture.

npm i
#  node-gyp configure
npm run configure
# node-gyp build
npm run build
# test build addon
npt test
# if prime number stdot `true` eles `false`