bit-extract

0.0.1 • Public • Published

bit-extract is a big-endian extractor for groups of bits. You give it a number, and it gives you the value of groups of bits, starting from the most significant end of the number.

Installation

If you have npm installed, just run

npm install bit-extract

Usage

var bit_extract = require('bit-extract');
 
/* Set up a bit reader. Specify the value and how many bits it has. */
var bx = bit_extract(305419896, 32); // 305419896 is 0x12345678 hexadecimal
 
/* Extract the bits */
console.log(bx.extract_bits(4));
console.log(bx.extract_bits(4));
console.log(bx.extract_bits(8).toString(16));
console.log(bx.extract_bits(16).toString(16));
 

Don't

use this to extract values from a buffer. The node.js buffer object can do this for you, and can probably do it much better than this can.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i bit-extract

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • richardeoin