Just use Buffer.compare()
. It has been available since Node.js 0.12.
Node.js
Buffer.compare()
ponyfill
$ npm install --save buf-compare
var bufCompare = require('buf-compare');
bufCompare(new Buffer('a'), new Buffer('a'));
//=> 0
bufCompare(new Buffer('a'), new Buffer('b'));
//=> -1
See the Buffer.compare()
docs.
- buffer-equals - Node.js
buffer.equals()
ponyfill - buf-indexof - Node.js
buffer.indexOf()
ponyfill
MIT © Sindre Sorhus