New Upstream Release - node-buffer-xor
Ready changes
Summary
Merged new upstream version: 2.0.2 (was: 2.0.1.REALLY.1.0.3).
Resulting package
Built on 2022-05-16T11:22 (took 3m39s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases node-buffer-xor
Lintian Result
Diff
diff --git a/.travis.yml b/.travis.yml
index d9f695b..bd9a504 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,18 @@
+sudo: false
+os: linux
language: node_js
-before_install:
- - "npm install npm -g"
node_js:
+ - "0.10"
+ - "0.11"
- "0.12"
+ - "iojs"
+ - "4"
+ - "5"
env:
- - TEST_SUITE=standard
- - TEST_SUITE=unit
+ matrix:
+ - TEST_SUITE=unit
+matrix:
+ include:
+ - node_js: "4"
+ env: TEST_SUITE=standard
script: "npm run-script $TEST_SUITE"
diff --git a/README.md b/README.md
index 007f058..c741be3 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# buffer-xor
-[![TRAVIS](https://secure.travis-ci.org/crypto-browserify/buffer-xor.png)](http://travis-ci.org/crypto-browserify/buffer-xor)
-[![NPM](http://img.shields.io/npm/v/buffer-xor.svg)](https://www.npmjs.org/package/buffer-xor)
+[![NPM Package](https://img.shields.io/npm/v/buffer-xor.svg?style=flat-square)](https://www.npmjs.org/package/buffer-xor)
+[![Build Status](https://img.shields.io/travis/crypto-browserify/buffer-xor.svg?branch=master&style=flat-square)](https://travis-ci.org/crypto-browserify/buffer-xor)
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
@@ -11,25 +11,28 @@ A simple module for bitwise-xor on buffers.
## Examples
``` javascript
-var xor = require("buffer-xor")
+var xor = require('buffer-xor')
var a = new Buffer('00ff0f', 'hex')
var b = new Buffer('f0f0', 'hex')
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
-var xorInplace = require("buffer-xor/inplace")
+var xorInplace = require('buffer-xor/inplace')
var a = new Buffer('00ff0f', 'hex')
var b = new Buffer('f0f0', 'hex')
console.log(xorInplace(a, b))
-// => <Buffer f0 0f>
-// NOTE: xorInplace will return the shorter slice of its parameters
+// => <Buffer f0 0f 0f>
// See that a has been mutated
console.log(a)
@@ -38,4 +41,3 @@ console.log(a)
## License [MIT](LICENSE)
-
diff --git a/debian/changelog b/debian/changelog
index 59bfab1..6f5395e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+node-buffer-xor (2.0.2-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk> Mon, 16 May 2022 11:18:35 -0000
+
node-buffer-xor (2.0.1.REALLY.1.0.3-3) unstable; urgency=medium
* Team upload
diff --git a/index.js b/index.js
index 85ee6f6..a27fd36 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,8 @@
+var Buffer = require('safe-buffer').Buffer
+
module.exports = function xor (a, b) {
- var length = Math.min(a.length, b.length)
- var buffer = new Buffer(length)
+ var length = Math.max(a.length, b.length)
+ var buffer = Buffer.allocUnsafe(length)
for (var i = 0; i < length; ++i) {
buffer[i] = a[i] ^ b[i]
diff --git a/inline.js b/inline.js
deleted file mode 100644
index 8797570..0000000
--- a/inline.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require('./inplace')
diff --git a/inplace.js b/inplace.js
index d71c172..5422971 100644
--- a/inplace.js
+++ b/inplace.js
@@ -5,5 +5,5 @@ module.exports = function xorInplace (a, b) {
a[i] = a[i] ^ b[i]
}
- return a.slice(0, length)
+ return a
}
diff --git a/package.json b/package.json
index 5074b02..1de0617 100644
--- a/package.json
+++ b/package.json
@@ -1,12 +1,16 @@
{
"name": "buffer-xor",
- "version": "1.0.3",
+ "version": "2.0.2",
"description": "A simple module for bitwise-xor on buffers",
+ "files": [
+ "index.js",
+ "inplace.js"
+ ],
"main": "index.js",
"scripts": {
"standard": "standard",
- "test": "npm run-script unit",
- "unit": "mocha"
+ "test": "npm run standard && npm run unit",
+ "unit": "tape test/*.js"
},
"repository": {
"type": "git",
@@ -31,7 +35,10 @@
"author": "Daniel Cousens",
"license": "MIT",
"devDependencies": {
- "mocha": "*",
- "standard": "*"
+ "standard": "*",
+ "tape": "*"
+ },
+ "dependencies": {
+ "safe-buffer": "^5.1.1"
}
}
diff --git a/test/fixtures.json b/test/fixtures.json
index 6f3431e..57a4f8e 100644
--- a/test/fixtures.json
+++ b/test/fixtures.json
@@ -8,12 +8,13 @@
"a": "000f0f",
"b": "f0ff",
"mutated": "f0f00f",
- "expected": "f0f0"
+ "expected": "f0f00f"
},
{
"a": "000f",
"b": "f0ffff",
- "expected": "f0f0"
+ "mutated": "f0f0",
+ "expected": "f0f0ff"
},
{
"a": "000000",
diff --git a/test/index.js b/test/index.js
index 06eacab..60fd04a 100644
--- a/test/index.js
+++ b/test/index.js
@@ -1,38 +1,46 @@
-/* global describe, it */
-
-var assert = require('assert')
+var Buffer = require('safe-buffer').Buffer
+var tape = require('tape')
var xor = require('../')
var xorInplace = require('../inplace')
+
var fixtures = require('./fixtures')
-describe('xor', function () {
+tape.test('xor', function (t) {
fixtures.forEach(function (f) {
- it('returns ' + f.expected + ' for ' + f.a + '/' + f.b, function () {
- var a = new Buffer(f.a, 'hex')
- var b = new Buffer(f.b, 'hex')
+ t.test('returns ' + f.expected + ' for ' + f.a + '/' + f.b, function (t) {
+ var a = Buffer.from(f.a, 'hex')
+ var b = Buffer.from(f.b, 'hex')
var actual = xor(a, b)
- assert.equal(actual.toString('hex'), f.expected)
+ t.same(actual.toString('hex'), f.expected)
// a/b unchanged
- assert.equal(a.toString('hex'), f.a)
- assert.equal(b.toString('hex'), f.b)
+ t.same(a.toString('hex'), f.a)
+ t.same(b.toString('hex'), f.b)
+
+ t.end()
})
})
+
+ t.end()
})
-describe('xor/inplace', function () {
+tape.test('xor/inplace', function (t) {
fixtures.forEach(function (f) {
- it('returns ' + f.expected + ' for ' + f.a + '/' + f.b, function () {
- var a = new Buffer(f.a, 'hex')
- var b = new Buffer(f.b, 'hex')
+ t.test('returns ' + f.expected + ' for ' + f.a + '/' + f.b, function (t) {
+ var a = Buffer.from(f.a, 'hex')
+ var b = Buffer.from(f.b, 'hex')
var actual = xorInplace(a, b)
- assert.equal(actual.toString('hex'), f.expected)
+ t.same(actual.toString('hex'), a.toString('hex'))
// a mutated, b unchanged
- assert.equal(a.toString('hex'), f.mutated || f.expected)
- assert.equal(b.toString('hex'), f.b)
+ t.same(a.toString('hex'), f.mutated || f.expected)
+ t.same(b.toString('hex'), f.b)
+
+ t.end()
})
})
+
+ t.end()
})
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/share/nodejs/buffer-xor/inline.js
No differences were encountered in the control files