{"id":18429641,"url":"https://github.com/jsdom/js-symbol-tree","last_synced_at":"2025-04-12T18:49:20.219Z","repository":{"id":34985119,"uuid":"39068410","full_name":"jsdom/js-symbol-tree","owner":"jsdom","description":"Turn any collection of objects into its own efficient tree or linked list using Symbol","archived":false,"fork":false,"pushed_at":"2020-04-25T23:51:56.000Z","size":87,"stargazers_count":109,"open_issues_count":3,"forks_count":22,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-11T10:01:35.652Z","etag":null,"topics":["algorithms","browser","data-structure","dom","efficiency","es6","js","linked-list","list","metadata","nodejs","queue","symbol","symbol-tree","tree"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsdom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-14T10:23:42.000Z","updated_at":"2025-03-31T20:34:28.000Z","dependencies_parsed_at":"2022-08-08T03:15:40.884Z","dependency_job_id":null,"html_url":"https://github.com/jsdom/js-symbol-tree","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fjs-symbol-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fjs-symbol-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fjs-symbol-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsdom%2Fjs-symbol-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsdom","download_url":"https://codeload.github.com/jsdom/js-symbol-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618218,"owners_count":21134199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","browser","data-structure","dom","efficiency","es6","js","linked-list","list","metadata","nodejs","queue","symbol","symbol-tree","tree"],"created_at":"2024-11-06T05:18:01.186Z","updated_at":"2025-04-12T18:49:20.196Z","avatar_url":"https://github.com/jsdom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"symbol-tree\n===========\n[![Travis CI Build Status](https://api.travis-ci.org/jsdom/js-symbol-tree.svg?branch=master)](https://travis-ci.org/jsdom/js-symbol-tree) [![Coverage Status](https://coveralls.io/repos/github/jsdom/js-symbol-tree/badge.svg?branch=master)](https://coveralls.io/github/jsdom/js-symbol-tree?branch=master)\n\nTurn any collection of objects into its own efficient tree or linked list using `Symbol`.\n\nThis 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.\n\nNode.js 4+, io.js and modern browsers are supported.\n\nExample\n-------\nA linked list:\n\n```javascript\nconst SymbolTree = require('symbol-tree');\nconst tree = new SymbolTree();\n\nlet a = {foo: 'bar'}; // or `new Whatever()`\nlet b = {foo: 'baz'};\nlet c = {foo: 'qux'};\n\ntree.insertBefore(b, a); // insert a before b\ntree.insertAfter(b, c); // insert c after b\n\nconsole.log(tree.nextSibling(a) === b);\nconsole.log(tree.nextSibling(b) === c);\nconsole.log(tree.previousSibling(c) === b);\n\ntree.remove(b);\nconsole.log(tree.nextSibling(a) === c);\n```\n\nA tree:\n\n```javascript\nconst SymbolTree = require('symbol-tree');\nconst tree = new SymbolTree();\n\nlet parent = {};\nlet a = {};\nlet b = {};\nlet c = {};\n\ntree.prependChild(parent, a); // insert a as the first child\ntree.appendChild(parent,c ); // insert c as the last child\ntree.insertAfter(a, b); // insert b after a, it now has the same parent as a\n\nconsole.log(tree.firstChild(parent) === a);\nconsole.log(tree.nextSibling(tree.firstChild(parent)) === b);\nconsole.log(tree.lastChild(parent) === c);\n\nlet grandparent = {};\ntree.prependChild(grandparent, parent);\nconsole.log(tree.firstChild(tree.firstChild(grandparent)) === a);\n```\n\nSee [api.md](api.md) for more documentation.\n\nTesting\n-------\nMake sure you install the dependencies first:\n\n    npm install\n\nYou can now run the unit tests by executing:\n\n    npm test\n\nThe line and branch coverage should be 100%.\n\nAPI Documentation\n-----------------\n\u003ca name=\"module_symbol-tree\"\u003e\u003c/a\u003e\n\n## symbol-tree\n**Author**: Joris van der Wel \u003cjoris@jorisvanderwel.com\u003e  \n\n* [symbol-tree](#module_symbol-tree)\n    * [SymbolTree](#exp_module_symbol-tree--SymbolTree) ⏏\n        * [new SymbolTree([description])](#new_module_symbol-tree--SymbolTree_new)\n        * [.initialize(object)](#module_symbol-tree--SymbolTree+initialize) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.hasChildren(object)](#module_symbol-tree--SymbolTree+hasChildren) ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\n        * [.firstChild(object)](#module_symbol-tree--SymbolTree+firstChild) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.lastChild(object)](#module_symbol-tree--SymbolTree+lastChild) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.previousSibling(object)](#module_symbol-tree--SymbolTree+previousSibling) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.nextSibling(object)](#module_symbol-tree--SymbolTree+nextSibling) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.parent(object)](#module_symbol-tree--SymbolTree+parent) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.lastInclusiveDescendant(object)](#module_symbol-tree--SymbolTree+lastInclusiveDescendant) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.preceding(object, [options])](#module_symbol-tree--SymbolTree+preceding) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.following(object, [options])](#module_symbol-tree--SymbolTree+following) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.childrenToArray(parent, [options])](#module_symbol-tree--SymbolTree+childrenToArray) ⇒ \u003ccode\u003eArray.\u0026lt;Object\u0026gt;\u003c/code\u003e\n        * [.ancestorsToArray(object, [options])](#module_symbol-tree--SymbolTree+ancestorsToArray) ⇒ \u003ccode\u003eArray.\u0026lt;Object\u0026gt;\u003c/code\u003e\n        * [.treeToArray(root, [options])](#module_symbol-tree--SymbolTree+treeToArray) ⇒ \u003ccode\u003eArray.\u0026lt;Object\u0026gt;\u003c/code\u003e\n        * [.childrenIterator(parent, [options])](#module_symbol-tree--SymbolTree+childrenIterator) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.previousSiblingsIterator(object)](#module_symbol-tree--SymbolTree+previousSiblingsIterator) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.nextSiblingsIterator(object)](#module_symbol-tree--SymbolTree+nextSiblingsIterator) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.ancestorsIterator(object)](#module_symbol-tree--SymbolTree+ancestorsIterator) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.treeIterator(root, [options])](#module_symbol-tree--SymbolTree+treeIterator) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.index(child)](#module_symbol-tree--SymbolTree+index) ⇒ \u003ccode\u003eNumber\u003c/code\u003e\n        * [.childrenCount(parent)](#module_symbol-tree--SymbolTree+childrenCount) ⇒ \u003ccode\u003eNumber\u003c/code\u003e\n        * [.compareTreePosition(left, right)](#module_symbol-tree--SymbolTree+compareTreePosition) ⇒ \u003ccode\u003eNumber\u003c/code\u003e\n        * [.remove(removeObject)](#module_symbol-tree--SymbolTree+remove) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.insertBefore(referenceObject, newObject)](#module_symbol-tree--SymbolTree+insertBefore) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.insertAfter(referenceObject, newObject)](#module_symbol-tree--SymbolTree+insertAfter) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.prependChild(referenceObject, newObject)](#module_symbol-tree--SymbolTree+prependChild) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n        * [.appendChild(referenceObject, newObject)](#module_symbol-tree--SymbolTree+appendChild) ⇒ \u003ccode\u003eObject\u003c/code\u003e\n\n\u003ca name=\"exp_module_symbol-tree--SymbolTree\"\u003e\u003c/a\u003e\n\n### SymbolTree ⏏\n**Kind**: Exported class  \n\u003ca name=\"new_module_symbol-tree--SymbolTree_new\"\u003e\u003c/a\u003e\n\n#### new SymbolTree([description])\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| [description] | \u003ccode\u003estring\u003c/code\u003e | \u003ccode\u003e\u0026quot;\u0026#x27;SymbolTree data\u0026#x27;\u0026quot;\u003c/code\u003e | Description used for the Symbol |\n\n\u003ca name=\"module_symbol-tree--SymbolTree+initialize\"\u003e\u003c/a\u003e\n\n#### symbolTree.initialize(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nYou can use this function to (optionally) initialize an object right after its creation,\nto take advantage of V8's fast properties. Also useful if you would like to\nfreeze your object.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - object  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+hasChildren\"\u003e\u003c/a\u003e\n\n#### symbolTree.hasChildren(object) ⇒ \u003ccode\u003eBoolean\u003c/code\u003e\nReturns `true` if the object has any children. Otherwise it returns `false`.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+firstChild\"\u003e\u003c/a\u003e\n\n#### symbolTree.firstChild(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nReturns the first child of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+lastChild\"\u003e\u003c/a\u003e\n\n#### symbolTree.lastChild(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nReturns the last child of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+previousSibling\"\u003e\u003c/a\u003e\n\n#### symbolTree.previousSibling(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nReturns the previous sibling of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+nextSibling\"\u003e\u003c/a\u003e\n\n#### symbolTree.nextSibling(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nReturns the next sibling of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+parent\"\u003e\u003c/a\u003e\n\n#### symbolTree.parent(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nReturn the parent of the given object.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+lastInclusiveDescendant\"\u003e\u003c/a\u003e\n\n#### symbolTree.lastInclusiveDescendant(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nFind the inclusive descendant that is last in tree order of the given object.\n\n* `O(n)` (worst case) where `n` is the depth of the subtree of `object`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+preceding\"\u003e\u003c/a\u003e\n\n#### symbolTree.preceding(object, [options]) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nFind the preceding object (A) of the given object (B).\nAn object A is preceding an object B if A and B are in the same tree\nand A comes before B in tree order.\n\n* `O(n)` (worst case)\n* `O(1)` (amortized when walking the entire tree)\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e |  |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  |\n| [options.root] | \u003ccode\u003eObject\u003c/code\u003e | 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` |\n\n\u003ca name=\"module_symbol-tree--SymbolTree+following\"\u003e\u003c/a\u003e\n\n#### symbolTree.following(object, [options]) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nFind the following object (A) of the given object (B).\nAn object A is following an object B if A and B are in the same tree\nand A comes after B in tree order.\n\n* `O(n)` (worst case) where `n` is the amount of objects in the entire tree\n* `O(1)` (amortized when walking the entire tree)\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e |  |  |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  |  |\n| [options.root] | \u003ccode\u003eObject\u003c/code\u003e |  | 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` |\n| [options.skipChildren] | \u003ccode\u003eBoolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | If set, ignore the children of `object` |\n\n\u003ca name=\"module_symbol-tree--SymbolTree+childrenToArray\"\u003e\u003c/a\u003e\n\n#### symbolTree.childrenToArray(parent, [options]) ⇒ \u003ccode\u003eArray.\u0026lt;Object\u0026gt;\u003c/code\u003e\nAppend all children of the given object to an array.\n\n* `O(n)` where `n` is the amount of children of the given `parent`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| parent | \u003ccode\u003eObject\u003c/code\u003e |  |  |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  |  |\n| [options.array] | \u003ccode\u003eArray.\u0026lt;Object\u0026gt;\u003c/code\u003e | \u003ccode\u003e[]\u003c/code\u003e |  |\n| [options.filter] | \u003ccode\u003efunction\u003c/code\u003e |  | Function to test each object before it is added to the array.                            Invoked with arguments (object). Should return `true` if an object                            is to be included. |\n| [options.thisArg] | \u003ccode\u003e\\*\u003c/code\u003e |  | Value to use as `this` when executing `filter`. |\n\n\u003ca name=\"module_symbol-tree--SymbolTree+ancestorsToArray\"\u003e\u003c/a\u003e\n\n#### symbolTree.ancestorsToArray(object, [options]) ⇒ \u003ccode\u003eArray.\u0026lt;Object\u0026gt;\u003c/code\u003e\nAppend all inclusive ancestors of the given object to an array.\n\n* `O(n)` where `n` is the amount of ancestors of the given `object`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e |  |  |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  |  |\n| [options.array] | \u003ccode\u003eArray.\u0026lt;Object\u0026gt;\u003c/code\u003e | \u003ccode\u003e[]\u003c/code\u003e |  |\n| [options.filter] | \u003ccode\u003efunction\u003c/code\u003e |  | Function to test each object before it is added to the array.                            Invoked with arguments (object). Should return `true` if an object                            is to be included. |\n| [options.thisArg] | \u003ccode\u003e\\*\u003c/code\u003e |  | Value to use as `this` when executing `filter`. |\n\n\u003ca name=\"module_symbol-tree--SymbolTree+treeToArray\"\u003e\u003c/a\u003e\n\n#### symbolTree.treeToArray(root, [options]) ⇒ \u003ccode\u003eArray.\u0026lt;Object\u0026gt;\u003c/code\u003e\nAppend all descendants of the given object to an array (in tree order).\n\n* `O(n)` where `n` is the amount of objects in the sub-tree of the given `object`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| root | \u003ccode\u003eObject\u003c/code\u003e |  |  |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  |  |\n| [options.array] | \u003ccode\u003eArray.\u0026lt;Object\u0026gt;\u003c/code\u003e | \u003ccode\u003e[]\u003c/code\u003e |  |\n| [options.filter] | \u003ccode\u003efunction\u003c/code\u003e |  | Function to test each object before it is added to the array.                            Invoked with arguments (object). Should return `true` if an object                            is to be included. |\n| [options.thisArg] | \u003ccode\u003e\\*\u003c/code\u003e |  | Value to use as `this` when executing `filter`. |\n\n\u003ca name=\"module_symbol-tree--SymbolTree+childrenIterator\"\u003e\u003c/a\u003e\n\n#### symbolTree.childrenIterator(parent, [options]) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nIterate over all children of the given object\n\n* `O(1)` for a single iteration\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - An iterable iterator (ES6)  \n\n| Param | Type | Default |\n| --- | --- | --- |\n| parent | \u003ccode\u003eObject\u003c/code\u003e |  | \n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  | \n| [options.reverse] | \u003ccode\u003eBoolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+previousSiblingsIterator\"\u003e\u003c/a\u003e\n\n#### symbolTree.previousSiblingsIterator(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nIterate over all the previous siblings of the given object. (in reverse tree order)\n\n* `O(1)` for a single iteration\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - An iterable iterator (ES6)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+nextSiblingsIterator\"\u003e\u003c/a\u003e\n\n#### symbolTree.nextSiblingsIterator(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nIterate over all the next siblings of the given object. (in tree order)\n\n* `O(1)` for a single iteration\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - An iterable iterator (ES6)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+ancestorsIterator\"\u003e\u003c/a\u003e\n\n#### symbolTree.ancestorsIterator(object) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nIterate over all inclusive ancestors of the given object\n\n* `O(1)` for a single iteration\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - An iterable iterator (ES6)  \n\n| Param | Type |\n| --- | --- |\n| object | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+treeIterator\"\u003e\u003c/a\u003e\n\n#### symbolTree.treeIterator(root, [options]) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nIterate over all descendants of the given object (in tree order).\n\nWhere `n` is the amount of objects in the sub-tree of the given `root`:\n\n* `O(n)` (worst case for a single iteration)\n* `O(n)` (amortized, when completing the iterator)\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - An iterable iterator (ES6)  \n\n| Param | Type | Default |\n| --- | --- | --- |\n| root | \u003ccode\u003eObject\u003c/code\u003e |  | \n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  | \n| [options.reverse] | \u003ccode\u003eBoolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+index\"\u003e\u003c/a\u003e\n\n#### symbolTree.index(child) ⇒ \u003ccode\u003eNumber\u003c/code\u003e\nFind the index of the given object (the number of preceding siblings).\n\n* `O(n)` where `n` is the amount of preceding siblings\n* `O(1)` (amortized, if the tree is not modified)\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eNumber\u003c/code\u003e - The number of preceding siblings, or -1 if the object has no parent  \n\n| Param | Type |\n| --- | --- |\n| child | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+childrenCount\"\u003e\u003c/a\u003e\n\n#### symbolTree.childrenCount(parent) ⇒ \u003ccode\u003eNumber\u003c/code\u003e\nCalculate the number of children.\n\n* `O(n)` where `n` is the amount of children\n* `O(1)` (amortized, if the tree is not modified)\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type |\n| --- | --- |\n| parent | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+compareTreePosition\"\u003e\u003c/a\u003e\n\n#### symbolTree.compareTreePosition(left, right) ⇒ \u003ccode\u003eNumber\u003c/code\u003e\nCompare the position of an object relative to another object. A bit set is returned:\n\n\u003cul\u003e\n    \u003cli\u003eDISCONNECTED : 1\u003c/li\u003e\n    \u003cli\u003ePRECEDING : 2\u003c/li\u003e\n    \u003cli\u003eFOLLOWING : 4\u003c/li\u003e\n    \u003cli\u003eCONTAINS : 8\u003c/li\u003e\n    \u003cli\u003eCONTAINED_BY : 16\u003c/li\u003e\n\u003c/ul\u003e\n\nThe semantics are the same as compareDocumentPosition in DOM, with the exception that\nDISCONNECTED never occurs with any other bit.\n\nwhere `n` and `m` are the amount of ancestors of `left` and `right`;\nwhere `o` is the amount of children of the lowest common ancestor of `left` and `right`:\n\n* `O(n + m + o)` (worst case)\n* `O(n + m)` (amortized, if the tree is not modified)\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n\n| Param | Type |\n| --- | --- |\n| left | \u003ccode\u003eObject\u003c/code\u003e | \n| right | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+remove\"\u003e\u003c/a\u003e\n\n#### symbolTree.remove(removeObject) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nRemove the object from this tree.\nHas no effect if already removed.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - removeObject  \n\n| Param | Type |\n| --- | --- |\n| removeObject | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+insertBefore\"\u003e\u003c/a\u003e\n\n#### symbolTree.insertBefore(referenceObject, newObject) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nInsert the given object before the reference object.\n`newObject` is now the previous sibling of `referenceObject`.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - newObject  \n**Throws**:\n\n- \u003ccode\u003eError\u003c/code\u003e If the newObject is already present in this SymbolTree\n\n\n| Param | Type |\n| --- | --- |\n| referenceObject | \u003ccode\u003eObject\u003c/code\u003e | \n| newObject | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+insertAfter\"\u003e\u003c/a\u003e\n\n#### symbolTree.insertAfter(referenceObject, newObject) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nInsert the given object after the reference object.\n`newObject` is now the next sibling of `referenceObject`.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - newObject  \n**Throws**:\n\n- \u003ccode\u003eError\u003c/code\u003e If the newObject is already present in this SymbolTree\n\n\n| Param | Type |\n| --- | --- |\n| referenceObject | \u003ccode\u003eObject\u003c/code\u003e | \n| newObject | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+prependChild\"\u003e\u003c/a\u003e\n\n#### symbolTree.prependChild(referenceObject, newObject) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nInsert the given object as the first child of the given reference object.\n`newObject` is now the first child of `referenceObject`.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - newObject  \n**Throws**:\n\n- \u003ccode\u003eError\u003c/code\u003e If the newObject is already present in this SymbolTree\n\n\n| Param | Type |\n| --- | --- |\n| referenceObject | \u003ccode\u003eObject\u003c/code\u003e | \n| newObject | \u003ccode\u003eObject\u003c/code\u003e | \n\n\u003ca name=\"module_symbol-tree--SymbolTree+appendChild\"\u003e\u003c/a\u003e\n\n#### symbolTree.appendChild(referenceObject, newObject) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nInsert the given object as the last child of the given reference object.\n`newObject` is now the last child of `referenceObject`.\n\n* `O(1)`\n\n**Kind**: instance method of [\u003ccode\u003eSymbolTree\u003c/code\u003e](#exp_module_symbol-tree--SymbolTree)  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - newObject  \n**Throws**:\n\n- \u003ccode\u003eError\u003c/code\u003e If the newObject is already present in this SymbolTree\n\n\n| Param | Type |\n| --- | --- |\n| referenceObject | \u003ccode\u003eObject\u003c/code\u003e | \n| newObject | \u003ccode\u003eObject\u003c/code\u003e | \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdom%2Fjs-symbol-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsdom%2Fjs-symbol-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsdom%2Fjs-symbol-tree/lists"}