
Security News
Static vs. Runtime Reachability: Insights from Latio’s On the Record Podcast
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
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 36 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
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.