Code coverage report for lib/deps/binary/binaryStringToArrayBuffer.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/ » binaryStringToArrayBuffer.js
1 2 3 4 5 6 7 8 9 10 11 12 13        1                
'use strict';
 
// From http://stackoverflow.com/questions/14967647/ (continues on next line)
// encode-decode-image-with-base64-breaks-image (2013-04-21)
module.exports = function (bin) {
  var length = bin.length;
  var buf = new ArrayBuffer(length);
  var arr = new Uint8Array(buf);
  for (var i = 0; i < length; i++) {
    arr[i] = bin.charCodeAt(i);
  }
  return buf;
};