1.0.1 • Published 5 years ago

@glencfl/ffi-napi-binding v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

@glencfl/ffi-napi-binding

This repository contains only the native module component of the ffi-napi package. Separating this native module out from the JavaScript code was necessary for the use of ffi-napi when writing an extension for Visual Studio Code.

This can be used in conjunction with @glencfl/ffi-napi-di to conditionally load prebuilt, platform-specific variants of this native component at runtime. This is useful in environments where builds are not runnable.

Usage

This package is available through NPM as @glencfl/ffi-napi-binding. This package is primarily intended to be used alongside the following packages:

Installation of all using yarn:

yarn add @glencfl/ref-napi-binding @glencfl/ref-napi-di @glencfl/ffi-napi-binding @glencfl/ffi-napi-di

Usage

The above installation method will build all packages as normal on your system. This is the most basic usage case, where build tools are expected to be available in both the production and development environment. A usage example for this case:

const refBinding = require('@glencfl/ref-napi-binding');
const ref = require('@glencfl/ref-napi-di')(refBinding);
const ffiBinding = require('@glencfl/ffi-napi-binding');
const ffi = require('@glencfl/ffi-napi-di')(ref, ffiBinding);

The point of this package is to cater to more elaborate usage scenarios where builds are just outright out of the question in the production environment, while still maintaining that build compatibility for ease of development. This is the reason for pre-compiled binaries being available on the repository's releases page, though only for common desktop systems and architectures. It is still largely up to you as the user to come up with a scheme for delivering the appropriate binary onto the user's system and conditionally calling require() on the appropriate .node file.