Socket
Socket
Sign inDemoInstall

bits

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bits

Easy bit manipulation


Version published
Weekly downloads
13
Maintainers
1
Install size
4.58 kB
Created
Weekly downloads
 

Readme

Source

bits

Build Status Dependency Status NPM version

Usage

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, 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

Test

npm test

License

MIT license

FAQs

Last updated on 12 Dec 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc