# btreenode

> A binary tree module for NodeJS

Latest version **1.0.3** (published 2021-11-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install btreenode
pnpm add btreenode
yarn add btreenode
bun add btreenode
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-11-06 |
| First published | 2016-03-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 16.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Rich Haigh |
| Maintainers | richmondo |
| Keywords | btree, node, binary tree |

## Links

- npm: https://www.npmjs.com/package/btreenode
- Repository: https://github.com/richhaigh/btreenode
- Homepage: https://github.com/richhaigh/btreenode#readme
- Issues: https://github.com/richhaigh/btreenode/issues
- npm.io page: https://npm.io/package/btreenode

## Dependencies (3)

- [chai](https://npm.io/package/chai.md) *
- [util](https://npm.io/package/util.md) *
- [node.extend](https://npm.io/package/node.extend.md) *

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-11-06
- 1.0.1 — 2016-03-07

## README

# btreenode
A binary tree module for NodeJS.

			var btree = require('btreenode');  
			
			// Create a new tree
			var tree = new btree.createTree();	
			
			// Initialise a new tree using an array of values and specify a custom sort key
			tree.init([
						{type: 'fruit',id: 1,name: 'apple'}, 
						{type: 'fruit', id: 2, name: 'orange'}, 
						{type: 'fruit', id: 5, name: 'pear'}, 
						{type: 'fruit', id: 4, name: 'banana'}
					], 
				{key: 'name'});
			
			// Add a new item
			tree.add({type: 'vegetable', id: 3, name: 'potato'});
			
			// Remove an item
			tree.remove('pear');
			
			// Iterate through the tree
			tree.forEach(function(value){
				console.log('I am a ', value.type, ' and my name is ', value.name);
			});
			
			// Check if the tree is balanced and balance it if not
			if(!tree.isBalanced()){
				tree.balance();
			}
			
			// Get the minimum key value
			var min = tree.minimum();
			
			// Get the maximum key value
			var max = tree.maximum();
			
			// Find items by key value
			var apple = tree.find('apple');
			
			// Find items by any property
			var banana = tree.find({id: 4});

---
_Source: https://npm.io/package/btreenode · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
