Skip to content

benOS library for bit fields, that allocates a series of tiny buffs to support thinning bits without setting aside a massive buffer to do so.

License

Notifications You must be signed in to change notification settings

benchOS/thinbit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThinBit

benOSShield-OfficialbenOSShield-Utilsbuild statusJavaScript Style Guide benOSRepoHeader

ThinBit is a high-level Bitfield implementation that allocates a series of 1kb buffers to support very thin bitfields without having to suffocate from the cost of dealing with massive buffers.

Table of Contents

Background

ThinBit is a high-level Bitfield implementation that allocates a series of 1kb buffers to support very thin bitfields without having to suffocate from the cost of dealing with massive buffers. If you want to simple implementation of a flat bitfield see the bitfield module. ThinBit is used for big bitfields where every single bit isn't truly needed and we are able to thin the frame.

benOSRepoHeader

Installation

With NPM

npm install thinbit

With YARN

yarn add global thinbit

Usage

var thinbit = require('thinbit')
var tbits = thinbit()

tbits.set(0, true) // set first bit
tbits.set(1, true) // set second bit
tbits.set(1000000000000, true) // set the 1.000.000.000.000th bit

Running the above example will allocate two 1kb buffers internally. Each 1kb buffer can hold information about 8192 bits so the first one will be used to store information about the first two bits and the second will be used to store the 1.000.000.000.000th bit.

NOTE: The above was written by the developers of the BitField libraries.

API

var tbits = thinbit([options])

Create a new thinbit. Options include

{
  pageSize: 1024, // how big should the partial buffers be
  buffer: anExistingBitfield,
  trackUpdates: false // track when pages are being updated in the pager
}

tbits.set(index, value)

Set a bit to true or false.

tbits.get(index)

Get the value of a bit.

var buffer = tbits.toBuffer()

Get a single buffer representing the entire thinbit.

Related Projects

  • benOS - benOS Decentralized Operating System
  • benny - benOS Native Container Builder
  • bennyfile - Build File Library For Benny Containers
  • thinbit - BitField Library For Benny

Why The Internet Must Have A Decentralized Alternative

Today, the internet is more censored than ever and it's only getting worse. Our mission with the dWeb Protocol was to create a truly powerful P2P protocol, around benOS, dBrowser and many of benOS' underlying libraries to bring the most powerful P2P products to life. In the last few months, by rebuilding P2P technologies that have existed since the early 2000s, we have built a powerful suite of decentralized libraries for benOS and the Bench Network, that will only improve over time. But we also brought new ideas to life, like:

and more! These were the protocols and libraries that we needed to create a completely decentralized operating system, where everything was distributed, protected and people were once again in control of their data. benOS is made up of over 1100+ different libraries that we are releasing on a day-by-day basis as we move them to a stable/production state. While financial support is great for this open source project, we need developers who want to be some of the first to build the dApps and dSites of the future. We have to take back what our forefathers originally designed for freedom, by making our code the law, instead of releasing weak and highly centralized applications where law cannot be applied because the code lacks the foundation to implement a legal framework for itself. Join us for a truly historic journey on the BenchLabs Telegram. See you there.

Bench On The dWeb

dweb://bench.dnames.io // dNames Short Link dweb://3EDAE09848B77401445B7739CAFCE442DDE1752AED63025A1F94E6A86D7E9F04 // dWeb Key Link

In order to make the links above clickable or to view these links period, you will need dBrowser (Available for Mac OSX, Linux, Windows and soon to be available on iOS/Android)

"The Code Is The Law" - Stan Larimer - Godfather of BitShares.

License

MIT

JavaScript Style Guide
forthebadge
dWebShield

Copyright

Copyright (c) 2018 Bench Open Systems. All rights reserved.

About

benOS library for bit fields, that allocates a series of tiny buffs to support thinning bits without setting aside a massive buffer to do so.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published