As we can construct a bitset object by a Buffer, Can we convert the bitset to Buffer let bitset = require("bitset"); let buf = Buffer.from([100, 97, 98]); let bs = bitset(buf); bs.toString(); '11000100110000101100100' Can we convert a bitset into buffer? let bs1 = new bitset(); bs1.setRange(4,9,1); { data: [ 1008, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], _: 0 } bs1.toString(); '1111110000' Now can this be converted into the buffer? eg. add the padding 0's left and make it's size multiple of 8 then convert to byte array or Buffer.