Snapshot of jsdom/js-symbol-tree: 113★, JavaScript, Backend. Turn any collection of objects into its own efficient tree or linked list using Symbol
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Turn any collection of objects into its own efficient tree or linked list using Symbol.
This library has been designed to provide an efficient backing data structure for DOM trees. You can also use this library as an efficient linked list. Any meta data is stored on your objects directly, which ensures any kind of insertion or deletion is performed in constant time. Because an ES6 Symbol is used, the meta data does not interfere with your object in any way.
Node.js 4+, io.js and modern browsers are supported.
Example
A linked list:
const SymbolTree = require('symbol-tree');
const tree = new SymbolTree();
let a = {foo: 'bar'}; // or `new Whatever()`
let b = {foo: 'baz'};
let c = {foo: 'qux'};
tree.insertBefore(b, a); // insert a before b
tree.insertAfter(b, c); // insert c after b
console.log(tree.nextSibling(a) === b);
console.log(tree.nextSibling(b) === c);
console.log(tree.previousSibling(c) === b);
tree.remove(b);
console.log(tree.nextSibling(a) === c);
A tree:
const SymbolTree = require('symbol-tree');
const tree = new SymbolTree();
let parent = {};
let a = {};
let b = {};
let c = {};
tree.prependChild(parent, a); // insert a as the first child
tree.appendChild(parent,c ); // insert c as the last child
tree.insertAfter(a, b); // insert b after a, it now has the same parent as a
console.log(tree.firstChild(parent) === a);
console.log(tree.nextSibling(tree.firstChild(parent)) === b);
console.log(tree.lastChild(parent) === c);
let grandparent = {};
tree.prependChild(grandparent, parent);
console.log(tree.firstChild(tree.firstChild(grandparent)) === a);
You can use this function to (optionally) initialize an object right after its creation,
to take advantage of V8's fast properties. Also useful if you would like to
freeze your object.
O(1)
Kind: instance method of SymbolTree Returns: Object - object
Param
Type
object
Object
symbolTree.hasChildren(object) ⇒ Boolean
Returns true if the object has any children. Otherwise it returns false.
Find the inclusive descendant that is last in tree order of the given object.
O(n) (worst case) where n is the depth of the subtree of object
Kind: instance method of SymbolTree
Param
Type
object
Object
symbolTree.preceding(object, [options]) ⇒ Object
Find the preceding object (A) of the given object (B).
An object A is preceding an object B if A and B are in the same tree
and A comes before B in tree order.
O(n) (worst case)
O(1) (amortized when walking the entire tree)
Kind: instance method of SymbolTree
Param
Type
Description
object
Object
[options]
Object
[options.root]
Object
If set, root must be an inclusive ancestor of the return value (or else null is returned). This check assumes that root is also an inclusive ancestor of the given object
symbolTree.following(object, [options]) ⇒ Object
Find the following object (A) of the given object (B).
An object A is following an object B if A and B are in the same tree
and A comes after B in tree order.
O(n) (worst case) where n is the amount of objects in the entire tree
O(1) (amortized when walking the entire tree)
Kind: instance method of SymbolTree
Param
Type
Default
Description
object
Object
[options]
Object
[options.root]
Object
If set, root must be an inclusive ancestor of the return value (or else null is returned). This check assumes that root is also an inclusive ancestor of the given object
No homepage URL was recorded for jsdom/js-symbol-tree in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
How active is development on jsdom/js-symbol-tree?
The most recent commit recorded on jsdom/js-symbol-tree was 6.3 years ago, based on the GitHub push timestamp. The repository has 23 forks — one of the better signals of community interest.
How many stars does jsdom/js-symbol-tree have?
jsdom/js-symbol-tree has 113 GitHub stars — refresh the page for the live number, or check github.com/jsdom/js-symbol-tree. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is jsdom/js-symbol-tree open source?
Yes — jsdom/js-symbol-tree ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/jsdom/js-symbol-tree.
What else is in the Backend space?
jsdom/js-symbol-tree is tracked by TopGit under the Backend category, alongside 15 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What topics is jsdom/js-symbol-tree associated with?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/jsdom/js-symbol-tree is the definitive source.
Read full README in the tab above.
Is js-symbol-tree worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of js-symbol-tree.