Comparing version 2.5.0-beta.1 to 2.5.0-beta.2
@@ -12,2 +12,3 @@ # Special parameters | ||
- [Structs](types.md#struct-types) (to/from JS objects) | ||
- [Unions](unions.md) | ||
- [Opaque types](types.md#opaque-types) | ||
@@ -14,0 +15,0 @@ - String buffers |
{ | ||
"name": "koffi", | ||
"version": "2.5.0-beta.1", | ||
"version": "2.5.0-beta.2", | ||
"stable": "2.4.2", | ||
@@ -5,0 +5,0 @@ "description": "Fast and simple C FFI (foreign function interface) for Node.js", |
@@ -421,2 +421,3 @@ # AsyncWorker | ||
return info.Env().Undefined(); | ||
} | ||
``` | ||
@@ -423,0 +424,0 @@ |
@@ -63,1 +63,22 @@ # Creating a release | ||
* Tweet that the release has been created. | ||
## Optional Steps | ||
Depending on circumstances for the release, additional steps may be required to | ||
support the release process. | ||
### Major Releases to Drop Support Node.js Versions | ||
`node-addon-api` provides support for Node.js versions following the same | ||
[release schedule](https://nodejs.dev/en/about/releases/): once a Node.js | ||
version leaves maintenance mode, the next major version of `node-addon-api` | ||
published will drop support for that version. These are the steps to follow to | ||
drop support for a Node.js version: | ||
* Update minimum version supported in documentation ([README.md](../README.md)) | ||
* Remove from GitHub actions ([ci.yml](../.github/workflows/ci.yml) and | ||
[ci-win.yml](../.github/workflows/ci-win.yml)) | ||
* Remove from Jenkins CI ([node-test-node-addon-api-LTS versions | ||
[Jenkins]](https://ci.nodejs.org/view/x%20-%20Abi%20stable%20module%20API/job/node-test-node-addon-api-LTS%20versions/)) |
@@ -144,2 +144,9 @@ # Value | ||
```cpp | ||
bool Napi::Value::IsBigInt() const; | ||
``` | ||
Returns `true` if the underlying value is a JavaScript `Napi::BigInt` or `false` | ||
otherwise. | ||
### IsBoolean | ||
@@ -146,0 +153,0 @@ |
@@ -402,2 +402,10 @@ { | ||
"url": "https://github.com/F3n67u" | ||
}, | ||
{ | ||
"name": "wanlu wang", | ||
"url": "https://github.com/wanlu" | ||
}, | ||
{ | ||
"name": "Caleb Hearon", | ||
"url": "https://github.com/chearon" | ||
} | ||
@@ -463,4 +471,4 @@ ], | ||
"pre-commit": "lint", | ||
"version": "6.1.0", | ||
"version": "7.0.0", | ||
"support": true | ||
} |
@@ -73,3 +73,3 @@ NOTE: The default branch has been renamed! | ||
## **Current version: 6.1.0** | ||
## **Current version: 7.0.0** | ||
@@ -87,3 +87,3 @@ (See [CHANGELOG.md](CHANGELOG.md) for complete Changelog) | ||
The oldest Node.js version supported by the current version of node-addon-api is Node.js 14.x. | ||
The oldest Node.js version supported by the current version of node-addon-api is Node.js 16.x. | ||
@@ -280,2 +280,3 @@ ## Setup | ||
![Node-API v8 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v8%20Badge.svg) | ||
![Node-API v9 Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20v9%20Badge.svg) | ||
![Node-API Experimental Version Badge](https://github.com/nodejs/abi-stable-node/blob/doc/assets/Node-API%20Experimental%20Version%20Badge.svg) | ||
@@ -282,0 +283,0 @@ |
@@ -7,8 +7,142 @@ 'use strict'; | ||
module.exports = common.runTest(test); | ||
const nodeVersion = process.versions.node.split('.')[0]; | ||
let asyncHooks; | ||
function checkAsyncHooks () { | ||
if (nodeVersion >= 8) { | ||
if (asyncHooks === undefined) { | ||
asyncHooks = require('async_hooks'); | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
async function test ({ asyncprogressqueueworker }) { | ||
await success(asyncprogressqueueworker); | ||
await fail(asyncprogressqueueworker); | ||
await asyncProgressWorkerCallbackOverloads(asyncprogressqueueworker.runWorkerWithCb); | ||
await asyncProgressWorkerRecvOverloads(asyncprogressqueueworker.runWorkerWithRecv); | ||
await asyncProgressWorkerNoCbOverloads(asyncprogressqueueworker.runWorkerNoCb); | ||
} | ||
async function asyncProgressWorkerCallbackOverloads (bindingFunction) { | ||
bindingFunction(common.mustCall()); | ||
if (!checkAsyncHooks()) { | ||
return; | ||
} | ||
const hooks = common.installAysncHooks('cbResources'); | ||
const triggerAsyncId = asyncHooks.executionAsyncId(); | ||
await new Promise((resolve, reject) => { | ||
bindingFunction(common.mustCall(), 'cbResources'); | ||
hooks.then(actual => { | ||
assert.deepStrictEqual(actual, [ | ||
{ | ||
eventName: 'init', | ||
type: 'cbResources', | ||
triggerAsyncId: triggerAsyncId, | ||
resource: {} | ||
}, | ||
{ eventName: 'before' }, | ||
{ eventName: 'after' }, | ||
{ eventName: 'destroy' } | ||
]); | ||
resolve(); | ||
}).catch((err) => reject(err)); | ||
}); | ||
} | ||
async function asyncProgressWorkerRecvOverloads (bindingFunction) { | ||
const recvObject = { | ||
a: 4 | ||
}; | ||
function cb () { | ||
assert.strictEqual(this.a, recvObject.a); | ||
} | ||
bindingFunction(recvObject, common.mustCall(cb)); | ||
if (!checkAsyncHooks()) { | ||
return; | ||
} | ||
const asyncResources = [ | ||
{ resName: 'cbRecvResources', resObject: {} }, | ||
{ resName: 'cbRecvResourcesObject', resObject: { foo: 'bar' } } | ||
]; | ||
for (const asyncResource of asyncResources) { | ||
const asyncResName = asyncResource.resName; | ||
const asyncResObject = asyncResource.resObject; | ||
const hooks = common.installAysncHooks(asyncResource.resName); | ||
const triggerAsyncId = asyncHooks.executionAsyncId(); | ||
await new Promise((resolve, reject) => { | ||
if (Object.keys(asyncResObject).length === 0) { | ||
bindingFunction(recvObject, common.mustCall(cb), asyncResName); | ||
} else { | ||
bindingFunction(recvObject, common.mustCall(cb), asyncResName, asyncResObject); | ||
} | ||
hooks.then(actual => { | ||
assert.deepStrictEqual(actual, [ | ||
{ | ||
eventName: 'init', | ||
type: asyncResName, | ||
triggerAsyncId: triggerAsyncId, | ||
resource: asyncResObject | ||
}, | ||
{ eventName: 'before' }, | ||
{ eventName: 'after' }, | ||
{ eventName: 'destroy' } | ||
]); | ||
resolve(); | ||
}).catch((err) => reject(err)); | ||
}); | ||
} | ||
} | ||
async function asyncProgressWorkerNoCbOverloads (bindingFunction) { | ||
bindingFunction(common.mustCall()); | ||
if (!checkAsyncHooks()) { | ||
return; | ||
} | ||
const asyncResources = [ | ||
{ resName: 'noCbResources', resObject: {} }, | ||
{ resName: 'noCbResourcesObject', resObject: { foo: 'bar' } } | ||
]; | ||
for (const asyncResource of asyncResources) { | ||
const asyncResName = asyncResource.resName; | ||
const asyncResObject = asyncResource.resObject; | ||
const hooks = common.installAysncHooks(asyncResource.resName); | ||
const triggerAsyncId = asyncHooks.executionAsyncId(); | ||
await new Promise((resolve, reject) => { | ||
if (Object.keys(asyncResObject).length === 0) { | ||
bindingFunction(asyncResName, common.mustCall(() => {})); | ||
} else { | ||
bindingFunction(asyncResName, asyncResObject, common.mustCall(() => {})); | ||
} | ||
hooks.then(actual => { | ||
assert.deepStrictEqual(actual, [ | ||
{ | ||
eventName: 'init', | ||
type: asyncResName, | ||
triggerAsyncId: triggerAsyncId, | ||
resource: asyncResObject | ||
}, | ||
{ eventName: 'before' }, | ||
{ eventName: 'after' }, | ||
{ eventName: 'destroy' } | ||
]); | ||
resolve(); | ||
}).catch((err) => reject(err)); | ||
}); | ||
} | ||
} | ||
function success (binding) { | ||
@@ -15,0 +149,0 @@ return new Promise((resolve, reject) => { |
@@ -7,3 +7,15 @@ 'use strict'; | ||
module.exports = common.runTest(test); | ||
const nodeVersion = process.versions.node.split('.')[0]; | ||
let asyncHooks; | ||
function checkAsyncHooks () { | ||
if (nodeVersion >= 8) { | ||
if (asyncHooks === undefined) { | ||
asyncHooks = require('async_hooks'); | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
async function test ({ asyncprogressworker }) { | ||
@@ -14,4 +26,126 @@ await success(asyncprogressworker); | ||
await signalTest(asyncprogressworker.doSignalAfterProgressTest); | ||
await asyncProgressWorkerCallbackOverloads(asyncprogressworker.runWorkerWithCb); | ||
await asyncProgressWorkerRecvOverloads(asyncprogressworker.runWorkerWithRecv); | ||
await asyncProgressWorkerNoCbOverloads(asyncprogressworker.runWorkerNoCb); | ||
} | ||
async function asyncProgressWorkerCallbackOverloads (bindingFunction) { | ||
bindingFunction(common.mustCall()); | ||
if (!checkAsyncHooks()) { | ||
return; | ||
} | ||
const hooks = common.installAysncHooks('cbResources'); | ||
const triggerAsyncId = asyncHooks.executionAsyncId(); | ||
await new Promise((resolve, reject) => { | ||
bindingFunction(common.mustCall(), 'cbResources'); | ||
hooks.then(actual => { | ||
assert.deepStrictEqual(actual, [ | ||
{ | ||
eventName: 'init', | ||
type: 'cbResources', | ||
triggerAsyncId: triggerAsyncId, | ||
resource: {} | ||
}, | ||
{ eventName: 'before' }, | ||
{ eventName: 'after' }, | ||
{ eventName: 'destroy' } | ||
]); | ||
}).catch(common.mustNotCall()); | ||
resolve(); | ||
}); | ||
} | ||
async function asyncProgressWorkerRecvOverloads (bindingFunction) { | ||
const recvObject = { | ||
a: 4 | ||
}; | ||
function cb () { | ||
assert.strictEqual(this.a, recvObject.a); | ||
} | ||
bindingFunction(recvObject, common.mustCall(cb)); | ||
if (!checkAsyncHooks()) { | ||
return; | ||
} | ||
const asyncResources = [ | ||
{ resName: 'cbRecvResources', resObject: {} }, | ||
{ resName: 'cbRecvResourcesObject', resObject: { foo: 'bar' } } | ||
]; | ||
for (const asyncResource of asyncResources) { | ||
const asyncResName = asyncResource.resName; | ||
const asyncResObject = asyncResource.resObject; | ||
const hooks = common.installAysncHooks(asyncResource.resName); | ||
const triggerAsyncId = asyncHooks.executionAsyncId(); | ||
await new Promise((resolve, reject) => { | ||
if (Object.keys(asyncResObject).length === 0) { | ||
bindingFunction(recvObject, common.mustCall(cb), asyncResName); | ||
} else { | ||
bindingFunction(recvObject, common.mustCall(cb), asyncResName, asyncResObject); | ||
} | ||
hooks.then(actual => { | ||
assert.deepStrictEqual(actual, [ | ||
{ | ||
eventName: 'init', | ||
type: asyncResName, | ||
triggerAsyncId: triggerAsyncId, | ||
resource: asyncResObject | ||
}, | ||
{ eventName: 'before' }, | ||
{ eventName: 'after' }, | ||
{ eventName: 'destroy' } | ||
]); | ||
}).catch(common.mustNotCall()); | ||
resolve(); | ||
}); | ||
} | ||
} | ||
async function asyncProgressWorkerNoCbOverloads (bindingFunction) { | ||
bindingFunction(common.mustCall(() => {})); | ||
if (!checkAsyncHooks()) { | ||
return; | ||
} | ||
const asyncResources = [ | ||
{ resName: 'noCbResources', resObject: {} }, | ||
{ resName: 'noCbResourcesObject', resObject: { foo: 'bar' } } | ||
]; | ||
for (const asyncResource of asyncResources) { | ||
const asyncResName = asyncResource.resName; | ||
const asyncResObject = asyncResource.resObject; | ||
const hooks = common.installAysncHooks(asyncResource.resName); | ||
const triggerAsyncId = asyncHooks.executionAsyncId(); | ||
await new Promise((resolve, reject) => { | ||
if (Object.keys(asyncResObject).length === 0) { | ||
bindingFunction(asyncResName, common.mustCall(() => {})); | ||
} else { | ||
bindingFunction(asyncResName, asyncResObject, common.mustCall(() => {})); | ||
} | ||
hooks.then(actual => { | ||
assert.deepStrictEqual(actual, [ | ||
{ | ||
eventName: 'init', | ||
type: asyncResName, | ||
triggerAsyncId: triggerAsyncId, | ||
resource: asyncResObject | ||
}, | ||
{ eventName: 'before' }, | ||
{ eventName: 'after' }, | ||
{ eventName: 'destroy' } | ||
]); | ||
}).catch(common.mustNotCall()); | ||
resolve(); | ||
}); | ||
} | ||
} | ||
function success (binding) { | ||
@@ -18,0 +152,0 @@ return new Promise((resolve, reject) => { |
@@ -35,2 +35,47 @@ /* Test helpers ported from test/common/index.js in Node.js project. */ | ||
exports.installAysncHooks = function (asyncResName) { | ||
const asyncHooks = require('async_hooks'); | ||
return new Promise((resolve, reject) => { | ||
let id; | ||
const events = []; | ||
/** | ||
* TODO(legendecas): investigate why resolving & disabling hooks in | ||
* destroy callback causing crash with case 'callbackscope.js'. | ||
*/ | ||
let destroyed = false; | ||
const hook = asyncHooks.createHook({ | ||
init (asyncId, type, triggerAsyncId, resource) { | ||
if (id === undefined && type === asyncResName) { | ||
id = asyncId; | ||
events.push({ eventName: 'init', type, triggerAsyncId, resource }); | ||
} | ||
}, | ||
before (asyncId) { | ||
if (asyncId === id) { | ||
events.push({ eventName: 'before' }); | ||
} | ||
}, | ||
after (asyncId) { | ||
if (asyncId === id) { | ||
events.push({ eventName: 'after' }); | ||
} | ||
}, | ||
destroy (asyncId) { | ||
if (asyncId === id) { | ||
events.push({ eventName: 'destroy' }); | ||
destroyed = true; | ||
} | ||
} | ||
}).enable(); | ||
const interval = setInterval(() => { | ||
if (destroyed) { | ||
hook.disable(); | ||
clearInterval(interval); | ||
resolve(events); | ||
} | ||
}, 10); | ||
}); | ||
}; | ||
exports.mustCall = function (fn, exact) { | ||
@@ -37,0 +82,0 @@ return _mustCallInner(fn, exact, 'exact'); |
@@ -27,2 +27,5 @@ /* eslint-disable no-lone-blocks */ | ||
assert.strictEqual(obj.testGetterT, 'instance getter 2'); | ||
assert.throws(() => clazz.prototype.testGetter, /Invalid argument/); | ||
assert.throws(() => clazz.prototype.testGetterT, /Invalid argument/); | ||
} | ||
@@ -65,2 +68,5 @@ | ||
assert.strictEqual(obj.testGetSetT, 'instance getset 4'); | ||
assert.throws(() => { clazz.prototype.testGetSet = 'instance getset'; }, /Invalid argument/); | ||
assert.throws(() => { clazz.prototype.testGetSetT = 'instance getset'; }, /Invalid argument/); | ||
} | ||
@@ -103,2 +109,5 @@ | ||
assert.strictEqual(obj[clazz.kTestMethodTInternal](), 'method<>(Symbol)'); | ||
assert.throws(() => clazz.prototype.testMethod('method')); | ||
assert.throws(() => clazz.prototype.testMethodT()); | ||
assert.throws(() => clazz.prototype.testVoidMethodT('method<>(const char*)')); | ||
}; | ||
@@ -105,0 +114,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 22 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 22 instances in 1 package
83748714
368
6960
66