
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@webkrafters/auto-bst
Advanced tools
Name: Auto-BST
Install:
npm i -S @webkrafters/auto-bst
Self-balancing binary search tree data structure for typescripters and javascript users.
Tree contents are automatically deduped and sorted according to either client injected criteria when available or the default ones otherwise.
Automatically rebalances when properties are set to new values.
This tree is complete at all times and aims to be in perfect balance at the earliest possiblity.
import AutoBST from '@webkrafters/auto-bst';
const timedMap = new AutoBST(); // defaults to empty tree with default isValueBefore (<) and isSameValue (Object.is) camparer options
Sets both isSameValue and isValueBefore propeties simultaneously.
undefined are replaced with the default matching criteria.undefined to reset both isSameValue and isValueBefore properties to their internal default functions.Sets while the tree is in the clean-up process. Clean up process starts when the user invokes the cleanup(...) method.
A function to determine if parameter1 is a value equaling the value property of parameter2.
undefined or Tree.DEFAULT will reset it to default.A function to determine if parameter1 is a value whose node should come before parameter2.
undefined or Tree.DEFAULT will reset it to defaultNumber of undetached nodes on the tree
Array<T> values of all undetached nodes in the tree. Accepts any Iterable<T> type.
undefined will reset it. Alias: this.clear()Triggers the immediate disassociation of any longer-living associated objects (such as detached nodes).
Recommended: invoke this method before either deleting your tree instance or setting it to null.
Disassociates all undetached nodes from the tree.
Compares certain value to the value of an undetached node in this tree using the current isSameValue and isValueBefore properties.
Generator method for this tree traversal.
tree.size.Returns the undetached node located at the supplied index using a Left-to-Right In-Order traversal.
Attention: index parameter also accepts a negative integer to obtain the node located -N places from tree.size.
Returns the Left-to-Right In-Order traversal index of an undetached node in the tree whose value is the same as the first argument.
Attention: may provide a ranged search through the start and the end optional arguments.
start: optional parameter is assigned 0 by default. When assigned a value exceeding tree.size - 1, method immediately returns -1. When negative, method attempts to resolve it by applying tree.size + start. If still negative, method begins its search from index #0.
end: optional parameter is assigned tree.size - 1 by default. When assigned a value exceeding tree.size - 1, method searches to until the end of the tree. When negative, method attempts to resolve it by applying tree.size + end. When the resolved end index is still less than the start index, method searches only the value at start index. Otherwise, method searches up to and including the resolved end index.
Creates and inserts a node constaining the value argument into the tree such that the tree remains balanced.
Re-inserts either a free node into a tree or a detached but associated node back into its tree.
Alternate API: node.join(...)
ReferenceError.Disassociates from its tree an associated node whose value property is isSameValue as the value parameter.
Disassociates an associated node from its tree.
Alternate API: node.free(...)
ReferenceError.Balances this tree.
This method synchronizes changes in the value property of an undetached node with its tree.
ReferenceError.Traverses undetached tree nodes.
cb: optional parameter accepts a callback to be invoked on every traversed node.
signature:
(node: TreeNode<T>): void
When this argument is in its default undefined state, the method returns an array of the nodes traversed.
Otherwise, void is returned.
options: optional parameter accepts a TraversalOptions payload object containing traversal direction, order and range. This argument, by default, holds the directive for the traditional IN_ORDER traversal (i.e. a right ward in-order traversal of the entire tree).
Default settings string
Tree traversal direction options.
Invalid node error message text: when performing tree operations on an invalid node type.
Tree mismatch error message text: when performing tree operations on an unassociated node.
Tree traversal order options.
Verifies a valid tree type.
*This is an internal constructor used by the Tree to spin up new nodes as needed.
Nevertheless:
tree: parameter accepts a reference to the tree creating this node.value: optional parameter accepts the node initial value.index: optional parameter accepts this node index on the tree (according to the Left-to-Right In-Order positioning)Holds the left and right child nodes respectively
Left-to-Right In-Order index positioning of this node on the tree.
This property changes whenever its tree rebalances.
However, if this node is detached from its tree, then this property may become stale.
Is set if this node is currently associated to but not an accessible part of its tree.
Is set if this node is not associated with any valid tree.
Left child node.
Right child node.
Parent node.
Current transitioning mode. This describes which tree transitioning process this node is currently undergoing.
See TransitionType
A tree instance with which this node is associated.
Updating this property disassociates this node from its current tree and moves it to the new tree property.
The disassociated tree self-rebalances (if an undetached node is being disassociated).
The newly associated tree self-rebalances upon inserting this node into it.
A value stored and held in this node.
Updating this property (when this node is undetached) triggers rebalancing of its associated tree.
Mutating this property is a no op.
Detaches (but not disassociate) this node from its associated tree. This node becomes inaccessible to its tree until reinstasted.
May use tree.insertNode(...) or node.join(...) to reinstate this node to its tree.
Detaches (if not already detached) and disassociates this node from its associated tree.
Generates parent nodes up the tree until nGenerations ancestors reached or tree height exhausted.
nGenerations: optional parameter accepts the ancestor position in proximity to this TreeNode. Exmaple: this node.root has nGenerations = 1.Generates descendant nodes down the tree until nGenerations descendants reached or tree depth exhausted.
nGenerations: optional parameter accepts the descendants sorted in ascending order starting from left to right.Generates parent nodes up the tree until anscestorNode is reached - including the ancestorNode. Returns empty array if ancestorNode not found in the hierarchy.
Returns parent nodes up the tree until nGenerations ancestors reached or tree height exhausted.
nGenerations: optional parameter accepts the ancestor position in proximity to this TreeNode. Exmaple: this node.root has nGenerations = 1.Returns descendant nodes down the tree until nGenerations descendants reached or tree depth exhausted.
nGenerations: optional parameter accepts the descendants sorted in ascending order starting from left to right.Generates parent nodes up the tree until anscestorNode - including the ancestorNode. Returns empty array if ancestorNode not found in the hierarchy.
Inserts this node (when detached) into its associated tree.
Unsets this node's isDetached flag.
ISC
FAQs
auto-bst - Self balancing binary search tree.
We found that @webkrafters/auto-bst demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.