var assert = require('assert');

function BitRing(capacity) {
    assert.ok(capacity < 32, 'Capacity must be less than 32');
    this.capacity = capacity;
    this.bits = 0;
    this.pos = 0;
    this.length = 0;
    this._count = 0;
}

// Update the count and set or clear the next bit in the ring
BitRing.prototype.push = function(bool) {
    var num = bool === true ? 1 : 0;
    this._count += num - ((this.bits >>> this.pos) & 1);
    this.bits ^= (-num ^ this.bits) & (1 << this.pos);
    this.pos = (this.pos + 1) % this.capacity;
    if (this.length < this.capacity) {
        this.length++;
    }
};

// Return the number of bits set
BitRing.prototype.count = function() {
    return this._count;
};

module.exports = BitRing;

@@ -1,127 +1,61 @@
-var assert = require('assert');%0A%0Afunction BitRing(capacity) %7B%0A    assert.ok(capacity %3C 32, 'Capacity must be less than 32')
+function BitRing(capacity) %7B%0A    this.capacity = capacity
 ;%0A  
@@ -65,46 +65,46 @@
 his.
-capacity = capacity;%0A    this.bits = 0
+bits = new Uint8ClampedArray(capacity)
 ;%0A  
@@ -334,10 +334,8 @@
 m - 
-((
 this
@@ -343,21 +343,17 @@
 bits
- %3E%3E%3E 
+%5B
 this.pos
 ) & 
@@ -352,14 +352,9 @@
 .pos
-) & 1)
+%5D
 ;%0A  
@@ -368,48 +368,24 @@
 bits
- %5E= (-num %5E this.bits) & (1 %3C%3C this.pos)
+%5Bthis.pos%5D = num
 ;%0A  

Use a TypedArray instead of a number