[Pkg-javascript-commits] [node-buffer-equal] 01/04: Import Upstream version 1.0.0

Sruthi Chandran srud-guest at moszumanska.debian.org
Sun Oct 16 05:36:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

srud-guest pushed a commit to branch master
in repository node-buffer-equal.

commit 13b4c4818e70b7f0ea77f83c38e2bd9ede5d6962
Author: Sruthi <srud at disroot.org>
Date:   Sun Oct 16 10:54:04 2016 +0530

    Import Upstream version 1.0.0
---
 .travis.yml     |  4 ++++
 LICENSE         | 18 +++++++++++++++++
 README.markdown | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 example/eq.js   | 14 +++++++++++++
 index.js        | 14 +++++++++++++
 package.json    | 33 ++++++++++++++++++++++++++++++
 test/eq.js      | 35 ++++++++++++++++++++++++++++++++
 7 files changed, 180 insertions(+)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..dad2273
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+  - 0.8
+  - "0.10"
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..ee27ba4
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,18 @@
+This software is released under the MIT license:
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..8c062fd
--- /dev/null
+++ b/README.markdown
@@ -0,0 +1,62 @@
+buffer-equal
+============
+
+Return whether two buffers are equal.
+
+[![build status](https://secure.travis-ci.org/substack/node-buffer-equal.png)](http://travis-ci.org/substack/node-buffer-equal)
+
+example
+=======
+
+``` js
+var bufferEqual = require('buffer-equal');
+
+console.dir(bufferEqual(
+    new Buffer([253,254,255]),
+    new Buffer([253,254,255])
+));
+console.dir(bufferEqual(
+    new Buffer('abc'),
+    new Buffer('abcd')
+));
+console.dir(bufferEqual(
+    new Buffer('abc'),
+    'abc'
+));
+```
+
+output:
+
+```
+true
+false
+undefined
+```
+
+methods
+=======
+
+``` js
+var bufferEqual = require('buffer-equal')
+```
+
+bufferEqual(a, b)
+-----------------
+
+Return whether the two buffers `a` and `b` are equal.
+
+If `a` or `b` is not a buffer, return `undefined`.
+
+install
+=======
+
+With [npm](http://npmjs.org) do:
+
+```
+npm install buffer-equal
+```
+
+license
+=======
+
+MIT
diff --git a/example/eq.js b/example/eq.js
new file mode 100644
index 0000000..1eb0509
--- /dev/null
+++ b/example/eq.js
@@ -0,0 +1,14 @@
+var bufferEqual = require('../');
+
+console.dir(bufferEqual(
+    new Buffer([253,254,255]),
+    new Buffer([253,254,255])
+));
+console.dir(bufferEqual(
+    new Buffer('abc'),
+    new Buffer('abcd')
+));
+console.dir(bufferEqual(
+    new Buffer('abc'),
+    'abc'
+));
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..e640d4e
--- /dev/null
+++ b/index.js
@@ -0,0 +1,14 @@
+var Buffer = require('buffer').Buffer; // for use with browserify
+
+module.exports = function (a, b) {
+    if (!Buffer.isBuffer(a)) return undefined;
+    if (!Buffer.isBuffer(b)) return undefined;
+    if (typeof a.equals === 'function') return a.equals(b);
+    if (a.length !== b.length) return false;
+    
+    for (var i = 0; i < a.length; i++) {
+        if (a[i] !== b[i]) return false;
+    }
+    
+    return true;
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..ec5850b
--- /dev/null
+++ b/package.json
@@ -0,0 +1,33 @@
+{
+    "name" : "buffer-equal",
+    "description" : "return whether two buffers are equal",
+    "version" : "1.0.0",
+    "repository" : {
+        "type" : "git",
+        "url" : "git://github.com/substack/node-buffer-equal.git"
+    },
+    "main" : "index.js",
+    "keywords" : [
+        "buffer",
+        "equal"
+    ],
+    "directories" : {
+        "example" : "example",
+        "test" : "test"
+    },
+    "scripts" : {
+        "test" : "tap test/*.js"
+    },
+    "devDependencies" : {
+        "tap" : "0.2.4"
+    },
+    "engines" : {
+        "node" : ">=0.4.0"
+    },
+    "license" : "MIT",
+    "author" : {
+        "name" : "James Halliday",
+        "email" : "mail at substack.net",
+        "url" : "http://substack.net"
+    }
+}
diff --git a/test/eq.js b/test/eq.js
new file mode 100644
index 0000000..3d34006
--- /dev/null
+++ b/test/eq.js
@@ -0,0 +1,35 @@
+var bufferEqual = require('../');
+var test = require('tap').test;
+
+test('equal', function (t) {
+    var eq = bufferEqual(
+        new Buffer([253,254,255]),
+        new Buffer([253,254,255])
+    );
+    t.strictEqual(eq, true);
+    t.end();
+});
+
+test('not equal', function (t) {
+    var eq = bufferEqual(
+        new Buffer('abc'),
+        new Buffer('abcd')
+    );
+    t.strictEqual(eq, false);
+    t.end();
+});
+
+test('not equal not buffer', function (t) {
+    var eq = bufferEqual(
+        new Buffer('abc'),
+        'abc'
+    );
+    t.strictEqual(eq, undefined);
+    t.end();
+});
+
+test('equal not buffer', function (t) {
+    var eq = bufferEqual('abc', 'abc');
+    t.strictEqual(eq, undefined);
+    t.end();
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-buffer-equal.git



More information about the Pkg-javascript-commits mailing list