simdle-universal
Advanced tools
Comparing version 1.0.4 to 1.1.0
@@ -70,2 +70,28 @@ const b4a = require('b4a') | ||
exports.allo = function allo (buf) { | ||
if (buf.byteLength % 16 !== 0) { | ||
throw new Error('Buffer length must be a multiple of 16') | ||
} | ||
const m = 2 ** (buf.BYTES_PER_ELEMENT * 8) - 1 | ||
for (let i = 0, n = buf.length; i < n; i++) { | ||
if (buf[i] !== m) return false | ||
} | ||
return true | ||
} | ||
exports.allz = function allz (buf) { | ||
if (buf.byteLength % 16 !== 0) { | ||
throw new Error('Buffer length must be a multiple of 16') | ||
} | ||
for (let i = 0, n = buf.length; i < n; i++) { | ||
if (buf[i] !== 0) return false | ||
} | ||
return true | ||
} | ||
exports.and = binary( | ||
@@ -72,0 +98,0 @@ (a, b, result) => { |
@@ -58,2 +58,18 @@ const binding = require('node-gyp-build')(__dirname) | ||
exports.allo = function allo (buf) { | ||
if (buf.byteLength % 16 !== 0) { | ||
throw new Error('Buffer length must be a multiple of 16') | ||
} | ||
return binding.simdle_napi_allo_v128(buf) !== 0 | ||
} | ||
exports.allz = function allz (buf) { | ||
if (buf.byteLength % 16 !== 0) { | ||
throw new Error('Buffer length must be a multiple of 16') | ||
} | ||
return binding.simdle_napi_allz_v128(buf) !== 0 | ||
} | ||
exports.and = binary( | ||
@@ -60,0 +76,0 @@ binding.simdle_napi_and_v128_u8, |
{ | ||
"name": "simdle-universal", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Universal wrapper for libsimdle with a JavaScript fallback", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,2 +22,10 @@ # simdle-universal | ||
#### `const result = allo(buffer)` | ||
Check if the buffer contains only ones. | ||
#### `const result = allz(buffer)` | ||
Check if the buffer contains only zeros. | ||
#### `const result = and(a, b[, result])` | ||
@@ -24,0 +32,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 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
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
413919
333
77
4