Skip to content

Commit

Permalink
Increased version number; created README
Browse files Browse the repository at this point in the history
  • Loading branch information
kormanowsky committed Jul 26, 2020
1 parent 3e2347a commit 5191ed9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# JavaScirpt Bit List
- Bit list is a data structure which may be used to store arrays of boolean values in a number. This method allows such arrays to be used in places where the data shortness is important, e. g. in query string parameters.
- This data structure plays with the binary representation of the numbers. Each element (named "bit") is just a bit of the number. To set the nth bit to true means to add pow(2, n) to the number, to set it to false means to subtract pow(2, n) from the number.
## Examples
```javascript
// Import the class
const BitList = require("js-bit-list");
// Create new bit list
let list = new BitList();
// Add some values
list.setBit(3, 1);
list.setBit(4, 1);
// Convert to number
let num = list.toNumber(); // Gives 2**3 + 2**4 = 24
// Convert to array
let arr = list.toArray(); // Gives [0, 0, 0, 1, 1]
// Predefined values
let predefinedList = new BitList([0, 0, 0, 1, 1, 0, 0])
let predefinedListFromNumber = new BitList(31);
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-bit-list",
"version": "1.0.0",
"version": "1.0.1",
"description": "Store arrays of boolean values in numbers.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 5191ed9

Please sign in to comment.