GithubHelp home page GithubHelp logo

hebertcisco / cpp-npm-package-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 976 KB

A boilerplate for creating a C++ npm package: https://www.npmjs.com/package/cpp-npm-package-boilerplate

Home Page: https://github.com/nodejs/node-addon-api

License: MIT License

C++ 100.00%
boilerplate boilerplate-template node node-js node-module node-napi node-native node-native-addons nodejs nodejs-modules npm npm-module npm-package npm-packages cpp cpp-programming cpp14 cpp17-library

cpp-npm-package-boilerplate's Introduction

:package: cpp-npm-package-boilerplate

๐Ÿ“ฆ cpp-npm-package-boilerplate

A boilerplate for creating a C++ npm package

Issues GitHub pull requests GitHub Downloads GitHub Total Downloads GitHub release

Report Bug Request Feature

Systems on which it has been tested:

Ubuntu

Did you like the project? Please, considerate a donation to help improve!

A boilerplate for creating a C++ npm packageโœจ

Getting started

Node.js build and publish package

Running Code Coverage

TypeScript Nodejs C++

NPM Free. Built on open source. Runs everywhere. GitHub Actions

Installation(Example purposes)

Install with yarn or npm: yarn or npm:

# yarn
yarn add cpp-npm-package-boilerplate
# npm
npm i cpp-npm-package-boilerplate --save

Usage example

import { helloNative } from 'cpp-npm-package-boilerplate';

console.log(helloNative('C++')); // Hello C++

Note: This is example is a binding of the C++ function helloNative to the JavaScript function helloNative.

C++ function

#include <napi.h>

Napi::String Method(const Napi::CallbackInfo &info)
{
    Napi::Env env = info.Env();
    return Napi::String::New(env, "world");
}

Napi::Object Init(Napi::Env env, Napi::Object exports)
{
    exports.Set(Napi::String::New(env, "hello"),
                Napi::Function::New(env, Method));
    return exports;
}

NODE_API_MODULE(hello, Init)

JavaScript function

import bindings from 'bindings';
export const helloNative = bindings('hello.node').hello;

TypeScript implementation

import bindings from 'bindings';

type THelloNative = (string: string) => string;

export const helloNative: THelloNative = bindings('hello.node').hello;

๐Ÿค Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a โญ๏ธ if this project helped you!

Or buy me a coffee ๐Ÿ™Œ๐Ÿพ

๐Ÿ“ License

Copyright ยฉ 2023 Hebert F Barros.
This project is MIT licensed.

cpp-npm-package-boilerplate's People

Contributors

dependabot[bot] avatar favelado-web avatar hebertcisco avatar snyk-bot avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.