JavaScript · Comparison and Equality

Comparison and Equality

6.0.0-rc.1 · 91a27bdd

equal reports whether two buffers hold identical bytes, returning a JavaScript boolean. compare orders two buffers lexicographically, returning -1, 0, or 1 as a plain number.

assert.strictEqual(sz.equal(Buffer.from("abc"), Buffer.from("abc")), true);
assert.strictEqual(sz.compare(Buffer.from("abc"), Buffer.from("abd")), -1);