
Security News
Insecure Agents Podcast: Certified Patches, Supply Chain Security, and AI Agents
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.
avltree-js
Advanced tools
Supports all basic operations and custom sort comparison functions.
tree.insert(2);
tree.delete(2);
var element = tree.search(target);
returns the element if it exists.
var sum = 0;
tree.forEach(function (element) {
sum += element;
});
var min = tree.getMin();
var max = tree.getMax();
var max = tree.deleteMax();
var nodesAtZero = tree.getElementsAtDepth(0);
returns an array of elements at depth 0 (in this case, the root);
// Create a custom sorting function that will order people by age.
var personSortingFunction = function (personA, personB) {
if (personA.age < personB.age) {
return -1
} else if (personA.age > personB.age) {
return 1;
}
return 0;
};
// pass in the custom sorting function the the tree's constructor
var personTree = new AvlTree(personSortingFunction);
// create some test people to add to the tree
var person1 = { age: 1 };
var person2 = { age: 2 };
var person3 = { age: 3 };
var person4 = { age: 4 };
// add the people to the tree in any order
personTree.insert(person2);
personTree.insert(person1);
personTree.insert(person4);
personTree.insert(person3);
personTree.forEach(function (person) {
console.log(person.age);
});
output 1 2 3 4
Tests are run using mocha in the test directory.
npm install -g mocha
npm test
If you wish to help improve the speed there are some benchmarks in the speedTest directory.
npm run speedTest
does not support duplicate values at this time.
FAQs
Supports all basic operations and custom sort comparison functions.
The npm package avltree-js receives a total of 5 weekly downloads. As such, avltree-js popularity was classified as not popular.
We found that avltree-js demonstrated a not healthy version release cadence and project activity because the last version was released 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 joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.

Security News
The planned feature introduces a review step before releases go live, following the Shai-Hulud attacks and a rocky migration off classic tokens that disrupted maintainer workflows.