"use strict"

function BitBuffer(number,buffer) {
  if (buffer != undefined && buffer.length == number/8) {
    this.buffer = buffer;
  } else {
	  this.buffer = new Buffer(Math.ceil(number / 8))
	  this.buffer.fill(0)
  } 
}


BitBuffer.prototype = {
	set: function(index, bool) {
		var pos = index >>> 3
		if(bool) {
			this.buffer[pos] |= 1 << (index % 8)
		} else {
			this.buffer[pos] &= ~(1 << (index % 8))
		}
	},
	get: function(index) {
		return (this.buffer[index >>> 3] & (1 << (index % 8))) != 0
	},
	toggle: function(index) {
		this.buffer[index >>> 3] ^= 1 << (index % 8)
	},
	toBuffer: function() {
		return this.buffer
	}
}

exports.BitBuffer = BitBuffer

@@ -43,16 +43,49 @@
 ffer) %7B%0A
+  var size = Math.ceil(number/8)%0A
   if (bu
@@ -122,24 +122,20 @@
 ngth == 
-number/8
+size
 ) %7B%0A    
@@ -158,9 +158,8 @@
 ffer
-;
 %0A  %7D
@@ -198,29 +198,12 @@
 fer(
-Math.ceil(number / 8)
+size
 )%0A%09 

fix math.ceil bug