GithubHelp home page GithubHelp logo

atishay / napi Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 0.0 3.17 MB

N-API based Souvenir service for CascadiaJS 2018

Home Page: https://n-api.herokuapp.com

Python 17.88% JavaScript 19.90% HTML 21.39% C++ 40.83%
nodejs cplusplus n-api nan cascadiajs javascript tutorial sample-code imagemagick

napi's Introduction

N-API Tutorial

Sample Output

Do not use this on production. This is is meant to be a tutorial and not a production API. The code has been intentionally minimized to ignore many error cases and uses synchronous APIs for simplification.

Sample code which introduces the N-API stable in Node.js since Node 10+. The native code is present in the native folder. The rest of the code is present to demonstrate a sample application. This code was prepared for the Cascadia JS conference - https://2018.cascadiajs.com/.

Here are the native pieces and the order in which they should be read:

  1. Version Gets the ImageMagick version as a string.
  2. Info Gets some basic information about the image from ImageMagick.
  3. Edit Edits an image via ImageMagick to create a new version used in the demo.

There are three versions of the sample usage app:

  1. CLI Wonderful for testing and debugging. Also used for the C++ debugger provided for VS Code.
  2. Server Express.js based web server hosting a sample app for the Edit application.
  3. Electron Sample Electron code using the Edit module.

No recompilation should be needed to run the electron and the node versions. Switching node versions should not need a recompilation to utilize the API. While the API is experimental in node 8 and should not be used in production, this code works for Node 8+ (with a warning in Node 8).

Important Scripts:

  • Recompile Native code
node-gyp rebuild
  • Run Electron Version
npm run electron
  • Run Web server
npm start
  • Run command line API tests
npm test

More resources on the N-API

Image from: https://pixnio.com/transportation-vehicles/cars-automobile/wet-cold-mirror-dew-rain-car#

napi's People

Contributors

atishay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.