Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
ml-bit-array
Advanced tools
Readme
Bit-array operations in JavaScript.
npm install ml-bit-array
All exported methods are static and do not change the original array unless indicated otherwise.
Numbers in array arguments are treated as 32-bit signed integers.
The library is designed with speed in mind so argument type and length are not checked.
Computes the amount of 1
s in the array. This is also known as Hamming weight.
Computes the logical AND operation and returns the result in a new array.
Computes the logical OR operation and returns the result in a new array.
Computes the logical XOR operation and returns the result in a new array.
Computes the logical NOT operation and returns the result in a new array.
Returns true
if the bit at position n
is 1, false
if it is 0.
Imagine that you have an array of 4-bit numbers like this ['0001', '1010']
, the 0th position will be 0
because it is the most significant bit of the 0th element of the array, and the 4th position will be 1
, because will be the most significant bit in the 1st element of the array (remember that the true number of bits for a number in this case is 32).
Sets the bit at position n
to 1 if val
is a truthy value, otherwise sets it to 0.
Converts an array of numbers to a string representation of the bits, so toBinaryString([1])
will return '00000000000000000000000000000001'
.
The length of the string will be arr.length * 32
.
Converts a string representation of bits to an array, so parseBinaryString('00000000000000000000000000000010')
will return [2]
.
This is the exact inverse of toBinaryString
.
Converts an array of numbers to a hexadecimal representation of the bits, so toHexString([-1])
will return 'ffffffff'
.
The length of the string will be arr.length * 8
.
Converts a hexadecimal representation of bits to an array, so parseHexString('00000010ffff0000')
will return [16, -65536]
.
This is the exact inverse of toHexString
.
Returns a human-readable string from the array in the format:
0000: 0000 1000 1111 1000 0011 1101 1111 0001
0020: 0000 1000 1111 1000 0011 1101 1111 0001
0040: 0000 1000 1111 1000 0011 1101 1111 0001
FAQs
Bit-array operations in JavaScript
The npm package ml-bit-array receives a total of 82 weekly downloads. As such, ml-bit-array popularity was classified as not popular.
We found that ml-bit-array demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.