Comparing version 1.0.3 to 2.0.0
module.exports = function xor (a, b) { | ||
var length = Math.min(a.length, b.length) | ||
var length = Math.max(a.length, b.length) | ||
var buffer = new Buffer(length) | ||
@@ -4,0 +4,0 @@ |
@@ -8,3 +8,3 @@ module.exports = function xorInplace (a, b) { | ||
return a.slice(0, length) | ||
return a | ||
} |
{ | ||
"name": "buffer-xor", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "A simple module for bitwise-xor on buffers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,8 +19,12 @@ # buffer-xor | ||
console.log(xor(a, b)) | ||
// => <Buffer f0 0f> | ||
// => <Buffer f0 0f 0f> | ||
``` | ||
Or for those seeking those few extra cycles, perform the operation in place: | ||
Or for those seeking those few extra cycles, perform the operation in place with | ||
`xorInplace`: | ||
_NOTE: `xorInplace` won't xor past the bounds of the buffer it mutates so make | ||
sure it is long enough!_ | ||
``` javascript | ||
@@ -32,4 +36,3 @@ var xorInplace = require("buffer-xor/inplace") | ||
console.log(xorInplace(a, b)) | ||
// => <Buffer f0 0f> | ||
// NOTE: xorInplace will return the shorter slice of its parameters | ||
// => <Buffer f0 0f 0f> | ||
@@ -43,2 +46,1 @@ // See that a has been mutated | ||
## License [MIT](LICENSE) | ||
@@ -11,3 +11,3 @@ [ | ||
"mutated": "f0f00f", | ||
"expected": "f0f0" | ||
"expected": "f0f00f" | ||
}, | ||
@@ -17,3 +17,4 @@ { | ||
"b": "f0ffff", | ||
"expected": "f0f0" | ||
"mutated": "f0f0", | ||
"expected": "f0f0ff" | ||
}, | ||
@@ -20,0 +21,0 @@ { |
@@ -31,3 +31,3 @@ /* global describe, it */ | ||
assert.equal(actual.toString('hex'), f.expected) | ||
assert.strictEqual(actual, a) | ||
@@ -34,0 +34,0 @@ // a mutated, b unchanged |
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
4840
44
9