🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

bit-encode

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bit-encode

Low level bit encoder for buffers

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 06 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts