napii

0.0.3 • Public • Published

napii

Easily adding node.js N-API Modules to your project!

  • Add native modules to your project.
  • Access all native modules just by const napii = require('napii);.
  • Example of native module is attached.
  • Only Git-Repositories supported right now.

Prerequisites

N-API Module like attached Example with following structure

lib/
  cpp/
    napi.cc
    module.hpp
  js/
    module.js #optional - if same module exists in javascript 
test#optional 
binding.gyp
index.hpp
index.js
package.json
README.md #optional but recommended 

Getting Started

  • For use in C++

    Just add #include "<native_module>/index.hpp" to your header.

  • For using in node.js

    • Yarn is recommended: npm install -g yarn.

    • Install package: yarn add --dev napii or install it globally with yarn global add napii.

Usage

  # Add your N-API Modules with... 
 
  # Run: 
  ./node_modules/.bin/napii -a <name> <type> <repo>
 
  #OR 
 
  # Add to your npm scripts: 
  "add:native""napii -a"
 
  # Run: 
  yarn add:native <name> <type> <repo>
 
  #OR 
 
  # Run globally: 
  napii -a <name> <type> <repo>

This adds dependecy to your package.json like example below.

{
  ...
 
  "nativeDependencies"{
    "sample"{
      "type""git",
      "source""https://github.com/path/to/your/repository.git"
    }
  }
  ...
}
  # Build your modules with... 
 
  # Run 
  ./node_modules/.bin/napii -b
 
  #OR 
 
  # Run globally 
  napii -b
 
  # For automised build add to your npm scripts 
  "postinstall""napii -b"
# Use native modules in your code. 
const { sample } = require('napii');
 
sample.<function>()

Readme

Keywords

Package Sidebar

Install

npm i napii

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

10.6 kB

Total Files

16

Last publish

Collaborators

  • kaiser-panda