🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

ffi-napi

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ffi-napi - npm Package Compare versions

Comparing version

to
3.1.0

9

lib/dynamic_library.js

@@ -41,2 +41,3 @@ 'use strict';

this._path = path;
this._handle = dlopen(path, mode);

@@ -124,3 +125,2 @@ assert(Buffer.isBuffer(this._handle), 'expected a Buffer instance to be returned from `dlopen()`');

*/
DynamicLibrary.prototype.error = function error () {

@@ -130,1 +130,8 @@ debug('dlerror()');

}
/**
* Returns the path originally passed to the constructor
*/
DynamicLibrary.prototype.path = function error () {
return this._path;
}

11

lib/library.js

@@ -37,3 +37,3 @@ 'use strict';

if (libfile && libfile.indexOf(EXT) === -1) {
if (libfile && typeof libfile === 'string' && libfile.indexOf(EXT) === -1) {
debug('appending library extension to library name', EXT);

@@ -46,3 +46,8 @@ libfile += EXT;

}
const dl = new DynamicLibrary(libfile || null, RTLD_NOW);
let dl;
if (typeof libfile === 'string' || !libfile) {
dl = new DynamicLibrary(libfile || null, RTLD_NOW);
} else {
dl = libfile;
}

@@ -56,3 +61,3 @@ Object.keys(funcs || {}).forEach(function (func) {

if (fptr.isNull()) {
throw new Error('Library: "' + libfile
throw new Error('Library: "' + dl.path()
+ '" returned NULL function pointer for "' + func + '"');

@@ -59,0 +64,0 @@ }

{
"name": "ffi-napi",
"version": "3.0.1",
"version": "3.1.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": "Anna Henningsen <anna@addaleax.net>",

@@ -6,2 +6,3 @@ 'use strict';

const ffi = require('../');
const DynamicLibrary = ffi.DynamicLibrary;
const Library = ffi.Library;

@@ -56,2 +57,11 @@

it('should accept a DynamicLibrary instance as the first argument', function () {
const lib = process.platform == 'win32' ? 'msvcrt' : 'libm';
const libm = new Library(new DynamicLibrary(lib + ffi.LIB_EXT, DynamicLibrary.FLAGS.RTLD_NOW), {
'ceil': [ 'double', [ 'double' ] ]
});
assert(typeof libm.ceil === 'function');
assert(libm.ceil(1.1) === 2);
})
it('should accept a lib name with file extension', function() {

@@ -58,0 +68,0 @@ const lib = process.platform == 'win32'

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 not supported yet

Sorry, the diff of this file is not supported yet