
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Easy-to-use bitfields for Node.js and browsers.
For Node.js or webpack projects, install with the NPM package manager:
npm install --save bitfields
For use in the browser without a bundler, include this script tag in your HTML.
<script src="https://unpkg.com/bitfields@1.0.3/dist/bitfields.js"></script>
// commonjs module
const { Bitfield } = require('bitfields')
// esmodules
import { Bitfield } from 'bitfields'
// in the browser
const { Bitfield } = window.Bitfields
const bitfield = new Bitfield(64) // create a Bitfield with 64 bits
bitfield.set(1) // set the first bit
bitfield.set(1, 1) // same as above
bitfield.set(1, true) // same as above
bitfield.set(3) // set the third bit
console.log(bitfield.get(1)) // 'true'
console.log(bitfield.get(2)) // 'false'
console.log(bitfield.get(3)) // 'true'
bitfield.set(3, false) // unset the third bit
bitfield.set(3, 0) // same as above
console.log(bitfield.get(3)) // 'false'
const buffer = bitfield.toBuffer() // convert to Buffer
const bigint = bitfield.toBigInt() // convert to BigInt
const hex = bitfield.toHex() // convert to hexadecimal string
const string = bitfield.toString() // convert to UTF-8 encoded string
console.log(buffer) // '<Buffer 40 00 00 00 00 00 00 00>'
console.log(bigint) // '4611686018427387904n'
console.log(hex) // '4000000000000000'
console.log(string) // '@'
const bitfieldFromBuffer = Bitfield.fromBuffer(buffer) // create a Bitfield from a Buffer
const bitfieldFromBigInt = Bitfield.fromBigInt(bigint) // create a Bitfield from a BigInt
const bitfieldFromHex = Bitfield.fromHex(hex) // create a Bitfield from a hexadecimal string
const bitfieldFromString = Bitfield.fromString(string) // create a Bitfield from a string
FAQs
Easy-to-use bitfields for Node.js and browsers.
The npm package bitfields receives a total of 2 weekly downloads. As such, bitfields popularity was classified as not popular.
We found that bitfields demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.