
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@prachwal_org/bplus-tree
Advanced tools
High-performance B+ Tree data structure implementation in TypeScript with visualization support
A high-performance B+ Tree data structure implementation in TypeScript with comprehensive visualization support and pluggable storage providers.
npm install @prachwal_org/bplus-tree
import { BPlusTree } from '@prachwal_org/bplus-tree';
// Create a new B+ Tree
const tree = new BPlusTree<string>();
// Insert values
tree.insert(10, 'value1');
tree.insert(20, 'value2');
tree.insert(5, 'value3');
// Lookup values
console.log(tree.lookup(10)); // 'value1'
console.log(tree.lookup(15)); // null
// Get all keys
console.log(tree.getAllKeys()); // [5, 10, 20]
// Visualize the tree
console.log(tree.generateMermaid()); // Generate Mermaid diagram
tree.printAsciiTree(); // Print ASCII tree
tree.saveMermaidToFile('tree.md'); // Save diagram to file
BPlusTree supports pluggable storage providers for persistence. The library includes built-in providers and allows custom implementations.
import { BPlusTree } from '@prachwal_org/bplus-tree';
import { FileStorageProvider } from '@prachwal_org/bplus-tree';
const tree = new BPlusTree<string>();
const provider = new FileStorageProvider('tree-data.msgpack');
// Insert data
tree.insert(1, 'value1');
tree.insert(2, 'value2');
// Save to file
await tree.save(provider);
// Load from file
await tree.load(provider);
import { BPlusTree } from '@prachwal_org/bplus-tree';
import { RedisStorageProvider } from '@prachwal_org/bplus-tree';
const tree = new BPlusTree<string>();
const provider = new RedisStorageProvider('my-tree-data');
// Connect to Redis
await provider.connect();
// Save/Load operations
await tree.save(provider);
await tree.load(provider);
// Cleanup
await provider.disconnect();
Implement the StorageProvider interface for custom storage backends:
import { StorageProvider } from '@prachwal_org/bplus-tree';
class MyCustomProvider implements StorageProvider {
async save(data: Buffer): Promise<void> {
// Your save logic here
}
async load(): Promise<Buffer> {
// Your load logic here
}
}
See PROVIDERS_PLAN.md for a comprehensive list of planned storage providers.
new BPlusTree<T>()
insert(key: number, value: T): voidInserts a key-value pair into the tree.
lookup(key: number): T | nullRetrieves the value associated with the given key.
getAllKeys(): number[]Returns all keys in the tree in sorted order.
generateMermaid(): stringGenerates a Mermaid diagram representing the tree structure.
printAsciiTree(): voidPrints an ASCII representation of the tree to the console.
saveMermaidToFile(filename?: string): voidSaves a Mermaid diagram to a Markdown file.
save(provider: StorageProvider): Promise<void>Saves the tree to a storage provider.
load(provider: StorageProvider): Promise<void>Loads the tree from a storage provider.
interface User {
name: string;
age: number;
data: number[];
}
const tree = new BPlusTree<User>();
tree.insert(1, {
name: 'Alice',
age: 30,
data: [1, 2, 3]
});
tree.insert(2, {
name: 'Bob',
age: 25,
data: [4, 5, 6]
});
const tree = new BPlusTree<string>();
// Add some data
for (let i = 1; i <= 10; i++) {
tree.insert(i, `value${i}`);
}
// Generate Mermaid diagram
const mermaid = tree.generateMermaid();
console.log(mermaid);
// Save to file
tree.saveMermaidToFile('my-tree.md');
# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Build the project
npm run build
# Development mode
npm run dev
This implementation uses a B+ Tree with the following characteristics:
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project helpful, please give it a ⭐️!
For issues and questions, please open an issue on GitHub.
FAQs
High-performance B+ Tree data structure implementation in TypeScript with visualization support
We found that @prachwal_org/bplus-tree demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.