@wecandobetter/btree
TypeScript icon, indicating that this package has built-in type declarations

1.0.1-alpha.0 • Public • Published

B-Tree for TypeScript

A B-Tree implementation for TypeScript, for use in Odin, an in-memory, browser-first knowledge graph database.

⚠️ This project is still in the early stages of development. It is not yet ready for use. Tinker with it if you like, but don't come to me when it burns down your house. You've been warned.

Installation

npm i @wecandobetter/btree

Usage

⚠️ Not all functionality is implemented yet.

import { BTree, type Comparator, type Selector } from "@wecandobetter/btree";

const tree = new BTree<string, string>({
  t: 2, // The minimum degree of the tree. Must be >= 2.
  comparator: (a, b) => a.localeCompare(b), // the comparator function to use for sorting keys
  selector: (a) => a, // the selector function to use to select the value from the input
});

// Insert a value into the tree.
tree.insert("foo");

// Search for a value in the tree.
const results = tree.search("foo"); // returns a Set<string>

Contributing

Contributions are welcome! If you encounter a bug, have a question, or have an idea for a new feature, please open an issue. If you would like to contribute code, please open an issue first to discuss your idea.

License

This library is licensed under the MIT License.

Links

Coded with ❤️ by We Can Do Better.

Package Sidebar

Install

npm i @wecandobetter/btree

Weekly Downloads

12

Version

1.0.1-alpha.0

License

MIT

Unpacked Size

25.1 kB

Total Files

17

Last publish

Collaborators

  • michielvdvelde