Socket
Socket
Sign inDemoInstall

bit-buffers

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bit-buffers

A simple bit buffer (bit-string) implementation with base64 zlib compressed bitstring support.


Version published
Weekly downloads
4
decreased by-84%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

bit-buffers

A simple bit buffer (bit-string) implementation with base64 zlib compressed bitstring support.

Usage

import { BitBuffer } from "bit-buffers"

// BitBuffers are immutable and default to 16kb capacity by default.
const bits = new BitBuffer()

// To create a smaller BitBuffer, you can pass in a smaller capacity, for
// example this will create a BitBuffer with 16 bytes:
// const smallerBits = new BitBuffer(16 * 8)

// set bit 7 to 1.
const bits2 = bits.set(7) // => bits
bits2.test(7) // => true

// unset bit 7 to 0
const bits3 = bits2.unset(7) // => bits
bits3.test(7) // => false

const bits4 = bits3.set(3)
const bitstring = bits4.toBitstring() // => "eJwTYEAFAAEQABE="

const bits5 = BitBuffer.fromBitstring(bitstring)
bits5 === bits4 // true
const indexArray = bits5.toIndexArray() // => [3]

const bits6 = BitBuffer.fromIndexArray(indexArray)
bits6 === bits5 // => true

Building

npm run build

Testing

npm test

Linting

npm run lint

Type-checking

npm run type-check

Brought to you by M2 Labs

M2 Labs

This project is maintained and funded by M2 Labs, a Web3 product development studio.

FAQs

Last updated on 11 Jan 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc