Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 5, 2024 via pnpm

symbol-tree 3.2.4

Turn any collection of objects into its own efficient tree or linked list using Symbol
Package summary
Share
0
issues
1
license
1
MIT
Package created
14 Jul 2015
Version published
12 Jun 2019
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
symbol-tree@3.2.4
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of symbol-tree 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does symbol-tree do?

Symbol-tree is a JavaScript library that allows users to efficiently turn any collection of objects into its own tree or linked list using the ES6 Symbol. It has been specifically designed as an optimal backing data structure for DOM trees, but can also be utilized as a proficient linked list. The meta data is stored directly on the objects, ensuring performing any kind of insertion or deletion is carried out in constant time.

How do you use symbol-tree?

To use the symbol-tree package, you first need to install it via npm using npm install symbol-tree. After that, you can include it in your JavaScript file using the require statement. Here's how you create a linked list and a tree using symbol-tree:

Linked List

const SymbolTree = require('symbol-tree');
const tree = new SymbolTree();

let a = {foo: 'bar'};
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);

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);

Where are the symbol-tree docs?

The detailed documentation of symbol-tree is included in the api.md file in the repository. This provides instructions on how to use each method in the SymbolTree class. Additionally, complete API documentation is presented within the readme file of the GitHub repository at git+https://github.com/jsdom/js-symbol-tree.git.