Socket
Socket
Sign inDemoInstall

@digitalcredentials/bitstring

Package Overview
Dependencies
Maintainers
9
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digitalcredentials/bitstring

Bitstring module for universal JavaScript


Version published
Weekly downloads
3.1K
increased by10.88%
Maintainers
9
Weekly downloads
 
Created
Source

Universal Bitstring Library (@digitalcredentials/bitstring)

Build status NPM Version

A Bitstring module for Javascript (Node, browsers, React Native).

Install

To install get the latest version from NPM:

npm install @digitalcredentials/bitstring

To install locally for development:

git clone https://github.com/digitalcredentials/bitstring.git
cd bitstring
npm install

Usage

import {Bitstring} from '@digitalcredentials/bitstring';

// You can make a new instance by passing in a length
const bitstring = new Bitstring({length: 10});

// OR by passing in a buffer
const buffer = Uint8Array.from([255]);
const bitstring = new Bitstring({buffer});

API

set(position, on)

Sets the value of a bit for the given position to the given boolean.

bitstring.set(1, true);

get(position)

Gets the value of a bit for the given position.

bitstring.get(3);

encodeBits()

Compresses and encodes bits to a base64url encoded string.

await bitstring.encodeBits();

decodeBits({encoded})

Decodes and uncompresses a given base64url encoded string to a Uint8Array.

await Bitstring.decodeBits({encoded});

compressBits()

Compresses bits to a Uint8Array.

await bitstring.compressBits();

uncompressBits({compressed})

Uncompresses compressed bits.

await Bitstring.uncompressBits({compressed});

Contribute

Please follow the existing code style.

PRs accepted.

If editing the Readme, please conform to the standard-readme specification.

License

BSD-3-Clause © Digital Bazaar

Keywords

FAQs

Package last updated on 06 Dec 2023

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc