From 03e7b9a83abe6891064ea3ff9b3f0badf1446ee2 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, 17 Aug 2020 00:53:01 +0300 Subject: [PATCH] Added example, fixed bug --- example.js | 14 ++++++++++++++ index.js | 1 + 2 files changed, 15 insertions(+) create mode 100644 example.js diff --git a/example.js b/example.js new file mode 100644 index 0000000..e5701d9 --- /dev/null +++ b/example.js @@ -0,0 +1,14 @@ +/** + * js-bit-list working example + * @author Mikhail Kormanowsky + */ + +const BitList = require("./index"); + +const MyBitList = BitList.useKeys(["myKey", "otherKey"]); + +let myBitListInstance = new MyBitList({myKey: true}); + +console.log("It works!"); +console.log("Number", myBitListInstance.toNumber()); +console.log("myKey value", myBitListInstance.toObject().myKey); \ No newline at end of file diff --git a/index.js b/index.js index cd68a21..5871078 100644 --- a/index.js +++ b/index.js @@ -195,6 +195,7 @@ class BitList { super(initialValue); } catch (error) { if (typeof initialValue === "object" && initialValue !== null) { + super(0); this.setObject(initialValue); } else { throw error;