Just use Buffer#indexOf(). It has been available since Node.js 4.
Node.js
Buffer#indexOf()ponyfill
$ npm install --save buf-indexof
var bufIndexof = require('buf-indexof');
bufIndexof(new Buffer('unicorn'), 'corn');
//=> 3See the buffer.indexOf() docs.
The only difference is that you pass in the buffer as the first argument instead of calling the .indexOf() method on the buffer instance.
- buffer-equals - Node.js
buffer.equals()ponyfill - buf-compare - Node.js
Buffer.compare()ponyfill
MIT © Sindre Sorhus