New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

large-bitfield

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

large-bitfield

Use node.js Buffer as a bitfield for storing lots of bools

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

large-bitfield

Use node.js Buffer as a bitfield for storing lots of bools

install

npm i large-bitfield

usage

const LargeBitfield = require('large-bitfield')

const field = new LargeBitfield(8) // 8 bits = 1 byte

field.true(4) // Set bit 4 to TRUE
field.false(7) // Set bit 7 to FALSE
field.write(0, true) // Set bit 0 to TRUE

field.read(3) // Read bit 3: Not defined - not initialized.
field.read(4) // TRUE
field.read(7) // FALSE


// Initializing values: (Otherwise behavior is undefined: Might be true or false.)
const initializedTrue = new LargeBitfield(16, true) // 2-bytes, initialized True
const initializedFalse = new LargeBitfield(16, false) // 2-bytes, initialized False

const trueTest = Array(16).reduce((prev, curr, i) =>
  prev && initializedTrue.read(i), true)
const falseTest = Array(16).reduce((prev, curr, i) =>
  prev || initializedFalse.read(i), false)

console.log(trueTest && !falseTest) //= true

FAQs

Package last updated on 17 Nov 2019

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