Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Easy bit manipulation
Latest commit 02fab77 @flosse describe bower install
Failed to load latest commit information.
.gitignore use mocha & chai
.npmignore use mocha & chai
.travis.yml run node v0.10.x tests describe bower install support AMD
bits.js added bower support use mocha & chai
bower.json added bower support
package.json added bower support


Build Status Dependency Status NPM version


If you're using Node.js type:

npm install --save bits

Then load the module:

var bits = require("bits");

If you'd like to use it in your browser application, download it manually or use bower:

bower install bits

...and then just link the JS file:

<script src="bits.js"></script>

You can also use script loaders like require.js:

define(["./bits"], function(bits){ /* .. */ });

Now here is the API:

var data = 0;
data = bits.set(data, 2);
data = bits.set(data, [0,3,7]); // set bit 0, 3 and 7
data = bits.clear(data, 1);
data = bits.clear(data, 1, 5);  // clear bit 1,3,4,5
data = bits.toggle(data, 5);
data = bits.test(data, 6);      // returns true or false
data = bits.get(data, 6);       // returns 0 or 1


npm test


MIT license

Something went wrong with that request. Please try again.