opaque-bitfield

0.0.2 • Public • Published

opaque-bitfield

A bitfield where you can't see the insides

Overview

This is an implementation of a bitfield in JavaScript, for Node.JS. It's designed for minimal implementation leakage so that I can implement any kind of optimisations I like without breaking any consuming packages.

Right now the implementation is quite naiive, but I hope to improve it as time goes on.

Usage

var Bitfield = require("opaque-bitfield");

var bf = new Bitfield();

bf.set(0, true);

console.log(bf.get(0));

API

get

Bitfield.get(n);
var a = bf.get(0);

Arguments

  • n - the index of the value you want to get

Return Value

boolean value

set

Bitfield.set(n, v);
bf.set(0, true);
// field 0 is now true

Arguments

  • n - the index of the value you want to set
  • v - a boolean value

Return Value

Bitfield self

toBuffer

Bitfield.toBuffer(options);
var buf = bf.toBuffer();
// buf is a binary representation of the bitfield's content

Arguments

  • options - an object specifying options (so far unused)

Return Value

Buffer content

License

3-clause BSD. A copy is included with the source.

Contact

Readme

Keywords

none

Package Sidebar

Install

npm i opaque-bitfield

Weekly Downloads

0

Version

0.0.2

License

BSD

Last publish

Collaborators

  • deoxxa