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.
bitstring
Advanced tools
Readme
A class to read and write packed binary strings, bit-by-bit.
var BitString = require('bitstring');
var bits = new BitString();
bits.writebits(4)
.writebits(255)
.writebits(1,4)
.writebits(8)
bits.number() == 10478336
bits.hex() == '9fe30'
bits.bin() == '10011111111000110'
bits.bytearray() // == [ 159, 227, 0 ]
On the server, install it:
npm install bitstring
And then just require it:
var BitString = require('bitstring');
In the browser, you have a number of options. You can download this package and include bitstring.js
somewhere, which will add itself as a global, window.BitString
. Alternatively, if you're using something like [require.js][require_js] to wrap your modules, BitString will check for the module
variable and properly set itself as module.exports
.
Create a new BitString buffer. Optionally takes source data as a String, and/or an Array to use as the byte-buffer.
The size in bytes of the BitString.
The size in bits of the BitString.
Writes the bits n
to the stream (bits must be supplied as a number). Supplying n=0
will write one bit. Supplying the optional parameter size
treats the bits as a field with the given length.
Flushes any pending bits to the stream.
Truncates the stream to zero bits.
Flushes the bit-buffer and moves to the given byte-offset. Mode Constants:
BitString.SEEK_ABSOLUTE = 0
BitString.SEEK_RELATIVE = 1
BitString.SEEK_FROM_EOF = 2
Returns the current position of the cursor as a byte offset from the start of the stream.
Reads the next n
bits from the stream.
Reads the next n
bits without moving the cursor.
True if there is more data to read.
Iterates over the bytes in the BitString.
As Array.map
, but over the bytes in the BitString.
As Array.reduce
, but over the bytes in the BitString.
Returns the stream as an Array of bytes.
Dumps the stream as a binary string. Unlike .number()
, .bin()
will not cause int overflow.
Returns the stream as a hex string.
Returns the buffer as a number. Use this with obvious caution.
Dumps the stream as a string of UTF8 characters; does not flush or change cursor position.
String representation of the data-structure; if dump_buf
is true, the contents of the stream will be included, but it will not flush or change cursor position.
Dumps the stream as a string; flushes the bit-buffer but leaves cursor position unchanged.
FAQs
Read/write packed binary strings bit-by-bit
The npm package bitstring receives a total of 8 weekly downloads. As such, bitstring popularity was classified as not popular.
We found that bitstring 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
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.