#bitfield
a very simple bitfield, compliant with the Bittorrent spec
npm install bitfield
####Example
var Bitfield = require("bitfield");
var field = new Bitfield(256);
field.set(128);
field.set(128, true);
field.get(128);
field.get(200);
field.get(1e3);
field.set(128, false);
field.buffer;
####Methods
Bitfield(data)
: Data can be either a node.js buffer, WebGL Int8Array or numeric array, or a number representing the maximum number of supported bytes.
Bitfield#get(index)
: Returns a boolean indicating whether the bit is set.
Bitfield#set(index[, value])
: Values defaults to true. Sets the bit to the boolean value of the value (true = 1, false = 0).
Auto-grow mode
Bitfield(data, { grow: size })
: If you set
an index that is out-of-bounds, the Bitfield will automatically grow so that the bitfield is big enough to contain the given index, up to the given size
. If you want the Bitfield to grow indefinitely, pass Infinity
as the size.
####Properties
Bitfield#buffer
: The contents of the bitfield.
##License
MIT