A simple Node.js native addon example that calculates Fibonacci numbers using C++.
npm install
npm run buildnpm startExample output:
JS Fibonacci(40) = 102334155
js: 942.685ms
Sync Fibonacci(40) = 102334155
native-sync: 308.387ms
native-async: 307.161ms
Async Fibonacci(40) = 102334155
const addon = require('./build/Release/fibonacci.node');
// Synchronous
const result = addon.FibonacciSync(40);
// Asynchronous
addon.FibonacciAsync(40, (err, result) => {
console.log(result);
});ISC