@yuuang/ffi-rs-linux-arm64-musl
Advanced tools
Comparing version 1.0.16 to 1.0.17
{ | ||
"name": "@yuuang/ffi-rs-linux-arm64-musl", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"os": [ | ||
@@ -5,0 +5,0 @@ "linux" |
@@ -12,3 +12,3 @@ # ffi-rs | ||
ffi-rs is a module written in Rust and N-API that provides FFI (Foreign Function Interface) features for Node.js. It allows developers to call functions written in other languages such as C++, C, and Rust directly from JavaScript without writing any C++ code. | ||
[ffi-rs](https://github.com/zhangyuang/node-ffi-rs) is a module written in Rust and N-API that provides FFI (Foreign Function Interface) features for Node.js. It allows developers to call functions written in other languages such as C++, C, and Rust directly from JavaScript without writing any C++ code. | ||
@@ -24,11 +24,14 @@ This module aims to provide similar functionality to the node-ffi module, but with a completely rewritten underlying codebase. The node-ffi module has been unmaintained for several years and is no longer usable, which is why ffi-rs was developed. | ||
ffi: | ||
2 007 ops/s, ±9.38% | slowest, 99.24% slower | ||
ffi-napi: | ||
2 028 ops/s, ±4.87% | slowest, 99.24% slower | ||
koffi: | ||
78 846 ops/s, ±13.74% | 70.63% slower | ||
ffi-rs: | ||
263 846 ops/s, ±0.20% | fastest | ||
268 468 ops/s, ±0.27% | fastest | ||
Finished 2 cases! | ||
Finished 3 cases! | ||
Fastest: ffi-rs | ||
Slowest: ffi-c++ | ||
Slowest: ffi-napi | ||
@@ -147,2 +150,3 @@ ``` | ||
// first open dynamic library with key for close | ||
// It only needs to be opened once. | ||
open({ | ||
@@ -155,4 +159,4 @@ library: 'libsum', // key | ||
funcName: 'sum', // the name of the function to call | ||
retType: RetType.I32, // the return value type | ||
paramsType: [ParamsType.I32, ParamsType.I32], // the parameter types | ||
retType: DataType.I32, // the return value type | ||
paramsType: [DataType.I32, DataType.I32], // the parameter types | ||
paramsValue: [a, b] // the actual parameter values | ||
@@ -165,3 +169,3 @@ }) | ||
const c = "foo" | ||
const d = "bar" | ||
const d = c.repeat(200) | ||
@@ -171,4 +175,4 @@ equal(c + d, load({ | ||
funcName: 'concatenateStrings', | ||
retType: RetType.String, | ||
paramsType: [ParamsType.String, ParamsType.String], | ||
retType: DataType.String, | ||
paramsType: [DataType.String, DataType.String], | ||
paramsValue: [c, d] | ||
@@ -180,3 +184,3 @@ })) | ||
funcName: 'noRet', | ||
retType: RetType.Void, | ||
retType: DataType.Void, | ||
paramsType: [], | ||
@@ -186,16 +190,17 @@ paramsValue: [] | ||
equal(1.1 + 2.2, load({ | ||
library: 'libsum', | ||
funcName: 'doubleSum', | ||
retType: RetType.Double, | ||
paramsType: [ParamsType.Double, ParamsType.Double], | ||
retType: DataType.Double, | ||
paramsType: [DataType.Double, DataType.Double], | ||
paramsValue: [1.1, 2.2] | ||
})) | ||
let bigArr = new Array(100000).fill(100) | ||
let bigArr = new Array(100).fill(100) | ||
equal(bigArr[0], load({ | ||
library: 'libsum', | ||
funcName: 'createArrayi32', | ||
retType: RetType.I32Array, | ||
paramsType: [ParamsType.I32Array, ParamsType.I32], | ||
retType: DataType.I32Array, | ||
paramsType: [DataType.I32Array, DataType.I32], | ||
paramsValue: [bigArr, bigArr.length], | ||
@@ -209,4 +214,4 @@ retTypeLen: bigArr.length | ||
funcName: 'createArrayDouble', | ||
retType: RetType.DoubleArray, | ||
paramsType: [ParamsType.DoubleArray, ParamsType.I32], | ||
retType: DataType.DoubleArray, | ||
paramsType: [DataType.DoubleArray, DataType.I32], | ||
paramsValue: [bigDoubleArr, bigDoubleArr.length], | ||
@@ -216,11 +221,2 @@ retTypeLen: bigDoubleArr.length | ||
const boolVal = false | ||
equal(!boolVal, load({ | ||
library: 'libsum', | ||
funcName: 'return_opposite', | ||
retType: RetType.Boolean, | ||
paramsType: [ParamsType.Boolean], | ||
paramsValue: [bool_val], | ||
})) | ||
let stringArr = [c, c.repeat(200)] | ||
@@ -230,7 +226,15 @@ equal(stringArr[0], load({ | ||
funcName: 'createArrayString', | ||
retType: RetType.StringArray, | ||
paramsType: [ParamsType.StringArray, ParamsType.I32], | ||
retType: DataType.StringArray, | ||
paramsType: [DataType.StringArray, DataType.I32], | ||
paramsValue: [stringArr, stringArr.length], | ||
retTypeLen: stringArr.length | ||
})[0]) | ||
const bool_val = true | ||
equal(!bool_val, load({ | ||
library: 'libsum', | ||
funcName: 'return_opposite', | ||
retType: DataType.Boolean, | ||
paramsType: [DataType.Boolean], | ||
paramsValue: [bool_val], | ||
})) | ||
@@ -244,15 +248,15 @@ const person = { | ||
funcName: 'getStruct', | ||
retType: RetType.Object, | ||
retType: { | ||
name: DataType.String, | ||
age: DataType.I32, | ||
}, | ||
paramsType: [{ | ||
name: ParamsType.String, | ||
age: ParamsType.I32, | ||
name: DataType.String, | ||
age: DataType.I32, | ||
}], | ||
paramsValue: [person], | ||
retFields: { | ||
name: ParamsType.String, | ||
age: ParamsType.I32, | ||
} | ||
paramsValue: [person] | ||
}) | ||
equal(person.name, personObj.name) | ||
equal(person.age, personObj.age) | ||
``` |
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 1 instance 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
496074
251
2