As we can construct a bitset object by a Buffer, Can we convert the bitset to Buffer

Open
#44 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
32/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
tooling

Research direction

No source file or test is named. Start by tracing the Buffer constructor path and the existing toString() behavior, then determine the intended byte order and padding from the examples. Done means a bitset can be converted to a Buffer with zero padding to a byte boundary and the behavior is covered by tests.

Written by the indexing model from the issue text.

Description

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.

Dominant language
JavaScript
Stars
238
Forks
31
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rawify/BitSet.js

All issues in rawify/BitSet.js

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.