Permalink
Browse files

readme test and example

  • Loading branch information...
0 parents commit 98c601934a06da2ef2085574ae7ff6da3eebe8ad @substack committed May 11, 2012
Showing with 109 additions and 0 deletions.
  1. +60 −0 README.markdown
  2. +14 −0 example/eq.js
  3. +35 −0 test/eq.js
@@ -0,0 +1,60 @@
+buffer-equal
+============
+
+Return whether two buffers are equal.
+
+example
+=======
+
+``` js
+var bufferEqual = require('bufferEqual');
+
+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
@@ -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'
+));
@@ -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();
+});

0 comments on commit 98c6019

Please sign in to comment.