🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

bit-and-tree

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bit-and-tree

A tree on top of a bitfield that represent a BITWISE-AND structure

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

bit-and-tree

A tree on top of a bitfield that represent a BITWISE-AND structure.

npm install bit-and-tree

Uses flat-tree indexing to represent the tree on top of a bitfield. If you are not familiar with this you should read that module's README first to understand what each index means.

Usage

var bat = require('bit-and-tree')

var tree = bat()

// returns false since at least one child is false
console.log(tree.get(1))

// set two bottom nodes to true
tree.set(0, true)
tree.set(2, true)

// returns true since both children are now true
console.log(tree.get(1))

API

var tree = bat([buffer])

Create a new bit tree. Optionally pass in a buffer representing your tree.

var updated = tree.set(index, bool)

Set a bit. If you set a bit to true and the sibling bit is also true the parent bit will set as well. Similarly if you set a bit to false all parent bits will be set to false.

Returns true if the bitfield was updated and false otherwise.

var bool = tree.get(index)

Get the status of a bit.

License

MIT

FAQs

Package last updated on 17 Feb 2017

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