Code coverage report for lib/deps/binary/arrayBufferToBinaryString.js

Statements: 14.29% (1 / 7)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 14.29% (1 / 7)      Ignored: none     

All files » lib/deps/binary/ » arrayBufferToBinaryString.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14          1                
'use strict';
 
//Can't find original post, but this is close
//http://stackoverflow.com/questions/6965107/ (continues on next line)
//converting-between-strings-and-arraybuffers
module.exports = function (buffer) {
  var binary = '';
  var bytes = new Uint8Array(buffer);
  var length = bytes.byteLength;
  for (var i = 0; i < length; i++) {
    binary += String.fromCharCode(bytes[i]);
  }
  return binary;
};