Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bits

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bits

Easy bit manipulation

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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

Package last updated on 12 Dec 2013

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc