From 5191ed9e54344b86b72794c59ef088146a822daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD=D0=BE=D0=B2=D1=81=D0=BA=D0=B8=D0=B9?= Date: Mon, 27 Jul 2020 02:23:55 +0300 Subject: [PATCH] Increased version number; created README --- README.md | 20 ++++++++++++++++++++ package.json | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..cb723b8 --- /dev/null +++ b/README.md @@ -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); +``` diff --git a/package.json b/package.json index ff8cb91..deeedb7 100644 --- a/package.json +++ b/package.json @@ -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": {