!function(a,b){"function"==typeof define&&define.amd?define([],function(){var c=b();return a.Bitmask=c,c}):"undefined"!=typeof exports?module.exports=b():a.Bitmask=b()}(this,function(){var a,b,c,d=function(a,b){for(var c=[];0!==a;)c.push(1&a),a>>=1,b--;for(;b-->0;)c.push(0);return c},e=function(a){return a.reduce(function(a,b,c){return a+Math.pow(2,c)*b})},f=function(f,g){if(c=g||8,f.constructor===Number||f.constructor===String)a=parseInt(f),b=d(a,c);else{if(f.constructor!==Array)throw"Constructor needs either a number or an array o bits";b=f.map(function(a){return 1&parseInt(a)}),a=e(b)}return this};return f.prototype.getInteger=function(){return a},f.prototype.getBits=function(){return b},f.prototype.hasBit=function(a){return 1&b[a]},f.prototype.setBit=function(c,d){return d=d===!0?1:0,b[c]=d,a=e(b),this},f.prototype.toggleBit=function(a){return status=!this.hasBit(a),this.setBit(a,status),this},f.prototype.rShift=function(e){return e=e||1,a>>=e,b=d(a,c),this},f.prototype.lShift=function(e){return e=e||1,a<<=e,b=d(a,c),this},f});