'use strict';

module.exports = function binary([str]) {
  const trimmed = str.replace(/[ \r\n]/g, '');
  const result = [];
  for (let i = 0; i < trimmed.length; i += 8) {
    result.push(parseInt(trimmed.substr(i, 8).padEnd(8, '0'), 2));
  }
  return result;
};

'use strict';

module.exports = function binary([str]) {
  const trimmed = str.replace(/[ \r\n]/g, '');
  const result = new Uint8Array(Math.ceil(trimmed.length / 8));
  for (let i = 0; i < trimmed.length; i += 8) {
    const index = i / 8;
    result[index] = parseInt(trimmed.substr(i, 8).padEnd(8, '0'), 2);
  }
  return result;
};

update binary test util