
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@bitarray/es6
Advanced tools
An ES6 BitArray class for easy and native-like operations on sequences of bits
A BitArray class for easy and native-like operations on sequences of bits.
The library implements ArrayBuffers behind the hood. This allows for:
optimal memory usage: each bit is effectively coded in just one bit in memory, as opposed to being coded as, e.g. booleans or integers in regular arrays.
efficient bitwise operations: operations treat 32 bits at once, as opposed to dealing with entries one by one in regular arrays.
:bulb: It comes at the cost that accessing a single bit at a given index will be slightly more expensive than accessing the value stored in a regular array: indeed, the interesting bit needs to be extracted once a Uint32 value has been found first.
Having said that, in the very vast majority of cases, any difference either way should be unnoticeable; and you may very well opt to use this library for the sole reason that it provides a convenient native-like interface for your needs.
The library relies on the Proxy object, which is an ES6 (aka ES2015) feature. It can NOT be polyfilled (to the extent it is used by the library).
Note: standard TypedArray is also a feature of ecmascript ES6.
npm install @bitarray/es6
or
yarn add @bitarray/es6
Usage is same as for any standard typed array. You may check the MDN documentation for details. This is because the BitArray object extends @bitarray/typedarray. Check it for details.
It adds bitwise operations on top.
import BitArray from "@bitarray/es6"
const bits = BitArray.from("11001010");
const otherbits = new BitArray(12); // 12 bits, the values of which default to zero.
bits.count; // === 4; number of bits set to 1.
// same as bits.and(otherbits)
(bits)['&'](otherbits); // an instance holding a sequence of eight zeros
// same as bits.or(otherbits)
(bits)['|'](otherbits); // 11001010
// same as bits.xor(otherbits)
(bits)['^'](otherbits); // 11001010
for (let i=0; i<bits.length; i++)
// do something with bits[i]
bits.forEach((val, i, arr) => { /* do something */ });
for (let i in bits)
// do something with bits[i]
for (let bit of bits)
// do something with bit
Object.keys(bits); // [0, 1, 2, 3, 4, 5, 6, 7]
Object.values(bits); // [1, 1, 0, 0, 1, 0, 1, 0]
Object.entries(bits); // [["0", 1], ["1", 1], ["2", 0], ["3", 0], ...]
FAQs
An ES6 BitArray class for easy and native-like operations on sequences of bits
The npm package @bitarray/es6 receives a total of 3 weekly downloads. As such, @bitarray/es6 popularity was classified as not popular.
We found that @bitarray/es6 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.