You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

napi-build-utils

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

napi-build-utils - npm Package Compare versions

Comparing version

to
2.0.0

.github/workflows/run-npm-tests.yml

15

index.js

@@ -50,3 +50,3 @@ 'use strict'

* Determines whether the specified N-API version is supported by the package.
* The N-API version must be preseent in the `package.json`
* The N-API version must be present in the `package.json`
* `binary.napi_versions` array.

@@ -60,3 +60,3 @@ *

if (pkg.binary && pkg.binary.napi_versions &&
pkg.binary.napi_versions instanceof Array) {
pkg.binary.napi_versions instanceof Array) { // integer array
for (var i = 0; i < pkg.binary.napi_versions.length; i++) {

@@ -139,3 +139,3 @@ if (pkg.binary.napi_versions[i] === napiVersion) return true

*
* Note that this function is speicifc to the `prebuild` and `prebuild-install`
* Note that this function is specific to the `prebuild` and `prebuild-install`
* packages.

@@ -171,6 +171,7 @@ *

var bestNapiBuildVersion = 0
var napiBuildVersions = exports.getNapiBuildVersions(pkg)
var napiBuildVersions = exports.getNapiBuildVersions(pkg) // array of integer strings
if (napiBuildVersions) {
var ourNapiVersion = exports.getNapiVersion()
napiBuildVersions.forEach(function (napiBuildVersion) {
napiBuildVersions.forEach(function (napiBuildVersionStr) {
var napiBuildVersion = parseInt(napiBuildVersionStr, 10)
if (napiBuildVersion > bestNapiBuildVersion &&

@@ -188,3 +189,3 @@ napiBuildVersion <= ourNapiVersion) {

*
* @returns {Array<string>}
* @returns {Array<string>|undefined}
*/

@@ -212,3 +213,3 @@ exports.getNapiBuildVersions = function () {

exports.getNapiVersion = function () {
var version = process.versions.napi // string, can be undefined
var version = process.versions.napi // integer string, can be undefined
if (!version) { // this code should never need to be updated

@@ -215,0 +216,0 @@ if (versionArray[0] === 9 && versionArray[1] >= 3) version = '2' // 9.3.0+

{
"name": "napi-build-utils",
"version": "1.0.2",
"version": "2.0.0",
"description": "A set of utilities to assist developers of tools that build N-API native add-ons",

@@ -10,3 +10,3 @@ "main": "index.js",

"lint": "standard",
"prepublishOnly": "npm run test && npm run doc"
"prepublishOnly": "npm run test"
},

@@ -39,5 +39,6 @@ "keywords": [

2,
3
3,
10
]
}
}

@@ -5,15 +5,15 @@ # napi-build-utils

![Node version](https://img.shields.io/node/v/prebuild.svg)
[![Build Status](https://travis-ci.org/inspiredware/napi-build-utils.svg?branch=master)](https://travis-ci.org/inspiredware/napi-build-utils)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![Build Status](https://github.com/inspiredware/napi-build-utils/actions/workflows/run-npm-tests.yml/badge.svg)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
A set of utilities to assist developers of tools that build [N-API](https://nodejs.org/api/n-api.html#n_api_n_api) native add-ons.
A set of utilities to assist developers of tools that build [Node-API](https://nodejs.org/api/n-api.html#n_api_n_api) native add-ons.
## Background
This module is targeted to developers creating tools that build N-API native add-ons.
This module is targeted to developers creating tools that build Node-API native add-ons.
It implements a set of functions that aid in determining the N-API version supported by the currently running Node instance and the set of N-API versions against which the N-API native add-on is designed to be built. Other functions determine whether a particular N-API version can be built and can issue console warnings for unsupported N-API versions.
It implements a set of functions that aid in determining the Node-API version supported by the currently running Node instance and the set of Node-API versions against which the Node-API native add-on is designed to be built. Other functions determine whether a particular Node-API version can be built and can issue console warnings for unsupported Node-API versions.
Unlike the modules this code is designed to facilitate building, this module is written entirely in JavaScript.
Unlike the modules this code is designed to facilitate building, this module is written entirely in JavaScript.

@@ -23,3 +23,3 @@ ## Quick start

```bash
$ npm install napi-build-utils
npm install napi-build-utils
```

@@ -31,8 +31,8 @@

var napiBuildUtils = require('napi-build-utils');
var napiVersion = napiBuildUtils.getNapiVersion(); // N-API version supported by Node, or undefined.
var napiVersion = napiBuildUtils.getNapiVersion(); // Node-API version supported by Node, or undefined.
```
## Declaring supported N-API versions
## Declaring supported Node-API versions
Native modules that are designed to work with [N-API](https://nodejs.org/api/n-api.html#n_api_n_api) must explicitly declare the N-API version(s) against which they are coded to build. This is accomplished by including a `binary.napi_versions` property in the module's `package.json` file. For example:
Native modules that are designed to work with [Node-API](https://nodejs.org/api/n-api.html#n_api_n_api) must explicitly declare the Node-API version(s) against which they are coded to build. This is accomplished by including a `binary.napi_versions` property in the module's `package.json` file. For example:

@@ -43,10 +43,14 @@ ```json

}
```
```
In the absence of a need to compile against a specific N-API version, the value `3` is a good choice as this is the N-API version that was supported when N-API left experimental status.
In the absence of a need to compile against a specific Node-API version, the value `3` is a good choice as this is the Node-API version that was supported when Node-API left experimental status.
Modules that are built against a specific N-API version will continue to operate indefinitely, even as later versions of N-API are introduced.
Modules that are built against a specific Node-API version will continue to operate indefinitely, even as later versions of Node-API are introduced.
## History
**v2.0.0** This version was introduced to address a limitation when the Node-API version reached `10` in NodeJS `v23.6.0`. There was no change in the API, but a SemVer bump to `2.0.0` was made out of an abundance of caution.
## Support
If you run into problems or limitations, please file an issue and we'll take a look. Pull requests are also welcome.
If you run into problems or limitations, please file an issue and we'll take a look. Pull requests are also welcome.