bare-buffer
Advanced tools
Comparing version
60
index.js
@@ -107,3 +107,12 @@ const constants = require('./lib/constants') | ||
return binding.compare(source, target) === 0 | ||
return ( | ||
binding.compare( | ||
source.buffer, | ||
source.byteOffset, | ||
source.byteLength, | ||
target.buffer, | ||
target.byteOffset, | ||
target.byteLength | ||
) === 0 | ||
) | ||
} | ||
@@ -122,25 +131,32 @@ | ||
if (arguments.length === 1) return binding.compare(source, target) | ||
if (arguments.length > 1) { | ||
if (targetStart < 0) targetStart = 0 | ||
if (targetStart > target.byteLength) targetStart = target.byteLength | ||
if (targetStart < 0) targetStart = 0 | ||
if (targetStart > target.byteLength) targetStart = target.byteLength | ||
if (targetEnd < targetStart) targetEnd = targetStart | ||
if (targetEnd > target.byteLength) targetEnd = target.byteLength | ||
if (targetEnd < targetStart) targetEnd = targetStart | ||
if (targetEnd > target.byteLength) targetEnd = target.byteLength | ||
if (sourceStart < 0) sourceStart = 0 | ||
if (sourceStart > source.byteLength) sourceStart = source.byteLength | ||
if (sourceStart < 0) sourceStart = 0 | ||
if (sourceStart > source.byteLength) sourceStart = source.byteLength | ||
if (sourceEnd < sourceStart) sourceEnd = sourceStart | ||
if (sourceEnd > source.byteLength) sourceEnd = source.byteLength | ||
if (sourceEnd < sourceStart) sourceEnd = sourceStart | ||
if (sourceEnd > source.byteLength) sourceEnd = source.byteLength | ||
if (sourceStart !== 0 || sourceEnd !== source.byteLength) { | ||
source = source.subarray(sourceStart, sourceEnd) | ||
} | ||
if (sourceStart !== 0 || sourceEnd !== source.byteLength) { | ||
source = source.subarray(sourceStart, sourceEnd) | ||
if (targetStart !== 0 || targetEnd !== target.byteLength) { | ||
target = target.subarray(targetStart, targetEnd) | ||
} | ||
} | ||
if (targetStart !== 0 || targetEnd !== target.byteLength) { | ||
target = target.subarray(targetStart, targetEnd) | ||
} | ||
return binding.compare(source, target) | ||
return binding.compare( | ||
source.buffer, | ||
source.byteOffset, | ||
source.byteLength, | ||
target.buffer, | ||
target.byteOffset, | ||
target.byteLength | ||
) | ||
} | ||
@@ -550,2 +566,3 @@ | ||
exports.isBuffer = function isBuffer(value) { | ||
if (value instanceof Buffer) return true | ||
if (typeof value !== 'object' || value === null) return false | ||
@@ -596,3 +613,10 @@ | ||
exports.compare = function compare(a, b) { | ||
return binding.compare(a, b) | ||
return binding.compare( | ||
a.buffer, | ||
a.byteOffset, | ||
a.byteLength, | ||
b.buffer, | ||
b.byteOffset, | ||
b.byteLength | ||
) | ||
} | ||
@@ -599,0 +623,0 @@ |
{ | ||
"name": "bare-buffer", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"description": "Native buffers for JavaScript", | ||
@@ -5,0 +5,0 @@ "exports": { |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1019769
0.32%794
3.25%13
18.18%