/nodejs-addons

πŸ’ͺ This repository contains C++ Addons Examples for NodeJS. The main idea is to document with examples and tips on how to create plugins with C ++ for NodeJS

Primary LanguagePythonMIT LicenseMIT



Node.js C++ Addons

πŸ’ͺ This repository contains C++ Addons Examples for NodeJS.



πŸ”– Description

The main idea is to document with examples and tips on how to create plugins with C ++ for Node.js. C and C ++ were my first programming languages, I learned the basics with them and I am very fond of them (although I am rusty πŸ˜†).

🌍 Websites of Interest

πŸ“Œ Methodologies and Guidelines

Quality Assurance Code (QAC)

βœ… Prerequisites

In order to work with this project, your local environment must have at least the following versions:

  • NodeJS Version: 14.xx
  • NPM Version: 6.14.7

πŸ“ How to work with this project

Install Dependencies

$npm i

Running the App

$node ./src/'folder'/'file.js'

πŸ“¦ How to prepare and build a C++ Addons

Install Dependencies

$npm i -g node-gyp

Generate the appropriate project build files.

$node-gyp configure

Build the addon project.

$node-gyp build

πŸ“‚ Code scaffolding

/
β”œβ”€β”€ assets 🌈                     # Images Sources.
β”œβ”€β”€ env πŸ”Œ                        # Configure enviroments deploy.
β”œβ”€β”€ src πŸ’―
|   β”œβ”€β”€ hello-world
|   |   β”œβ”€β”€ example01             # Show Hello word message.
|   |   └── example02             # Add colors and reset default color.
|   |
|   β”œβ”€β”€ data-types
|   |   β”œβ”€β”€ example01             # Working with int, float and double.
|   |   β”œβ”€β”€ example02             # Working with char and char array.
|   |   β”œβ”€β”€ example03             # Working with string.
|   |   └── example04             # Working with bool.
|   |
|   β”œβ”€β”€ arrays
|   |   β”œβ”€β”€ example01             # Create array with int values and show by index.
|   |   β”œβ”€β”€ example02             # Read the number of bytes that an array with int occupies.
|   |   β”œβ”€β”€ example03             # Create array with strings values and show by index.
|   |   β”œβ”€β”€ example04             # Read the number of bytes that an array with strings occupies.
|   |   β”œβ”€β”€ example05             # Execute other function and return array strings.
|   |   β”œβ”€β”€ example06             # Execute other function with internal bucle for and return array strings.
|   |   └── example07             # Execute other function with internal bucle for and show the array size.
|   |
|   β”œβ”€β”€ operators
|   |   β”œβ”€β”€ example01             # Sum, sub, multi and div with two int.
|   |   β”œβ”€β”€ example02             # Increment and decrement with two int.
|   |   └── example03             # Working with div and precision with decimals.
|   |
|   β”œβ”€β”€ conditionals
|   |   β”œβ”€β”€ example01             # Use if and else conditionals.
|   |   └── example02             # Working with switch conditionals.
|   |
|   β”œβ”€β”€ bucles
|   |   β”œβ”€β”€ example01             # Working with bucle while.
|   |   β”œβ”€β”€ example02             # Working with bucle for.
|   |   β”œβ”€β”€ example03             # Working with bucle do while.
|   |   └── example04             # Working with nested loops.
|   |
|   β”œβ”€β”€ methods
|   |   β”œβ”€β”€ example01             # Define two public method into the addons.
|   |   └── example02             # Define two public method and one internal.
|   |
|   β”œβ”€β”€ params
|   |   └── example01             # Get if param is number, string and the length.
|   |
|   β”œβ”€β”€ returns
|   |   β”œβ”€β”€ example01             # Return from addon to js the number of params.
|   |   └── example02             # Return from addon to js the value of the param.
|   └── ...
└── ...

⛽️ Review and Update Dependences

For review and update all npm dependences of this project you need install in global npm package "npm-check-updates" npm module.

# Install and Run
$npm i -g npm-check-updates
$ncu

Happy Code

Created with JavaScript, lot of ❀️ and a few β˜•οΈ

This README.md file has been written keeping in mind