JSPM

bit-encode

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q30359F
  • License MIT

Low level bit encoder for buffers

Package Exports

  • bit-encode

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bit-encode) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

bit-encode

Low level bit encoder for buffers

npm install bit-encode

build status

Usage

var bits = require('bit-encode')

var buf = Buffer([0])

console.log(bits.get(buf, 0)) // get first bit, returns false (0)

bits.set(buf, 0, true) // set first bit

console.log(bits.get(buf, 0)) // get first bit, returns true (1)

API

var bool = bits.get(buffer, index)

Read the bit at index. A byte in the buffer contains 8 bits so index 0 would return the first bit in the first byte and index 8 would return the first bit in the second byte.

var updated = bits.set(buffer, index, bool)

Set the bit at index. Returns true if a bit was updated false otherwise.

License

MIT