index.js
function isBinary(buffer) {
  var chunk = buffer.toString('utf8', 0, Math.min(buffer.length, 24));
  for (var i in chunk) {
    var charCode = chunk.charCodeAt(i);
    if (charCode == 65533 || charCode <= 8) {
      return true;
    }
  }
  return false;
}
function isBinary(buffer) {
  var chunk = buffer.toString('utf8', 0, Math.min(buffer.length, 24));
  for (var i in chunk) {
    var charCode = chunk.charCodeAt(i);
    if (charCode == 65533 || charCode <= 8) {
      return true;
    }
  }
  return false;
}
function isBinary ( buffer ) { var chunk = buffer . toString ( 'utf8' , 0 , Math . min ( buffer . length , 24 ) ) ; for ( var i in chunk ) { var charCode = chunk . charCodeAt ( i ) ; if ( charCode == 65533 || charCode <= 8 ) { return true ; } } return false ; }
Helper function that detects whether a buffer is binary or utf8.
@param {Buffer} buffer
@returns {boolean}
Helper function that detects whether a buffer is binary or utf8 .