Socket
Socket
Sign inDemoInstall

bitfield

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitfield - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

1

index.js

@@ -17,3 +17,2 @@ var Container = typeof Buffer !== "undefined" ? Buffer //in node, use buffers

if(typeof data === "number" || data === undefined){
if(data % 8 !== 0) data += 1 << 3;
data = new Container(getByteSize(data));

@@ -20,0 +19,0 @@ if(data.fill) data.fill(0); // clear node buffers of garbage

12

package.json
{
"name": "bitfield",
"version": "1.0.1",
"version": "1.0.2",
"description": "a very simple bitfield implementation using buffers",

@@ -20,2 +20,12 @@ "main": "index.js",

},
"testling": {
"files": "tests.js",
"browsers": [
"ie/9..latest",
"chrome/25..latest",
"firefox/20..latest",
"safari/6..latest",
"opera/15.0..latest"
]
},
"author": "Felix Boehm <me@feedic.com>",

@@ -22,0 +32,0 @@ "license": "MIT",

@@ -7,2 +7,4 @@ #bitfield

[![browser support](https://ci.testling.com/fb55/bitfield.png)](https://ci.testling.com/fb55/bitfield)
####Example

@@ -28,10 +30,10 @@

####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(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).
`Bitfield#set(index[, value])`: `value` defaults to true. Sets the bit to `1` for a value of `true` or `0` for `false`.
##### 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.
`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` (in bit). If you want the Bitfield to grow indefinitely, pass `Infinity` as the size.

@@ -42,4 +44,6 @@

`Bitfield#grow`: The passed growth option (defaults to `0`).
##License
MIT

@@ -99,1 +99,22 @@ var test = require("tape"),

});
test("correct size bitfield", function(t){
t.equal(new BitField(1).buffer.length, 1);
t.equal(new BitField(2).buffer.length, 1);
t.equal(new BitField(3).buffer.length, 1);
t.equal(new BitField(4).buffer.length, 1);
t.equal(new BitField(5).buffer.length, 1);
t.equal(new BitField(6).buffer.length, 1);
t.equal(new BitField(7).buffer.length, 1);
t.equal(new BitField(8).buffer.length, 1);
t.equal(new BitField(9).buffer.length, 2);
t.equal(new BitField(10).buffer.length, 2);
t.equal(new BitField(11).buffer.length, 2);
t.equal(new BitField(12).buffer.length, 2);
t.equal(new BitField(13).buffer.length, 2);
t.equal(new BitField(14).buffer.length, 2);
t.equal(new BitField(15).buffer.length, 2);
t.equal(new BitField(16).buffer.length, 2);
t.equal(new BitField(17).buffer.length, 3);
t.end();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc