Permalink
Browse files

check for multiples of 8

  • Loading branch information...
1 parent 28f1036 commit 06c6b99fa1631ef0a5187ebc8aa772e59aceaeda @substack committed Nov 1, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 index.js
View
4 index.js
@@ -1,6 +1,10 @@
module.exports = function (buf, bits) {
var output = new Buffer(buf.length);
+ if (bits % 8 !== 0) {
+ throw new Error('bits must be a multiple of 8');
+ }
+
var bytes = bits / 8;
if (buf.length % bytes !== 0) {
throw new Error((buf.length % bytes) + ' non-aligned trailing bytes');

0 comments on commit 06c6b99

Please sign in to comment.